Skip to content

perf: cap shared-path scans and synchronize Windows PTY access - #23194

Merged
nwparker merged 14 commits into
mainfrom
nwparker/perf-09-25-shared-path-suggestion-limit
Sep 26, 2026
Merged

nwparker merged 14 commits into
mainfrom
nwparker/perf-09-25-shared-path-suggestion-limit

Conversation

@nwparker

@nwparker nwparker commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Typing in Worktree Shared Paths stops checking names once it has filled the 50 suggestions it can show.

What Changed

Collect matching entries in order and stop at the limit instead of filtering the entire list first. Empty searches, sparse arrays and unusual limits retain the existing results. With 50,000 matching entries, name reads fall from 50,050 to 100, including the final exact-match check.

Why

Stopping when the result is full avoids extra work without another cache or invalidation rule.

Linked Issue

N/A — PR only, as requested.

Visual Proof

N/A — identical suggestion results and interaction behavior; no UI markup changed.

Testing

  • Automated tests added/updated.
  • Live packaged-app check; no whole-app latency claim.

Eleven suggestion tests pass, with original/candidate differential and work-count coverage. The changed-code quality checks and dedicated anti-slop lint pass. All 46 checks completed successfully or were correctly skipped on merged head 32983f5e4c0879bc7ed1ae9cc5216cc8250917ae.

The new Windows installer-probe fixture repair is tracked in #23209. This PR was merged by another contributor after its same-head Windows rerun passed, before that fixture correction reached its branch. The later branch commit containing the fixture correction is not part of this merge.

Review

Suggestion behavior was independently reviewed against 1,680 input combinations. Queries with too few matches still scan the full list. The helper adds no filesystem, provider, credential or wire operation.

The earlier native race repair is already on main via #23257. Neither those passing native tests nor the module-path experiment establish the cause of the historical worker exit or 20-second probe timeout.

Agent skill upstream boundary

  • Not applicable.

Notes

Folder and SSH behavior is unchanged. The suggestion work-count reduction is measured; end-to-end latency is not. No GitHub issue was created.

Checklist

  • Before/after, mechanism and alternative explained.
  • Visual N/A explained; cross-platform and remote behavior considered.
  • Self-reviewed; focused tests and changed-code checks pass.
  • Merged-head full CI; the historical timeout cause remains unproven.

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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 7582f78b-3a59-4598-9c0b-9f17f599daea

📥 Commits

Reviewing files that changed from the base of the PR and between 195e51b and 7c36110.

📒 Files selected for processing (1)
  • config/scripts/playwright-focused-workflow-selection.test.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/scripts/playwright-focused-workflow-selection.test.mjs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The changes update the node-pty patch, including Windows ConPTY job tracking and cleanup, and add Windows stress and regression coverage. Worktree symlink filtering now uses a bounded scan for eligible queries and limits. Focused Playwright workflow commands no longer include a standalone -- before spec paths, and new tests verify spec selection. The Japanese and Korean AI-note translations are revised.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 7c361

No identified issue currently blocks merging; complete the normal final-head checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 195e5

The Windows terminal change adds controls for process ownership and coordinated cleanup. No new security exposure was confirmed, but concurrent teardown and some Windows runtime modes remain insufficiently verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The direct containment surface is Windows PTY shells and their descendant processes. Per-PTY job assignment can improve tree targeting, but assignment failure retains the prior unassigned-process behavior.

Trust Boundaries and Controls

  • observed — The production ConPTY termination path supplies PTY ID and shell PID, while the native operation checks both against the baton before terminating its job. No new attacker-controlled production entrypoint was established by the selection test.

Resilience and Maintainability Implications

  • inferred — Whether a concurrent close can occur before shell and job publication is unresolved. The previous lifecycle also exposed an unlocked creation interval, so the available evidence does not establish a newly introduced security condition.

Hardening Proposals

  • proposed — Validate close-during-connect and job-assignment-failure transitions on the final head, including whether fallback teardown contains descendants when no per-PTY job is available.
🚥 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 8 functions across 8 files. 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 two primary changes: bounded shared-path scans and synchronized Windows PTY access.
Description check ✅ Passed The description includes the required sections and explains the user impact, implementation, rationale, testing, scope, compatibility considerations, and remaining CI requirements. It appropriately ma…
  • 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 new issues found.

Reviewed changes

  • Early-exit suggestion scan — getWorktreeSymlinkPathFilterState now collects matches in a bounded loop that stops once maxSuggestions results are found, instead of filtering the whole list and slicing. Only entries needed to fill the visible list have their name read.
  • Compatibility fallback preserved — empty queries and non-integer/negative/NaN/±Infinity limits still take the original filter().slice() expression, so slice semantics are untouched for unusual caller-supplied bounds.
  • New scan-budget tests — pins the bounded name-read count and differentially compares against the original expression across limits, sparse arrays, and the exact-match-after-limit case.

Behavior is output-preserving: I ran the 11 scoped tests (all pass) and a separate 20,000-case differential fuzz over random arrays (including holes) and the full unusual-limit set — zero divergences in output, order, element identity, hole handling, or showLiteralItem. The new tests genuinely fail against the pre-change code (the maxSuggestions: 0 getter case would throw under filter()), so they are not tautological. No native, IPC, wire, or filesystem surface changes; the helper is renderer-local and only used by WorktreeSymlinksSection.tsx.

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

@nwparker
nwparker force-pushed the nwparker/perf-09-25-shared-path-suggestion-limit branch from ca67e5c to 326ca5b Compare September 26, 2026 19:50
@nwparker

Copy link
Copy Markdown
Contributor Author

Reviewed the CodeRabbit docstring-coverage warning. This repository explicitly requires concise comments limited to non-obvious reasoning (AGENTS.md), so I am declining the generic 80% docstring suggestion. The existing ownership/behavior comments and focused regression tests cover the decisions in this change. No code change is warranted for that style-only warning.

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 92d9662b-daa4-4784-9fa0-3ac6dd29a616

📥 Commits

Reviewing files that changed from the base of the PR and between 326ca5b and fe31037.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • config/patches/[email protected]
  • 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

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment thread config/patches/[email protected] Resolved
@nwparker nwparker changed the title perf: stop scanning shared paths when suggestions are full perf: cap shared-path scans and synchronize Windows PTY access Sep 26, 2026

@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

  • Full ConPTY table synchronization — conpty.cc now holds ptyJobMutex for every ptyHandles/pty_baton access that was still unprotected: PtyStartProcess insertion (now via a local handle instead of ptyHandles.back()), PtyConnect's lookup and hShell/shellPid/hJob store, and PtyResize/PtyClear, which also gained a consoleClosed guard. get_pty_baton/remove_pty_baton are renamed _locked to mark the contract.
  • Kill path unchanged in shape, now on the renamed helper — PtyKill still resolves the conpty DLL before touching state and closes the pseudoconsole outside the lock, so the lock is not held across the draining call.
  • Native regression coverage — new windows-pty-table-stress.cjs drives kill/resize/clear concurrently with fresh spawns; a new .win32 test runs it and asserts the survivor keeps its job; the MSYS job test now reports exit/job/output diagnostics on timeout.
  • i18n catalog entries — the three DiffCommentPopover keys added to six locales match the fallbacks in DiffCommentDraftCard.tsx.

I audited the synchronization for remaining gaps: ptyHandles is only touched by the two _locked helpers and the locked emplace_back; the outside-lock reads (allowJobBreakaway, hpc, handle values) are immutable after publish; the exit watcher releases the mutex before its blocking BlockingCall; and holding the mutex across ResizePseudoConsole/ClearPseudoConsole is the deliberate inverse of PtyKill's placement — it is what keeps hpc valid for the call — with conout draining on its own worker, so it does not gate those calls. No lock-ordering cycle found.

ℹ️ Native scope still travels under a renderer-perf title

The PR presents as the shared-path suggestion optimization, but the delta now also carries a Windows ConPTY table-lifetime synchronization fix and its stress fixture. Worth making the merge record and any future revert match the change set.

Technical details
# Scope vs. title

## Affected sites
- `config/patches/[email protected]` — `ptyJobMutex` now covers `PtyStartProcess`, `PtyConnect`, `PtyResize`, `PtyClear`
- `config/scripts/windows-pty-table-stress.cjs` — new stress fixture
- `src/main/windows/windows-pty-job.win32.test.ts` — new integration test

## Required outcome
- The title/description should make clear that a native Windows teardown change rides along, so the merge record and any revert match the change set.

## Open questions for the human
- Is the native synchronization intended to ship in this PR, or should it be split from the renderer perf change?

Pullfrog  | 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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 0a35c73d-62c7-4505-9ee3-800d2987e22b

📥 Commits

Reviewing files that changed from the base of the PR and between fe31037 and 195e51b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .github/workflows/golden-e2e-experiment.yml
  • .github/workflows/terminal-ime-e2e.yml
  • config/scripts/playwright-focused-workflow-selection.test.mjs
  • config/scripts/run-terminal-ibus-hangul-e2e.mjs
  • config/scripts/terminal-ime-e2e-workflow.test.mjs
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
💤 Files with no reviewable changes (1)
  • config/scripts/run-terminal-ibus-hangul-e2e.mjs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/ja.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@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

