-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: pseudoterminal issue #4242
Conversation
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
warning eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options. 概述演练在 变更
序列图sequenceDiagram
participant Extension
participant ExtHostTerminal
participant VSCode
Extension->>ExtHostTerminal: 创建终端
ExtHostTerminal->>ExtHostTerminal: 生成短 ID
ExtHostTerminal->>ExtHostTerminal: 创建延迟对象
ExtHostTerminal->>VSCode: 启动终端
VSCode-->>ExtHostTerminal: 终端启动确认
ExtHostTerminal->>ExtHostTerminal: 解析延迟对象
这个序列图展示了终端创建和启动的基本流程,突出了新增的短 ID 和延迟对象管理机制。 Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (2)
packages/extension/src/hosted/api/vscode/ext.host.terminal.ts (2)
81-82
: 缺少对新添加属性的注释说明请为新添加的私有属性
_terminalStartDeferreds
添加注释,以提高代码的可读性和维护性。
Line range hint
463-495
: 优化_setupExtHostProcessListeners
方法中的事件监听顺序建议调整事件监听的顺序,确保在设置完所有监听器后再处理终端启动,以避免可能的事件丢失。
this._terminalProcesses.set(shortId, p); + // 确保终端进程已存在,再处理启动逻辑 this._terminalStartDeferreds.get(shortId)?.promise.then(() => { const awaitingStart = this._extensionTerminalAwaitingStart[shortId]; if (awaitingStart && p instanceof ExtHostPseudoterminal) { p.startSendingEvents(awaitingStart.initialDimensions); delete this._extensionTerminalAwaitingStart[shortId]; } });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/extension/src/hosted/api/vscode/ext.host.terminal.ts
(6 hunks)
🔇 Additional comments (3)
packages/extension/src/hosted/api/vscode/ext.host.terminal.ts (3)
490-495
: 避免异步操作中的竞态条件
在终端启动的 Promise 中,可能存在竞态条件,导致 startSendingEvents
在终端进程未完全准备好时被调用。
请确保在调用 startSendingEvents
前,终端进程已完全就绪。
451-456
:
确保终端进程存在时再调用 startSendingEvents
在 $startExtensionTerminal
方法中,您假设了终端进程一定存在,但实际情况下可能为空,需增加空值检查。
请在调用 startSendingEvents
前添加空值检查:
const terminalProcess = this._terminalProcesses.get(this.getTerminalShortId(id));
+ if (!terminalProcess) {
+ return { message: 'Terminal process not found' };
+ }
Likely invalid or redundant comment.
459-459
: 避免在终端未启动时调用 resolve
在 _terminalStartDeferreds
中调用 resolve
时,需要确保终端已正确启动,否则可能导致状态不一致。
请运行以下脚本以验证所有调用 resolve
的地方都确保了终端已启动:
/next |
🎉 PR Next publish successful! 3.6.3-next-1734429911.0 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4242 +/- ##
=======================================
Coverage 53.92% 53.93%
=======================================
Files 1618 1618
Lines 98295 98300 +5
Branches 20113 20115 +2
=======================================
+ Hits 53010 53014 +4
- Misses 37623 37624 +1
Partials 7662 7662
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Types
Background or solution
Changelog
Summary by CodeRabbit
新功能
Bug 修复