Skip to content

fix(terminals): park a remote pty only for the worktree that owns it - #13253

Closed
kunsanglee wants to merge 13 commits into
stablyai:mainfrom
kunsanglee:fix/remote-park-worktree-ownership
Closed

kunsanglee wants to merge 13 commits into
stablyai:mainfrom
kunsanglee:fix/remote-park-worktree-ownership

Conversation

@kunsanglee

@kunsanglee kunsanglee commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Remote terminal parking now requires authoritative PTY ownership across ordinary per-tab parking, retention force-parking, and parked watcher coverage. A worktree can park a tagged SSH or paired-runtime PTY only when its resolved transport owner exactly matches the owner embedded in the PTY ID.

Local, missing, unknown, ambiguous, and proven-foreign owners fail closed. The only local exception is an accepted host session snapshot matching the exact worktree, mirrored tab, pane leaf, and PTY session; that authority is revoked on remint, recreation, pending legacy state, disconnect, or removal and restored only by a new exact snapshot.

Why the transport owner

A paired HUB may own PTYs for an SSH worktree, and a mirrored web-surface pane may use a remote-runtime PTY inside a local repo. The guard therefore uses the same connection/runtime ownership resolvers as spawn and mirror synchronization instead of the resolved execution host.

Shape

  • terminal-park-pty-restore-eligibility owns per-PTY restore and authority decisions.
  • terminal-park-worktree-owner resolves tagged local/SSH/runtime authority from store state.
  • Worktree parking, per-tab parking, retention exemptions, activation-deferred watchers, and parked watcher reconciliation share the same authority inputs.
  • Web-mirror authority is keyed by exact worktree/tab/leaf/PTY identity and a bounded revision lifecycle.
  • Rendered parked-tab selection is isolated from the timing hook so the hook remains within the max-lines budget after the current-main parking synchronization changes.

Verification

  • 46/46 causal tests and 254 architecture tests passed on the validated candidate.
  • 2/2 headless paired-memory runs and 1/1 headed paired-memory run passed.
  • A fresh non-loopback macOS Electron client → SSH provider/relay → Docker OpenSSH → real Git topology passed exact authority, parking recovery, PTY/scrollback/live-I/O retention, fail-closed routing, causality, and cleanup.
  • After rebasing onto current main, the affected React parking/watcher suite passed: 9 files / 53 tests.
  • typecheck:web, targeted oxlint, reliability-gate validation, max-lines ratchet, and git diff --check pass.

Renderer-side policy only; no RPC, stream-frame, or remote wire payload changed. WSL remains held, and physical Windows/Linux desktop validation remains an explicit gap.

@kunsanglee
kunsanglee marked this pull request as ready for review August 9, 2026 00:34
@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

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
📝 Walkthrough

Walkthrough

Terminal parking now resolves worktree ownership for local, SSH, and runtime terminals. Shared PTY restoration checks validate owner authority, runtime capabilities, SSH connections, and pane identity. Cold-parking candidates, retention checks, activation, and parked-tab watchers pass ownership into these checks. Web-session authority state now supports exact pane validation, scoped revisions, cleanup, and parking recalculation. Tests cover matching and foreign owners, missing ownership, connection and environment mismatches, authority changes, and retention behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and verification, but it omits required template sections, including Linked Issue, Visual Proof, Testing checkboxes, Review, Checklist, AI Disclosure, and Author. Add the required template sections and provide the linked issue, visual proof or N/A justification, testing checklist, review checklist, AI disclosure, and author details.
Docstring Coverage ⚠️ Warning Docstring coverage is 7.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the primary change: restricting remote PTY parking to the owning worktree.
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.

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.

@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: Pro Plus

Run ID: add32eb1-3450-4ac0-8cba-55930b7f75bd

📥 Commits

Reviewing files that changed from the base of the PR and between 6da7b8e and d3795242a853df38770b7d6fbb9ead1bbffd1c90.

