Skip to content

feat: improve debug variables order and fix console log#4533

Merged
erha19 merged 3 commits intomainfrom
fix/python-debug-console
May 12, 2025
Merged

feat: improve debug variables order and fix console log#4533
erha19 merged 3 commits intomainfrom
fix/python-debug-console

Conversation

@erha19
Copy link
Copy Markdown
Member

@erha19 erha19 commented May 9, 2025

Types

  • 🐛 Bug Fixes

Background or solution

优化调试变量顺序展示(更符合直觉习惯)
image
修复 Python 调试无法在控制台 print 的问题
image

Changelog

improve debug variables order and fix console log

Summary by CodeRabbit

  • Bug Fixes
    • 修正了调试控制台清空时的本地化消息字符串错误,提升了提示信息的准确性。
  • Style
    • 调整了调试变量节点的左侧内边距,从16像素增加到18像素,优化了界面显示效果。
    • 新增了调试控制台日志文本的样式,提升了日志信息的视觉区分度。
  • Refactor
    • 优化了调试树节点的排序规则,改进了节点名称的排序方式,并调整了复合节点与非复合节点的排序优先级。
    • 对部分内部节点父级处理逻辑进行了优化,提升了节点管理的稳定性。
  • New Features
    • 扩展了消息类型,新增“日志”类别,丰富了消息分类体系。

@erha19 erha19 requested review from Aaaaash, Ricbet and ensorrow May 9, 2025 10:08
@opensumi opensumi Bot added 🎨 feature feature required 🐞 bug Something isn't working labels May 9, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2025

"""

Walkthrough

本次变更主要包括对调试树节点排序逻辑的调整、树节点父级处理的细节优化、调试控制台清屏提示文案的修正、调试变量视图缩进像素的微调、消息类型枚举新增 Log 成员,以及调试控制台树节点颜色样式的调整。所有改动均未涉及对外部导出接口的声明修改。

Changes

文件/文件组 变更摘要
packages/components/src/recycle-tree/tree/TreeNode.ts 优化 mv 方法,当父节点为 null 或非 CompositeTreeNode 时,直接将 _parent 设为 undefined,绕过 setter。
packages/debug/src/browser/tree/debug-tree-node.define.ts 调整 ExpressionTreeService 的排序逻辑:去除 variablesReference 优先级,变更同构造器节点排序规则,并对复合节点与非复合节点的排序顺序进行了反转。移除无用 import 和注释。
packages/debug/src/browser/view/console/debug-console-session.ts 修正控制台清屏提示的本地化字符串键名拼写错误(consoleCleareconsoleCleared)。
packages/debug/src/browser/view/variables/debug-variables.view.tsx 调整变量节点左侧缩进:非 ExpressionContainer 的偏移由 16px 增加到 18px。
packages/core-common/src/types/message.ts MessageType 枚举中新增 Log 成员,位于 Error 之后。
packages/debug/src/browser/tree/debug-console-tree-node.define.tsx 修改 getColor 函数,未定义或未知 severity 时返回 variable_repl_textlog 样式组合,替代原先的 info 样式。
packages/debug/src/browser/view/console/debug-console.module.less 新增 .variable_repl_text.log 样式,设置文本颜色为 CSS 变量 --foreground
packages/components/src/dialog/index.ts,x packages/components/src/notification/index.tsx, packages/core-browser/src/progress/progress.service.tsx, packages/extension/src/browser/vscode/api/main.thread.file-system-event.ts, packages/monaco/src/browser/contrib/merge-editor/widget/resolve-result-widget.tsx 统一将 MessageType 的导入从本地模块或 @opensumi/ide-components 移动到 @opensumi/ide-core-common,无功能变更。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DebugConsole
    participant Localization

    User->>DebugConsole: 发送清屏指令(ANSI序列)
    DebugConsole->>Localization: 获取 'debug.console.consoleCleared' 文案
    Localization-->>DebugConsole: 返回本地化字符串
    DebugConsole-->>User: 在控制台插入清屏提示
Loading
sequenceDiagram
    participant TreeNode
    participant ParentNode

    TreeNode->>ParentNode: mv(to)
    alt to 为 null 或非 CompositeTreeNode
        TreeNode->>TreeNode: _parent = undefined
        TreeNode->>TreeNode: dispose()
    else to 为 CompositeTreeNode
        TreeNode->>ParentNode: 正常迁移逻辑
    end
Loading

Suggested reviewers

  • hacke2
  • Ricbet
  • Aaaaash
    """

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
warning eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead
warning eslint > file-entry-cache > flat-cache > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning eslint > @humanwhocodes/config-array > @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > rimraf > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > glob@7.2.3: Glob versions prior to v9 are no longer supported
error Couldn't find any versions for "@opensumi/ide-dev-tool" that matches "workspace:*"
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between adb30e7 and cd111f2.

