Skip to content

sessions: fix chat history picker not opening selected session#312158

Merged
roblourens merged 2 commits intomainfrom
roblou/agents/fix-chat-history-picker-issue
Apr 23, 2026
Merged

sessions: fix chat history picker not opening selected session#312158
roblourens merged 2 commits intomainfrom
roblou/agents/fix-chat-history-picker-issue

Conversation

@roblourens
Copy link
Copy Markdown
Member

In the Agents window, workbench.action.chat.history showed the session picker but selecting a session did nothing.

Cause

The default session opener (openSessionDefault in agentSessionsOpener.ts) calls IChatWidgetService.openSession(..., ChatViewPaneTarget), which opens ChatViewId. In the Agents window that view is registered with a when clause gated on IsNewChatSessionContext.negate() && IsNewChatInSessionContext.negate(), so when the user is on the new-chat view it stays hidden and nothing happens.

Fix

Register a SessionsOpenerParticipant in vs/sessions that intercepts session opens and routes them through ISessionsManagementService.openSession. That service updates the active session / context keys properly, so the chat view becomes visible and loads the picked session.

(Written by Copilot)

The chat history picker (workbench.action.chat.history) showed sessions but
clicking one didn't open it in the Agents window. The default session opener
calls IChatWidgetService.openSession with ChatViewPaneTarget, which opens the
ChatViewId view -- but in the Agents window that view is gated by a when
clause on IsNewChatSessionContext / IsNewChatInSessionContext, so it stayed
hidden.

Register a SessionsOpenerParticipant that routes opens through
ISessionsManagementService.openSession, which updates the active session/chat
context keys so the right view becomes visible and loads the session.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 16:02
The chat history picker now hides sessions in the Completed state so the
list focuses on sessions that are still active or need attention.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens roblourens enabled auto-merge (squash) April 23, 2026 16:11
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

Fixes session selection from workbench.action.chat.history in the Agents window by ensuring session opens flow through the sessions app’s management layer so the correct context keys are updated and the chat view becomes visible.

Changes:

  • Add a ISessionOpenerParticipant implementation in vs/sessions to reroute session opens via ISessionsManagementService.openSession.
  • Register the participant as a sessions workbench contribution at startup.
Show a summary per file
File Description
src/vs/sessions/contrib/chat/browser/sessionsOpenerParticipant.ts Adds a session opener participant that routes opens through ISessionsManagementService to update sessions-window state/context keys.
src/vs/sessions/contrib/chat/browser/chat.contribution.ts Registers the new participant contribution during startup.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/sessions/contrib/chat/browser/sessionsOpenerParticipant.ts:27

  • If sessionsManagementService.getSession(session.resource) returns undefined, this returns false and falls back to the default opener. In the Agents window the default opener is the path that can fail to show anything due to the ChatViewId when clause, so this leaves the original issue unaddressed for any sessions not represented in ISessionsManagementService (e.g., provider-filtered session types). Consider handling the “not found” case by still updating the sessions window context keys / routing, or by broadening ISessionsManagementService.openSession to support opening by resource even when not in the sessions list.
		const target = sessionsManagementService.getSession(session.resource);
		if (!target) {
			return false;
		}
  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment on lines +24 to +25
const target = sessionsManagementService.getSession(session.resource);
if (!target) {
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

target is assigned but never used. With noUnusedLocals enabled in this repo, this will fail TypeScript compilation. Either remove the variable and inline the check, or use the returned session object for something meaningful.

Suggested change
const target = sessionsManagementService.getSession(session.resource);
if (!target) {
if (!sessionsManagementService.getSession(session.resource)) {

Copilot uses AI. Check for mistakes.
if (!target) {
return false;
}

Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

When this participant handles the open, it bypasses openSessionDefault, which marks the IAgentSession as read (session.setRead(true)). Consider preserving that behavior here as well so sessions opened from the history picker don't remain unread.

This issue also appears on line 24 of the same file.

Suggested change
target.setRead(true);

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +31
class SessionsOpenerParticipant implements ISessionOpenerParticipant {

async handleOpenSession(accessor: ServicesAccessor, session: IAgentSession, openOptions?: ISessionOpenOptions): Promise<boolean> {
const sessionsManagementService = accessor.get(ISessionsManagementService);
const target = sessionsManagementService.getSession(session.resource);
if (!target) {
return false;
}

await sessionsManagementService.openSession(session.resource, { preserveFocus: openOptions?.editorOptions?.preserveFocus });
return true;
}
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

This change introduces new session-opening behavior specific to the Agents window, but there’s no unit test coverage. There are existing tests for other ISessionOpenerParticipant implementations (e.g. GrowthSessionOpenerParticipant), and src/vs/sessions/contrib/chat/test/browser already hosts lightweight tests. Consider adding a test that asserts this participant calls ISessionsManagementService.openSession(...) and returns true (and that it returns false when it should fall back).

Copilot uses AI. Check for mistakes.
@roblourens roblourens merged commit 5aaa5be into main Apr 23, 2026
26 checks passed
@roblourens roblourens deleted the roblou/agents/fix-chat-history-picker-issue branch April 23, 2026 16:29
@vs-code-engineering vs-code-engineering Bot added this to the 1.118.0 milestone Apr 23, 2026
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