Skip to content

fix: decouple snackbar display from caller so busy state always resets#314

Merged
fioan89 merged 3 commits into
mainfrom
fix-error-reporting-while-handling-uri
Jun 4, 2026
Merged

fix: decouple snackbar display from caller so busy state always resets#314
fioan89 merged 3 commits into
mainfrom
fix-error-reporting-while-handling-uri

Conversation

@fioan89
Copy link
Copy Markdown
Collaborator

@fioan89 fioan89 commented Jun 3, 2026

logAndShowError/Warning/Info were suspend functions that called
ui.showSnackbar directly on the caller's coroutine. Toolbox keeps that
coroutine suspended for the entire lifetime of the snackbar and cancels
it (rather than resuming) when the snackbar is dismissed. As a result,
dismissing a snackbar cancelled the calling coroutine and skipped any
code meant to run after the error was shown - most visibly leaving
coderHeaderPage.isBusy stuck at true after a failed URI handling.

Introduce a fire-and-forget CoderToolboxContext.showSnackbar that
launches the snackbar on the plugin scope, swallowing the expected
CancellationException on dismissal. The logAndShow* helpers become
regular (non-suspend) functions delegating to it, so callers continue
immediately and their cleanup always runs.

Also harden the busy-state handling in CoderRemoteProvider.handleUri and
deferredLinkHandler with try/finally so isBusy is reset on every path,
and drop the fragile onConnect.andThen { isBusy = false } chaining.
ErrorReporter now reuses context.showSnackbar instead of its own launch.

 logAndShowError/Warning/Info were suspend functions that called
 ui.showSnackbar directly on the caller's coroutine. Toolbox keeps that
 coroutine suspended for the entire lifetime of the snackbar and cancels
 it (rather than resuming) when the snackbar is dismissed. As a result,
 dismissing a snackbar cancelled the calling coroutine and skipped any
 code meant to run after the error was shown - most visibly leaving
 coderHeaderPage.isBusy stuck at true after a failed URI handling.

 Introduce a fire-and-forget CoderToolboxContext.showSnackbar that
 launches the snackbar on the plugin scope, swallowing the expected
 CancellationException on dismissal. The logAndShow* helpers become
 regular (non-suspend) functions delegating to it, so callers continue
 immediately and their cleanup always runs.

 Also harden the busy-state handling in CoderRemoteProvider.handleUri and
 deferredLinkHandler with try/finally so isBusy is reset on every path,
 and drop the fragile onConnect.andThen { isBusy = false } chaining.
 ErrorReporter now reuses context.showSnackbar instead of its own launch.
}
linkHandler.handle(params, newUrl, this.client!!, this.cli!!)
} finally {
coderHeaderPage.isBusy.update { false }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nbd at all but I think these changes make the coderHeaderPage.isBusy.update { false } in the parent catch unnecessary

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point. Thx. Fixed

@fioan89 fioan89 merged commit 8783eb8 into main Jun 4, 2026
6 checks passed
@fioan89 fioan89 deleted the fix-error-reporting-while-handling-uri branch June 4, 2026 19:35
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.

2 participants