Repository navigation
fix(core): run web terminal PTYs on the bundled ConPTY backend - #11643
Conversation
The web terminal spawned its PTYs with node-pty's default inbox ConPTY backend, where a natural shell exit orphans the conhost.exe --headless the backend spawned: the native exit watcher erases the pty baton before delivering onExit, pty_baton has no destructor, and the erased HPCON is unreachable from JS (microsoft/node-pty#965). Every exited web terminal leaked ~8 MB for the life of the CLI, and a pin bump does not fix it. Mirror the #11497 shell path: spawn with useConptyDll on Windows so the bundled backend releases its host reference right after spawn and the host exits with its last client. The bundled backend adds one synchronous throw point — a missing or unloadable conpty.dll — and a web terminal has no child_process fallback, so a failed bundled spawn retries once on the inbox backend: the pre-fix leaking behavior beats a terminal that cannot start at all. A failed spawn produced no child, so the retry cannot double-spawn. The 4001 non-retryable close path is unchanged. Also switch the agent-view PTY host to the bundled backend (same leak, lower rate), refresh the conpty-host release docs, and add a VERIFIED_NODE_PTY pin test so a node-pty bump forces re-verification of the native teardown semantics the release path depends on. Refs #11352
5cb5f11 to
cce1866
Compare
|
Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. 中文请勿对活跃的 PR 执行 rebase 或 force-push,因为这会使已有的评审评论失效。另外,供日后参考:作为集成流程的一部分,机器人始终会自动将所有改动压缩(squash)为单个提交。 |
doudouOUC
left a comment
There was a problem hiding this comment.
Agent-assisted review at cce1866c0b8eb028130b5618923de7c51ce83423 — no confirmed code Criticals in this static review.
Reviewed the full six-file diff against base 518f6795f9eda4b9911c2a1e8ea76ddc787551cb, the complete changed production files, and the added tests. Traced useConptyDll from both spawn sites through the actual PTY loaders; checked the registry's failed-spawn retry, creation bookkeeping, early output/exit, live release and exit-time cleanup. Downstream inspection included the terminal WebSocket handler, server registry ownership/workspace drain, the shell-service precedent, and Agent View's host-process launch/exit cleanup. No daemon route is added or changed here; the terminal handler continues to supply its resolved workspace cwd/environment to the registry.
Suggestion (non-blocking): packages/cli/src/agent-view/pty-host.ts:346-357 has no inbox-backend retry, unlike web-terminal-registry.ts:325-336. A bundled-DLL load failure propagates through runAgentViewPtyHostProcess before it starts the host server (pty-host-process.ts:477-481). Please confirm that failing Agent View startup, rather than using the web terminal's compatibility fallback, is intentional. This is not a claim that the shipped DLL is missing or that normal Windows launches fail.
History / scope: There were no prior formal review Criticals in the fetched history; the triage comment's fallback asymmetry is the suggestion above, not an independently reproduced native failure. Core/cross-package policy: approximately 57 changed production-file lines including comments; this is a small fix, not a 500+ line refactor. The author has repository admin permission, verified via GitHub's collaborator-permission endpoint.
Verification limits: Static source/test inspection only; no PR code, unit tests, builds, Windows PTYs, or native leak measurements were executed. The mock tests verify option propagation and cleanup calls, not native conhost.exe reclamation. The deliberately retained inbox fallback's natural-exit leak is documented, not presented as fixed.
Comment only; no approval implied.
Co-authored-by: Qwen-Coder <[email protected]> Patrol-Run: qwen-pr-conflict/jmtx6sqi9yb
The six `@lydell/node-pty*` pins live in three unsynchronized places — the root manifest, packages/core's manifest, and a hardcoded map in scripts/prepare-package.js — but the conpty-host tripwire asserted only one key of one manifest, so bumping the win32 prebuild keys or the root manifest left it green and skipped the human re-check it exists to force. Derive the six pins in writeDistPackageJson from packages/core's manifest (deleting the third hardcoded table), and widen the tripwire to assert all six core keys plus an equality against the root manifest's six — the declaration packages/cli's agent-view actually resolves in a dev tree. Co-authored-by: Qwen-Coder <[email protected]> Patrol-Run: qwen-pr-closeout/jmtxennouyn
…eb terminal Switching the web-terminal registry to the bundled ConPTY backend let a probing shell's DA / DSR query bytes into the recorded scrollback; a reconnect that replays the buffer made the client's xterm.js re-answer each query and write the fresh reply back into the still-live shell's stdin. The bundled backend answers no queries itself, and the browser is not guaranteed to be attached when the startup probe fires. Mirror the other half of the shell path (#11497): on win32, feed a headless terminal the PTY stream so it answers the probe server-side, and strip the query bytes from both the scrollback and the live stream so a replay cannot re-emit them. Also bring the releasePtyResources docstring in line with the bundled backend (R1-8). Co-authored-by: Qwen-Coder <[email protected]> Patrol-Run: qwen-pr-closeout/jmtxennouyn
|
@qwen-code /triage |
1 similar comment
|
@qwen-code /triage |
Maintainer verification — the Windows half, on a real Windows machineI verified this locally as a maintainer, deliberately aimed at the one thing the PR lists as not validated: "Windows real-machine acceptance (conhost/OpenConsole counting, pwsh latency, interactive rendering) — needs a Windows environment; PR CI skips the Windows job." The sandboxed verification above also had to leave exactly that uncovered ("This container is Linux"). So I ran the PR on a real Verdict: LGTM — the central claim holds on real Windows, and the fix is exactly as large as advertised. Three non-blocking follow-ups below; two of them independently reproduce findings the sandbox report already filed. 1 · The leak, and its absence, measured on Windows18 web terminals opened and exited through the real registry (3 rounds × 6, each shell exits naturally), counting
The same A/B at the raw backend level (6 PTYs, no registry) isolates it to the backend rather than to anything in this diff, and the interactive arms answer the rest of the manual acceptance list — Two results in that figure are worth calling out:
Also: the PR's own unit tests actually executed on Windows — the platform PR CI skips. 2 · POSIX is unchanged, and the built product still works
Against a real PTY and a real shell, head·native ≡ base·native on every observable, and the new behaviour appears only behind the win32 gate (2 × 2 matrix in the next figure). 3 · Do the new tests hold the new behaviour down?10 mutations, each applied alone, then the PR's own suites re-run — 7 killed, 3 survived: Two of the survivors are the same gaps the sandbox report filed (responder dispose; the 4 · Follow-ups (none blocks the merge)
5 · The description has drifted from the head commit
Environment, harnesses and how to reproduce
中文版维护者本地验证 —— 在真实 Windows 机器上补齐 Windows 那一半我以维护者身份在本地做了一轮验证,目标明确对准 PR 自己列为未验证的那一项:「Windows 真机验收(conhost/OpenConsole 计数、pwsh 延迟、交互渲染)—— 需要 Windows 环境;PR CI 跳过 Windows job」。上面那份沙箱验证同样把这块留空了("This container is Linux")。 所以我在真实的 结论:LGTM —— 核心声明在真机上成立,修复范围与描述一致。 下面三条后续项均不阻塞合并,其中两条与沙箱报告的发现相互独立复现。 1 · Windows 上实测到的泄漏与其消失通过真实 registry 开/关 18 个 web terminal(3 轮 × 6,每个 shell 自然退出),统计挂在 daemon 进程下的
裸后端层面的同款 A/B(6 个 PTY,不经 registry)说明泄漏来自后端本身而非本 diff 的任何代码;交互臂回答了手工验收清单的其余部分 —— 其中两点值得单独说:
另外,PR 自带单测这次真的在 Windows 上跑过了(PR CI 跳过的那个平台): 2 · POSIX 行为不变,打出来的产物照常可用head 上 对真实 PTY + 真实 shell,head·native 与 base·native 在每一个可观测量上完全一致,新行为只出现在 win32 门后(见 2 × 2 矩阵)。 3 · 新增测试能否钉住新行为10 个变异逐个施加后重跑 PR 自带套件:7 个被杀、3 个存活。其中两个与沙箱报告所报的缺口相同(应答器 dispose; 4 · 后续项(都不阻塞合并)
5 · PR 描述已与 head commit 脱节
(复现环境与方法见英文正文折叠块;证据图托管在 |
|
@qwen-code /triage |
Three review findings on the bundled-ConPTY web terminal path: - The scrollback scrub was a stateless per-chunk regex over only the `c`/`n` finals, so the query families xterm.js answers beyond those (tertiary DA, DECRQM, DECRQSS, XTVERSION, DECREQTPARM, OSC colour queries) still reached the scrollback and were re-answered into the live shell on reconnect. Replace it with a stateful stripper covering every family and carrying a probe split across two chunks. - resize() resized only session.pty, leaving the headless query responder on its 80x24 spawn grid, so geometry-dependent replies were computed against the wrong size. Forward the resize to session.queryTerminal. - loadXtermHeadless() was a second suspension point whose cancelledCreations/ disposed guards were not re-checked, so a release()/releaseWorkspace()/ dispose() landing during the import leaked a PTY the caller had cancelled. Re-check both after the import. Co-authored-by: Qwen-Coder <[email protected]> Patrol-Run: qwen-pr-closeout/jmtxrimarz8
yiliang114
left a comment
There was a problem hiding this comment.
A bounded reproduction found one correctness blocker at this head; see the inline finding. The issue remains scoped to web-terminal PTYs, while agent-view also switches backend and has no equivalent validation. The PR body also still says no headless xterm is introduced, although the implementation now contains a responder. Recommend correcting the actual query handling, removing the unrelated agent-view switch, and updating the description before another triage. No Windows conhost/OpenConsole-count or latency acceptance test was run, so this is not a Windows end-to-end sign-off.
Co-authored-by: Qwen-Coder <[email protected]> Patrol-Run: qwen-pr-closeout/jmty6iqs0zv
|
@qwen-code /triage |
The stateful stripper held any unterminated OSC (a title SET included) with no cap, so one stray ESC ] swallowed every later chunk and grew pending unbounded; the DCS alternative also required the full introducer, leaking its halves that reassemble into a re-answered DECRQSS. Hold only viable query prefixes, cap the hold, end an OSC partial at a bare ESC (accepting the C1 ST terminator), hold the DCS introducer, and gate the stripper on the responder so a failed headless load no longer strips with nobody left to answer. Correct the query-set doc comment. Co-authored-by: Qwen-Coder <[email protected]> Patrol-Run: qwen-pr-closeout/jmtyf3dx109
Co-authored-by: Qwen-Coder <[email protected]> Patrol-Run: qwen-pr-conflict/jmtyhy9mj0e
|
Closeout at The registry no longer rewrites terminal bytes. Its Windows responder forwards only primary DA, and snapshot metadata tells the browser when that probe is server-owned. A new PTY's initial output can receive replies. Reconnect history restores into a detached terminal with no forwarding listener; the old visible terminal keeps accepting input, and the snapshot callback swaps views and enables replies before queued live output parses. Both sides reject incompatible replay protocols explicitly. This applies to Web Shell on all hosts, not only VS Code; daemon and Web Shell must update together. Verification:
Scope integrity (changed lines = additions + deletions, including comments/scripts; not pure production-logic LOC):
The two added implementation files are the existing terminal WebSocket route and Web Shell component, both required by the explicitly approved replay contract. This additive commit touches three implementation files, +123/-131, replacing the handwritten filters with the boundary above; it does not add dependencies or extend agent view. The original baseline is preserved and the conservative round count is now five. Scope verdict: corrected under the recorded user approval, not a new baseline. Four obsolete tests were deleted and two payload/display cases merged into the exact-stream regression after independent deletion defense; the parallel color regression remains. Feedback: R2-1 is addressed by this correction. The two overlapping color threads were already resolved by the parallel patrol; their correction was retained. Public Status snapshot: the pushed head is mergeable, but CI/review gates are still pending. Lint & Static, Ubuntu tests and no-AK integration were in progress; the native Windows unit job was skipped. No automated-review wait or merge was performed. Native Windows process counts, startup/DLL-fallback behavior and real-daemon/PTY acceptance remain outstanding; the existing inbox fallback is not claimed to fix the leak. No further Suggestions or unrelated agent-view changes are included in this round. |
Co-authored-by: Qwen-Coder <[email protected]>
chiga0
left a comment
There was a problem hiding this comment.
Review Summary
Files reviewed
packages/core/src/services/web-terminal-registry.ts(+185/-16)packages/core/src/services/web-terminal-registry.test.ts(+466/-43)packages/core/src/services/conpty-host.ts(+10/-8)packages/core/src/services/conpty-host.test.ts(+156, new file)packages/cli/src/agent-view/pty-host.ts(+5)packages/cli/src/agent-view/pty-host.test.ts(+22)scripts/prepare-package.js(+14/-6)
Findings
No blockers found. All previously raised Critical findings (query scrub, resize forwarding, loadXtermHeadless cancellation, stripper/responder gate mismatch, DCS DECRQSS coverage, chunk-split handling) are resolved at HEAD.
Clean areas
- ConPTY backend selection:
useConptyDll: os.platform() === 'win32'is correct; bundled spawn with inbox fallback on failure is sound (failed synchronous spawn produces no child, no double-spawn risk). TerminalQueryStripperregex correctness: Covers all xterm.js query families (DA1/2/3, DSR, DECRQM, DECRQSS, XTVERSION, DECREQTPARM, OSC colour queries).PARTIAL_ESCAPE_SUFFIX_REcorrectly identifies viable query prefixes without swallowing non-query OSC title sets. Non-query escapes (SGR, erase, cursor) preserved.- Lifecycle management:
releasePtyResourceswithptyResourcesReleasedflag prevents double-disposal.queryTerminalandqueryReplyDisposableproperly disposed. No resource leaks — all synchronous code between creation andsessions.set()prevents event-loop interleaving. - Concurrency: Each session has its own
TerminalQueryStripperandqueryTerminalinstance. No shared mutable state between terminal sessions. prepare-package.js: Derivation frompackages/core/package.jsonoptionalDependencies is correct. Version tripwire test asserts all 6 pins match across both manifests.- Platform gating: Off Windows,
queryTerminalstaysundefined, stripping is a no-op. Test-pinned. - Test coverage: Comprehensive — bundled backend spawn, DA probe answer/strip, split chunks, DCS DECRQSS (complete and split), OSC partial handling, non-query escape preservation, responder resize, cancellation during headless load, inbox retry on bundled failure, double-failure cleanup.
Needs human review
- Windows CI skipped:
windows-latestjob was not run. Actual native ConPTY behavior, bundled-to-inbox fallback with realconpty.dll, andconhost.exeleak reclamation are unverified on real Windows. @xterm/headlessdependency: Dynamically imported on every Windows terminal creation. Verify it's in the published package's dependencies (not just devDependencies) — runtimeimport()requires it to be installed.
Reviewed with AI assistance.
qqqys
left a comment
There was a problem hiding this comment.
COMMENT
核对基线:head 77257a5acc1d1e663f2b42433f0d3d21bb456bbf。
本次不 Approve:唯一未解决的线程是一条 Critical(R2-1,web-terminal-registry.ts:112),作者已明确说明只修了其中两个症状、其余三个转入 #11734 并刻意不关闭该线程。我在当前 head 的代码上独立复核,确认其中症状 (3) 仍然成立。
已确认修好的部分:症状 (1) 与 (4)
我逐条对过 web-terminal-registry.ts:83-122,缓解措施与线程里给出的方案一致且实现正确:
pending现在有上界,吞字节不会永不结束。MAX_HELD_ESCAPE_CHARS = 256(:110)配合strip()里的const hold = partial !== null && partial[0].length <= MAX_HELD_ESCAPE_CHARS;(:118)——超界时pending清空、complete取整个combined,也就是把累积内容当 payload 整体放行。原报告里「之后每个 chunk 都返回''、pending在MAX_BUFFER_BYTES之外持续增长、$锚定正则反复全量重扫」这条失效路径已经关掉。- OSC 挂起分支收窄成只hold 颜色查询前缀。
PARTIAL_ESCAPE_SUFFIX_RE的 OSC 分支是\x1b\](?:10|11|4;[0-9]+);\?(?:[^\x07\x1b\x9c])*:保留?谓词(因此未终结的标题/颜色 SET 不会被误当查询挂起,也就不会被从两个出口丢掉)、字符类排除\x1b(遇到裸 ESC 即结束,与 xterm 取消 OSC 的行为一致)、排除\x9c(接受 C1 ST 作为终结符)。三点都对上了。 - DCS 引导符已纳入挂起。 正则末尾新增的
|\x1bP\$?让ESC P与ESC P $这两种落在引导符中间的切分也被hold,因此不会再两半漏进session.buffer重新拼成一个完整 DECRQSS 被浏览器二次应答。症状 (4) 关闭。
作者记录的红绿确认(移除 OSC 上界会让 does not swallow payload after an unterminated non-query OSC 变红、移除 DCS 分支会让 DECRQSS 用例变红,48/48 registry 测试通过)与我在代码上看到的一致。
仍然存在的阻塞:症状 (3) —— OSC 12 与多下标 OSC 4 逃过过滤,回放会把应答写进仍然存活的 shell
这一条我不是转述,而是在当前 head 的正则上直接核出来的。TERMINAL_QUERY_SEQUENCE_RE(:83-85)的 OSC 分支是:
\x1b\](?:10|11|4;[0-9]+);\?(?:\x07|\x1b\\)
它只覆盖 OSC 10、OSC 11,以及单下标形式的 OSC 4,且要求 ;? 之后紧跟 BEL 或 ESC \。因此:
- OSC 12(光标色查询)
\x1b]12;?\x07不在(?:10|11|4;[0-9]+)的候选里,原样通过strip()。 - 多下标 OSC 4 如
\x1b]4;0;?;1;?\x07:4;0;?之后跟的是;而不是\x07或\x1b\\,无法匹配,同样原样通过。
而按该 Critical 的实测,声明的客户端对这两者都会应答。于是它们会被记进 scrollback,每次重连回放都把它们重新应答进仍然存活的 shell 的 stdin —— 正是这个特性要消除的危害本身。这与「过滤清单在服务端手工枚举」是同一个根因:漏掉一族就漏掉一族,且漏掉的那一族恰好是会写回 stdin 的。
其余两个症状
- 症状 (2)(OSC 10/11/4 从两个出口都被删掉,但 pin 住的
@xterm/headless5.5.0 responder 结构上无法应答,导致 Neovim/bat/delta 的ESC ] 11 ; ?背景探测从「merge base 上浏览器会应答」变成「无人应答」):我没有独立复核 responder 的能力边界,按现有 GitHub 数据记为作者已承认、仍未关闭。若成立,这是一条明确回归。 - 症状 (5)(responder 按自身 DECRQM 状态作答,36 个模式里 1 处与出货客户端分歧):影响面小,我未独立复核。
关于结论分歧
chiga0 已在同一 head(16:34:27Z)APPROVED。我的结论不同,原因是本渠道的判定规则:只要有一条历史阻塞问题在当前 head 上仍然存在,就不能 Approve——而症状 (3) 我已在代码上确认仍成立,且作者本人也说明 (2)/(3)/(5) 未被本次缓解关闭。把结构性修复拆到 #11734 是合理的工程安排,但它不改变「当前 head 上这条 Critical 的一部分仍在」这个事实。
CI:Lint & Static、Test (ubuntu-latest, Node 22.x)、Integration Tests (no-AK, No Sandbox) 在当前 head 上均为 pass;review-pr pending,按策略不作为门禁。Test (windows-latest, Node 22.x) 为 skipped,而本 PR 的主题正是 Windows 上的 ConPTY 后端,真机确认仍欠着。
下一步
两个方向任选其一:
- 按线程里的结构性方案收口(也是我认同的方向):不再在服务端改写字节,而是只在回放期间抑制应答——
serve/routes/terminal.ts已有CONTROL_FRAME_PREFIX的服务端到客户端控制帧通道,把 snapshot 作为{ type: 'replay', output }下发,在TerminalPanel.tsx里用replaying = true; term.write(output, () => { replaying = false; })包住写入并在该标志期间丢弃onData。这样现有与未来的所有查询族一次覆盖,两个正则和它们的逐角落测试都可以删掉;headless responder 保留给 bundled backend 的 DA 停顿,但收窄到它本来要解决的 DA 族,避免它按自身模式状态作答。 - 若本轮必须保留服务端过滤,则至少把 OSC 分支从手工枚举改成能覆盖 OSC 12 与多下标 OSC 4 的形式(例如按
OSC <数字>;?的通用查询形态匹配,并保留?谓词以免误删 SET),同时补上线程里点名的两个用例。
无论走哪条,请把症状 (2) 的回归一并给出结论:要么让 responder 能应答颜色查询,要么不要从客户端出口删掉这些查询。
yiliang114
left a comment
There was a problem hiding this comment.
Reviewed at 77257a5acc (7 files, +858/-73) against ea10c604bf.
Verdict: the standing [Critical] R2-1 is stale at this head, and I could not reproduce any of its blocking witnesses. What is left is a wiring gap in the responder, which is non-blocking.
I transcribed the two regexes from this head and ran R2-1's own witnesses against them.
| R2-1 witness | as reported (at 1bd418b328) |
this head (77257a5acc) |
|---|---|---|
\x1b]0;title, then visible, then more visible text\r\n |
listener payloads ["","",""], snapshot "" |
\x1b]0;titlevisiblemore visible text\r\n -- nothing is swallowed |
DCS split after \x1bP, and after \x1bP$ |
the report measured leaks in that window | both deliver AFTER; the \x1bP\$? alternative closes them |
Symptoms (1) and (4) -- the two the report itself named as the urgent mitigation -- landed in f6c306adfd, which is one commit after the round-4 review at 1bd418b328. The thread is describing code that is no longer here, so it can be resolved.
One measured correction to that finding's evidence. Symptom (2) rests on grep -c "onColor(" returning 0 for the pinned headless build. That count is an artifact of the minified bundle: @xterm/headless 5.5.0 does ship the handlers -- setOrReportSpecialColor (x4) and setOrReportIndexedColor (x2) are present, and the OSC 4 / 10 / 11 / 12 handlers are registered. The real gap is narrower, and it is a channel mismatch:
// @xterm/headless 5.5.0, driven directly
t.write('\x1b]11;?\x07'); t.write('\x1b]10;?\x07'); t.write('\x1b]4;1;?\x07');
t.write('\x1b[6n'); t.write('\x1b[c');
// onData = ["\u001b[1;1R", "\u001b[?1;2c"] <- DSR + DA1 answered here
// onColor = [] <- colour reports do not touch this channel
_setOrReportSpecialColor only calls this._onColor.fire(...); it never routes the reply through the data event. This registry subscribes to onData only (web-terminal-registry.ts:507), so the OSC 10/11/4 arm of the strip removes those queries from the browser's stream while the server-side responder cannot answer them on the channel it uses. Either also forward onColor into proc.write, or drop the colour arm from TERMINAL_QUERY_SEQUENCE_RE -- as it stands that is the one family that is stripped with no server-side answerer. (xterm 6.0.0's browser build takes the same _onColor path and the web-shell app has no onColor subscription, so I could not establish that main answered colour probes either; treat this as an unproven benefit rather than a demonstrated regression.)
Also confirmed at this head:
- The earlier blocking item -- the responder constructed at 80x24 and never resized -- is fixed:
resize()now carriessession.queryTerminal?.resize(cols, rows). - R2-1 symptom (3) still stands:
strip('\x1b]12;?\x07')andstrip('\x1b]4;0;?;1;?\x07')return their input unchanged while\x1b]11;?\x07is removed. Inconsistent within one family, andmainis no worse, so it is a coverage gap rather than a regression. - The agent-view host sets
useConptyDll: win32with no inbox retry (packages/cli/src/agent-view/pty-host.ts:356) while the registry retries once. The description's reasoning -- a web terminal has nochild_processfallback -- applies equally there, so either add the same single retry or say in a comment why the two sites differ.
None of these block merge.
qwen-code-dev-bot
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES
已核对 head 77257a5acc1d1e663f2b42433f0d3d21bb456bbf(vs merge-base ea10c604)。required 四项全部 success(Test (ubuntu-latest, Node 22.x)、Lint & Static、Integration Tests (no-AK, No Sandbox)、web-shell E2E Smoke)。ConPTY 后端切换、创建期取消、退出期资源释放与打包那几块我复核没有发现问题。
拦的是线程 R2-1(未解决,且作者自己写明「(2)/(3)/(5) 未被本轮缓解关闭,留档在 #11734」)。先说清楚已确认修好的部分:PARTIAL_ESCAPE_SUFFIX_RE(web-terminal-registry.ts:99)的 OSC 分支现在保留 ? 谓词、遇裸 ESC 即终止并接受 C1 ST \x9c,DCS 引导串 ESC P / ESC P$ 也被兜住。我在该 head 复跑基线 Tests 48 passed (48),并分别注入两个变异:把 OSC 分支退回「任何未终止的 ESC ]」、删掉 |\x1bP\$? 这一支 → 各自恰好打红 1 条具名用例,所以「吃掉渲染字节」和「chunk 边界分裂」两条性质确实已经闭合。
阻塞项:剥离集合与服务端应答器的能力不匹配(症状 (2)(3)(5),我实测)
应答器是 core 钉死的 @xterm/[email protected](packages/core/package.json:69;实例 web-terminal-registry.ts:328,其 onData 在 :506 回灌进 PTY)。我用本机这份 5.5.0 直接量各族查询的应答:
OSC 10;? / OSC 11;? / OSC 4;1;? / OSC 4;1;2;? / OSC 12;? -> ""(完全不应答)
CSI 6n -> ESC [ 1 ; 1 R
DECRQM ?2026;$p -> ESC [ ?2026;0$y
DECRQSS ESC P $ q ... ESC \ -> ESC P 0 $ r ESC \
而 TERMINAL_QUERY_SEQUENCE_RE(:85)剥掉的恰是 10|11|4;[0-9]+ 这三族颜色查询。于是这些探针既不再到达浏览器、服务端也答不出来,结果退化成代码里为「无应答器」写明的「查询被丢弃、最多等约 2 秒」——合并基线上它们本可得到应答。这是本 PR 引入的行为回归(Neovim / bat / delta 的背景色探测是直接触发方)。
同一处的另两点:OSC 12 与多索引 OSC 4;1;2;?... 不在交替式里,仍会原样落入 buffer 并在每次重连回放时被浏览器再应答进仍然存活的 shell stdin(即本功能要消除的害处对这两族依旧存在);而剥掉查询等于把回答者从「正在使用的客户端」换成另一份状态的 headless —— 我用随包的 @xterm/[email protected] 对同一输入实测得到 ESC [ ?2026;2$y(识别),服务端给的是 ;0(不识别),应用据此会判定同步输出不可用而放弃使用。
不必等 #11734 的结构化方案,最小修法即可:把剥离集合收窄到「这份应答器确实会答的族」,暂时让 10|11|4(以及本就未剥的 12、多索引 4)继续到达浏览器,恢复合并基线行为;或为这几族补上服务端应答并在用例里钉住。若决定维持现状,请至少把「颜色查询此后不再被任何一侧应答」与 OSC 12/多索引 4 的处理差异写进 :66-84 的注释与 docs/——现在那段注释把这三族描述成已由服务端职责覆盖,与实测不符。
一处缓解自身缺见证(同一线程,顺手补)
把 strip() 里的 partial[0].length <= MAX_HELD_ESCAPE_CHARS 整个删掉(即恢复 R2-1 症状 (1) 里「pending 无上限、每个 chunk 重扫整段累积」的形态)后,48 条用例全部仍绿:256 字符封顶这一条目前没有可失败的见证。请补一条:喂入超过该长度且始终以 ESC ] / ESC P 前缀结尾的输出,断言前缀之外的字节仍然落到 buffer 与 readSnapshot(),并确认去掉封顶会让它变红。
其余
另外 17 条线程(readSnapshot 回放不再携带查询、退出期 releasePtyResources、ConPTY 探测、prepare-package.js 打包面等)逐条对过当前 head,作者回复所述与代码一致,本轮不再重复提出。review-pr 在本 head 仍 pending,属评审机器人自身档,不计入门禁。
…nnot answer The stateful stripper added here removed the OSC 10/11/12/4 colour queries from both the scrollback and the live listener, but the pinned @xterm/headless 5.5.0 responder answers none of them: `onData` carries DA/DSR/DECRQM/DECRQSS only, while `_setOrReportSpecialColor` reports on the internal `_onColor` emitter that the headless Terminal does not expose (`term.onColor` is undefined) and that nothing in this file subscribes to. Deleting the family from the browser's stream as well left a probing program unanswered, where the browser's own xterm.js 6.0.0 `_handleColorEvent` is the answerer and answered it at the merge base. Narrow both regexes to the families the responder actually answers (plus the never-display-content DA3 / XTVERSION / DECREQTPARM trio that no build answers), drop the half-covered colour arm from the partial matcher — so the strip set and the doc block no longer disagree about what the colour family is — and correct the doc block to state the split. Covered by a new test asserting the whole family reaches both the live listener and the snapshot untouched, and that nothing is written back; it fails if the colour arm is restored. The colour queries that a reconnect replay re-answers are part of the replay-suppression redesign tracked in #11734. Co-authored-by: Qwen-Coder <[email protected]> Patrol-Run: qwen-pr-closeout/jmtyno0zh0n
Preserve raw PTY bytes and limit the Windows server responder to primary DA. Mark snapshots explicitly and restore history into a detached browser terminal while the old terminal continues forwarding user input. Activate live replies at the snapshot write callback, reject incompatible peers, and preserve the parallel color-query regression fix. Refs #11734. Co-authored-by: Qwen-Coder <[email protected]>
|
@qwen-code /triage |
11643 — state at the current head, and a re-review requestThe standing
So the change-request is stale: it predates both the fix and the approval. Requesting a fresh review of — 巡检 jmtyrycka0u (pr-closeout-sweep) |
Maintainer verification, round 2 —
|









What this PR does
Windows web-terminal and agent-view PTYs use bundled ConPTY to address the inbox backend's natural-exit host leak. Web terminals retry once on the inbox backend if bundled spawn fails, and release the remaining worker resources after exit while retaining scrollback.
The review follow-up keeps terminal output intact. The Windows server answers only primary device-attribute startup probes; the browser owns colors, modes and geometry. Reconnect history is restored without forwarding its automatic replies, while the old visible terminal keeps accepting keyboard input. First-connection output and subsequent live output can still receive replies. This removes the hand-written query filters instead of adding more escape-sequence cases.
Why it's needed
#11352 tracks Windows terminal processes left behind after exit. Selecting bundled ConPTY changes who answers terminal probes, so the backend switch also needs to preserve live answers without injecting historical responses into the shell on reconnect. The original filtering approach lost some color answers and replayed others. #11734 tracks that follow-up; the cross-package replay contract was explicitly approved for this PR.
Reviewer Test Plan
How to verify
Evidence (Before & After)
Before this correction, real package probes at
77257a5showed OSC 11 losing its only answer and OSC 12/multi-index OSC 4 answering again on replay. The interveningd8975farestored live color queries; this change preserves that correction and removes replayed replies as well.After: the actual modified React terminal component, real xterm and FitAddon were mounted in Chromium with controlled surrounding contexts and WebSocket transport. Fresh output produced six color/mode/DCS replies, plus one DA only when browser-owned. On reconnect, 14 native historical reply events produced zero outgoing replies; a real keyboard
karrived once during delayed restoration and the queued live batch produced seven replies once. Canceled restoration and legacy-protocol rejection passed, with no browser errors. This is component-boundary evidence, not a real daemon/PTY or Windows process-count test.Tested on
Environment (optional)
Node 22.22.0, React 19.2.4, browser xterm 6.0.0, FitAddon 0.11.0, headless xterm 5.5.0 and Chromium 149.0.7827.55. Focused registry, WebSocket-route and terminal-component tests passed, as did ESLint on the six edited TypeScript files. Package typechecks encountered stale project-reference build declarations, including APIs already present in source; they are not reported as passing. No dependency installation or full rebuild was run in this round.
Risk & Scope
Linked Issues
Refs #11352 · Refs #11497 · Refs #11734 · microsoft/node-pty#965. No issue is automatically closed by this description.
中文说明
这个 PR 做了什么
Windows web-terminal 和 agent-view PTY 改用 bundled ConPTY,处理 inbox 后端在自然退出时遗留 host 的问题。web terminal 在 bundled spawn 失败时回退 inbox 重试一次,并在退出后释放剩余 worker 资源,同时保留 scrollback。
本次评审修正保留完整终端输出。Windows 服务端只应答启动时的 primary DA 探测,颜色、模式和几何查询交给浏览器。重连历史恢复时不转发自动应答,旧的可见终端仍接受键盘输入;首次连接输出和随后的实时输出仍能得到应答。删除手写查询过滤器,不再继续枚举转义序列。
为什么需要
#11352 跟踪 Windows 终端退出后残留进程的问题。切换 bundled ConPTY 会改变终端探测的应答方,因此还必须保留实时应答,并防止重连把历史应答重新注入 shell。原有过滤方案会丢失一部分颜色应答,也会重放另一部分。#11734 跟踪该后续问题;这次跨包回放协议已获明确批准,放在本 PR 中修正。
评审测试计划
如何验证
证据(前后对比)
修正前,
77257a5上的真实终端包探测显示 OSC 11 丢失唯一应答,OSC 12 和多下标 OSC 4 在回放时再次应答。期间提交的d8975fa已恢复实时颜色查询;本次保留该修复,并消除历史回放应答。修正后,在 Chromium 中挂载实际修改的 React 终端组件、真实 xterm 和 FitAddon,仅控制外围 context 和 WebSocket 传输。首次输出产生六次颜色/模式/DCS 应答,只有浏览器负责 DA 时才额外产生一次 DA。重连时观察到的 14 次原生历史应答没有任何一次向外转发;延迟恢复期间真实键盘
k到达一次,排队的实时查询产生七次应答且各一次。中断恢复、旧协议拒绝均通过,浏览器没有错误。这是组件边界验证,不是真实 daemon/PTY 或 Windows 进程计数测试。测试平台
环境(可选)
Node 22.22.0、React 19.2.4、浏览器 xterm 6.0.0、FitAddon 0.11.0、headless xterm 5.5.0、Chromium 149.0.7827.55。registry、WebSocket 路由和终端组件的定向测试通过,六个改动 TypeScript 文件的 ESLint 通过。包级类型检查遇到过期的 project-reference 构建声明,其中包含源码中已有的 API;不将类型检查报告为通过。本轮没有安装依赖或运行完整构建。
风险与范围
关联 Issue
Refs #11352 · Refs #11497 · Refs #11734 · microsoft/node-pty#965。本描述不自动关闭任何 issue。