Skip to content

feat(chat): keep Home first with a floating identity banner - #45421

Merged
AmethystLiang merged 5 commits into
mainfrom
AmethystLiang/bot-home-pin
Nov 20, 2026
Merged

AmethystLiang merged 5 commits into
mainfrom
AmethystLiang/bot-home-pin

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

An agent's page always shows its main chat (Home) as the first, pinned tab. Side chats can no longer be pinned ahead of it. Home also gets a small floating name pill that opens the agent's Activity.

Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​595 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​590
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​518 $\color{#cf222e}{\Huge{\mathbf{−}}}$​31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​487

What Changed

Scope: agents hosted on this computer only. Paired-server agents are unchanged here; remote support is the next follow-up.

  • Before: Home was found by session id only. Restored side chats could stay pinned in front of Home, any chat could be pinned, and duplicate Home views could pile up after a restore.
  • After: Home stays first and pinned. Side chats in the agent's workspace are unpinned on restore, and the pin action is removed for them (the store's pinTab refuses them too). When duplicate Home views exist, the oldest ready view is kept (previews never win over ready views). The extra views close without ending the conversation, and if one of them was focused, focus moves to Home.
  • Banner: Home gets a tab accent and a floating identity pill. The pill shrinks to its avatar as the transcript scrolls and is hidden when the header content width is 260 CSS px or less.
  • Mechanism: a shared Home rule (src/shared/bots/bot-home-tab.ts) identifies Home by the agent's chat session, workspace and host, never by tab label or order. Placement, pin rules, close locks and the banner all use it. Placement waits for workspaceSessionReady, so restore ordering can't race it.

Why

Home is where the agent's memory, automations and requests land, so it should always be easy to find. One identity rule keeps placement, pinning and presentation consistent, so they can't disagree about which tab is Home. Remote hosts are left out because their tab restore and ownership need their own design.

Linked Issue

N/A (maintainer change; no pre-existing issue).

Visual Proof

Synthetic fixture data, dark theme.

Local Home, header content exactly 260px (banner hidden, Home pinned) Paired-server Home (unchanged, banner not rendered)
Local Home at 260px Paired-server Home

Testing

Focused unit tests cover: Home identity and selection (ready before preview, then age, then id), placement and duplicate cleanup, Home chat reopen gating, focus after a split restore, the pane header banner (local vs paired), the side-chat pin rule, and mobile tab close. Locally: those 6 test files (23 tests), pnpm typecheck:web, pnpm typecheck:node and pnpm lint pass. Platform: macOS only.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

Performance

Reasoned from the code; nothing was measured.

  • Placement: this subscriber already runs when tabs, groups or layout change. It now also runs once when workspaceSessionReady flips. Each run does a filter and sort over one workspace's tabs for each local agent, which is tiny. A reentrancy guard stops its own pin, unpin and close writes from triggering nested passes.
  • Selectors: the new store selectors return booleans, so they only re-render when the answer changes. Tab rows check whether Home is local in O(1). Each visible chat pane header and each agent page does one find or some over that workspace's tabs.
  • Banner: shrinking uses a CSS scroll-driven animation (scroll-timeline), and hiding uses a container query. There's no scroll listener, resize observer or per-frame JS.
  • No new costs elsewhere: no IPC, polling, timers or main-process work. The pinTab guard does one tab lookup per pin, and pins are user-initiated.

Risk

The riskiest part is that placement automatically closes duplicate Home views and unpins side chats in a local agent's workspace. If the identity rule were wrong, users would see a chat tab close or unpin on that page. It is guarded three ways: it only runs after session restore, a preview never replaces a ready Home, and closes use preserveAgentSession. Placement is the only caller of preserveAgentSession, so other close paths behave as before. Paired, SSH and non-agent workspaces don't change. No saved data or settings format changes. Back out with a plain revert.

Level: Low

Review

  • Cross-platform: renderer-only UI and store logic, with no OS-specific paths or shortcuts. Only verified on macOS; Linux and Windows not exercised.
  • SSH/remote: paired and SSH agent pages keep their existing Home placement and get no banner. Local-only gating is checked by executionHostId and the agent's hostId.
  • Agent/integration compatibility: Home identity uses the agent's chat session pointer. It doesn't depend on agent type, labels or order. Reopening Home after an agent change still works.
  • Performance: see above. Only cheap boolean selectors, plus a CSS-only scroll effect.
  • UI quality: the pill has an accessible label, a focus ring and a tooltip, uses theme tokens, and hides at narrow widths.
  • Security: no new IPC, inputs or persistence.

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.

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

AmethystLiang and others added 5 commits November 20, 2026 01:51
Keep the Home tab first and prevent side chats from being pinned. Unpin restored side chats on pages owned by this window and use one Home identity rule for placement and presentation.

Add the Home tab accent and a floating identity pill that shrinks on scroll and opens Activity.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Codex <[email protected]>
Wait for restored local Home tabs, retain the oldest duplicate view without retiring its conversation, and re-resolve Home when its identity changes or its tab disappears. Keep paired and SSH pin behavior unchanged and hide the floating identity banner in narrow panes.

Co-authored-by: Codex <[email protected]>
Use one deterministic selection for cleanup and placement: published views before previews, then creation time and stable tab id. Keep the oldest published Home when an older preview exists, and wait if all matching views are previews.

Co-authored-by: Codex <[email protected]>
Document that scrolling shrinks the Home banner to its avatar while header content widths at or below 260 CSS pixels hide the entire banner. Add synthetic local-breakpoint and paired-server Home fixtures and restore the header store import required for eligibility rendering.

