Skip to content

fix(runtime): save a windowless host's chat tabs in its layout - #28354

Merged
Jinwoo-H merged 16 commits into
mainfrom
fix/headless-chat-tabs-saved
Oct 14, 2026
Merged

Jinwoo-H merged 16 commits into
mainfrom
fix/headless-chat-tabs-saved

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​519 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​517
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​182 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​176

ELI5

On a computer running Orca without a window (a server that phones and other desktops connect to), chat tabs were remembered only in the chat system's own list, not in the saved tab layout that holds every other tab. This change also saves them in the layout, so the layout is a complete record of the host's tabs.

What Changed

  • Before: on a host with no window, opening a chat added its tab only to the in-memory tab list. The saved layout (terminals, browser tabs, editors) never had a tab for it; only the chat system's list of open chats remembered it.
  • After: on a host with no window:
    • opening or revealing a chat also saves its tab in that worktree's layout, in the active group, under the chat's own tab id (the one status and attention updates already address);
    • closing a chat by any path (a tab close, the chat close call, a worker stop or release, a failed start, workspace removal) also removes the saved tab. Chats run only on this machine, so their saved tabs live in the local partition, and only that partition is edited: SSH and remote-server partitions (where a desktop mirrors a remote server's chats, without a host stamp) are left alone, as is a tab stamped with another execution host. A close that fails and puts the chat back keeps it;
    • at startup, a chat the chat system restores but that has no saved tab gets one. That covers layouts saved before this change. Once a tab is saved, this is a no-op;
    • at startup, a saved chat tab whose chat the chat system no longer lists is removed. That state means a close outlived its layout save: the process died between the chat system's commit and the scheduled layout save, or an older build closed the chat. The removal is only justified because both records exist; it is not a general cleanup. A chat written by a newer Orca, which this build only cannot read, keeps its tab, and a chat run by another execution host (SSH) is left alone.
  • Also covers a desktop with no window open: a desktop app with no window (macOS with the window closed, or the moment before the window attaches) is a host with no window too. A chat a phone opens or closes then is saved in the desktop's layout, so the window shows the right chat tabs when it reopens.
  • Claude chats restore from saved tabs: on a profile with no chat index yet, saved Claude chats are now restored at startup like other chats; before, their saved tabs were skipped.
  • Unchanged: what clients see. The tab list a phone or desktop receives is still built the same way, and the tab keeps the same row id (agent-session:<session id>). A host with a window is untouched; the window saves its own layout, chat tabs included.
  • Mechanism: the change is built with the shared layout commands the window uses (openAgentSessionTab, closeTabs), applied in one layout load per worktree and written through the runtime's existing per-worktree session writer. At startup, one function beside the chat index seed works out every open and close that makes the saved chat tabs match the index. "This host's saved chat tab" is the existing savedSessionId rule the startup restore already uses. That rule no longer skips Claude chats: the skip predates Claude structured chats, so a saved Claude chat is now restored, and its tab removed when it closes, like any other. Closing hangs on the chat system's "tab hidden" notice, which every close path already sends once its close settles, and removes the tab only if the chat system's list no longer has the chat.

Why

The windowless tab list is moving to be built from the saved layout, as a window builds its own. Without this, chats would disappear from that list. Saving the tab at the same points that already record a chat as open or closed keeps the layout and the chat system's list in step, so the startup fill cannot bring back a closed chat.

Alternatives considered:

  • Listing chats from the chat system's list on top of the layout. That keeps two sources of truth for one tab strip, and their order and group would disagree.
  • Dropping the chat system's list as the record of open chats. It still serves other readers (which chats are alive for workers, mail addressing, lineage), so it stays.

Linked Issue

N/A (maintainer; part of the single saved-layout work).

Visual Proof

N/A: no visible change. The tab list clients receive is unchanged; only the saved layout gains the chat tabs.

Testing

  • I manually tested these changes locally

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

  • structured-agent-session-windowless-layout.test.ts:

    • opening a chat saves one tab, and opening it again does not add another;
    • the hidden notice removes the tab even from a runtime that lists no chats (as when the close call or a worker stop runs before a restore), with a check that it was saved first;
    • a failed close that put the chat back keeps the tab;
    • startup saves a tab for a chat the index restores without one;
    • the saved tab's id is structured-agent-session-<session id>, or the id the chat host already reserved (fails if the id is minted fresh);
    • a window that later opens on that layout finds the saved tab when the user opens the same chat, because the saved tab carries the id, type and chat the window's lookup matches, instead of the window creating a second tab (fails if the id is minted fresh);
    • with a window attached, nothing is saved.
    • All but the window case fail without the change; that one passes on both by design.
  • structured-agent-session-windowless-layout-host.test.ts, against a real chat host:

    • the host hiding a chat (setSessionTabVisibility(false)) reaches the runtime and removes only that chat's saved tab;
    • a chat whose record is gone loses its saved tab at startup, and a listed one keeps it;
    • a chat whose record this build cannot read keeps its tab even when the list omits it (fails with that guard removed);
    • another execution host's chat tab is left alone at startup;
    • a remote server's chat a desktop mirrored into that server's partition, with no host stamp, is left alone at startup (fails with unstamped tabs counted outside the local partition);
    • with no list on disk yet, startup removes nothing;
    • a closed Claude chat's saved tab is removed at startup (fails with the old Claude skip);
    • closing edits only the local partition: SSH, remote-runtime and mirrored remote chats' partitions are untouched.
    • Records use real-length session ids; shorter ids load as unreadable, which the earlier fixture hit by accident.
  • saved-structured-agent-session-restoration.test.ts: a saved Claude chat is a restore target (fails with the old Claude skip).

  • Targeted unit tests for the files above and src/shared/workspace-layout pass; typecheck and the changed-code gates pass.

  • Earlier heads ran targeted e2e (headless layout oracle, old phone on a new server, remote chat focus, chat quit and resume) against main at the same base; not re-run on this head.

AI Disclosure

Review

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

  • Layout-writer count: saving a windowless chat tab adds one main-process layout write (orca-runtime-close-structured-agent-session-tab.ts), counted in the baseline. The change is already built as shared layout commands; the write moves to the runtime's layout command channel when that lands.
  • Old clients / wire: no change; the row id and the list are unchanged.
  • SSH: the tab is saved in the worktree's own partition, as the host's other tabs are.
  • Known gap, unchanged from today: if the chat system's list cannot be written when a chat closes, the close still goes ahead, and the chat comes back at the next startup, as it does today.
  • Platforms: no platform-specific code.

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)