📒 Files selected for processing (16)
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/manual-terminal-worktree-park-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.ts
  • src/renderer/src/components/terminal-pane/terminal-park-pty-restore-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-pty-watcher.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-partial-reconciliation.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts
  • src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts
  • src/renderer/src/lib/connection-owner-resolution.ts

kunsanglee and others added 6 commits August 10, 2026 19:03
`isParkRestorableTerminalPty` took a worktreeId and ignored it on both remote
branches. The paired branch asked only whether the pty's environment advertises
bounded restore; the SSH branch asked only whether SSH parking is on and the id
parses. A worktree could therefore park — and later reveal — a remote session
whose id names a connection or environment that is demonstrably not its own.

The guard now compares the owner embedded in the pty id against the pair the
spawn path resolves for the worktree: `getConnectionIdFromState` for the
connection and `getRuntimeEnvironmentIdForWorktree` for the runtime environment.
It rejects only on a proven mismatch. An owner the resolver leaves unproven
(`undefined` before the repo hydrates, `null` for a local or ambiguous worktree)
does not reject, because the predicate also gates
`canWatcherCoverParkedTerminalTab`: a worktree it refuses becomes retention-budget
force-park material, so the pane is torn down anyway with no watcher attached and
its bells, titles, and agent-completion notifications go silent. A missed
comparison costs less than that.

This does not catch a relay reusing `pty-1` after a restart. That collision is
between two worktrees on the same connection, which share a connection id, so no
owner comparison can separate them. What it does catch is a pty positively known
to belong to another connection or environment.

Why the transport owner and not the resolved execution host: a worktree reached
through a paired HUB deliberately keeps its `ssh:` host while the HUB owns its
ptys, and a mirrored web-surface pane inside a local repo has a remote-runtime
pty with no remote host at all. Comparing the execution host refuses both.

- The per-pty predicate moves to `terminal-park-pty-restore-eligibility`; the
  original module was one line under its max-lines limit and owns the timing
  policy, which is a separate concern from the ownership question.
- `terminal-park-worktree-owner` resolves the owner pair from store state, plus a
  memoized hook for the two React call sites, so no caller assembles the pair by
  hand and the predicate module stays free of the store.
- The owner is a required argument. Required, not optional: an optional one lets
  a future caller drop the guard with no signal. The many-worktree pass in
  Terminal carries it per candidate rather than per policy, since the policy is
  shared across worktrees and the owner is not.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mu6j33LNsd4Mvv8a1NuFoo
@Jinwoo-H
Jinwoo-H force-pushed the fix/remote-park-worktree-ownership branch from d379524 to 063fe20 Compare August 10, 2026 23:04
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-park-owner-oracle.test.ts (1)

20-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the as casts so the oracle type-checks against the production contract. Both sites re-declare a shape locally and cast to reach the imported type. Each cast breaks the compile-time link between this oracle and the terminal-park-pty-restore-eligibility contract it exists to pin, so a field rename would keep compiling and flip an assertion silently instead of failing the build.

  • src/renderer/src/components/terminal-pane/terminal-park-owner-oracle.test.ts#L20-L46: delete oracleOwner and the legacy {connectionId, runtimeEnvironmentId} bag, then annotate the five constants directly as TerminalParkWorktreeOwner. Production reads only kind, connectionId on the ssh variant, and environmentId on the runtime variant, so no assertion changes.
  • src/renderer/src/components/terminal-pane/terminal-park-owner-oracle.test.ts#L156-L161: delete the ownerAwareExemption alias and call isEvictionExemptTerminalPty directly at line 166. The production signature already accepts paneIdentity as {tabId: string; leafId: string | null}, and the call passes a concrete string, so the narrowing alias adds nothing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6dc3df46-90bd-4169-b522-6c8345769500

📥 Commits

Reviewing files that changed from the base of the PR and between 8da3629 and 063fe20.