📒 Files selected for processing (6)
  • packages/components/src/dialog/index.tsx (1 hunks)
  • packages/components/src/notification/index.tsx (1 hunks)
  • packages/core-browser/src/progress/progress.service.tsx (2 hunks)
  • packages/core-common/src/types/message.ts (1 hunks)
  • packages/extension/src/browser/vscode/api/main.thread.file-system-event.ts (1 hunks)
  • packages/monaco/src/browser/contrib/merge-editor/widget/resolve-result-widget.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • packages/components/src/dialog/index.tsx
  • packages/extension/src/browser/vscode/api/main.thread.file-system-event.ts
  • packages/core-browser/src/progress/progress.service.tsx
  • packages/components/src/notification/index.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core-common/src/types/message.ts
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: 🚀🚀🚀 Next Version for pull request
  • GitHub Check: ubuntu-latest, Node.js 20.x
  • GitHub Check: unittest (ubuntu-latest, 18.x, jsdom)
  • GitHub Check: unittest (ubuntu-latest, 18.x, node)
  • GitHub Check: unittest (macos-latest, 18.x, jsdom)
  • GitHub Check: build (ubuntu-latest, 20.x)
  • GitHub Check: unittest (macos-latest, 18.x, node)
  • GitHub Check: build (macos-latest, 20.x)
  • GitHub Check: build-windows
🔇 Additional comments (1)
packages/monaco/src/browser/contrib/merge-editor/widget/resolve-result-widget.tsx (1)

4-4: 导入重构:将 MessageType 从 ide-components 移至 ide-core-common

这个变更是将 MessageType 的导入来源从 @opensumi/ide-components 迁移到 @opensumi/ide-core-common,同时与 localizeuuid 一起导入。这符合代码库中的更广泛重构工作,使导入更加一致和集中化。

变更不影响运行时逻辑,只是改变了导入的来源,保持了功能的一致性。

Also applies to: 9-9

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/debug/src/browser/view/variables/debug-variables.view.tsx (1)

193-194: 考虑使用可选链优化代码

静态分析工具建议在这里使用可选链表达式来简化代码并提高可读性。

-  const paddingLeft = `${
-    (defaultLeftPadding || 8) + (item.depth || 0) * (leftPadding || 0) + (ExpressionContainer.is(item) ? 0 : 18)
-  }px`;
+  const paddingLeft = `${
+    (defaultLeftPadding ?? 8) + (item.depth ?? 0) * (leftPadding ?? 0) + (ExpressionContainer.is(item) ? 0 : 18)
+  }px`;
🧰 Tools
🪛 Biome (1.9.4)

[error] 193-194: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e90988a and c57ef86.

📒 Files selected for processing (4)
  • packages/components/src/recycle-tree/tree/TreeNode.ts (1 hunks)
  • packages/debug/src/browser/tree/debug-tree-node.define.ts (2 hunks)
  • packages/debug/src/browser/view/console/debug-console-session.ts (1 hunks)
  • packages/debug/src/browser/view/variables/debug-variables.view.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/debug/src/browser/tree/debug-tree-node.define.ts (1)
packages/components/src/recycle-tree/tree/TreeNode.ts (1)
  • CompositeTreeNode (361-1882)
