Skip to content

chat - prevent race conditions in loadSession#303244

Merged
bpasero merged 5 commits intomainfrom
ben/brief-fowl
Mar 19, 2026
Merged

chat - prevent race conditions in loadSession#303244
bpasero merged 5 commits intomainfrom
ben/brief-fowl

Conversation

@bpasero
Copy link
Member

@bpasero bpasero commented Mar 19, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 19, 2026 16:15
@bpasero bpasero enabled auto-merge (squash) March 19, 2026 16:16
@bpasero bpasero self-assigned this Mar 19, 2026
Copy link
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@bpasero bpasero requested a review from Copilot March 19, 2026 16:19
@bpasero bpasero added this to the 1.113.0 milestone Mar 19, 2026
roblourens
roblourens previously approved these changes Mar 19, 2026
joaomoreno
joaomoreno previously approved these changes Mar 19, 2026
Copy link
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 targets chat session stability by ensuring overlapping ChatViewPane.loadSession() calls don’t race, so that newer session loads take precedence over older in-flight loads.

Changes:

  • Introduces a per-ChatViewPane cancellation token source to cancel previous loadSession calls when a new one starts.
  • Passes the cancellation token through to chatService.acquireOrLoadSession(...) and adds cancellation checks to avoid showing/discarding the wrong model.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
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 aims to prevent race conditions in the Chat view pane’s loadSession flow by ensuring that newer session-load requests cancel older in-flight ones, reducing UI flicker and incorrect model application when switching sessions quickly.

Changes:

  • Introduce a per-view CancellationTokenSource to cancel prior loadSession() calls (“last call wins”).
  • Thread cancellation into chatService.acquireOrLoadSession(...) and gate delayed widget-clearing on the active token.
  • Avoid error recovery/logging when cancellation is the reason the load was interrupted.

lszomoru
lszomoru previously approved these changes Mar 19, 2026
Copy link
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 hardens the Chat view pane’s session switching logic by ensuring loadSession is cancellation-aware, preventing older/in-flight loads from overwriting newer user actions (a “last call wins” model). This fits into the workbench chat UI by improving reliability when restoring/opening sessions (especially slower contributed/cloud session types).

Changes:

  • Introduces a per-ChatViewPane cancellation token source to cancel in-flight loadSession calls.
  • Threads a CancellationToken through showModel and into acquireOrLoadSession, adding cancellation checkpoints and cleanup (dispose) when canceled.
  • Avoids clearing the widget for stale/canceled loads and suppresses error UI when cancellation is the cause.

@bpasero bpasero merged commit 5e3ed39 into main Mar 19, 2026
23 checks passed
@bpasero bpasero deleted the ben/brief-fowl branch March 19, 2026 17:58
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.

5 participants