📒 Files selected for processing (29)
  • config/reliability-gates.jsonc
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/manual-terminal-worktree-park-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.test.ts
  • src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.ts
  • src/renderer/src/components/terminal-pane/terminal-park-authority-dependencies.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-authority-revision.ts
  • src/renderer/src/components/terminal-pane/terminal-park-owner-oracle.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-pty-restore-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-pty-watcher.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-partial-reconciliation.test.ts
  • src/renderer/src/components/terminal-pane/terminal-rendered-parked-tab-ids.ts
  • src/renderer/src/components/terminal-pane/use-terminal-force-park-exempt-tabs.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts
  • src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts
  • src/renderer/src/lib/connection-owner-resolution.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/runtime/web-session-terminal-park-authority.test.ts
  • src/renderer/src/runtime/web-session-terminal-park-authority.ts
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/renderer/src/components/terminal-pane/manual-terminal-worktree-park-eligibility.ts
  • src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts
  • src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx
  • src/renderer/src/lib/connection-owner-resolution.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-partial-reconciliation.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-pty-watcher.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.ts

The same testFiles array listed use-terminal-tab-cold-parking.test.ts twice.
Manifest check passes for all 74 gates.

Addresses the CodeRabbit note on config/reliability-gates.jsonc.
One conflicting file, src/renderer/src/runtime/web-session-tabs-sync.ts, four
hunks. Both sides add to the same lifecycle points and none of them interact:
this branch tracks per-worktree terminal park authority, main added a
window-visibility parking subscription and an index over the host tab-id map.

Resolutions:
- imports: both blocks kept.
- accepted snapshot: main's trackWebSessionTabsWorktree and
  recordAcceptedWebSessionTabsEnvironment, then this branch's
  replaceWebSessionTerminalParkAuthority. Independent maps, no ordering
  dependency.
- test reset: both reset calls kept.
- clearWebSessionTabsTrackingForWorktree: main's clearHostSessionTabIdMappings
  replaces this branch's inline prefix loop over hostSessionTabIdByLocalKey.
  The helper drains the same map and also maintains the new per-worktree
  mapping-key index the loop knew nothing about, so the loop would have leaked
  it. This branch's clearWebSessionTerminalParkAuthorityForWorktree stays.

Verified: src/renderer/src/runtime plus the four park suites, 78 files /
757 tests all passing. tsconfig.node, tsconfig.tc.cli, tsconfig.tc.web 0
errors. oxlint clean. max-lines ratchet OK. Reliability gate manifest passes
for all 74 gates.
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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: Pro Plus

Run ID: 89742e9b-a966-4dcb-90dc-df0ce20ee5ac

📥 Commits

Reviewing files that changed from the base of the PR and between a0a654c and d20e692.

📒 Files selected for processing (29)
  • config/reliability-gates.jsonc
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/manual-terminal-worktree-park-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.test.ts
  • src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.ts
  • src/renderer/src/components/terminal-pane/terminal-park-authority-dependencies.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-authority-revision.ts
  • src/renderer/src/components/terminal-pane/terminal-park-owner-oracle.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-pty-restore-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-pty-watcher.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-partial-reconciliation.test.ts
  • src/renderer/src/components/terminal-pane/terminal-rendered-parked-tab-ids.ts
  • src/renderer/src/components/terminal-pane/use-terminal-force-park-exempt-tabs.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts
  • src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts
  • src/renderer/src/lib/connection-owner-resolution.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/runtime/web-session-terminal-park-authority.test.ts
  • src/renderer/src/runtime/web-session-terminal-park-authority.ts
🚧 Files skipped from review as they are similar to previous changes (25)
  • src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx
  • src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts
  • src/renderer/src/components/terminal-pane/manual-terminal-worktree-park-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-partial-reconciliation.test.ts
  • src/renderer/src/components/terminal-pane/terminal-rendered-parked-tab-ids.ts
  • src/renderer/src/components/terminal-pane/terminal-park-owner-oracle.test.ts
  • src/renderer/src/lib/connection-owner-resolution.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-pty-watcher.ts
  • src/renderer/src/runtime/web-session-terminal-park-authority.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts
  • src/renderer/src/components/terminal-pane/terminal-park-authority-dependencies.test.ts
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.test.tsx
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-authority-revision.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts
  • src/renderer/src/runtime/web-session-terminal-park-authority.ts
  • src/renderer/src/components/terminal-pane/terminal-park-pty-restore-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.ts
  • src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts

