Skip to content

[cherry-pick] sessions: navigate between chats in back/forward history#315632

Merged
sandy081 merged 2 commits into
release/1.120from
cherry-pick/315626
May 11, 2026
Merged

[cherry-pick] sessions: navigate between chats in back/forward history#315632
sandy081 merged 2 commits into
release/1.120from
cherry-pick/315626

Conversation

@vs-code-engineering
Copy link
Copy Markdown
Contributor

Cherry-pick of #315626 from main.

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

Copilot AI review requested due to automatic review settings May 11, 2026 10:11
@vs-code-engineering vs-code-engineering Bot added the cherry-pick-artifact Auto-generated cherry-pick PR label May 11, 2026
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

…tion (#315638)

* sessions: read all observables before navigating guard and validate chat exists

- Read session.status and chat.status before the _navigating early return
  so the autorun keeps tracking status transitions during navigation
- Validate chat still exists in session.chats before calling openChat;
  fall back to openSession when the chat was deleted

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* sessions: add test for stale chat fallback in navigation

Verify that goBack falls back to openSession when the target chat was
deleted from the session after being recorded in history.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sandy081 sandy081 added this to the 1.120.0 milestone May 11, 2026
@sandy081 sandy081 enabled auto-merge (squash) May 11, 2026 14:16
@sandy081 sandy081 merged commit 801fd10 into release/1.120 May 11, 2026
25 of 26 checks passed
@sandy081 sandy081 deleted the cherry-pick/315626 branch May 11, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-artifact Auto-generated cherry-pick PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants