Repository navigation
agentHost: keep the default chat title in sync with a session rename - #337308
Merged
Sandeep Somavarapu (sandy081) merged 3 commits intoSep 22, 2026
Conversation
Renaming a session from the sessions list left the session header showing the old title, and committing that header handed the stale title back to the session, silently overwriting the rename. A session whose only chat is its default chat has no independently titled chat - the header shows the session title - but the chat still owns persisted title metadata written whenever something renamed it directly (the rename tool, the chat header, an automatic title). A session-scoped rename updated only the session, so that metadata went stale and restore seeded it back as the chat's own title. Mirror a session rename down onto the sole default chat in both live state and persisted metadata. Handling this in onDidApplyClientAction covers every session-channel rename rather than just the rename-tool path, and repairs already-affected sessions the next time they are renamed. Sessions that own peer chats are skipped: their default chat is independently titled by design. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The regression test aliases distinct production databases, leaving the critical cross-store persistence behavior inadequately covered.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Synchronizes sole default-chat titles with session renames to prevent stale titles and accidental overwrite.
Changes:
- Mirrors session renames into live and persisted default-chat state.
- Adds restore-focused regression coverage.
| File | Description |
|---|---|
sessionTitleContribution.ts |
Synchronizes sole default-chat titles and metadata. |
agentService.test.ts |
Tests rename behavior across restore. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Henning Dieterichs (hediet)
previously approved these changes
Sep 22, 2026
…tract Two follow-ups to the sole-default-chat rename fix. The new test passed one TestSessionDatabase to createSessionDataService, which returns that same database for every channel. That aliased the session and chat stores, so onHydrateChat could read the session's customTitle and the test still passed with the chat-local writes removed. Use createPerSessionDataService() and assert both databases, including the companion source keys, so all four writes are independently covered. Retitling the default chat also dispatches SessionChatUpdated on the session channel - that is how a live header updates - so a session rename now replays one more action than the protocol contract expected. Co-authored-by: Copilot <[email protected]>
Dmitriy Vasyura (dmitrivMS)
approved these changes
Sep 22, 2026
…-after-session-rename
Sandeep Somavarapu (sandy081)
deleted the
sandy081/agents/fix-stale-default-chat-title-after-session-rename
branch
September 22, 2026 19:18
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

Fixes #336995
Fixes #326054
Renaming a session from the sessions list left the session header showing the old title. Worse, clicking into that header and pressing Enter renamed the default chat, which mirrors back onto the session and overwrote the rename — silent data loss.
Why it happened
A session whose only chat is its default chat has no independently titled chat: the header renders the session title. But the default chat still owns persisted title metadata, written whenever something renamed it directly — the
rename_chattool, the chat header, or an automatic title.A session-scoped rename (the sessions list path) updated only the session, so that chat metadata went stale. On restore it was seeded back as the chat's own title, making the divergence sticky: the list showed the new name, the header showed the old one, and committing the header handed the stale title back to the session.
This regressed in #331509 (commit 771cd9d), which removed the
isDefaultChat && _isOnlySessionChat(session)guard from_renameChatFromTool— after that, a single-chat session could get an independent title stamped onto its default chat.What changed
SessionTitleContribution._retitleSoleDefaultChatmirrors a session rename down onto the sole default chat, updating both live state (so the open header updates immediately) and persisted metadata (so it survives restore).Restoring the old guard alone would not have been sufficient: it only covers the
rename_chattool path, while the UI header rename flows throughonDidApplyClientAction. Handling it inonDidApplyClientActioncovers every session-channel rename — sessions list, tool, or header — and repairs sessions already broken on disk the next time they are renamed.Sessions that own peer chats are skipped: their default chat is independently titled by design.
Notes for reviewers
…SOURCEkey marking it user-set — written to both the chat's own database and the session's database keyed by chat.onHydrateChatreads them in that order on restore, so writing only one would leave the other as a stale fallback.state.defaultChat ?? buildDefaultChatUri(session)covers state wheredefaultChatis not yet populated.Validation
a session rename retitles the sole default chat in the live session and across restorecovers live state, persisted metadata, and restore._retitleSoleDefaultChatcall makes the new test fail with exactly the bug signature (defaultChatTitle: 'Agent title'instead of'User title').agentHost/test/node: 5678 passing, 0 failing.agentHostChatContribution: 439 passing, 0 failing.eslint,hygieneandtypecheck-clientall clean.