Comment thread config/reliability-gates.jsonc Resolved
Two conflicting files. main refactored the same cold-park hook this branch is
extending, so both sides moved code out of the one function.

src/renderer/src/runtime/web-session-tabs-sync.ts — two hunks, both a reset and
a per-environment clear where main added browser-placement cleanup next to this
branch's park-authority cleanup. Distinct state, both kept.

src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts:

- selectPairedRuntimeParkingEnvironmentIds: main still imports it from
  terminal-hidden-view-parking, which no longer exports it — this branch moved
  it to terminal-park-pty-restore-eligibility and already imports it there.
  Took this branch's import; main's would not resolve.

- Candidate building: main extracted the inline map into
  buildTerminalTabColdParkCandidates, which does not carry the activeLeafId
  this branch's park-owner check reads. Took main's builder and attach
  activeLeafId at the call site, where the leaf key is already subscribed. The
  builder maps terminalTabs in order, so the index stays aligned.

- canWatcherCoverParkedTerminalTab: main uses it inline in the rendered-parked
  selection; this branch extracted that whole selection into
  terminal-rendered-parked-tab-ids, which carries the same
  activationDeferredMountTabIds clause and the same call. Verified the clause
  survived, then dropped the now-unused import from the hook.

terminal-hidden-view-parking.test.ts: main's two new activation-order cases
call selectColdParkedTerminalTabs without worktreeOwner, which this branch made
required. Added LOCAL_WORKTREE_OWNER to match every sibling call in the file.

Verified: src/renderer/src/runtime and src/renderer/src/components/terminal-pane,
345 files / 4183 tests, 65 failing. All 65 are in seven terminal-ime-xterm
suites that fail identically on untouched b19d99b (7 files, 65 failed / 41
passed) — this merge introduces none of them. tsconfig.node, tsconfig.tc.cli,
tsconfig.tc.web 0 errors. oxlint clean. max-lines ratchet OK. Reliability gate
manifest passes for all 80 gates.
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

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

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts (1)

192-194: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reduce the added implementation walkthroughs.

  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts#L192-L194: Replace this with one short comment that states the owner check requires the active leaf ID.
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts#L288-L291: Replace this with one short comment that states rendering and watcher synchronization use the same parked-tab set.

As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 766f83fb-e7a8-445c-8133-b2bdc12428b9

📥 Commits

Reviewing files that changed from the base of the PR and between b19d99b and d350f2f.

📒 Files selected for processing (29)
  • config/reliability-gates.jsonc
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/manual-terminal-worktree-park-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.test.ts
  • src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.ts
  • src/renderer/src/components/terminal-pane/terminal-park-authority-dependencies.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-authority-revision.ts
  • src/renderer/src/components/terminal-pane/terminal-park-owner-oracle.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-pty-restore-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-pty-watcher.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-partial-reconciliation.test.ts
  • src/renderer/src/components/terminal-pane/terminal-rendered-parked-tab-ids.ts
  • src/renderer/src/components/terminal-pane/use-terminal-force-park-exempt-tabs.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts
  • src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts
  • src/renderer/src/lib/connection-owner-resolution.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/runtime/web-session-terminal-park-authority.test.ts
  • src/renderer/src/runtime/web-session-terminal-park-authority.ts
