fix(use-toast-mutation): show error toast when successMsg is null#2294
Merged
Conversation
The entire `toast.promise(...)` call — including the `error:` branch — was gated on `resolvedSuccessMsg !== null`, so any configured `errorMsg` became dead code when callers passed `successMsg: null`. This silently swallowed mutation errors in flows that legitimately suppress the success toast (e.g. routes that navigate away on success) but still want user-visible error feedback. Register `toast.promise` whenever a success message or an error message is configured, and only emit the `success:` key when applicable. The silent-mode escape hatch (`successMsg: null` with no `errorMsg`) is preserved. Fixes #2293 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes useToastMutation so callers can suppress success toasts while still showing configured error toasts, addressing the silent failure scenario from issue #2293.
Changes:
- Registers
toast.promisewhen either a success message or an error message is configured. - Omits the
successtoast config whensuccessMsgresolves tonull. - Adds regression tests covering error-only, silent, fallback, function-based error message, and
toastIdbehavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
renderer/src/common/hooks/use-toast-mutation.ts |
Updates toast registration logic to support error-only toast handling. |
renderer/src/common/hooks/__tests__/use-toast-mutation.test.tsx |
Adds tests for the hook’s success, error, silent-mode, fallback, and toastId behavior. |
reyortiz3
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2293.
useToastMutationwas silently swallowing mutation errors when callers passedsuccessMsg: null. The entiretoast.promise(...)call — including theerror:branch — was gated on a non-null success message, so any configurederrorMsgbecame dead code.This PR registers
toast.promisewhenever a success message or an error message is configured, and only emits thesuccess:key when applicable. The silent-mode escape hatch (successMsg: nullwith noerrorMsg) is preserved.Behavior matrix
successMsgerrorMsgnullnullFirst observed in ToolHive Studio Enterprise's signin page, where a backend-unreachable scenario produced zero UI feedback (related downstream: stacklok/stacklok-enterprise-platform#1300).
Test plan
renderer/src/common/hooks/__tests__/use-toast-mutation.test.tsxcovers:successMsgsetsuccessMsg: null+errorMsg(the bug scenario)errorMsgas a function receiving the errorsuccessMsg: null, noerrorMsg)error.detailwhen noerrorMsgtoastIdpass-throughpnpm run lintpnpm run type-check🤖 Generated with Claude Code