Skip to content

sessions: scope last-turn changes pill to the viewed chat#324788

Open
benibenj wants to merge 2 commits into
mainfrom
agents/chat-last-turn-changes-widget
Open

sessions: scope last-turn changes pill to the viewed chat#324788
benibenj wants to merge 2 commits into
mainfrom
agents/chat-last-turn-changes-widget

Conversation

@benibenj

@benibenj benibenj commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What

Moves the "last turn changes" concept from the session to the chat. The changes pill shown above the chat input now reflects the last-turn changes of the specific chat being viewed. In a session with multiple chats, each chat tracks its own last-turn changes.

Why

Previously lastTurnChanges lived on ISession and picked the session's "most recent chat", so the pill above one chat's input could reflect a different chat's turn. This scopes it correctly to the chat the user is looking at.

Changes

  • Model (session.ts): removed lastTurnChanges from ISession; added optional lastTurnChanges to IChat.
  • Agent host provider (agentHostSessionFiles.ts): replaced the session-level lastTurnChanges (which selected the most-recent chat) with a per-chat getLastTurnChanges(chatUri) lookup that reduces that chat's last-turn edits. Reuses the already-parsed per-chat edits; dropped the now-unused most-recent-chat selection.
  • Provider wiring (baseAgentHostSessionsProvider.ts): stores the session output and wires the main chat and each peer chat to their own last-turn changes.
  • Delegation cleanup (visibleSessions.ts): dropped the session-level lastTurnChanges getters.
  • Pill widget host (sessionChatInputToolbar.ts): now tracks an IChat, reads chat.lastTurnChanges, and gates visibility on the chat's status (InProgress). Still resolves the owning session for the agent-host provider gate and the open-changes action. setChat takes an IChat; setSession(session, chat) is the explicit fixture override.
  • ChatView (chatView.ts): passes the IChat into the toolbar.
  • Fixture (sessionChatInputToolbar.fixture.ts): mock now provides an IChat (status + lastTurnChanges) plus a session.

Notes for reviewers

  • Pill visibility now gates on the chat's status rather than the session's aggregate status.
  • The "Last Turn Changes" changeset (Changes-view filter) is a separate feature and was intentionally left untouched.
  • Validated with typecheck-client and ESLint on the changed files.

Move `lastTurnChanges` from the session concept to the chat concept so a session with multiple chats tracks last-turn changes per chat. The changes pill above the chat input now reflects the viewed chat's last-turn changes and gates on that chat's status.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 16:06
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@sandy081

Matched files:

  • src/vs/sessions/services/sessions/browser/visibleSessions.ts
  • src/vs/sessions/services/sessions/common/session.ts

@lszomoru

Matched files:

  • src/vs/sessions/services/sessions/browser/visibleSessions.ts
  • src/vs/sessions/services/sessions/common/session.ts

@benibenj benibenj enabled auto-merge (squash) July 7, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 scopes the "last turn changes" pill (shown above the chat input) from the session to the specific chat being viewed. Previously lastTurnChanges lived on ISession and always resolved the session's most recently modified chat, so the pill above one chat's input could reflect a different chat's turn. The concept is moved onto IChat, and the agent-host provider now derives per-chat last-turn changes keyed by each chat's URI.

Changes:

  • Moved lastTurnChanges from ISession to an optional property on IChat (session.ts), and removed the now-obsolete session-level delegation getters (visibleSessions.ts).
  • Replaced ISessionOutputObs.lastTurnChanges (most-recent-chat selection) with a per-chat getLastTurnChanges(chatUri) lookup (agentHostSessionFiles.ts), and wired the default chat (buildDefaultChatUri) and each peer chat (ChatSummary.resource) to their own observable (baseAgentHostSessionsProvider.ts).
  • Updated the pill widget (sessionChatInputToolbar.ts) to track an IChat, read chat.lastTurnChanges, and gate visibility on the chat's status; updated chatView.ts and the fixture accordingly.
Show a summary per file
File Description
src/vs/sessions/services/sessions/common/session.ts Moves lastTurnChanges from ISession to optional IChat property.
src/vs/sessions/services/sessions/browser/visibleSessions.ts Drops the now-removed session-level lastTurnChanges delegation getters.
src/vs/sessions/contrib/providers/agentHost/browser/agentHostSessionFiles.ts Replaces session-level observable with per-chat getLastTurnChanges(chatUri); drops most-recent-chat selection.
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts Stores session output and wires default/peer chats to their own last-turn changes.
src/vs/sessions/contrib/chat/browser/sessionChatInputToolbar.ts Tracks an IChat, reads chat.lastTurnChanges, gates on chat status; setChat/setSession take IChat.
src/vs/sessions/contrib/chat/browser/chatView.ts Passes the IChat into the toolbar instead of the chat resource URI.
src/vs/workbench/test/browser/componentFixtures/sessions/sessionChatInputToolbar.fixture.ts Mock now provides an IChat (status + lastTurnChanges) alongside the session.

Notes from verification: the peer-chat key (summary.resource) and default-chat key (buildDefaultChatUri(sessionUri)) both match the keys used in chatUrisObs/editsPerChatObs; _sessionOutput is assigned in the constructor before any _createAdditionalChat call; selectMostRecentChatUri remains used by the "Last Turn Changes" changeset; and no remaining references to session.lastTurnChanges exist.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Medium

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.

3 participants