Skip to content

Fix chat history loading after provider cancellation - #341871

Closed
Harini (Harini410) wants to merge 2 commits into
microsoft:mainfrom
Harini410:fix/341828-chat-load-retry
Closed

Harini (Harini410) wants to merge 2 commits into
microsoft:mainfrom
Harini410:fix/341828-chat-load-retry

Conversation

@Harini410

@Harini410 Harini (Harini410) commented Oct 15, 2026 •

Copy link
Copy Markdown

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

  1. Unhandled Cancellation: Remote agent host initialization triggers provider replacement, cancelling in-
    flight loads with a CancellationError that left the chat permanently failed without retrying.
  2. 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.
  3. Draft Loss: Text entered into the composer while loading or during cancellation retries was wiped out when
    the model attached or failed.
  4. 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: () => {}.

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)

Copilot AI balanced review requested due to automatic review settings October 15, 2026 21:12
@vs-code-engineering

vs-code-engineering Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

Benjamin Christopher Simmonds (@benibenj)

Matched files:

  • src/vs/sessions/browser/parts/chatGroupView.ts
  • src/vs/sessions/browser/parts/chatGroupsView.ts
  • src/vs/sessions/browser/parts/sessionView.ts

Sandeep Somavarapu (@sandy081)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsService.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsService.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts

@Harini410

Copy link
Copy Markdown
Author

Harini (Harini (@Harini410)) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree

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.

🟡 Changes recommended

Automatic retries can erase typed input, and reselecting an already-active failed chat still does not trigger recovery.

2 open findings
What changed in this PR

Improves Agents Window chat-history recovery after provider cancellation, addressing #341828.

Changes:

  • Adds one automatic cancellation retry and allows failed loads to retry through setChat.
  • Separates surface-state updates from chat selection.
  • Adds cancellation and recovery regression tests.
File Description
src/​vs/​sessions/​contrib/​chat/​test/​browser/​chatView.test.ts Adds loading-recovery tests and supporting helpers.
src/​vs/​sessions/​contrib/​chat/​browser/​chatView.ts Adds cancellation and failed-load retry handling.
src/​vs/​sessions/​browser/​parts/​chatGroupView.ts Separates surface updates into their own autorun.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

🟡 Changes recommended

A test typing error and gaps in retry delivery, draft preservation, and host-visibility tracking remain unresolved.

5 open findings
1 resolved since last review

🧠 Review effort: Balanced

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.

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.

🔵 Needs a closer look

Sidebar chat-row reselection still bypasses retry dispatch for an already-active failed chat.

0 open findings

3 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Retry failed chat when reselected from sidebar

src/​vs/​sessions/​services/​sessions/​browser/​sessionsService.ts:1389

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.

🧠 Review effort: Balanced

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.

🟢 Approval recommended

No blocking issues remain, and focused regression coverage addresses cancellation, draft preservation, and reselection.

0 open findings

🧠 Review effort: Balanced

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.

🔵 Needs a closer look

No actionable defects were identified, but cross-layer cancellation and reselection behavior still need runtime validation with provider replacement.

0 open findings

🧠 Review effort: Balanced

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.

🟡 Changes recommended

Selecting a failed chat already displayed in an inactive split group still skips the retry dispatch.

1 open finding

🧠 Review effort: Balanced

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.

🟡 Changes recommended

Existing partial SessionView test doubles lack the newly invoked openSession method, breaking side-opening regression tests.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

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.

🟡 Changes recommended

Reactive surface updates still trigger chat selection, causing persistent load failures to retry indefinitely and clear the failure banner.

2 open findings

🧠 Review effort: Balanced

@Harini410

Copy link
Copy Markdown
Author

🟡 Changes recommended

Reactive surface updates still trigger chat selection, causing persistent load failures to retry indefinitely and clear the failure banner.

2 open findings

🧠 Review effort: Balanced

resolved

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.

🟡 Changes recommended

Ordinary grid reconciliation now triggers unintended retries in unselected failed chats.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

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.

🔵 Needs a closer look

No actionable defects remain identified, but remote-provider cancellation recovery across asynchronous service and UI lifecycles warrants human runtime validation.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

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.

🟢 Approval recommended

No blocking issues were identified, and focused regression coverage supports the recovery paths; reported tests were not rerun.

0 open findings

🧠 Review effort: Balanced

@Giuspepe

Copy link
Copy Markdown
Contributor

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.

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.

Remote agent host sessions often fail to open in Insiders 1.143 ("Couldn't load this conversation", and re-opening doesn't retry)

3 participants