Skip to content

fix(native-chat): make structured chat tabs renameable - #19153

Merged
brennanb2025 merged 8 commits into
mainfrom
brennanb2025/native-chat-tab-rename
Sep 7, 2026
Merged

brennanb2025 merged 8 commits into
mainfrom
brennanb2025/native-chat-tab-rename

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​531 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​528
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​86 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​66

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:

  1. The rename never landed. setTabCustomTitle scanned tabsByWorktree (terminal tabs only) and then bridged to the unified tab via contentType === 'terminal' && entityId === tabId. A structured chat tab has no TerminalTab record, 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 an agent-session tab by id.
  2. A landed rename was clobbered. buildMirroredAgentTabs rebuilt the tab on every host snapshot and hardcoded customLabel: null, while preserving color, createdAt, and isPinned from the existing tab. It now preserves customLabel too.

Plus one cosmetic fix: both placeholder sites (orca-runtime-restore-structured-agent-session-tabs-once.ts and the renderer fallback in terminal-surfaces.ts) now route through a single defaultAgentChatLabel helper, 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.tsx builds a synthetic TerminalTab for an agent-session tab and passes the same onSetCustomTitle the 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

  • Automated tests added
  • Manual testing in the app — not run; see Visual Proof

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:

  • Reverting the setTabCustomTitle fallback → the rename test fails.
  • Reverting customLabel preservation 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 null when the broken code also left null); 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, and pnpm run check:code-quality:changed (0 new findings across 6 files) all pass.

Agent skill upstream boundary

  • Not applicable.

Notes

  • Scope — known limitation, deliberately not fixed here. customLabel is a client-side unified-tab field, persisted via workspace-session-schema.ts, so a rename survives restart locally. The wire contract RuntimeMobileSessionAgentTab carries only title and no customLabel, 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.
  • Placeholder strings are not localized. 'Claude Chat' / 'Codex Chat' never passed through translate() before this PR and still don't; this change only consolidates them. Localizing them is a follow-up (it needs catalog sync).
  • Cross-platform: pure renderer/shared string and store logic, no platform branches.
  • SSH/remote: no execution-path changes. Remote structured sessions get the same client-local rename, with the sync limitation above.
  • Folder workspaces: no worktree assumptions.
  • Performance: the added lookup only runs when the first (terminal) lookup misses, i.e. on a structured tab rename.
  • orca-runtime-restore-structured-agent-session-tabs-once.ts carries @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

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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
  • Lint, typecheck, and targeted tests pass locally; full suite via CI

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. deriveActiveSurfaceForWorktree populates activeTabId from the active unified tab only when contentType === 'terminal', so with a structured tab active activeTabType is agent-session while activeTabId is a live, unrelated terminal — a wrong-tab mis-action rather than a harmless no-op. The handler now resolves the target through getActiveTab(worktreeId). The test builds the state the app actually derives (running the real buildActiveSurfacePatch and 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.ts skips editable targets so a rich-text editor keeps its own chords, and editable-target.ts special-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.rename sits three lines away with the identical symptom) and not an isEditableTarget special-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 composer KeybindingContext with 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.

Merge Sim added 2 commits September 6, 2026 16:53
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'.
@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review 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: Team

Run ID: 603c6c0e-930b-4f2e-8a74-65fea197bc61

📥 Commits

Reviewing files that changed from the base of the PR and between 154b1bb and 5620fb9.

📒 Files selected for processing (2)
  • src/renderer/src/app-shell/app-command-handlers-tab-rename.test.ts
  • src/renderer/src/app-shell/app-command-handlers.ts

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


📝 Walkthrough

Walkthrough