Co-authored-by: Codex <[email protected]>
When a focused duplicate Home view closes, focus is handed to the surviving Home only after Home's final move to the top-left group. Moving a tab keeps the destination group's selection, so activating Home before the move left a side chat selected after a split restore.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The changes add shared predicates for identifying bot Home, local bot chat, and side-chat tabs. Renderer logic uses them to reconcile local Home tabs after workspace readiness, preserve matching sessions when closing duplicates, and control tab pinning and presentation. Bot Home chat creation now checks readiness and existing tabs. The native chat header can display a bot banner that opens the bot activity panel.

Merge Risk: Low · up to 97d95

Home stays first and pinned for local agents in the normal case. Two edge cases should be fixed or accepted: restored local Home tabs without a host may not be recognized, and automatic cleanup of a duplicate Home group can shift focus away from the group the user was in. Neither is likely to block ordinary use.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(chat): keep Home first with a floating identity banner" names the two main changes: Home placement and the floating banner. Both are present in the changeset. It is specific and follow…
Description check Passed The description follows the template. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk, Review, Agent skill upstream boundary, and Checklist sections. It explains the before a…
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: Title check

Explanation

The title "feat(chat): keep Home first with a floating identity banner" names the two main changes: Home placement and the floating banner. Both are present in the changeset. It is specific and follows conventional commit form. Scope is local agents only, which the title does not state, but that is a detail rather than a mismatch.

Full details: Description check

Explanation

The description follows the template. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk, Review, Agent skill upstream boundary, and Checklist sections. It explains the before and after, the mechanism, and the risk with a back-out path. It includes before/after images in a table. Gaps: the Risk section has no explicit Level value beyond 'Low', which is filled in. The Linked Issue section says N/A rather than linking an issue, and the template says there should always be one for outside contributors, but the author is a maintainer. The AI Disclosure section is omitted, which is acceptable for internal contributors. The final lint/typecheck/test/build checklist item is unchecked, and the Testing section says only some checks passed. The Testing item 'Every added test fails without this change' is unchecked.

  • 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

@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 · Keep the active group when an inactive group's last tab closes. · tabs-close-actions.ts:178-180

src/renderer/src/store/slices/tabs/tabs-close-actions.ts:178-180
Minor · Functional Correctness · Quick win

Keep the active group when an inactive group's last tab closes.

When the last tab of a group closes, the code replaces activeGroupIdByWorktree with the collapsed sibling group. It does this even when the closed group was not the active group. For example, in split(split(A, B), C) with focus in C, closing the last tab of B makes A the active group. The surface then switches to A.

Use the collapsed fallback only when the removed group was active. Otherwise keep the current active group, provided it still exists.

Suggested fix

-              nextActiveGroupIdByWorktree = replaceRecordEntries(current.activeGroupIdByWorktree, [
-                [worktreeId, collapsed.activeGroupId]
-              ])
+              const currentActiveGroupId = current.activeGroupIdByWorktree[worktreeId]
+              const keepsActiveGroup =
+                currentActiveGroupId !== undefined &&
+                currentActiveGroupId !== group.id &&
+                nextGroups.some((candidate) => candidate.id === currentActiveGroupId)
+              if (!keepsActiveGroup) {
+                nextActiveGroupIdByWorktree = replaceRecordEntries(
+                  current.activeGroupIdByWorktree,
+                  [[worktreeId, collapsed.activeGroupId]]
+                )
+              }
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: 649e367b-37e2-445e-a88c-5746c2feafd0
Commits

Reviewing files that changed from the base of the PR and between 44abf8f and 97d9596.

Files selected for processing: 24

  • src/renderer/src/components/bots/BotHomeChat.test.tsx
  • src/renderer/src/components/bots/BotHomeChat.tsx
  • src/renderer/src/components/bots/bot-home-tab-placement.test.ts
  • src/renderer/src/components/bots/bot-home-tab-placement.ts
  • src/renderer/src/components/bots/bot-workspace.ts
  • src/renderer/src/components/bots/home-chat/BotHomeBanner.tsx
  • src/renderer/src/components/bots/home-chat/BotHomeTabAccent.tsx
  • src/renderer/src/components/bots/home-chat/bot-home-banner.css
  • src/renderer/src/components/native-chat/pane/actions/NativeChatPaneHeader.bot-home.test.tsx
  • src/renderer/src/components/native-chat/pane/actions/NativeChatPaneHeader.fixture.tsx
  • src/renderer/src/components/native-chat/pane/actions/NativeChatPaneHeader.tsx
  • src/renderer/src/components/tab-bar/model/TabBarItemRow.tsx
  • src/renderer/src/components/tab-bar/terminal-tabs/SortableTab.tsx
  • src/renderer/src/components/tab-bar/terminal-tabs/SortableTabContextMenu.tsx
  • src/renderer/src/components/tab-bar/terminal-tabs/sortable-tab-props.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/runtime/mobile-session-tab-close.test.ts
  • src/renderer/src/store/slices/tabs/bot-side-chat-pin-rule.ts
  • src/renderer/src/store/slices/tabs/create-tabs-slice.ts
  • src/renderer/src/store/slices/tabs/tabs-bot-side-chat-pin.test.ts
  • src/renderer/src/store/slices/tabs/tabs-close-actions.ts
  • src/renderer/src/store/slices/tabs/tabs-slice-contract.ts
  • src/shared/bots/bot-home-tab.test.ts
  • src/shared/bots/bot-home-tab.ts

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

Comment thread src/shared/bots/bot-home-tab.ts Resolved
@AmethystLiang
AmethystLiang merged commit b9d1d16 into main Nov 20, 2026
64 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