Skip to content

fix: session rename no longer requires reload (#318442) - #318667

Open
Yashwanth Reddy Katipally (katipally) wants to merge 10 commits into
microsoft:mainfrom
katipally:main
Open

Yashwanth Reddy Katipally (katipally) wants to merge 10 commits into
microsoft:mainfrom
katipally:main

Conversation

@katipally

Copy link
Copy Markdown

Fixes #318442

Problem

Renaming a session in the Agents window required a window reload for the new name to appear. Two separate bugs caused this:

Bug A — UI not updating (history sessions)
LocalAgentsSessionsController.refresh() only detected new session items (checking !this._items.has(resource)). When a history session was renamed, the resource URI was already in _items, so addedOrUpdated stayed empty and _onDidChangeChatSessionItems never fired — the sidebar stayed stale.

Bug B — Title not persisted
renameChat() in localChatSessionsProvider.ts called chatService.setSessionTitle() (synchronous, in-memory only) instead of chatService.setChatSessionTitle() (async, writes to _chatSessionStore). On reload the old title came back because nothing was written to disk.

Solution

  • Fix A (detection): Change refresh() to use existing.isEqual(item) so updated items (changed label, status, etc.) are included in addedOrUpdated.
  • Fix A (notification): Add onDidChangeChatSessionTitle event to IChatService. Fire it from setChatSessionTitle() for history sessions only (live sessions already propagate via model.onDidChange → autorun). Subscribe the controller to this event so it calls refresh() immediately.
  • Fix B: Change renameChat() to await chatService.setChatSessionTitle() so the title is persisted to the session store.
  • Interface fix: Correct IChatService.setChatSessionTitle return type from void to Promise<void> to match the implementation.

Files changed

File Change
chatService.ts Added onDidChangeChatSessionTitle event; fixed return type
chatServiceImpl.ts Added emitter; fires event after persisting title for history sessions
localAgentSessionsController.ts Fixed refresh() update detection; added event listener
localChatSessionsProvider.ts Bug B fix — use setChatSessionTitle instead of setSessionTitle
mockChatService.ts Updated mock to match new interface
copilotChatSessionsProvider.test.ts Updated inline stubs to async

Two bugs caused renaming a session to not persist without a reload:

Bug A — history sessions: The controller's refresh() only tracked newly
added items, not updated ones. When a history session was renamed, the
new items matched the same resource URIs, so addedOrUpdated stayed empty
and _onDidChangeChatSessionItems never fired. Fixed by comparing with
isEqual() to detect changed labels.

Added onDidChangeChatSessionTitle event to IChatService so the controller
can react to title changes for history sessions (which have no live model).
The event fires from setChatSessionTitle() only for history sessions; live
sessions are already handled by the model.onDidChange → autorun path.

Bug B — persistence: renameChat() in localChatSessionsProvider called
setSessionTitle() (sync, in-memory only) instead of setChatSessionTitle()
(async, writes to _chatSessionStore). On reload the old title would return
because nothing was actually written to disk. Fixed by awaiting
setChatSessionTitle() instead.

Also corrected the IChatService interface: setChatSessionTitle() was
declared void but implemented as async Promise<void>.
Copilot AI review requested due to automatic review settings May 28, 2026 02:35
@katipally

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

The test mock was missing setChatSessionTitle (async) which was
added to IChatService and called by renameChat(). This caused a
'not a function' TypeError across all CI platforms.

This branch has not been deployed

No deployments
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.

Renaming a session requires reload

2 participants