The 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 5620f

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.32% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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 p… Add a valid issue reference after "Fixes #". Attach before-and-after screenshots or a video showing the rename behavior, or provide the exact N/A statement only if the change has no visual or interaction impact.
✅ Passed checks (3 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 primary change: enabling renaming for structured native chat tabs.
Full details: Description check

Explanation

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 💡
  • Create stacked PR
  • Commit on current branch

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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Store action now finds structured tabs — setTabCustomTitle falls back to matching an agent-session unified tab by id when the terminal lookup misses, so the already-wired rename UI actually writes the label. I traced the full flow (tab-bar-item-surface.tsx builds the synthetic TerminalTab with id = item.id, which resolves to the unified tab id via use-tab-bar-item-projection.ts), and the fallback matches it exactly.
  • Mirrored tabs keep a manual rename — buildMirroredAgentTabs preserves existing?.customLabel instead of re-nulling it on every host snapshot. This is the single site that constructs agent-session unified 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.

Pullfrog  | View workflow run | Using 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.
Merge Sim added 2 commits September 6, 2026 20:42
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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Rename shortcut now reaches structured tabs — the tab.rename handler's gate required activeTabType === 'terminal', so the chord was a silent no-op on a chat tab; it now also claims for agent-session and dispatches requestTerminalTabRename(store.activeTabId), which resolves to the same unified tab id the inline editor already uses.
  • Shared findRenamableUnifiedTab helper — the terminal-vs-agent-session lookup is extracted and now backs both setTabCustomTitle and setTabColor, so structured chat tabs are also recolorable. The color write mirrors to the host through the existing setWebRuntimeTabProps path, which resolves the host tab id correctly (agent-session local ids are registered via setHostSessionTabIdMapping, and the wire contract carries color, unlike customLabel).
  • Tests bind to both new surfaces — the shortcut test asserts the agent-session case claims the chord (and browser does not), and the store test covers the color write; each would fail if its fix were reverted.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Unknown agents no longer read as Codex — defaultAgentChatLabel now routes through the existing formatAgentTypeLabel helper instead of a claude/codex ternary, so a future or custom agent falls back to its own name (Gemini Chat) rather than silently Codex Chat. null/undefined now yields Agent Chat, which is unreachable from the two call sites (both pass the wire-typed claude/codex) and strictly more correct.
  • Terminal rename path covered — the store test adds a case asserting a terminal rename keyed by entityId is routed to the terminal unified tab and not absorbed by the adjacent structured tab, guarding the findRenamableUnifiedTab precedence.
  • 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.

Pullfrog  | View workflow run | Using 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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Null title now degrades instead of throwing — buildMirroredAgentTabs switched tab.title.trim() to tab.title?.trim(), so a host that publishes a null title (violating the wire string type) falls back to the agent placeholder rather than throwing inside the snapshot patch. The new regression test asserts not.toThrow() and the placeholder fallback, which fails under the pre-change .trim().

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Rename shortcut now targets the focused tab — the tab.rename handler was dispatching requestTerminalTabRename(store.activeTabId), and activeTabId is terminal-only state that stays on the last terminal even while a structured chat tab is focused (see deriveActiveSurfaceForWorktree), so the chord renamed a background terminal. The new resolveRenameTargetTabId resolves a terminal tab by its activeTabId and a structured tab by its unified id via getActiveTab, mirroring the tab strip's own resolution.
  • Tests rebuilt around the real derived state — the shortcut test now assembles the store through buildActiveSurfacePatch with a premise guard proving activeTabId stays 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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ 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 by activeTabId, 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 via getActiveTab(worktreeId) and passes its entityId through a new activeAgentSessionEntityId parameter, so the agent-session branch yields null and the existing findIndex === -1 fallback jumps to the first (or last) terminal.
  • getActiveEntityIdForTabType extended without regressions — the new activeAgentSessionEntityId param defaults to null; the three other callers (recent-tab-switching.ts and the internal getNextTabWithinActiveType / getNextTabAcrossAllTypes) previously searched a stale terminal id that never matched a structured entry, and now search null with the identical -1 result, so their jump-to-boundary behavior is unchanged.
  • Active indicator reaches structured tabs — findActiveVisibleTabId gains an agent-session branch; its TabGroupPanel caller 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.ts runs the real buildActiveSurfacePatch and createTabsFocusActions resolvers and guards the premise (asserting activeTabId still 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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025
brennanb2025 merged commit bffdad9 into main Sep 7, 2026
34 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