Skip to content

fix(cli): don't block the UI thread on catalog refresh#850

Open
nickprotop wants to merge 2 commits into
managedcode:mainfrom
nickprotop:fix/refresh-catalog-no-ui-block
Open

fix(cli): don't block the UI thread on catalog refresh#850
nickprotop wants to merge 2 commits into
managedcode:mainfrom
nickprotop:fix/refresh-catalog-no-ui-block

Conversation

@nickprotop
Copy link
Copy Markdown
Contributor

The interactive command center's RefreshCatalogFromUi — wired to Ctrl+R, the refresh button, and the command palette — blocked the UI thread on the async catalog fetch:

LoadCatalogsAsync(refreshCatalog: true).GetAwaiter().GetResult();

This freezes the render loop and all input for the full duration of the network fetch, so the whole TUI locks up while the catalog refreshes.

Fix

Run the refresh off the UI thread and marshal results back:

  • Task.Run + ConfigureAwait(false) for the fetch.
  • The completion toast + Session.RaiseSnapshotChanged() + RebuildStatusBar(...) are marshalled onto the UI thread via EnqueueOnUIThread.
  • The initial "Refreshing…" toast still fires synchronously (the handler is already on the UI thread).

No public surface change; the method stays a void callable as an Action from every existing call site.

Builds clean (0 Error(s)).

RefreshCatalogFromUi (Ctrl+R, refresh button, command palette) blocked the
UI thread with LoadCatalogsAsync(...).GetAwaiter().GetResult(). That freezes
the render loop for the duration of the network fetch, and hard-deadlocks if
a UI SynchronizationContext is installed (the awaited continuation is posted
back to the blocked UI thread).

Run the refresh off-thread with Task.Run + ConfigureAwait(false), then
marshal the result toast and rebuilds back onto the UI thread via
EnqueueOnUIThread.
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.

1 participant