Repository navigation
fix(windows): synchronize native terminal table lifetime - #23257
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe changes update Windows ConPTY shell and console lifecycle handling, add job-management operations and stress coverage, and expand Windows job tests. E2E workflows and a runner now pass focused spec paths without a Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Japanese and Korean users may misunderstand whom the note is for. These localized wording issues can be corrected before merge or accepted as bounded follow-up work. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The Windows terminal changes address a native concurrency defect without a demonstrated new security exposure. Lifecycle behavior still warrants review because terminal cleanup governs whether process trees remain owned. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 6 files. (9 skipped: 9 unsupported.)
✨ Finishing Touches 💡 1📝 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. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — the locking change reads as correct. Two minor test-diagnostic suggestions inline.
Reviewed changes
- Native table lock extended (
config/patches/[email protected], patchedsrc/win/conpty.cc): everyptyHandlesaccess now takesptyJobMutex— creation publishes a fully-built baton under the lock, andget_pty_baton/remove_pty_batonwere renamed to*_lockedwith all callers wrapped.PtyResize/PtyCleargained aconsoleClosedguard;PtyKillresolvesconpty.dllbefore the lock and callsClosePseudoConsole/TerminateProcessafter releasing it so the exit watcher can run. - Windows stress probe (
config/scripts/windows-pty-table-stress.cjs+windows-pty-job.win32.test.ts): spawns real ConPTYs, overlaps terminal replacement with the prior shell's exit watcher, and reports native exit codes and operation phases. - MSYS test diagnostics (
windows-msys-job.win32.test.ts): bounded transcript, captured exit, and job membership on failure. - Patch-expectation + i18n updates: self-exit test tracks the
*_lockedrename; the locale catalog entries are an ancestor from #23256, not this change.
Two independent passes — native concurrency and test efficacy — found no deadlock, use-after-free, or remaining table race in the new discipline. The two-way handshake between PtyKill and the watcher (consoleClosed + shellExited, whichever second frees the baton under the lock) can't double-erase, and PtyConnect's unlocked use of handle is sound because no watcher exists until SetupExitCallback at the end of that function.
ℹ️ Nitpicks
PtyResizeandPtyClearstill holdptyJobMutexacrossLoadConptyDlland theResizePseudoConsole/ClearPseudoConsolecall, whilePtyKilldeliberately resolves the DLL before the lock and closes outside it (conpty.cccomment: "ClosePseudoConsole blocks … and the watcher must be able to take the lock while it does"). If resize/clear can block, the exit watcher and a concurrentPtyKillstall for the duration; mirroringPtyKill's placement (copyhpcunder the lock, call outside) would remove the coupling.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 5c8da8a1-f73c-4e1e-8896-1869f126a97f
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (16)
.github/workflows/golden-e2e-experiment.yml.github/workflows/terminal-ime-e2e.ymlconfig/patches/[email protected]config/scripts/playwright-focused-workflow-selection.test.mjsconfig/scripts/run-terminal-ibus-hangul-e2e.mjsconfig/scripts/terminal-ime-e2e-workflow.test.mjsconfig/scripts/windows-pty-table-stress.cjssrc/main/pty/node-pty-self-exit-pseudoconsole-close.test.tssrc/main/windows/windows-msys-job.win32.test.tssrc/main/windows/windows-pty-job.win32.test.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.json
💤 Files with no reviewable changes (1)
- config/scripts/run-terminal-ibus-hangul-e2e.mjs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| "c845170b3b": "行 {{value0}}-{{value1}}", | ||
| "commentTooLarge": "コメントが大きすぎるため安全に送信できません。" | ||
| "commentTooLarge": "コメントが大きすぎるため安全に送信できません。", | ||
| "f6c449191e": "AI に関するメモを追加", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 3 'f6c449191e|Add note for the AI' src/renderer/srcRepository: stablyai/orca
Length of output: 8171
Use a recipient-oriented Japanese translation.
f6c449191e maps to the placeholder “Add note for the AI”. AI に関するメモを追加 means “Add a note about AI,” not “Add a note for the AI.”
Suggested fix
- "f6c449191e": "AI に関するメモを追加",
+ "f6c449191e": "AI向けのメモを追加",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "f6c449191e": "AI に関するメモを追加", | |
| "f6c449191e": "AI向けのメモを追加", |
| "c845170b3b": "라인 {{value0}}-{{value1}}", | ||
| "commentTooLarge": "댓글이 너무 길어 안전하게 제출할 수 없습니다." | ||
| "commentTooLarge": "댓글이 너무 길어 안전하게 제출할 수 없습니다.", | ||
| "f6c449191e": "AI에 대한 메모 추가", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Clarify that the note is for the AI.
AI에 대한 메모 추가 reads as “add a note about AI.” Use AI에게 전달할 메모 추가 to make clear that the note is intended for the AI.
There was a problem hiding this comment.
✅ No new issues found in the commits since the last review.
Reviewed changes
- Removed the misplaced
--from the focused IME and golden commands (.github/workflows/golden-e2e-experiment.yml,.github/workflows/terminal-ime-e2e.yml,config/scripts/run-terminal-ibus-hangul-e2e.mjs).pnpmforwards the separator to the Playwright CLI, which then treats the spec paths as user arguments and schedules the whole suite instead of the requested files. - Added
config/scripts/playwright-focused-workflow-selection.test.mjs, which extracts the focused commands, runs the installed Playwright CLI in--listmode against a temp fixture that also contains an unrelated control spec, and asserts each command discovers only its requested files. - Tightened the shape assertion in
config/scripts/terminal-ime-e2e-workflow.test.mjsso a reintroduced--in the runner fails.
I confirmed the separator's effect against the checkout: playwright test -- a.spec.ts lists every spec under testDir, while the same invocation without -- lists only a.spec.ts. The new test therefore fails if the separator returns, so it is real coverage rather than a tautology.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ailures # Conflicts: # src/renderer/src/i18n/locales/ja.json # src/renderer/src/i18n/locales/ko.json
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Merged
origin/maininto the branch (93d5d61a26). The merge advanced the PR's merge-base to71344de1, and no PR-authored file changed:git diffbetween the previously reviewed head4074f652and this head across all 11 PR paths is empty. - The i18n catalog files dropped out of the PR diff.
en/es/fr/ja/ko/zhnow match the new merge-base (main also carries theuseDiffCommentDecorator/commentTooLarge/Add noteentries this branch had added), so they are no longer PR-authored changes. The checked-out head still contains every one of those entries.
The prior native-locking review stands: the ConPTY table synchronization, the Windows stress probe, and the CI focused-Playwright separator fix are byte-identical to the version reviewed at 4074f652. The two earlier inline threads on config/scripts/windows-pty-table-stress.cjs (assert native job membership for the freshly spawned slots; preserve the primary error through the finally drain) remain open on code this merge did not touch.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Assert each golden platform step and its focused arguments before deduplicating Playwright discovery probes.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Preserved the PTY stress probe's primary failure (
config/scripts/windows-pty-table-stress.cjs): thefinallydrain now records adrain-errorwhen the body already threw instead of replacing it, and the original error is rethrown. - Asserted native job membership for every ready shell (
config/scripts/windows-pty-table-stress.cjs):waitForReadynow checkslistJobProcessIdsfor each record, so the three slots whose creation, resize and clear overlap the previous shell's exit watcher are inspected, not just the survivor. - Isolated the hourly build identity from
package.json(config/scripts/hourly-build-version.mjs+ its test):getHourlyBuildIdentityaccepts an optionalpackageVersion, both tests pass it explicitly, and a new test covers a newer package version acting as the base floor. - Added a per-platform focused-command assertion (
config/scripts/playwright-focused-workflow-selection.test.mjs): the golden workflow's Linux/macOS/Windows steps must each run exactly their expected spec files, so a reintroduced--separator fails the test.
Both prior inline threads on the stress probe are now addressed (replies and resolutions posted). The two touched unit tests pass locally (18 tests across 2 files).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Opening a Windows terminal while another closes can race over the native terminal list. Protecting the complete list prevents concurrent access from corrupting it.
What Changed
Use the existing mutex for every terminal-table lookup, insertion, removal, and resize/clear operation. Initialize new entries before publishing them; keep blocking pipe waits, console closure, and callbacks outside the lock. Job ownership and process-termination behavior stay intact.
Add a real-Windows subprocess stress test that waits for shell readiness, overlaps terminal replacement with cleanup, and reports native exit codes and operation phases. The MSYS marker test now includes a bounded transcript, shell exit, and job membership on failure, with its original deadline and assertions.
The focused IME and golden CI commands also remove a misplaced
--separator. Playwright 1.63 was treating the filenames after it as user arguments, launching 824 tests instead of four in the X11 IME lane and exhausting its 25-minute budget. The same correction is tracked separately in #23270.Why
The exit watcher already removed entries under a lock, but creation and several readers did not use it. Synchronizing all accesses fixes the demonstrated race directly. A portable ThreadSanitizer extraction reports the race before this change; the fixed version completes 20,000 entries without a finding. This proves the source defect, not the cause of the historical #23194 worker crash or #23162 MSYS marker timeout.
Linked Issue
N/A. Follow-up to CI evidence on #23194 and #23162; no tracking issue created.
Visual Proof
N/A — native terminal lifetime and test diagnostics; no visual change.
Shared hourly CI prerequisite
The branch also carries the shared hourly-build fixture correction from #23274. Historical package-version inputs are explicit, with exact version/build-number assertions retained and a newer-package control. Default build commands still read package.json; the dedicated no-module-mocking lint rule stays enabled.
Testing
macOS: 58 focused tests passed; eight Windows-only tests skipped. Node typecheck, changed-code quality, focused lint/format, script syntax, and frozen offline patch install passed. Installed native source matches the reviewed patch.
Portable C++ ThreadSanitizer: extracted baseline insertion/removal reports a race on
ptyHandles; fixed code completes 20,000 entries with an empty table. This does not execute Windows APIs.Hosted Windows Windows CI compiled fresh native source and passed 495 tests (23 skipped), including the new 31.8-second stress test, all six original ownership tests, MSYS, Git Bash foreground, and host-crash cleanup. Packaged native capability and CLI smoke passed. Tested merge
13c6e1e4contains head8ab235f95aand base668fa719.A separate Windows baseline/fixed experiment rebuilt both addons without native caches. Each build passed two 49-terminal stress samples and two samples of each MSYS mode (original immediate write, explicit-prompt control, and wait-for-prompt), retaining the same 15-second marker deadline. All 16 scheduled samples passed. This bounded experiment did not reproduce either historical Windows failure, so their attribution remains unproven. Source, patch, addon hashes, transcripts, and every sample result are retained in the run artifacts.
A separate Linux Wayland check failed: the captured browser trace deletes the second composed Hangul syllable and emits an empty composition end before the digit; PTY bytes are
아1,1,아1. Linux and renderer source are unchanged by the native fix, but the cause of that cancellation remains under investigation. The assertion remains intact. A separate isolated diagnostic run retained Wayland/IBus traces and passed all nine input sequences with unchanged cadence and zero retries. That run did not reproduce the cancellation and does not establish its cause. Fresh current-head CI includes the concrete X11 command correction and is still being verified.Native stress probe review
The stress probe now checks native job membership for every ready replacement shell, preserves its original failure when exit draining also times out, and labels the required host-job capability as a runner precondition. Both 15-second deadlines and the required host-job assertion remain intact. VM fault injection demonstrates that the old probe missed six corrupted replacement slots and could mask the original error; the revised probe catches each case. Final-head Windows CI remains the native execution gate.
Review
Native locking and the readiness-aware stress test independently reviewed. The MSYS timeout remains under investigation; diagnostics do not classify it as flaky or prove a fix.
Agent skill upstream boundary
Notes
Windows-only native behavior; no RPC, SSH execution boundary, or mobile changes. Existing kill-on-close, breakaway, and unverifiable ownership semantics are preserved.
Checklist