Repository navigation
fix(native-chat): make structured chat tabs renameable - #19153
Conversation
Renaming a native chat tab accepted the text and silently did nothing: setTabCustomTitle only scanned terminal tabs and only bridged to unified tabs whose contentType was 'terminal', so the agent-session tab it was keyed to never matched. Any label that did land was then re-nulled by the next host snapshot, which preserved color/createdAt/isPinned but not customLabel. Also routes both placeholder sites through one helper so a Claude chat stops falling back to 'Codex Chat'.
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change centralizes agent-specific chat labels for published and mirrored tabs. Mirrored tabs preserve custom labels across host snapshots. A shared lookup resolves terminal and agent-session tabs for renaming and recoloring. The rename shortcut now supports agent-session tabs. Tests cover fallback labels, title precedence, rename preservation, label clearing, recoloring, and shortcut handling. Merge Risk: ⚪ Minimal · up to Structured chat tabs can now be renamed and recolored correctly, preserve local custom labels across host snapshots, and use agent-specific fallback labels. The covered behavior is ready to merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the changes, rationale, testing, limitations, and checklist. However, it does not provide the required linked issue, and it does not attach the required visual proof for a behavior change. ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Store action now finds structured tabs —
setTabCustomTitlefalls back to matching anagent-sessionunified tab byidwhen the terminal lookup misses, so the already-wired rename UI actually writes the label. I traced the full flow (tab-bar-item-surface.tsxbuilds the syntheticTerminalTabwithid = item.id, which resolves to the unified tab id viause-tab-bar-item-projection.ts), and the fallback matches it exactly. - Mirrored tabs keep a manual rename —
buildMirroredAgentTabspreservesexisting?.customLabelinstead of re-nulling it on every host snapshot. This is the single site that constructsagent-sessionunified tabs (local and remote structured sessions both route through it), so no parallel builder is left to clobber the rename. - Placeholder consolidation — both restore sites now route through
defaultAgentChatLabel, so a Claude session no longer falls back to'Codex Chat'. - Tests bind to the fixes — the rename test asserts the intermediate write before the clear (so it can't false-green), and the mirrored-label test would fail under either reverted fix.
The scope is genuinely complete: both the local structured-session path and the mirrored remote path flow through buildMirroredAgentTabs, and the rename entry point is shared with terminal tabs, so no separate wiring is missing. The one thing to note: pnpm-lock.yaml picks up an unrelated @pnpm/[email protected] entry — benign pnpm churn, but it is noise relative to the fix.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Swept in accidentally; running pnpm here adds @pnpm/exe to the root lockfile, which fails CI's frozen-lockfile guard.
Review found the first fix covered only the context-menu path. The tab.rename shortcut gated on activeTabType === 'terminal', so on a structured chat tab it stayed the silent no-op this branch set out to fix. setTabColor carried the identical terminal-only lookup one function below the one that was fixed. Both lookups now share one resolver instead of two copies.
…minal path Review found the placeholder helper encoded "unknown means Codex": its signature accepts null/undefined and Tab.agentSessionAgent is the open AgentType, so the first caller passing a Tab would label gemini or grok as "Codex Chat". Routed through the shared agent-name table instead. Also adds the missing regression test that a terminal rename still resolves through its entityId now that both rename and color share one resolver, and a guard on a test that passed with the fix reverted.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Rename shortcut now reaches structured tabs — the
tab.renamehandler's gate requiredactiveTabType === 'terminal', so the chord was a silent no-op on a chat tab; it now also claims foragent-sessionand dispatchesrequestTerminalTabRename(store.activeTabId), which resolves to the same unified tab id the inline editor already uses. - Shared
findRenamableUnifiedTabhelper — the terminal-vs-agent-session lookup is extracted and now backs bothsetTabCustomTitleandsetTabColor, so structured chat tabs are also recolorable. The color write mirrors to the host through the existingsetWebRuntimeTabPropspath, which resolves the host tab id correctly (agent-session local ids are registered viasetHostSessionTabIdMapping, and the wire contract carriescolor, unlikecustomLabel). - Tests bind to both new surfaces — the shortcut test asserts the agent-session case claims the chord (and
browserdoes not), and the store test covers the color write; each would fail if its fix were reverted.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Unknown agents no longer read as Codex —
defaultAgentChatLabelnow routes through the existingformatAgentTypeLabelhelper instead of aclaude/codexternary, so a future or custom agent falls back to its own name (Gemini Chat) rather than silentlyCodex Chat.null/undefinednow yieldsAgent Chat, which is unreachable from the two call sites (both pass the wire-typedclaude/codex) and strictly more correct. - Terminal rename path covered — the store test adds a case asserting a terminal rename keyed by
entityIdis routed to the terminal unified tab and not absorbed by the adjacent structured tab, guarding thefindRenamableUnifiedTabprecedence. - Null-label guard hardened — the mirrored-label test now asserts the row was actually built before checking
customLabel, so it cannot false-green on an empty result.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
A stacked branch can publish title: null when a conversation name is cleared. The wire type says string, so this consumer trusted it and threw inside the store patch that applies the snapshot. Fall back to the placeholder — the producer bug is fixed separately, but a consumer of wire data should not crash on a contract violation.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Null title now degrades instead of throwing —
buildMirroredAgentTabsswitchedtab.title.trim()totab.title?.trim(), so a host that publishes anulltitle (violating the wirestringtype) falls back to the agent placeholder rather than throwing inside the snapshot patch. The new regression test assertsnot.toThrow()and the placeholder fallback, which fails under the pre-change.trim().
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Rename shortcut now targets the focused tab — the
tab.renamehandler was dispatchingrequestTerminalTabRename(store.activeTabId), andactiveTabIdis terminal-only state that stays on the last terminal even while a structured chat tab is focused (seederiveActiveSurfaceForWorktree), so the chord renamed a background terminal. The newresolveRenameTargetTabIdresolves a terminal tab by itsactiveTabIdand a structured tab by its unified id viagetActiveTab, mirroring the tab strip's own resolution. - Tests rebuilt around the real derived state — the shortcut test now assembles the store through
buildActiveSurfacePatchwith a premise guard provingactiveTabIdstays on the background terminal, and asserts the structured-tab and terminal cases each target the correct id.
The resolution is safe on the mismatch edges: getActiveTab resolves the group's activeTabId directly, so any divergence from the derived activeTabType degrades to a null target (chord not claimed) rather than renaming the wrong tab.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Terminal cycling now starts from the structured tab, not a background terminal —
handleSwitchTerminalTab(Ctrl+PageUp/PageDown) searched a terminal pre-filtered list byactiveTabId, which keeps naming the last-focused terminal while a structured chat tab is active, so the chord cycled from a tab the user was not on. It now resolves the active tab viagetActiveTab(worktreeId)and passes itsentityIdthrough a newactiveAgentSessionEntityIdparameter, so the agent-session branch yieldsnulland the existingfindIndex === -1fallback jumps to the first (or last) terminal. getActiveEntityIdForTabTypeextended without regressions — the newactiveAgentSessionEntityIdparam defaults tonull; the three other callers (recent-tab-switching.tsand the internalgetNextTabWithinActiveType/getNextTabAcrossAllTypes) previously searched a stale terminal id that never matched a structured entry, and now searchnullwith the identical-1result, so their jump-to-boundary behavior is unchanged.- Active indicator reaches structured tabs —
findActiveVisibleTabIdgains anagent-sessionbranch; itsTabGroupPanelcaller passes the structured tab's own unified id (activeTab.id), so the strip now underlines the focused chat tab. - Tests bind to the fix —
ipc-tab-switch-structured-tab-cycle.test.tsruns the realbuildActiveSurfacePatchandcreateTabsFocusActionsresolvers and guards the premise (assertingactiveTabIdstill names the background terminal), so the cycle assertions cannot pass with the bug present, and the existing-terminal and sole-terminal edge cases are covered.
I verified the divergent-surface edges degrade safely: when activeTabType and the group-resolved active tab disagree, the agent-session branch receives null (or the terminal branch ignores the extra argument), so the chord falls back to jumping to a boundary terminal rather than cycling from the wrong tab.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

ELI5
You can't rename a native chat tab. You can open the rename box, type a name, and press Enter — the box closes and nothing happens. This makes rename actually work. It also stops a Claude chat from being labelled "Codex Chat".
What Changed
Two stacked defects, either of which alone breaks rename:
setTabCustomTitlescannedtabsByWorktree(terminal tabs only) and then bridged to the unified tab viacontentType === 'terminal' && entityId === tabId. A structured chat tab has noTerminalTabrecord, and its rename arrives keyed by the unified tab id, so neither lookup matched and the write was dropped silently. It now falls back to matching anagent-sessiontab by id.buildMirroredAgentTabsrebuilt the tab on every host snapshot and hardcodedcustomLabel: null, while preservingcolor,createdAt, andisPinnedfrom the existing tab. It now preservescustomLabeltoo.Plus one cosmetic fix: both placeholder sites (
orca-runtime-restore-structured-agent-session-tabs-once.tsand the renderer fallback interminal-surfaces.ts) now route through a singledefaultAgentChatLabelhelper, so a Claude session no longer falls back to'Codex Chat'. The renderer fallback previously hardcoded'Codex Chat'for both agents.Why
The rename UI was already fully wired for these tabs —
tab-bar-item-surface.tsxbuilds a syntheticTerminalTabfor an agent-session tab and passes the sameonSetCustomTitlethe terminal tabs use. Only the store action and the snapshot rebuild were terminal-only, so the feature looked present and did nothing.Linked Issue
N/A — found while investigating where native chat tab titles come from.
Visual Proof
Not attached. The change is a behavior fix behind an existing control with no layout change: before, the rename box discards your input; after, it keeps it. Covered by unit tests at both broken layers, each verified by ablation (see Testing). Happy to attach a recording if wanted.
Testing
Added:
src/renderer/src/store/terminals/structured-chat-tab-rename.test.ts— rename writes the label, and clearing it resets to null.src/renderer/src/runtime/web-session-tabs-sync/mirrored-agent-tab-label.test.ts— agent-specific placeholder, host title preferred, and a manual rename surviving a host snapshot.Each fix was ablated to confirm the tests bind to it, not merely to surrounding behavior:
setTabCustomTitlefallback → the rename test fails.customLabelpreservation and the label helper → the rename-survives-snapshot and Claude-placeholder tests fail; the two regression guards stay green, as expected.One test initially passed under ablation (asserting
nullwhen the broken code also leftnull); it now asserts the intermediate state so it cannot false-green.Regression:
local-structured-session-tabs-sync,local-structured-session-retired-epoch-repair,web-session-tabs-sync,local-structured-session-tabs-host-isolation,local-structured-session-empty-worktree-visibility,tabs-model-reconciliation— 57 passed.pnpm tc,oxlint,oxfmt, andpnpm run check:code-quality:changed(0 new findings across 6 files) all pass.Agent skill upstream boundary
Notes
customLabelis a client-side unified-tab field, persisted viaworkspace-session-schema.ts, so a rename survives restart locally. The wire contractRuntimeMobileSessionAgentTabcarries onlytitleand nocustomLabel, so a rename does not sync to other clients — rename on desktop and mobile still shows the old label. Fixing that means an additive optional wire field, which is safe but is a separate change with its own compatibility story.'Claude Chat'/'Codex Chat'never passed throughtranslate()before this PR and still don't; this change only consolidates them. Localizing them is a follow-up (it needs catalog sync).orca-runtime-restore-structured-agent-session-tabs-once.tscarries@ts-nocheck, so typecheck does not validate its new import; the path was checked by hand and the module's existing characterization tests pass.Checklist
End-to-end validation
Validated in the running app against real Claude and Codex structured chat sessions (not just unit tests). Verified: agent-specific placeholders; both providers self-naming after the first message; rename via the tab context menu holding across sustained use; the sidebar agent row matching the tab; and tab color on a structured tab.
That run caught a real defect this PR had missed, now fixed here: the rename keyboard shortcut renamed a background terminal instead of the focused chat tab.
deriveActiveSurfaceForWorktreepopulatesactiveTabIdfrom the active unified tab only whencontentType === 'terminal', so with a structured tab activeactiveTabTypeisagent-sessionwhileactiveTabIdis a live, unrelated terminal — a wrong-tab mis-action rather than a harmless no-op. The handler now resolves the target throughgetActiveTab(worktreeId). The test builds the state the app actually derives (running the realbuildActiveSurfacePatchand focus actions) rather than stubbing the store fields, plus a premise guard asserting the stale id is still produced, so the assertion cannot silently start passing for the wrong reason.Known limitation — follow-up, not fixed here
The rename shortcut does not fire while the chat composer has focus.
use-global-keybindings.tsskips editable targets so a rich-text editor keeps its own chords, andeditable-target.tsspecial-cases the terminal's helper textarea to opt back in. Native chat's plain-text composer was never added, so a focused composer loses every app chord —workspace.rename, the sidebar toggles and the explorer/search bindings, not just rename.Deliberately left out of scope. The honest fix is not a rename-only exemption (
workspace.renamesits three lines away with the identical symptom) and not anisEditableTargetspecial-case, which would become a fourth place keybinding authority lives, after the window handler, the terminal runtime, and native chat's own capture handler. The principled shape is a composerKeybindingContextwith per-action opt-in, matching how the terminal already works. Filed as follow-up.Not verified
Persistence of a custom title across an app restart. The validation run covered sustained use but no restart.