@coderabbitai

coderabbitai Bot commented Oct 13, 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

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: 1917722a-c2d9-471b-af90-d7d11d93bdc2
📥 Commits

Reviewing files that changed from the base of the PR and between 2beecb9 and 3e6a263.

📒 Files selected for processing: 3
  • src/main/runtime/agent-session-tab-layout.ts
  • src/main/runtime/orca-runtime-close-structured-agent-session-tab.ts
  • src/main/runtime/structured-agent-session-windowless-layout.test.ts

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

📝 Walkthrough

The change adds helpers to open and close agent-session tabs in saved workspace layouts. Runtime lifecycle and restoration paths use these helpers to persist windowless tab changes. Layout updates are skipped when an authoritative window is available. Tests cover repeated opens, tab removal, startup restoration, partition isolation, and the authoritative-window case.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 3e6a2

Startup can remove a remote chat’s saved tab from its layout. The issue is limited to unstamped tabs under specific index conditions, but should be fixed or explicitly accepted before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed 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 and concisely describes the main change: saving chat tabs in the layout for windowless runtime hosts.
Description check Passed The description is detailed and covers the required ELI5, changes, rationale, issue context, visual proof, testing, review notes, compatibility considerations, and checklist. The maintainer exception …
✨ 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


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 18ee504e-463d-4382-ae48-d9676ee446a1
📥 Commits

Reviewing files that changed from the base of the PR and between 3a011e4 and 8736736.

📒 Files selected for processing (5)
  • config/main-layout-writer-baseline.txt
  • src/main/runtime/agent-session-tab-layout.ts
  • src/main/runtime/orca-runtime-close-structured-agent-session-tab.ts
  • src/main/runtime/orca-runtime-restore-structured-agent-session-tabs-once.ts
  • src/main/runtime/structured-agent-session-windowless-layout.test.ts

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

Comment thread config/main-layout-writer-baseline.txt Resolved

@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: 745c1227-eed4-42f6-b1cc-3a1353265496
📥 Commits

Reviewing files that changed from the base of the PR and between 10a28e7 and 434ab10.

📒 Files selected for processing (3)
  • src/main/runtime/orca-runtime-close-structured-agent-session-tab.ts
  • src/main/runtime/orca-runtime-restore-structured-agent-session-tabs-once.ts
  • src/main/runtime/structured-agent-session-windowless-layout-host.test.ts

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

Review pass: the saved tab reuses the id status and attention address, the close
checks for a window before scanning partitions, and the host tests seed readable
records with unreadable, other-host and no-index cases.

Claude-Session: p2-headless
The window's existing-tab lookup moves to the shared projection so the
windowless-layout test exercises it without importing the renderer.

Claude-Session: p2-headless
Drops the shared lookup added for the test; two functions already carry that name.

Claude-Session: p2-headless
…e local partition

A desktop mirrors a remote server's chats into that server's runtime partition
without a host stamp; the startup sweep must not delete them.

Claude-Session: p2-headless
…rtition only

Chats run only on local hosts, so their saved tabs live in the local partition:
the cross-partition listing and its writer go. Open and close share one layout
load, the startup fill and sweep become one function beside the index seed, and
the tab filter is the existing savedSessionId.

Claude-Session: p2-headless
…uctured chat

The Claude skip predates Claude structured chats (#18519, #18560); an id the host
has no record of is already dropped by the readable restorer.

Claude-Session: p2-headless
@Jinwoo-H
Jinwoo-H merged commit d3b17ca into main Oct 14, 2026
39 checks passed
@nwparker nwparker mentioned this pull request Oct 14, 2026
6 tasks done
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