You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix chat history loading after provider cancellation - #341871
Fixes an issue where remote agent host sessions fail to open or retry when extension startup or provider
replacement cancels the in-flight chat load, and prevents infinite retry loops when rendering load failure
banners.
Root Cause
Unhandled Cancellation: Remote agent host initialization triggers provider replacement, cancelling in-
flight loads with a CancellationError that left the chat permanently failed without retrying.
Autorun Feedback Loop: ChatGroupView previously executed view.setChat() in an autorun that also observed
reactive surface and historyStatus changes. When a load failed, updating the failure banner re-ran the autorun,
causing an infinite retry loop.
Draft Loss: Text entered into the composer while loading or during cancellation retries was wiped out when
the model attached or failed.
Reselection Inaction: Reselecting an already-focused failed chat returned early because the view already
held the resource, preventing manual recovery without switching away first.
Changes
• chatView.ts:
• Added bounded automatic retry (at most 1 retry) for in-flight loads cancelled by provider replacement
(isCancellationError).
• Preserved drafts across loading, retries, late provider registrations, and manual retries via
_inputBeforeLoad.
• Allowed same-chat reselection to retry unbound, failed chats instead of returning early.
• chatGroupView.ts:
• Decoupled view.setChat() selection from reactive surface and historyStatus updates into separate
autoruns to prevent retry feedback loops.
• Exposed reopenActiveChat() for clean manual and same-chat retry dispatching.
• chatGroupsView.ts & sessionView.ts:
• Forwarded same-session and same-chat reselection down to reopenActiveChat().
• Preserved hostVisible when reopening an already-open session.
• sessionsService.ts:
• Forwarded openSession() to SessionView on active session reselection to support single-click recovery of
both active chats and chats in inactive split groups.
• sessionsManagementService.test.ts:
• Updated partial SessionView test doubles to implement openSession: () => {}.
Harini (Harini (@Harini410)) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Reselecting an already-active failed chat from a sidebar chat row still does not retry. Those rows call SessionsService.openChat (sessionsView.ts:331), which uses _openChat, not _showSession. When the session and chat are already active and preserveFocus is unchanged, the visibility updates are no-ops, so the mounted view never receives setChat. Also forward the explicit _openChat request to the mounted view after selecting the target chat, and add a regression test through the public openChat API.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
No actionable defects remain identified, but remote-provider cancellation recovery across asynchronous service and UI lifecycles warrants human runtime validation.
Thanks for digging into this and putting together a fix! I went with #342062 because it keeps the original history request alive across provider replacements, instead of retrying from the view. That lets us handle concurrent callers and cancellation in the shared loader. We also added coverage for preserving drafts through repeated replacements.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #341828
Summary
Fixes an issue where remote agent host sessions fail to open or retry when extension startup or provider
replacement cancels the in-flight chat load, and prevents infinite retry loops when rendering load failure
banners.
Root Cause
flight loads with a CancellationError that left the chat permanently failed without retrying.
reactive surface and historyStatus changes. When a load failed, updating the failure banner re-ran the autorun,
causing an infinite retry loop.
the model attached or failed.
held the resource, preventing manual recovery without switching away first.
Changes
• chatView.ts:
• Added bounded automatic retry (at most 1 retry) for in-flight loads cancelled by provider replacement
(isCancellationError).
• Preserved drafts across loading, retries, late provider registrations, and manual retries via
_inputBeforeLoad.
• Allowed same-chat reselection to retry unbound, failed chats instead of returning early.
• chatGroupView.ts:
• Decoupled view.setChat() selection from reactive surface and historyStatus updates into separate
autoruns to prevent retry feedback loops.
• Exposed reopenActiveChat() for clean manual and same-chat retry dispatching.
• chatGroupsView.ts & sessionView.ts:
• Forwarded same-session and same-chat reselection down to reopenActiveChat().
• Preserved hostVisible when reopening an already-open session.
• sessionsService.ts:
• Forwarded openSession() to SessionView on active session reselection to support single-click recovery of
both active chats and chats in inactive split groups.
• sessionsManagementService.test.ts:
• Updated partial SessionView test doubles to implement openSession: () => {}.
Testing
Verified against current pushed commit 93d48ee:
• Unit & Integration Tests:
• .\scripts\test.bat --run src/vs/sessions/contrib/chat/test/browser/chatView.test.ts: 121 passing
• .\scripts\test.bat --run src/vs/sessions/test/browser/chatGroupsView.test.ts: 115 passing
• .\scripts\test.bat --run src/vs/sessions/test/browser/sessionView.test.ts: 17 passing
• .\scripts\test.bat --run src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.
ts: 277 passing (2 pending)
• ESLint: Clean (0 errors, 0 warnings across all 9 modified files)
• git diff --check: Clean (0 errors)
• TypeScript Transpilation: Clean (10,283 client source files compiled without error)