🪛 Biome (1.9.4)
packages/debug/src/browser/view/variables/debug-variables.view.tsx

[error] 193-194: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: unittest (ubuntu-latest, 18.x, jsdom)
  • GitHub Check: unittest (macos-latest, 18.x, jsdom)
  • GitHub Check: unittest (macos-latest, 18.x, node)
  • GitHub Check: unittest (ubuntu-latest, 18.x, node)
  • GitHub Check: ubuntu-latest, Node.js 20.x
  • GitHub Check: build-windows
  • GitHub Check: build (ubuntu-latest, 20.x)
  • GitHub Check: build (macos-latest, 20.x)
🔇 Additional comments (5)
packages/debug/src/browser/view/console/debug-console-session.ts (1)

111-111: 修复了控制台清屏消息的本地化键值

将本地化键从原来错误的拼写 'debug.console.consoleCleare' 更正为 'debug.console.consoleCleared',确保在控制台被清除时显示正确的提示信息。

packages/debug/src/browser/view/variables/debug-variables.view.tsx (1)

194-194: 优化了非ExpressionContainer节点的缩进距离

将非ExpressionContainer类型节点的左侧缩进从16px增加到18px,提升了变量树视图的可读性和层次感。这种微调有助于更清晰地区分不同类型的调试变量节点。

🧰 Tools
🪛 Biome (1.9.4)

[error] 193-194: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

packages/components/src/recycle-tree/tree/TreeNode.ts (1)

312-312: 优化了节点父级引用的处理逻辑

当目标父节点为null或非CompositeTreeNode时,直接设置_parent属性而非通过setter,避免了额外的路径重置逻辑,这是一个细微但有效的优化。

packages/debug/src/browser/tree/debug-tree-node.define.ts (2)

117-128: 改进了变量排序逻辑,提升了用户体验

修改后的排序算法做了以下几个关键改进:

  1. 使用displayNamename作为排序依据,更符合用户直观认知
  2. 将字母数字字符排在符号字符之前,符合常见的排序习惯
  3. 采用区域感知的数字排序(localeComparenumeric:true选项),使得"变量10"能正确排在"变量2"之后
  4. 提供了更一致、更符合直觉的变量显示顺序

这些改进使得调试过程中的变量排序更加直观和易用。


129-129: 优化了复合节点和普通节点的排序优先级

调整了复合节点(CompositeTreeNode)的排序优先级,现在将复合节点(如对象、数组等可展开的变量)排在普通节点之前,这与标准的调试器行为保持一致,更加符合用户预期。

@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2025

Codecov Report

Attention: Patch coverage is 15.38462% with 11 lines in your changes missing coverage. Please review.

Project coverage is 52.89%. Comparing base (e90988a) to head (cd111f2).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/debug/src/browser/tree/debug-tree-node.define.ts 0.00% 5 Missing and 5 partials ⚠️
.../src/browser/view/console/debug-console-session.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4533      +/-   ##
==========================================
- Coverage   52.90%   52.89%   -0.01%     
==========================================
  Files        1677     1677              
  Lines      103326   103331       +5     
  Branches    22387    22381       -6     
==========================================
- Hits        54660    54658       -2     
- Misses      40487    40492       +5     
- Partials     8179     8181       +2     
Flag Coverage Δ
jsdom 48.40% <15.38%> (-0.01%) ⬇️
node 12.06% <7.69%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erha19
Copy link
Copy Markdown
Member Author

erha19 commented May 9, 2025

/next

@erha19
Copy link
Copy Markdown
Member Author

erha19 commented May 12, 2025

/next

@opensumi
Copy link
Copy Markdown
Contributor

opensumi Bot commented May 12, 2025

🎉 PR Next publish successful!

3.8.3-next-1747014731.0

@erha19 erha19 merged commit ef1836d into main May 12, 2025
12 checks passed
@erha19 erha19 deleted the fix/python-debug-console branch May 12, 2025 03:55
@coderabbitai coderabbitai Bot mentioned this pull request May 12, 2025
1 task
@erha19 erha19 mentioned this pull request May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working 🎨 feature feature required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants