Skip to content

sessions: fix observable tracking and stale chat validation in navigation#315638

Merged
sandy081 merged 2 commits into
mainfrom
sandy081/sessions-nav-chat-fixes
May 11, 2026
Merged

sessions: fix observable tracking and stale chat validation in navigation#315638
sandy081 merged 2 commits into
mainfrom
sandy081/sessions-nav-chat-fixes

Conversation

@sandy081
Copy link
Copy Markdown
Member

Follow-up to #315626 — addresses two review comments.

Fixes

1. Read all observables before _navigating guard

activeSession.status and activeChat.status were read after the _navigating early return. During navigation, the autorun would skip those reads and lose dependency tracking on status changes. Now sessionStatus and chatStatus are read upfront so the autorun keeps tracking status transitions (e.g. Untitled → Completed) even during navigation.

2. Validate chat still exists before opening

_navigateTo now checks that the chatResource still exists in session.chats before calling openChat(). If the chat was deleted after being recorded in history, it falls back to openSession() instead of trying to open a stale URI.

…hat 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>
Copilot AI review requested due to automatic review settings May 11, 2026 10:42
@sandy081 sandy081 added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label May 11, 2026
@sandy081 sandy081 enabled auto-merge (squash) May 11, 2026 10:42
@sandy081 sandy081 self-assigned this May 11, 2026
@sandy081 sandy081 added this to the 1.120.0 milestone 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

This PR is a follow-up to session chat navigation history work, addressing observable dependency tracking during back/forward navigation and preventing navigation to stale/deleted chats.

Changes:

  • Ensures activeSession.status and activeChat.status are read before the _navigating early return to keep autorun dependency tracking intact during navigation.
  • Adds validation that a chatResource still exists in session.chats before calling openChat(), otherwise falls back to openSession().
Show a summary per file
File Description
src/vs/sessions/services/sessions/browser/sessionNavigation.ts Fixes observable tracking during navigation and adds a stale-chat existence check before opening a chat from history.

Copilot's findings

  • Files reviewed: 1/1 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
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>
Copy link
Copy Markdown

@XavierMP14 XavierMP14 left a comment

Choose a reason for hiding this comment

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

X

@sandy081 sandy081 merged commit fb36cfa into main May 11, 2026
25 checks passed
@sandy081 sandy081 deleted the sandy081/sessions-nav-chat-fixes branch May 11, 2026 13:33
@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
sandy081 added a commit that referenced this pull request May 11, 2026
…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 added a commit that referenced this pull request May 11, 2026
#315632)

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

* sessions: fix observable tracking and stale chat validation in navigation (#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>

---------

Co-authored-by: vs-code-engineering[bot] <vs-code-engineering[bot]@users.noreply.github.com>
Co-authored-by: Sandeep Somavarapu <sasomava@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

4 participants