Skip to content

Fix ui deadlock#182

Merged
xinyi-gong merged 2 commits into
mainfrom
tori/fix-deadlock
May 13, 2026
Merged

Fix ui deadlock#182
xinyi-gong merged 2 commits into
mainfrom
tori/fix-deadlock

Conversation

@xinyi-gong
Copy link
Copy Markdown
Member

@xinyi-gong xinyi-gong commented May 13, 2026

fix #179

Problem

When a 402 quota error occurs during chat, the UI freezes permanently due to a deadlock between the main thread and the LSP listener thread.

Deadlock chain:

  1. LSP listener thread receives chat progress → calls processTurnEvent() → blocks in Display.syncExec() waiting for UI thread
  2. UI thread handles 402 → calls setFallBackModelAsActiveModel()persistUserPreference()persistence().get() blocks waiting for LSP response
  3. LSP listener thread is the only thread that reads server messages, but it's blocked in syncExec → the persistence response can never arrive
  4. Both threads wait on each other indefinitely → permanent UI freeze

Changes

ModelService.java

  • persistUserPreference() is now called asynchronously via CompletableFuture.runAsync() in setActiveModel(), breaking the deadlock chain by keeping the UI thread unblocked.

Copilot AI review requested due to automatic review settings May 13, 2026 03:18
Copy link
Copy Markdown

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 the chat UI deadlock that could permanently freeze Eclipse when a 402 quota error triggers model fallback handling, and adds guards to prevent an infinite 402 retry loop. It also improves turn rendering so model info isn’t duplicated and stays positioned correctly when warnings are added.

Changes:

  • Make model preference persistence asynchronous to avoid blocking the UI thread during fallback switching.
  • Prevent infinite 402 fallback retry loops by detecting when the fallback model is already active and adjusting messaging accordingly.
  • Ensure the model info footer in a Copilot turn is replaced (not duplicated) and remains below warning widgets.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/ModelService.java Persists model preference asynchronously to break the UI-thread ↔ LSP-listener deadlock chain.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ChatContentViewer.java Adds “already on fallback” guard to avoid infinite 402 retry/switch loops and conditionally replaces the 402 message.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/CopilotTurnWidget.java Prevents duplicate model info labels and forces footer ordering below warning widgets.

eclipse-proplus

This comment was marked as duplicate.

@xinyi-gong xinyi-gong changed the title Fix ui deadlock and infinite retry loop on 402 quota error Fix ui deadlock May 13, 2026
Copy link
Copy Markdown
Contributor

@ethanyhou ethanyhou left a comment

Choose a reason for hiding this comment

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

Verified and LGTM, thanks!

@xinyi-gong xinyi-gong merged commit 382e03e into main May 13, 2026
4 checks passed
@xinyi-gong xinyi-gong deleted the tori/fix-deadlock branch May 13, 2026 09:44
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.

UI freeze: deadlock between main thread and LSP listener on quota fallback

4 participants