Skip to content

refactor(store): delete direct-SSH terminal ledgers - #27569

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/p399-C2
Oct 11, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/p399-C2

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When Orca still had its old SSH relay, a terminal on an SSH project kept a small notebook in memory: which shell attempt was in flight, which one was bound to the tab, and how many times it had retried. #27489 stopped those terminals from ever starting a shell over the relay, because nothing can serve one any more. The notebook kept getting written but nothing read it. This PR throws the notebook away.

What Changed

Before: the terminal store carried three in-memory maps for relay-era SSH tabs (directSshPaneRetryByTabId, directSshLivePtyBindingByTabId, directSshPaneRetryHistoryByTabId), plus retryDirectSshTargetPanes and settleDirectSshPaneRetry. When an SSH host connected or the machine woke, the retry action bumped each unconverted ssh: tab's generation, which remounted the pane.

After: the maps, both actions, the split-detach ledger transfer and the retry predicate are gone. For the user, nothing changes. Since #27489 a pane on an unconverted ssh: row uses an inert transport, so that remount only rebuilt the same inert pane. The host was already connected, so the pane's mount dial skipped. The host's conversion re-homes the workspace to its managed server, and that move remounts the pane. It never depended on this bump.

Mechanism:

  • clearDirectSshTargetPtyBindings (disconnect) is unchanged. invalidateStaleDirectSshTargetPtyBindings (new authority) is now the same clear, still gated on the authority being current. No pane binds an ssh: PTY any more, so the old "stale" test (a PTY id without a matching live binding) matched every bound tab anyway. One narrow exception: detaching a split pane out of a relay-era tab that still had a pending retry could copy a live-binding entry onto the new tab. That kept the new tab's stale relay id instead of nulling it. The pane is inert either way, and the leaf, last-known and deferred ids are kept, so nothing visible or saved changes. The wake and preparation correction path calls that clear too, as the retry did internally first. Stale relay-era PTY ids are dropped at exactly the moments they were dropped before.
  • updateTabPtyId loses its fourth directSshRetryAttemptId argument. No production caller passed it after refactor(terminal): panes have two transports, local or remote runtime #27489, so its lease branch could never run. clearTabPtyId loses its "continuation gap", which needed a live binding that is never written.
  • The reconnect coordinator still exists. C2b deletes it. Its retryTargetPanes dependency now returns 0. The only effect is that its telemetry counts no retried terminals.

Kept on purpose (scope shrunk from the plan): lastKnownRelayPtyIdByTabId and deferredSshSessionIdsByTabId stay. The plan listed them as unpersisted. But the first is written on every PTY bind, for local and remote tabs too. The second is filled at cold start from saved relay-era sessions. Both feed the workspace-session writer (buildTerminalSessionData falls back to them for a tab whose ptyId is null), the orphan sweep and the resource manager. Removing either would change what gets saved for legacy profiles in the ≤1.4.223 window. Nothing in the saved session shape changes here.

Why

This is Phase 3.99 C2. Every terminal-store change had to thread three dead maps through close, purge, hydration, target removal and PTY release. I considered keeping the generation bump on connect as a "free remount". But it races the conversion's catalog load: the bump fires synchronously on the connected push, before the server's rows arrive. So it always remounted into the same inert pane, and the conversion's re-home is what actually moves the pane.

Proof the code is dead. rg for every removed symbol (directSshPaneRetryByTabId, directSshLivePtyBindingByTabId, directSshPaneRetryHistoryByTabId, retryDirectSshTargetPanes, settleDirectSshPaneRetry, transferDirectSshPaneDetachLedger, shouldRetryPaneSpawnOnSshReconnect, isPtyBindingStillAddressable, DirectSshPaneRetryAttemptId, DirectSshPaneRetryResult, omitRetiredDirectSshLedgerByTabId, directSshRetryAttemptId …) over src config tests mobile .github finds none left. A per-symbol rg -w over all 159 @ts-nocheck files finds 0. The only hits left are a historical audit snapshot under docs/audits/. pnpm tc, build:electron-vite and build:cli pass.

Net lines: production −938 (+32 / −970); tests −1,494 (+32 / −1,526); config −43.

Linked Issue

Phase 3.99 (owner-approved cleanup plan), PR C2. Depends on #27489 (merged).

Visual Proof

N/A. No UI change. The only path that changes is the redundant remount of an inert relay-era pane, which drew the same pane again.

Testing

  • pnpm tc; pnpm lint (all ratchets at or below baseline); pnpm run check:code-quality:changed; pnpm run build:electron-vite; pnpm run build:cli.

  • pnpm test src/renderer/src/store src/renderer/src/hooks src/renderer/src/lib/workspace-session* src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.test.ts: 611 files, 5,353 tests.

  • Changed tests: direct-ssh-runtime-wake-isolation now asserts that a wake clears only the exact direct target, that a stale authority is a no-op, and that runtime-owned panes are untouched. The connect-reply routing tests observe the coordinator through the clear instead of the retry. Tests of the deleted ledgers (direct-ssh-terminal-retry, direct-ssh-pane-detach-ledger, ssh-reconnect-pane-retry) are deleted, and the reliability gate is updated to match.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

P0/P1 review: self + independent reviewer; reports in the Phase 3.99 review folder.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: an unconverted ssh: row is never treated as local or exited. Stale relay PTY ids are cleared at the same moments as before. A managed host is runtime:<env> and outside the cleared scope.
  • Wire: renderer-only. No IPC, RPC or saved-session shape changes. The host keeps publishing providerEpoch/connectionGeneration.
  • Folder workspaces and WSL: the cleared scope still comes from resolveDirectSshTerminalKeys, unchanged.
  • Follow-up for C2b: disownedPtyIds is now written but not read (its only reader was the deleted retry predicate). Its producer crosses preload, so it stays out of this PR.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Panes stopped spawning on unconverted ssh: rows in #27489, so the retry,
live-binding and history ledgers were written but never read. Delete them,
the retry and settle actions, and the detach transfer. The disconnect and
new-authority clears keep nulling stale ssh: PTY ids exactly as before.
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes remove Direct SSH pane retry, live-binding, and retry-history state and operations. Connection routing now invalidates bindings instead of retrying panes. Terminal state cleanup and related tests, reliability-gate records, CI timings, and the cleanup benchmark are updated to reflect the removed ledgers.



Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 4f1b6

The change removes unused Direct SSH retry state and should not alter runtime behavior. The reliability-gate records contain inaccurate test descriptions and evidence entries that should be corrected, but they do not block merge.

Pre-merge checks | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

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 10 functions across 14 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description is detailed and covers the change, rationale, testing, visual proof, review notes, and checklist. However, the required Linked Issue section is incomplete: it leaves "Fixes #" blank an… Add the actual issue link or issue number addressed by this pull request in the Linked Issue section, using the required "Fixes #" format or an equivalent repository-approved issue reference. Keep #27489 as a dependency if nee…
✅ Passed checks (3 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 and concisely describes the primary change: removing the obsolete direct-SSH terminal ledgers.

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 10 functions across 14 files. (1 skipped: 1 unsupported.)


Full details: Description check

Explanation

The description is detailed and covers the change, rationale, testing, visual proof, review notes, and checklist. However, the required Linked Issue section is incomplete: it leaves "Fixes #" blank and only mentions dependency #27489, which is not the issue addressed by this pull request.

Resolution

Add the actual issue link or issue number addressed by this pull request in the Linked Issue section, using the required "Fixes #<issue-number>" format or an equivalent repository-approved issue reference. Keep #27489 as a dependency if needed, but do not use it as the only issue reference unless it is the issue this pull request fixes.


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



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Replace the deleted-ledger assertion reference. · reliability-gates.jsonc:13262

config/reliability-gates.jsonc:13262
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Replace the deleted-ledger assertion reference.

terminals-hydration.test.ts now asserts retained deferred SSH-session behavior. It does not assert pruning of the removed retry, live-binding, or retry-history ledgers.

Suggested fix
-            "authoritative target-tab deletion prunes only that tab's retry, live-binding, and retry-history ledgers",
+            "hydration preserves deferred SSH session IDs for present targets and drops them for known-absent targets",

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 35527140-a191-45b3-bce6-f6c25afd31a4
📥 Commits

Reviewing files that changed from the base of the PR and between 47c9363 and 4f1b662.

📒 Files selected for processing (38)
  • config/reliability-gates.jsonc
  • config/scripts/ci-shard-timings.json
  • config/scripts/ssh-cleanup-tab-map-benchmark.mjs
  • src/renderer/src/hooks/direct-ssh-runtime-wake-isolation.test.tsx
  • src/renderer/src/hooks/ipc-events-ssh-authority-test-fixtures.ts
  • src/renderer/src/hooks/ipc-events/direct-ssh-bridge-runtime.ts
  • src/renderer/src/hooks/ipc-events/direct-ssh-connect-reply-routing.test.ts
  • src/renderer/src/hooks/ipc-events/direct-ssh-state-ipc-bridge.ts
  • src/renderer/src/hooks/ssh-reconnect-pane-retry.test.ts
  • src/renderer/src/hooks/ssh-reconnect-pane-retry.ts
  • src/renderer/src/hooks/useIpcEvents-agent-status-ssh-authority.test.ts
  • src/renderer/src/store/slices/bulk-worktree-purge-terminal-maps-leak.test.ts
  • src/renderer/src/store/slices/direct-ssh-pane-detach-ledger.test.ts
  • src/renderer/src/store/slices/direct-ssh-pane-retry-ledger.ts
  • src/renderer/src/store/slices/direct-ssh-terminal-authority-ledger.ts
  • src/renderer/src/store/slices/direct-ssh-terminal-recovery-types.ts
  • src/renderer/src/store/slices/direct-ssh-terminal-recovery.test.ts
  • src/renderer/src/store/slices/direct-ssh-terminal-recovery.ts
  • src/renderer/src/store/slices/direct-ssh-terminal-retry.test.ts
  • src/renderer/src/store/slices/ssh-target-cleanup.ts
  • src/renderer/src/store/slices/ssh.test.ts
  • src/renderer/src/store/slices/store-active-worktree-terminal-creation.test.ts
  • src/renderer/src/store/slices/terminals-hydration.test.ts
  • src/renderer/src/store/slices/terminals.ts
  • src/renderer/src/store/slices/worktrees/teardown/worktree-purge-omitters.ts
  • src/renderer/src/store/slices/worktrees/teardown/worktree-purge-state.ts
  • src/renderer/src/store/terminals/direct-ssh-terminal-bindings.ts
  • src/renderer/src/store/terminals/terminal-actions.ts
  • src/renderer/src/store/terminals/terminal-disowned-pty-sources.ts
  • src/renderer/src/store/terminals/terminal-layout-state.ts
  • src/renderer/src/store/terminals/terminal-pty-bindings.ts
  • src/renderer/src/store/terminals/terminal-pty-release.ts
  • src/renderer/src/store/terminals/terminal-state.ts
  • src/renderer/src/store/terminals/terminal-tab-close-intent.test.ts
  • src/renderer/src/store/terminals/terminal-tab-close.ts
  • src/renderer/src/store/terminals/terminal-tab-recovery-ledger.ts
  • src/renderer/src/store/terminals/workspace-terminal-hydration-patch.ts
  • src/shared/terminal-tab-types.ts
💤 Files with no reviewable changes (23)
  • src/renderer/src/store/slices/terminals.ts
  • src/renderer/src/hooks/ssh-reconnect-pane-retry.test.ts
  • src/renderer/src/store/slices/direct-ssh-terminal-retry.test.ts
  • src/renderer/src/store/slices/worktrees/teardown/worktree-purge-state.ts
  • src/renderer/src/store/terminals/terminal-disowned-pty-sources.ts
  • src/renderer/src/store/slices/direct-ssh-terminal-recovery-types.ts
  • src/shared/terminal-tab-types.ts
  • src/renderer/src/store/terminals/workspace-terminal-hydration-patch.ts
  • src/renderer/src/store/terminals/terminal-tab-close-intent.test.ts
  • src/renderer/src/hooks/ipc-events-ssh-authority-test-fixtures.ts
  • src/renderer/src/store/terminals/terminal-tab-close.ts
  • src/renderer/src/store/slices/direct-ssh-pane-detach-ledger.test.ts
  • src/renderer/src/hooks/ssh-reconnect-pane-retry.ts
  • src/renderer/src/store/slices/direct-ssh-pane-retry-ledger.ts
  • src/renderer/src/store/slices/ssh-target-cleanup.ts
  • config/scripts/ssh-cleanup-tab-map-benchmark.mjs
  • src/renderer/src/store/slices/worktrees/teardown/worktree-purge-omitters.ts
  • src/renderer/src/store/terminals/terminal-layout-state.ts
  • src/renderer/src/store/slices/terminals-hydration.test.ts
  • src/renderer/src/store/terminals/terminal-state.ts
  • src/renderer/src/store/slices/bulk-worktree-purge-terminal-maps-leak.test.ts
  • src/renderer/src/store/slices/direct-ssh-terminal-authority-ledger.ts
  • config/scripts/ci-shard-timings.json

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

"runner": "local",
"platform": "macos",
"command": "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/direct-ssh-terminal-retry.test.ts src/renderer/src/store/slices/direct-ssh-pane-detach-ledger.test.ts src/renderer/src/store/slices/direct-ssh-terminal-recovery.test.ts src/renderer/src/store/slices/direct-ssh-terminal-workspace-scope.test.ts src/renderer/src/store/slices/terminals-hydration.test.ts src/renderer/src/store/slices/repos-ssh-host-reconciliation.test.ts src/renderer/src/hooks/direct-ssh-reconnect-coordinator.test.ts src/renderer/src/hooks/direct-ssh-host-hydration.test.ts src/renderer/src/hooks/direct-ssh-state-routing.test.ts src/renderer/src/components/terminal-pane/pty-connection-pending-spawn.test.ts src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.test.ts --reporter=dot",
"command": "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/direct-ssh-terminal-recovery.test.ts src/renderer/src/store/slices/direct-ssh-terminal-workspace-scope.test.ts src/renderer/src/store/slices/terminals-hydration.test.ts src/renderer/src/store/slices/repos-ssh-host-reconciliation.test.ts src/renderer/src/hooks/direct-ssh-reconnect-coordinator.test.ts src/renderer/src/hooks/direct-ssh-host-hydration.test.ts src/renderer/src/hooks/direct-ssh-state-routing.test.ts src/renderer/src/components/terminal-pane/pty-connection-pending-spawn.test.ts src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.test.ts --reporter=dot",

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Keep these historical commands aligned with their recorded results.

Lines 13320 and 13356 now list commands with nine test files, but their summaries report 14 files/155 tests and 12 files/647 tests. Preserve the original commands that produced those results, or rerun the narrowed commands and update each result, duration, and summary.

Also applies to: 13356-13356

@OrcaWin
OrcaWin merged commit f0b310b into main Oct 11, 2026
39 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