Skip to content

sessions: navigate between chats in back/forward history#315626

Merged
sandy081 merged 1 commit into
mainfrom
sandy081/sessions-nav-chats
May 11, 2026
Merged

sessions: navigate between chats in back/forward history#315626
sandy081 merged 1 commit into
mainfrom
sandy081/sessions-nav-chats

Conversation

@sandy081
Copy link
Copy Markdown
Member

Summary

Extends the session back/forward navigation (#315382) to also track chat-level transitions within a session. Previously, switching between chats in a multi-chat session was not recorded in history.

Fixes #315623

Changes

sessionNavigation.ts

  • INavigationEntry now includes an optional chatResource: URI alongside sessionResource
  • Autorun observes activeSession.activeChat in addition to activeSession, reading both before the _navigating guard to keep subscriptions alive
  • Untitled chats (new-chat-in-session not yet submitted) are excluded from recording, consistent with untitled session handling
  • _navigateTo calls openChat(session, chatResource) when the entry has a chatResource, otherwise falls back to openSession()
  • _isSameEntry compares both sessionResource and chatResource
  • Updated trace logging to include chat resource

sessionNavigation.test.ts

  • Added stubChatWithId() helper for creating chat stubs with unique IDs
  • Updated stubSession() to accept optional chats parameter
  • Updated MockSessionStore with setActiveChat() and openChat() support, tracking lastOpenedChatResource
  • New tests:
    • Switching chats within a session is recorded in history
    • goBack restores previous chat within a session
    • Navigation across sessions and chats works together (cross-session + intra-session)
    • Untitled chats are not recorded with a chat resource

Track active chat changes within a session so that switching chats is
recorded in navigation history. Back/Forward now restores the specific
chat that was active at that point.

- Add optional chatResource to INavigationEntry
- Observe activeSession.activeChat in the autorun (reading before the
  _navigating guard to keep subscriptions alive)
- Skip untitled chats from recording (consistent with untitled sessions)
- _navigateTo calls openChat() when entry has a chatResource
- _isSameEntry compares both session and chat resources
- Add tests for intra-session chat navigation

Fixes #315623

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 11, 2026 09:52
@sandy081 sandy081 enabled auto-merge (squash) May 11, 2026 09:52
@sandy081 sandy081 added the release-cherry-pick Automated cherry-pick between release and main branches label May 11, 2026
@sandy081 sandy081 self-assigned this May 11, 2026
@sandy081 sandy081 added ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch and removed release-cherry-pick Automated cherry-pick between release and main branches labels May 11, 2026
@vs-code-engineering
Copy link
Copy Markdown
Contributor

This PR will be automatically cherry-picked to release/1.120 when merged.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends the Agents window’s SessionsNavigation history tracking so back/forward navigation restores not only the active session, but also the active chat within a multi-chat session (fixing #315623).

Changes:

  • Added optional chatResource to navigation entries and record history on activeSession.activeChat transitions (skipping untitled chats).
  • Updated navigation to open a specific chat via openChat(session, chatUri) when the history entry includes a chat resource.
  • Expanded sessionNavigation.test.ts with multi-chat stubs and new coverage for intra-session chat navigation.
Show a summary per file
File Description
src/vs/sessions/services/sessions/browser/sessionNavigation.ts Records chat-level navigation in history and restores chats on back/forward.
src/vs/sessions/services/sessions/test/browser/sessionNavigation.test.ts Adds test scaffolding and new tests covering chat-aware navigation history.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread src/vs/sessions/services/sessions/browser/sessionNavigation.ts
Comment thread src/vs/sessions/services/sessions/browser/sessionNavigation.ts
@sandy081 sandy081 merged commit f0b2653 into main May 11, 2026
29 checks passed
@sandy081 sandy081 deleted the sandy081/sessions-nav-chats branch May 11, 2026 10:09
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 11, 2026
@vs-code-engineering vs-code-engineering Bot added release-cherry-pick Automated cherry-pick between release and main branches and removed ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch labels May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-cherry-pick Automated cherry-pick between release and main branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sessions: Back/forward navigation should also navigate between chats within a session

3 participants