The delta since the prior pullfrog review is the focused-Playwright CI fix, its regression test, and a historical-version test pin; the native ConPTY synchronization and i18n entries are unchanged.

  • Focused file selection restored — golden-e2e-experiment.yml, terminal-ime-e2e.yml, and run-terminal-ibus-hangul-e2e.mjs no longer pass a literal -- before their spec paths, matching the pnpm run test:e2e "${TEST_FILES[@]}" form changed-e2e already uses; the terminal-ime-e2e-workflow.test.mjs regex follows.
  • Selection pinned by test — new playwright-focused-workflow-selection.test.mjs extracts the four focused commands and runs the installed Playwright 1.63.0 CLI --list over a temp fixture, asserting each resolves only its requested files and checking the golden commands per platform.
  • Historical hourly fixture pinned — hourly-build-version.test.mjs now mocks readFileSync to return its 1.4.201 package fixture, so a newer real package.json version can no longer break the expected 1.4.203 build identity.

I ran the new and changed config tests (23/23 pass) and reproduced the mechanism: with the locked Playwright 1.63.0, -- <file> selects every spec while <file> selects only the named one, and pnpm 12 forwards the literal -- to the script.

ℹ️ The -- fix leaves 28 reliability-gate commands on the broken form

config/reliability-gates.jsonc still carries 28 pnpm run test:e2e -- tests/e2e/<spec> commands. These traverse the same pnpm run → npx playwright test path, so the literal -- reaches Playwright and the file filter is dropped — the exact failure this PR fixes. changed-e2e already uses the correct no--- form (pinned at pr-e2e-gate-contract.test.mjs:177), so the manifest is now the outlier. Worth aligning in the same sweep if the reliability harness runs these commands verbatim; it does not block this PR.

Technical details
# Reliability-gate e2e commands still pass a literal `--`

## Affected sites
- `config/reliability-gates.jsonc` — 28 `"pnpm run test:e2e -- tests/e2e/<spec>"` commands (e.g. lines 13443-13445, 13970, 15030-15031).

## Evidence
- Probe with the locked Playwright 1.63.0: `playwright test --list --reporter=json -- <file>` lists the named file AND an unrelated spec; without `--` it lists only `<file>`.
- Probe with pnpm 12.0.0: `pnpm run <script> -- a --workers=1` echoes the script invocation with the literal `--` forwarded.
- The new `playwright-focused-workflow-selection.test.mjs` asserts the positive (no-`--`) case only; it does not scan `reliability-gates.jsonc`.

## Required outcome
- The 28 commands select their named specs (drop `--`), matching `changed-e2e`.

## Open questions for the human
- Does the external reliability harness execute these strings through `pnpm run` verbatim? If it strips `--` itself, no change is needed — but the inconsistency remains.

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

@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

The delta since the prior pullfrog review (d6a9934) is two commits: PTY stress-probe failure handling and an hourly build-identity test seam. Native production code and the renderer suggestion helper are unchanged.

  • Stress probe keeps the first failure — windows-pty-table-stress.cjs now stores the try-block failure and, if the exit drain also times out, logs drain-error and keeps the original error instead of overwriting it, so the first failure surfaces.
  • Ready shells assert job membership — waitForReady asserts listJobProcessIds includes each ready shell's pid, and the required host-job precondition is reported before its assertion.
  • Hourly identity takes an explicit package version — getHourlyBuildIdentity accepts an optional packageVersion that overrides the package.json read; the historical-identity test injects 1.4.201 directly instead of module-mocking node:fs. The CLI caller passes no override, so default resolution is unchanged.

The test seam and probe assertions are test-only and do not touch the shipped version-resolution or renderer paths.

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

@nwparker

Copy link
Copy Markdown
Contributor Author

I checked the manifest on the current head. The 28 text occurrences consist of 14 configured gate commands and 14 historical evidence-run command records across seven gates. This PR does not change that manifest; the repository’s manifest consumer validates it rather than executing the strings. I agree that an external runner which executes those configured strings verbatim can encounter the same forwarded--- behavior with locked Playwright 1.63.0.

I am keeping that existing manifest migration outside this PR, as your review explicitly marks it nonblocking. A blanket replacement would rewrite historical evidence, and the validator currently requires recorded evidence commands to match a configured command. A correction needs to preserve the commands actually recorded for old runs while updating future invocation semantics and their validation. No manifest correction or new evidence run is claimed here, and no GitHub issue was opened.

The focused workflows in this PR now omit the separator, and their test requires each platform’s command before deduplicating the actual discovery probes. This note does not change the native PTY risk verdict or substitute for final-head CI.

@nwparker
nwparker merged commit 003b37d into main Sep 26, 2026
78 of 80 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.

1 participant