Skip to content

fix(windows): synchronize native terminal table lifetime - #23257

Merged
OrcaWin merged 7 commits into
mainfrom
ci/resolve-reported-failures
Sep 26, 2026
Merged

OrcaWin merged 7 commits into
mainfrom
ci/resolve-reported-failures

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​148 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​143
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​289 $\color{#cf222e}{\Huge{\mathbf{−}}}$​66 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​223

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

  • I manually tested these changes locally
  • Automated tests added/updated

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 13c6e1e4 contains head 8ab235f95a and base 668fa719.

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

  • Not applicable.

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

  • This PR is small and focused
  • I explained what changed and why
  • N/A for visual proof, with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform and SSH/remote impact considered
  • Focused checks pass locally; CI covers platform-specific tests and packaging

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The 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 -- separator, with a test for Playwright file selection. Six locales add translations for AI-note and add-note actions.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 4074f

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 Review

Security architecture risk: 🔵 Low · up to 4074f

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
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A native lifetime error could affect terminals sharing the Windows host process; job termination itself targets the process tree associated with one verified terminal, not an external service or data store.

Trust Boundaries and Controls

  • observed — The native job control checks both terminal ID and shell PID and holds the mutex while using the job handle. The focused-selection test is test-local and adds no demonstrated production entrypoint.

Resilience and Maintainability Implications

  • observed — A missing or refused job operation reports unavailable rather than claiming the tree was terminated. Console closure is claimed once, and the remaining baton is removed by whichever of kill or shell exit completes second.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: synchronizing Windows native terminal table lifetime.
Description check ✅ Passed The description is complete and directly covers the change, rationale, testing, platform impact, visual proof, review status, and checklist. It also documents the unresolved Wayland failure and the la…
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ 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], patched src/win/conpty.cc): every ptyHandles access now takes ptyJobMutex — creation publishes a fully-built baton under the lock, and get_pty_baton/remove_pty_baton were renamed to *_locked with all callers wrapped. PtyResize/PtyClear gained a consoleClosed guard; PtyKill resolves conpty.dll before the lock and calls ClosePseudoConsole/TerminateProcess after 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 *_locked rename; 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

  • PtyResize and PtyClear still hold ptyJobMutex across LoadConptyDll and the ResizePseudoConsole/ClearPseudoConsole call, while PtyKill deliberately resolves the DLL before the lock and closes outside it (conpty.cc comment: "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 concurrent PtyKill stall for the duration; mirroring PtyKill's placement (copy hpc under the lock, call outside) would remove the coupling.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 5c8da8a1-f73c-4e1e-8896-1869f126a97f

📥 Commits

Reviewing files that changed from the base of the PR and between 668fa71 and 4074f65.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • .github/workflows/golden-e2e-experiment.yml
  • .github/workflows/terminal-ime-e2e.yml
  • config/patches/[email protected]
  • config/scripts/playwright-focused-workflow-selection.test.mjs
  • config/scripts/run-terminal-ibus-hangul-e2e.mjs
  • config/scripts/terminal-ime-e2e-workflow.test.mjs
  • config/scripts/windows-pty-table-stress.cjs
  • src/main/pty/node-pty-self-exit-pseudoconsole-close.test.ts
  • src/main/windows/windows-msys-job.win32.test.ts
  • src/main/windows/windows-pty-job.win32.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/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.

Comment thread src/renderer/src/i18n/locales/ja.json Outdated
"c845170b3b": "行 {{value0}}-{{value1}}",
"commentTooLarge": "コメントが大きすぎるため安全に送信できません。"
"commentTooLarge": "コメントが大きすぎるため安全に送信できません。",
"f6c449191e": "AI に関するメモを追加",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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/src

Repository: 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.

Suggested change
"f6c449191e": "AI に関するメモを追加",
"f6c449191e": "AI向けのメモを追加",

Comment thread src/renderer/src/i18n/locales/ko.json Outdated
"c845170b3b": "라인 {{value0}}-{{value1}}",
"commentTooLarge": "댓글이 너무 길어 안전하게 제출할 수 없습니다."
"commentTooLarge": "댓글이 너무 길어 안전하게 제출할 수 없습니다.",
"f6c449191e": "AI에 대한 메모 추가",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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). pnpm forwards 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 --list mode 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.mjs so 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

m4air added 2 commits September 26, 2026 14:19
…ailures

# Conflicts:
#	src/renderer/src/i18n/locales/ja.json
#	src/renderer/src/i18n/locales/ko.json

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Merged origin/main into the branch (93d5d61a26). The merge advanced the PR's merge-base to 71344de1, and no PR-authored file changed: git diff between the previously reviewed head 4074f652 and this head across all 11 PR paths is empty.
  • The i18n catalog files dropped out of the PR diff. en/es/fr/ja/ko/zh now match the new merge-base (main also carries the useDiffCommentDecorator / commentTooLarge / Add note entries 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

m4air and others added 2 commits September 26, 2026 14:41
Assert each golden platform step and its focused arguments before deduplicating Playwright discovery probes.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Preserved the PTY stress probe's primary failure (config/scripts/windows-pty-table-stress.cjs): the finally drain now records a drain-error when 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): waitForReady now checks listJobProcessIds for 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): getHourlyBuildIdentity accepts an optional packageVersion, 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).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit 4c38cab into main Sep 26, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants