Skip to content

Add Resource Manager PTY inventory and checked terminal termination - #31593

Merged
AmethystLiang merged 10 commits into
mainfrom
build-pty-manager
Oct 22, 2026
Merged

AmethystLiang merged 10 commits into
mainfrom
build-pty-manager

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 42 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3431 $\color{#cf222e}{\Huge{\mathbf{−}}}$​673 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2758
Prod 81 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2822 $\color{#cf222e}{\Huge{\mathbf{−}}}$​783 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2039

ELI5

The Resource Manager shows local terminals, including terminals without an active route, and lets users end a selected terminal after the host confirms it is still the same terminal.

What Changed

  • Add a PTYs view with terminal details and an End confirmation dialog.
  • Check terminal incarnation, ownership, and attachments before termination; refuse unchecked termination on older hosts.
  • Include unrouted daemon PTYs and preserve newer replacement terminals and their history during cleanup.
  • Limit diagnostic inventory and memory reads to when the Resources view is visible.
  • Simplify PTY controls and clarify when termination is unavailable.

Why

Users need to identify and stop local terminals without accidentally terminating a replacement session or scanning resources while the view is hidden.

Linked Issue

No linked issue supplied.

Visual Proof

Before/after captures were not collected during this rebase and PR task. Rendered UI and end-to-end validation remain outstanding.

Testing

  • Automated tests added/updated in this branch.
  • Manually tested rendered UI locally.
  • Passed: RecentTabSwitcher tests (2 tests).
  • Passed: focused daemon termination, router inventory, renderer kill, PTY view model, PTY actions, and session inventory tests (77 tests across 8 files).
  • Passed: pnpm tc:web (15,400 files).
  • Passed: oxlint and oxfmt checks for RecentTabSwitcher.tsx.
  • Passed: git diff --check for the working tree and complete rebased patch.
  • Tests ran on macOS with ORCA_BACKGROUND_LAUNCH=1. Full build, full test suite, Windows/Linux, SSH, mobile, and rendered UI checks were not run.

Review

The rebase conflict in RecentTabSwitcher.tsx retained both the current keyboard-router import and the replayed styling import. All three branch commits were replayed.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer material is copied.

Notes

Older daemon compatibility is guarded by protocol support checks before terminal termination.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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

The change adds a local PTY view to Resource Manager. It adds identity-aware inventory and fenced termination across daemon, IPC, preload, and renderer layers. Resource-view visibility gates inventory and memory requests. The renderer adds grouped PTY details, navigation, refresh, confirmation dialogs, lifecycle-aware caching, and termination feedback. Protocol versions, lifecycle metadata, foreground-process data, documentation, and unit and end-to-end tests are updated.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 50cfa

A regression in checked terminal cleanup could disturb a replacement terminal or its history without detection. The focused integration test is a bounded follow-up; no current production failure is established.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the user impact, implementation, rationale, and testing status. However, it does not provide the required linked issue, visual proof for the UI changes, or the repository chec… Add an actual linked issue under “Linked Issue,” attach before-and-after screenshots or a video for the PTY UI changes, and complete the required “Checklist” section. Keep the testing limitations explicit, including the missing manual UI, f…
Docstring Coverage Warning Docstring coverage is 4.65% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 55 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the two primary changes: Resource Manager PTY inventory and checked terminal termination.
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.
Full details: Description check

Explanation

The description explains the user impact, implementation, rationale, and testing status. However, it does not provide the required linked issue, visual proof for the UI changes, or the repository checklist section.

Resolution

Add an actual linked issue under “Linked Issue,” attach before-and-after screenshots or a video for the PTY UI changes, and complete the required “Checklist” section. Keep the testing limitations explicit, including the missing manual UI, full build, full test suite, and cross-platform validation.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • 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: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 35ff00e8-2910-452a-b90a-479fdec14be8
📥 Commits

Reviewing files that changed from the base of the PR and between d4a7494 and c9887a4.

📒 Files selected for processing: 111
  • docs/site/content/docs/terminal.mdx
  • src/main/daemon/daemon-fenced-termination.test.ts
  • src/main/daemon/daemon-fenced-termination.ts
  • src/main/daemon/daemon-foreground-confirmation-protocol.test.ts
  • src/main/daemon/daemon-protocol-version.ts
  • src/main/daemon/daemon-pty-adapter-checked-close.test.ts
  • src/main/daemon/daemon-pty-adapter.ts
  • src/main/daemon/daemon-pty-router-inventory.test.ts
  • src/main/daemon/daemon-pty-router-test-fixture.ts
  • src/main/daemon/daemon-pty-router.test.ts
  • src/main/daemon/daemon-pty-router.ts
  • src/main/daemon/daemon-pty-session-control.ts
  • src/main/daemon/daemon-pty-session-inventory.ts
  • src/main/daemon/daemon-request-router.ts
  • src/main/daemon/daemon-routed-session-shutdown.ts
  • src/main/daemon/daemon-session-owner-attach.ts
  • src/main/daemon/daemon-session-owner-inventory.ts
  • src/main/daemon/daemon-session-owner-resolution.test.ts
  • src/main/daemon/daemon-session-owner-resolution.ts
  • src/main/daemon/daemon-terminal-kill.ts
  • src/main/daemon/degraded-daemon-inventory.test.ts
  • src/main/daemon/degraded-daemon-owner-recovery.ts
  • src/main/daemon/degraded-daemon-pty-provider.ts
  • src/main/daemon/pty-subprocess-foreground-identity.test.ts
  • src/main/daemon/pty-subprocess/foreground-process-tracker.ts
  • src/main/daemon/session-subprocess-handle.ts
  • src/main/daemon/session.test.ts
  • src/main/daemon/session.ts
  • src/main/daemon/terminal-host-fenced-termination.test.ts
  • src/main/daemon/terminal-host-fenced-termination.ts
  • src/main/daemon/terminal-host-process-inspection.ts
  • src/main/daemon/terminal-host-session-access.ts
  • src/main/daemon/terminal-host-session-listing.ts
  • src/main/daemon/terminal-host.ts
  • src/main/daemon/types.ts
  • src/main/host/electron-runtime-desktop-surface.ts
  • src/main/ipc/memory.ts
  • src/main/ipc/pty-activation-inventory-scope.test.ts
  • src/main/ipc/pty-ipc-suite-environment.ts
  • src/main/ipc/pty/daemon-late-exit-test-fixture.ts
  • src/main/ipc/pty/delivery/exit.ts
  • src/main/ipc/pty/ipc/inspect.ts
  • src/main/ipc/pty/ipc/renderer-kill.ts
  • src/main/ipc/pty/ipc/session-listing.ts
  • src/main/ipc/pty/renderer-fenced-kill.test.ts
  • src/main/providers/pty-process-info.ts
  • src/main/providers/pty-process-list-admission.test.ts
  • src/main/providers/pty-process-list-admission.ts
  • src/main/providers/pty-provider-contract.ts
  • src/main/runtime/runtime-desktop-surface.ts
  • src/main/startup/main-window-controller.ts
  • src/main/window/resource-view-admission.test.ts
  • src/main/window/resource-view-admission.ts
  • src/preload/api/memory-bridge.ts
  • src/preload/api/pty-api.ts
  • src/preload/api/pty-bridge-session-control.ts
  • src/preload/api/pty-bridge-stream-and-serialization.ts
  • src/preload/api/telemetry-api.ts
  • src/renderer/src/components/shared/useDaemonActions.tsx
  • src/renderer/src/components/status-bar/ResourcePtyDetails.tsx
  • src/renderer/src/components/status-bar/ResourcePtyEndDialog.tsx
  • src/renderer/src/components/status-bar/ResourcePtyList.tsx
  • src/renderer/src/components/status-bar/ResourcePtyPanel.tsx
  • src/renderer/src/components/status-bar/ResourcePtyRow.tsx
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx
  • src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts
  • src/renderer/src/components/status-bar/resource-manager-exit-render-budget.test.tsx
  • src/renderer/src/components/status-bar/resource-manager-terminal-copy.ts
  • src/renderer/src/components/status-bar/resource-pty-view-model.test.ts
  • src/renderer/src/components/status-bar/resource-pty-view-model.ts
  • src/renderer/src/components/status-bar/resource-session-inventory-cache.ts
  • src/renderer/src/components/status-bar/resource-session-inventory.test.ts
  • src/renderer/src/components/status-bar/resource-session-labels.ts
  • src/renderer/src/components/status-bar/resource-session-navigation.test.ts
  • src/renderer/src/components/status-bar/resource-session-navigation.ts
  • src/renderer/src/components/status-bar/resource-session-removal-render-budget.test.tsx
  • src/renderer/src/components/status-bar/resource-usage-kill-dialog.tsx
  • src/renderer/src/components/status-bar/resource-usage-merge-types.ts
  • src/renderer/src/components/status-bar/resource-usage-popover-summary.tsx
  • src/renderer/src/components/status-bar/resource-usage-status-trigger.tsx
  • src/renderer/src/components/status-bar/use-resource-memory-snapshot.test.tsx
  • src/renderer/src/components/status-bar/use-resource-memory-snapshot.ts
  • src/renderer/src/components/status-bar/use-resource-pty-actions.test.tsx
  • src/renderer/src/components/status-bar/use-resource-pty-actions.ts
  • src/renderer/src/components/status-bar/use-resource-session-inventory.test.tsx
  • src/renderer/src/components/status-bar/use-resource-session-inventory.ts
  • src/renderer/src/components/status-bar/use-resource-usage-actions.test.tsx
  • src/renderer/src/components/status-bar/use-resource-usage-actions.ts
  • src/renderer/src/components/status-bar/use-resource-usage-derived-model.ts
  • src/renderer/src/components/status-bar/use-resource-usage-status-controller.ts
  • src/renderer/src/components/status-bar/use-resource-view-visible.ts
  • src/renderer/src/components/tab-bar/RecentTabSwitcher.tsx
  • src/renderer/src/components/ui/tabs.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/store/slices/memory.test.ts
  • src/renderer/src/store/slices/memory.ts
  • src/renderer/src/web/preload-api/web-terminal-api.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/renderer/src/web/web-preload-resource-visibility.test.tsx
  • src/shared/local-build-compatibility-contract.json
  • src/shared/local-build-compatibility-contract.ts
  • src/shared/pty-fenced-termination.ts
  • src/shared/pty-listed-session.ts
  • src/shared/resource-view-admission.ts
  • tests/e2e/helpers/resource-manager-visible-fixture.ts
  • tests/e2e/helpers/terminal-typing-benchmark.ts
  • tests/e2e/resource-manager-bound-ptys.spec.ts
  • tests/e2e/resource-manager-folder-labels.spec.ts
  • tests/e2e/resource-manager-local-pty-view.spec.ts
  • tests/e2e/resource-manager-pty-input-latency.spec.ts
  • tests/e2e/terminal-typing-latency.spec.ts
💤 Files with no reviewable changes: 2
  • src/renderer/src/components/status-bar/resource-session-navigation.ts
  • src/renderer/src/store/slices/memory.test.ts

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

Comment thread src/renderer/src/i18n/locales/en.json Resolved
@AmethystLiang
AmethystLiang force-pushed the build-pty-manager branch 2 times, most recently from 5071c8d to 689636a Compare October 22, 2026 04:44

@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
tests/e2e/resource-manager-pty-input-latency.spec.ts: 1

106-111: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Make visible-active latency samples overlap inventory processing.

Selecting the PTYs tab starts ResourceSessionInventoryCache.refresh() asynchronously. The 150 ms pty:listSessions delay can finish after all 16 samples, while the later DOM assertion waits for the result and still passes. Start an explicit refresh before sampling and assert that it completes while samples remain.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4cdb8347-4b4e-4564-9db3-70b05564f64a
📥 Commits

Reviewing files that changed from the base of the PR and between 5071c8d and 689636a.

📒 Files selected for processing: 3
  • src/main/ipc/pty/daemon-late-exit-test-fixture.ts
  • tests/e2e/resource-manager-local-pty-view.spec.ts
  • tests/e2e/resource-manager-pty-input-latency.spec.ts

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

@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/main/ipc/pty/daemon-late-exit-test-fixture.ts: 1

184-189: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add a registered fenced replacement-history test.

harness.killFenced(request) now reaches the registered pty:killFenced handler, but no current test uses it while a predecessor exits after replacement adoption. The provider tests call provider.killFenced(...) directly, and the IPC late-exit replacement tests call harness.kill(). A regression in the registered fenced path could therefore remove or alter the replacement PTY or its history without failing the existing assertions.

Add a focused test that starts a PTY with history, invokes harness.killFenced(...), adopts a replacement before the predecessor exit completes, then delivers the late predecessor exit and asserts that the replacement and its history remain intact.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 95994ced-e12b-4d9a-b978-73b19ad4dfea
📥 Commits

Reviewing files that changed from the base of the PR and between 689636a and 50cfa66.

📒 Files selected for processing: 1
  • src/main/ipc/pty/daemon-late-exit-test-fixture.ts

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

- Add a PTYs view to the Resource Manager that lists local terminals and can end one. Before stopping, the host confirms the terminal's incarnation, agent ownership, and attachments. This prevents ending a same-ID replacement that started after the list was read.
- Bump the daemon protocol to v50 and gate the new fenced kill on it. Older daemons ignore the extra fields, so the client refuses End instead of sending an unchecked kill.
- Admit diagnostic reads (PTY listing and memory snapshot) only while the Resources view is visible, so a hidden window does no background scanning.
- Report incarnation and host on spawn and exit events so the renderer can match them to the terminal it showed.
- Replace the popover's terminal-session list with the new inventory and move memory polling into the Resources view.
@AmethystLiang
AmethystLiang merged commit 8fc1698 into main Oct 22, 2026
69 checks passed
smwbev added a commit to smwbev/orca that referenced this pull request Oct 23, 2026
414 commits landed on main between ebc8b06 and f045046. The six older catalogs conflicted along with en-runtime-required.json, and pt.json, which stablyai#31627 added to main, came in with them, so all seven catalogs and en-runtime-required.json are taken from main and the prune is recomputed in one pass. It is the previous 1,618 keys plus 6: three lost their reader when stablyai#31831 combined untracked files into Changes, two when stablyai#31593 added the PTY inventory to the Resource Manager, and SshStatusSegment.connecting with stablyai#32083. None left the set. en.json goes from 16,929 entries to 15,305; en-runtime-required.json keeps 597 of them.

native-chat-shared-copy-matches-catalog.test.ts conflicted because stablyai#31425 added a test right above the block this branch rewrites. The branch's edit was re-applied on main's version of the file with git apply -C1 ("Context reduced to (1/1) to apply fragment at 45"); the file now differs from main by exactly the branch's added and removed lines.
sj900211 added a commit to sj900211/orcinus that referenced this pull request Oct 29, 2026
Ten days of upstream, measured from `e680d7c3b68`: 797 commits and 35
conflicting files, base `cb0b1524091`. Four cluster analysts, one implementer,
one independent critic, which returned ACCEPT with 0 blocking defects.

This is stage 1 of 4. The gap is 2,355 commits, and a PTY delivery refactor
(`ad1b81d53a0`, stablyai#33358, "group PTY delivery and drain ownership") lands just
past this checkpoint — conflicts jump from 35 to 54 and PTY conflicts from 7 to
19 the day after it. Stopping here keeps that refactor in a stage of its own,
the way an earlier PTY wall was handled.

## The fork's attribution nearly went nowhere

Upstream deleted `src/main/ipc/pty/ipc/spawn-commit-persist.ts`. The fork's
owner-window attribution lived in it, so the deletion applied cleanly and the
behaviour would simply have ceased to exist — a modify/delete where "resolve the
conflict" and "keep the fork's change" are different acts. The attribution is
ported into `spawn-commit-publication.ts:145,148`, the deps member in
`spawn-commit-assembly.ts:42` is widened to match, and the dead file is removed
rather than left as git's "kept in tree" copy. The critic traced the path end to
end rather than reading the diff.

## Two new upstream ratchets, grandfathered rather than obeyed

Upstream added `host-list-render` and `id-only-store-write`, each with an
allowance of 0 written against a tree that has no fork SFTP server explorer, no
remote hosts pane and no satellite-window session persistence. The fork's code
predates the rule it now violates, which is what grandfathering is for, and the
ratchet asks for reviewer sign-off.

Entries are the narrowest possible — specific files, exact counts, each with a
reason naming the fork feature. Measured against `120f01331ca` rather than
against `main` (most baselines differ from `main` only because upstream changed
them), exactly two baseline files differ from upstream's, by +2 and +3 lines.
Nothing else was widened.

The pre-existing `focus-read` ratchet was deliberately left red. It is red
identically on `main`, under a rule that predates this merge, so widening its
allowance here would be unrelated housekeeping. The aggregate `run-ratchets.mjs`
therefore still exits 1 on that one ratchet alone. Worth noting the other
direction too: `layout-writer` is red on `main` and this merge turns it green.

## What the gates found that the plans did not

- The cold typecheck caught two clean-merge breaks: `satellite-session-staging.ts`
  needed upstream's `flushPendingEditorBuffer`, and a new upstream test dropped
  `getMainWindow`.
- `clipboard-ipc-handlers.ts` merged cleanly at 305/300 — the seventh size breach
  of this sync, and again invisible to the `max-lines` ratchet, which tracks
  disables rather than breaches. Extracted to a sibling, no disable.
- The path-string set difference found the deleted SQLite allowlist still naming
  a removed test. No compiler or test executes that file.

Two fixes carry controls rather than assertions of correctness: reverting the
`applyMovedEditorFile` fix makes its new test fail (`Editor buffer mirror
"isDirty" … differs from its record`), and reverting the unlink-race fix makes
its test time out. A test that passes either way is worse than none.

## A fork rule this merge bends, deliberately shipped

Stage 5 ruled that an SFTP preview tab must never resolve to a local file. The
critic probed the merged tree: open a dirty local tab at `/repo/app.ts`, then an
SFTP preview of the same remote path, and both land on one editor buffer record
(`[null,"local",null,"/repo/app.ts"]`) — the remote preview displays the local
file's unsaved draft. Upstream's new `editorBufferIdentityOf` keys on a host id
from `resolveEditorModelOwner`, which reads `externalSshTargetId` but not the
fork's `sftpTargetId`.

This collision already exists on `main` one layer down, at the Monaco model, so
the merge widens it from a shared model to shared store state rather than
creating it; and the SFTP loader writes only `fileContents`, so no path was found
where remote content overwrites the local record. It ships for that reason, not
because it is acceptable. The fix belongs in `resolveEditorModelOwner` — give a
file with `sftpTargetId` its own host key ahead of the `externalSshTargetId`
branch — and is scheduled before stage 14.

## Gates

Every gate was re-measured by the critic in a worktree materialised from the
staged index with its own frozen install, after confirming all four trees match
the lockfile. That check is not ceremony: last stage every local gate passed
against a stale `node_modules` and CI then failed on a real error.

Cold typecheck 0 errors. Full-tree oxlint 0 errors. Identity OK,
`upstreamRefs=0 launcherProduct=Orcinus`. Unsigned smoke, fork contract tests,
the Windows CLI launcher's real Rust builds, and the localization set: pass.

Regression sweep over `discoverUnitFiles()`: `listed=13498 reported=13498
missing=0`, 510 failing files rechecked on both parents, `mergeOnly` 15 → 0
merge-caused after attribution. Path-string set difference `mergeOnly=0` with a
positive control of 3. The six `OXLINT_SCANS` on three trees: 4 raw merge-only
rows, all shown to be the same diagnostics at the same lines on `main` with only
an embedded variant list in the message changed.

Known and not addressed: project windows get no Resource Manager visibility
pushes (stablyai#31593 wired the main window only) — a fork feature gap, not a merge
regression; `attach-main-window-notifier-routing` stays red, and its failure
reason changed because upstream renamed a notifier member; full-tree `oxfmt`
is red on 19 fork-only files, identically on `main`.

## Committed with --no-verify

The pre-commit hook could not run on a merge this size. lint-staged split the
9,349 staged paths into 147 chunks of 60 and one chunk contained no lintable
file, so its oxlint invocation exited on "No files found to lint" and the whole
hook failed. lint-staged reverted cleanly and the staged merge was untouched
(same write-tree, MERGE_HEAD intact, nothing unstaged).

Nothing is skipped by this: full-tree oxlint, oxfmt, the cold typecheck and
every ratchet were run by the implementer and re-run by the critic in a
worktree materialised from this exact index with its own frozen install, which
is a stricter check than lint-staged performs.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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