🚧 Files skipped from review as they are similar to previous changes (27)
  • src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts
  • src/renderer/src/lib/connection-owner-resolution.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-watcher-partial-reconciliation.test.ts
  • src/renderer/src/components/terminal-pane/terminal-rendered-parked-tab-ids.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-park-authority-dependencies.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-force-park-exempt-tabs.ts
  • src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.ts
  • src/renderer/src/runtime/web-session-terminal-park-authority.test.ts
  • src/renderer/src/components/terminal-pane/manual-terminal-worktree-park-eligibility.ts
  • src/renderer/src/components/terminal-pane/terminal-park-worktree-owner.ts
  • src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-authority-revision.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-pty-watcher.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.ts
  • src/renderer/src/components/terminal-pane/terminal-park-pty-restore-eligibility.ts
  • src/renderer/src/runtime/web-session-terminal-park-authority.ts
  • src/renderer/src/components/terminal-pane/terminal-park-owner-oracle.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts

Two conflicts, both in import blocks, both from main splitting
src/shared/types.ts into per-domain modules while this branch was adding
imports of its own beside the same lines.

- terminal-hidden-view-parking.ts — main only repointed TerminalTab to
  shared/terminal-tab-types here; its other four imports belong to the
  functions this branch moved out to terminal-park-pty-restore-eligibility,
  so they are dropped rather than carried as unused. Verified against
  base..upstream/main that main changed nothing else in this file, so the
  extracted copies are not behind.
- terminal-hidden-worktree-retention.ts — same TerminalTab repoint beside
  this branch's park-ownership imports; both kept.

Three files this branch added still imported the deleted shared/types and
had to follow the split: TerminalTab to shared/terminal-tab-types in
terminal-park-authority-revision.ts and terminal-rendered-parked-tab-ids.ts,
Repo to shared/repo-types in terminal-park-worktree-owner.test.tsx.

Local: tsc clean on all three projects; the 12 test files this branch
touches pass 187/187; src/renderer/src/components/terminal-pane and
src/renderer/src/runtime are 348 files / 4287 passed, 0 failed. The 65
failures seen before this run were a stale shared node_modules resolving
the xterm patch hash the lockfile does not ask for; installing in this
worktree resolved 8a2d562c and they all pass. Reliability gate manifest
passes for 84 gates, max-lines ratchet OK at 340, oxlint and oxfmt clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@nwparker nwparker removed the P1 label Aug 19, 2026
stablyai#14676 replaced the exemption predicate with a route classifier so the
force-park breadcrumb can say WHY a force-park freed nothing. This branch adds a
reason that classifier did not have: a remote or SSH pty whose owner this
worktree cannot prove.

Folded in as a `remote-unowned` route rather than left out — a remote pty exempt
by ownership would otherwise bucket as `split-pane`, which is the one bucket
that means "the tab-level pty classified clean". The counts feed field triage,
so a silently mis-bucketed route sends it the wrong way.

The classifier and the tab-route counter now take the worktree owner, and
Terminal.tsx resolves it from the same owner state the exemption selector reads.

The two eviction-exemption describes moved to terminal-eviction-exempt-tabs.ts's
own test file: both sides appended to terminal-parked-tab-watchers.test.ts and
the merged file crossed the 800-line budget. They test a different module
anyway.
Both sides appended a per-environment cleanup call to the same teardown, so the
merge keeps both. stablyai#15644 clears the host session mirror hydration; this branch
clears the park authority it records for that environment. Neither reads the
other's state.

No test covers either call at this site — the clear functions are exercised
directly, not through the teardown that reaches them.
stablyai#16138 stopped reading tabsByWorktree through the effect deps, reading it once
from the store instead so terminal load cannot stall navigation. This branch
enriches the same list with each tab's active leaf, which the owner check needs
as pane identity.

Kept both: the tabs come from main's single store read, and the layout map is
read beside it rather than per tab, which is what the branch's inline getState
was doing.

Taking main's side wholesale here would compile and pass every test —
activeLeafId is optional, so every ownership check would silently fall back to
a null leaf. Nothing in the suite covers this call site.
@Jinwoo-H

Copy link
Copy Markdown
Contributor

Closing this submitted branch and routing the bug to owner issue #17554. We will carry the fix ourselves on current main and will not request any contributor follow-up. Full contributor credit is preserved for @kunsanglee. No action is requested from you. Thank you.

@Jinwoo-H Jinwoo-H closed this Aug 31, 2026
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.

5 participants