You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(bots): claim a Home restored without a host when this app owns its workspace - #46179
If Orca restores a bot's Home chat from a session saved before chat tabs recorded their host, the app didn't recognize it as the Home. So it wasn't pinned first, and the page could open a second Home next to it.
Files
Added
Deleted
Net
Test
3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$276
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$276
Prod
17
$\color{#1a7f37}{\Huge{\mathbf{+}}}$313
$\color{#cf222e}{\Huge{\mathbf{−}}}$114
$\color{#1a7f37}{\Huge{\mathbf{+}}}$199
What Changed
A chat tab with no saved host now counts as a local bot's chat when this app's own workspace records name it the sole owner of the bot's workspace. The routing default and a twin the user selected don't count as ownership.
Paired-server and SSH bots never claim a tab without a host.
For a chat tab without a host, the tab row and chat header look up the local bot first, so catalog order can't hand the tab to another host's bot with the same workspace id.
Placement also reruns when folder or project-group records change, because a hostless Home is claimed from those records and they can arrive after the tabs.
Placement, the Home check that opens a missing Home, the tab-row lock and pin menu, the Home banner and the side-chat pin rule all use the same check.
The "recorded owner" read is moved out of the legacy chat-rename owner into recorded-workspace-owner.ts, so both share it. Rename behavior is unchanged.
Why
Follow-up to a review comment on #45421. The tab predicates required executionHostId === 'local', but restored tabs can lack the field. Treating every hostless tab as local would let a local bot claim a chat in a workspace whose id another host also publishes. The existing side-chat pin test guards that case. Stamping hosts at restore would change routing for every chat. So the ownership read runs only for hostless chats on a local bot's page.
Visual Proof
N/A: this only appears when a legacy saved session is restored. It is covered by store-level tests that restore a session saved without tab hosts.
Testing
I manually tested these changes locally
Automated tests added/updated
Every added behavior test fails without this change. The other added tests guard existing behavior: no record, twin workspace, paired/SSH bots.
pnpm typecheck, pnpm lint, pnpm check:changed and the affected suites pass locally.
Performance
No new work for tabs that carry a host, which is every tab created today. For a hostless chat on a local bot's page, one ownership lookup runs, memoized for each placement pass and selector run. Placement now also reruns on folder/project-group record changes. Each pass is a small loop over the bots and their page tabs, with no I/O.
Risk
Level: Low. Only legacy hostless chats in a local bot's own workspace change behavior. A plain revert backs it out.
…s workspace
A session saved before chat tabs carried a host restores the bot's Home
without one, so the local-host checks skipped it: placement left it
unpinned and unplaced, and the page opened a second Home beside it.
A hostless chat now counts as a local bot's when this app's own
workspace records name it the sole owner (not the routing default, not
a twin the user selected). Paired and SSH bots never claim one. The
recorded-owner read is shared with the legacy chat-rename owner.
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.
The change adds recorded workspace ownership helpers and uses them to classify hostless chats as local when the recorded owner is the local execution host. Bot-chat predicates and renderer consumers use that classification. Chat-tab bot lookup also considers the tab’s execution host. Structured-session rename ownership uses the recorded workspace owner. Tests cover hostless restored Home-tab attribution and host-aware lookup, closing, and placement.
Merge Risk: Low · previous review c511e
This change recognizes a Home chat restored from an older session so it is pinned and not duplicated. Placement and header lookup now behave correctly. A hostless chat the app does not own can still be locked in the tab row. A close requested before local ownership is recorded can still remove a Home that becomes locked in the meantime. Both are narrow, recoverable edge cases to fix or accept before merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: a restored Home chat tab with no saved host is claimed by the local bot when this app owns its workspace. The title uses the 'fix(bots)' prefix and is specific. The ch…
Description check
The description follows the repository template. It has ELI5, What Changed, Why, Testing, Performance, and Risk sections, and each has substantive content. The Performance section is complete and the …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: a restored Home chat tab with no saved host is claimed by the local bot when this app owns its workspace. The title uses the 'fix(bots)' prefix and is specific. The changeset adds hostless-chat ownership checks (recordedWorkspaceOwner, hostlessChatsAreLocal) and applies them across placement, tab row, header, and pin rules, which matches the title.
Full details: Description check
Explanation
The description follows the repository template. It has ELI5, What Changed, Why, Testing, Performance, and Risk sections, and each has substantive content. The Performance section is complete and the Risk level is set to Low. Gaps: the Linked Issue section says 'Follow-up to a review comment on #45421' and has no 'Fixes #' issue link, the Visual Proof section is N/A with a reason, and the Review, Agent skill upstream boundary, Notes, Checklist, and AI Disclosure sections are not filled in. The Testing checkbox for manual testing is unchecked, which is acceptable with the stated reason.
Resolution
Optional improvements: add a linked issue (the template requires one for outside contributors) in the Linked Issue section, complete the Agent skill upstream boundary checkbox, and check the Checklist items that were verified.
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.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (2)
Minor · Reconcile placement when workspace ownership records change. · bot-home-tab-placement.ts:153-156
src/renderer/src/components/bots/bot-home-tab-placement.ts:153-156 Minor · Functional Correctness · Quick win
Reconcile placement when workspace ownership records change.
If folder records arrive after tab hydration, the first pass leaves hostless tabs unchanged. A later folderWorkspaces-only update does not satisfy this subscription condition. Home therefore remains unpinned and behind the pinned side chat until another watched event occurs.
Observe the ownership inputs used by hostlessChatsAreLocal, including folderWorkspaces, and rerun placement when those inputs change.
Minor · Select the local bot for a hostless chat by recorded ownership,… · NativeChatPaneHeader.tsx:52
src/renderer/src/components/native-chat/pane/actions/NativeChatPaneHeader.tsx:52 Minor · Functional Correctness · Quick win
Select the local bot for a hostless chat by recorded ownership, not catalog order.
For a hostless tab, NativeChatPaneHeader passes undefined as the host to useBotForWorkspace. findBotByWorkspace then returns the first bot in catalog order whose folder workspace matches. If the catalog lists a runtime bot before the local bot for the same folderWorkspaceId, bot is the runtime bot. isHostedBotChatTab then takes its host branch for a hostless tab. A bot on another host does not claim the tab, and hostlessChatsAreLocal is not called. The hostless chat in the local bot's Home is not classified as hosted, even when the local bot is the sole recorded owner.
For a hostless tab, the bot lookup needs to resolve to the local bot when hostlessChatsAreLocal(state, worktreeId) holds. Tabs with an explicit host keep their host-specific match. This is a policy choice about how a hostless tab resolves its bot, so no code block is given.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: a8effd17-28d9-453e-868e-c594ff28a2c6
Commits
Reviewing files that changed from the base of the PR and between 643d7e7 and 8d191e0.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…Home when records arrive
A chat tab with no host now looks up the local bot before any other host's
bot at the same workspace id, so catalog order cannot hide the local Home.
Placement also reruns when folder or project-group records change, since a
hostless Home is claimed from them and they can arrive after the tabs.
Placement now reruns when folder-workspace or project-group records change, so a hostless Home is claimed once those records arrive after the tabs (covered by a new placement test).
For a hostless chat tab, the chat header and tab row now look up the local bot first (findBotForChatTab), so catalog order can't hide the local Home behind another host's bot with the same workspace id. Tabs with a host keep their exact host match.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Minor · Apply the local-ownership gate to the Home lock. · TabBarItemRow.tsx:100
src/renderer/src/components/tab-bar/model/TabBarItemRow.tsx:100 Minor · Functional Correctness · Quick win
Apply the local-ownership gate to the Home lock.
isBotChat checks only that the tab's session matches bot.chatSessionId. ruledHome also requires the ownership gate for hostless tabs. When the workspace owner is ambiguous, a hostless tab that matches the local bot's Home session is not claimed as Home, but it is still locked: closable is false and fixedFirst is true. The user cannot close the tab or move it from the first position.
Use the same locality check for the lock. Keep isBotHomeTab for session identity, because isHostedBotChatTab does not check the session.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
For best results, initiate chat on the files or code changes.
@AmethystLiang Thanks for fixing both findings and adding the placement test. The local-first lookup also preserves exact host matching for tabs with a host.
Learnings used
Learnt from: AmethystLiang
Repo: stablyai/orca PR: 45421
File: src/shared/bots/bot-home-tab.ts:26-26
Timestamp: 2026-11-21T06:01:37.963Z
Learning: Within repository "stablyai/orca", only for files matching one of ["src/shared/bots/bot-home-tab.ts"]: For restored hostless bot chat tabs in src/shared/bots/bot-home-tab.ts, treat a tab as belonging to a local bot only when this app's workspace records identify the local host as the sole owner. A routing default or a selected workspace twin is not ownership evidence. Paired and SSH bots must not claim hostless tabs.
If you found this review helpful, would you consider giving us a shout-out on X?
The tab row locked any tab whose session matched the bot's Home, even a
hostless one the ownership check does not vouch for. The lock now uses the
same Home test as the banner and placement.
@coderabbitai Fixed in 789522b: the tab row's Home lock (isBotChat: not closable, fixed first) now uses the same check as the banner. isBotHomeTab matches the session and isHostedBotChatTab gates the host, so a hostless tab this app doesn't own stays closable and movable.
For best results, initiate chat on the files or code changes.
@AmethystLiang Thanks for fixing the Home lock. With this change, a hostless tab that the app does not own should remain closable and movable.
Learnings used
Learnt from: AmethystLiang
Repo: stablyai/orca PR: 45421
File: src/shared/bots/bot-home-tab.ts:26-26
Timestamp: 2026-11-21T06:01:37.963Z
Learning: Within repository "stablyai/orca", only for files matching one of ["src/shared/bots/bot-home-tab.ts"]: For restored hostless bot chat tabs in src/shared/bots/bot-home-tab.ts, treat a tab as belonging to a local bot only when this app's workspace records identify the local host as the sole owner. A routing default or a selected workspace twin is not ownership evidence. Paired and SSH bots must not claim hostless tabs.
Follows main's test policy (#46786): the five suites main deleted stay deleted, so
this branch's edits to them are dropped. One invariant test remains for the claim
rule: a Home restored without a host is claimed only when this app's records own
its workspace, never by a paired or SSH bot.
Conflicts kept main's behavior: selectBotsEnabled in the side-chat pin rule, and the
translated Home title plus room renaming in TabBarItemRow. The title keys on the
session match alone, as on main, not on the host-gated lock.
The reason will be displayed to describe this comment to others. Learn more.
Late records lack coverage
The new tests check hostlessChatsAreLocal and isHostedBotChatTab, but none exercise installBotHomeTabPlacement. They would still pass if this new subscription stopped working.
Add a store-level test that restores a hostless Home before its workspace records arrive, then adds those records and checks that Home becomes pinned and moves first.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
The reason will be displayed to describe this comment to others. Learn more.
Not adding this test, deliberately. A test that installs installBotHomeTabPlacement on a store and checks that Home gets pinned and moved first tests a store subscription and the resulting tab order. This repo's test policy (AGENTS.md: no UI-behavior or wiring tests) rules those out, and the placement suite was removed on main for that reason (#46786). The rule the subscription feeds is covered directly: whether a hostless Home is this app's once its workspace records arrive, and while a restored session still names another host (recorded-workspace-owner.test.ts, bot-chat-tab-owner.test.ts). The subscription itself now also re-runs on restoredRuntimeHostIdByWorkspaceSessionKey. Pinning and moving Home at runtime is left to an end-to-end or UI check, not a unit test. Leaving this thread open for a human to close.
…nership everywhere
One rule now picks a chat tab's bot: the bot on the tab's own host, and for a tab
saved without a host the local bot only once this app's records own the
workspace. A remote bot never claims a hostless tab, and the catalog order no
longer decides.
- Row identity, the pane header's Continue in Terminal and the translated Home
title follow that bot, so an unowned hostless chat stays a plain chat.
- The tab bar's pinned slot, the displayed order (shortcuts, drops, side
closes) and its memo read ownership too.
- The close gate (tab commands, chat pane, mobile close) uses the row's test,
so a tab the row leaves closable closes, and a second host's Home stays guarded.
- Placing another host's Home moves only a tab stamped with that host.
Hostless or foreign-host tabs are never moved, and older hosts' stamped tabs
are still placed.
- While a restored session names another host whose records have not arrived,
this app does not claim its hostless chats; placement re-runs when the hint
clears.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
…ep only ownership tests
- The chat pane decides its close lock with useBotForChatTab, the row's lookup,
which subscribes to the bot catalog and the bots setting. Before, it read the
catalog snapshot inside a store selector, so it went stale until something
else re-rendered the pane.
- bot-chat-tab-owner.test.ts keeps only the ownership invariants (which bot a
chat tab belongs to, and the close gate). The drawn-order and placement
outcome cases are removed per the test policy.
- makeTestBot moves to src/shared/bots/bot.test-fixture.ts, so renderer tests
use the same fixture as main; main's path re-exports it. The hand-copied
helper is gone.
The close command checked the lock only when a close was requested. A hostless
Home locks once this app's records arrive, and they can arrive while the close
waits for structured-session admission or a confirmation. closeItem now asks
again when it runs, against the live tab and store, so a Home locked by then
stays open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
If Orca restores a bot's Home chat from a session saved before chat tabs recorded their host, the app didn't recognize it as the Home. So it wasn't pinned first, and the page could open a second Home next to it.
What Changed
recorded-workspace-owner.ts, so both share it. Rename behavior is unchanged.Why
Follow-up to a review comment on #45421. The tab predicates required
executionHostId === 'local', but restored tabs can lack the field. Treating every hostless tab as local would let a local bot claim a chat in a workspace whose id another host also publishes. The existing side-chat pin test guards that case. Stamping hosts at restore would change routing for every chat. So the ownership read runs only for hostless chats on a local bot's page.Visual Proof
N/A: this only appears when a legacy saved session is restored. It is covered by store-level tests that restore a session saved without tab hosts.
Testing
pnpm typecheck,pnpm lint,pnpm check:changedand the affected suites pass locally.Performance
No new work for tabs that carry a host, which is every tab created today. For a hostless chat on a local bot's page, one ownership lookup runs, memoized for each placement pass and selector run. Placement now also reruns on folder/project-group record changes. Each pass is a small loop over the bots and their page tabs, with no I/O.
Risk
Level: Low. Only legacy hostless chats in a local bot's own workspace change behavior. A plain revert backs it out.