fix(desktop): show a chat's generated title instead of the agent label

SA
16h ago
+27-4

What & why

Fixes #10200.

A chat opened from the agent picker kept the agent's label (e.g. "Claude") as its tab and pane title. The generated session title never showed until the tab was closed and the session reopened from history.

The launch sites stored the label as titleOverride, the field a user rename uses. Every title lookup (ChatPaneTitle, useTabTitle, the undo-close toast, the activity menu) puts titleOverride above data.chatTitle. So the live title that sessionInfoPaneData writes to data.chatTitle stayed hidden.

The launch sites now seed the label as data.chatTitle, and the session's generated title replaces it when it arrives. titleOverride then only holds names the user typed. This is option 1 from the triage comment. focusAgentSession already seeds chatTitle the same way.

Changed launch sites:

  • useAgentSessionLauncher.openChatPane: the agent picker, openNewChat and the chat branch of createNewAgentSession.
  • ChatPane onNewChat and onOpenAgentChat.
  • ChatPane onSwitchAgent: it used to setTitle(label). It now sets chatTitle: label on the restarted pane data and clears the pane's titleOverride, so the next session's title can show. Before, the switch already replaced any rename with the label.

Notes:

  • Nothing writes a pane's chatTitle back to the session or history; I checked with grep. The only other reader is forkedChatPaneData, which copies it to a fork as its starting name.
  • The fork paths are unchanged. They copy titleOverride only when there is one, which after this change means only a user rename.
  • Panes saved before this change still have the label in titleOverride. Renaming them to an empty name clears it, as before.

How I tested it

  • Added a sessionInfoPaneData test: a pane launched with chatTitle: "Claude" gets chatTitle: "Fix the build" when the session title arrives.
  • bun test on the ChatPane folder: 39 pass, 0 fail.
  • biome check on the changed files is clean.
  • bun run typecheck in apps/desktop shows no errors in these files. The only errors are shell-quote not being found in packages/host-service, which comes from my stale local node_modules and is unrelated to this change.
  • Ran the dev app and drove it over CDP (real clicks and typing). In each case I opened a chat with "+" → Chat in the tab bar and sent one prompt.
    • Before (main): the pane stored titleOverride: "Claude" and chatTitle: "Git worktree explanation", and the tab and pane header kept showing "Claude".
    • After (this branch): the new pane stored chatTitle: "Claude" and no titleOverride. When the title arrived, the tab and pane header changed to "Git rebase explained". The older "Claude" tab next to it was opened before the switch and still has the launch label, as described above.
Before (main)After
beforeafter

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too). Biome is clean on the changed files; the full typecheck fails locally only on the unrelated shell-quote error above, so I'm leaving this to CI
  • "Allow edits from maintainers" is checked on fork PRs
  • I have signed the CLA (the bot asks on your first PR)

Summary by cubic

Fixes #10200. A chat opened from the agent picker, "New chat", or a switch to another agent kept the agent's label, e.g. "Claude", as its tab and pane title. The session's generated title never showed unless the tab was reopened from history.

The launch sites stored the label in titleOverride, which every title lookup prioritizes over the generated chatTitle. They now seed the label as chatTitle so the session title replaces it when it arrives, and titleOverride only holds names the user typed. Switching agents now also clears titleOverride instead of overwriting it with the new label.

Summary by CodeRabbit

  • Bug Fixes
    • New chats and chats opened for another agent now show the agent’s label as the initial chat title. Automatically generated session titles can replace it, while user-renamed titles remain preserved.
  • Tests
    • Added coverage to verify that a session-generated title takes precedence over the agent label when available.