Skip to content

fix(platform): raise one toast per failed write and guard the rule - #3806

Merged
yannickmonney merged 19 commits into
mainfrom
fix/one-failure-one-toast
Sep 29, 2026
Merged

yannickmonney merged 19 commits into
mainfrom
fix/one-failure-one-toast

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #3763 / #3795, which set the rule "one failure → one toast". A failed useBackendMutation / useBackendAction raises its own destructive toast unless the call passes errorToast: false, and a caller that reported the same failure again showed two (or, for retried queries, up to three). On main the new guard finds 183 such write-to-caller pairs.

What changed

Shared surfaces (packages/ui)

  • useFormEditor's submit (Enter in a field, a type="submit" Save) only logged a server failure, so the write's own toast was its only report. It now raises the same single toast EditorActions raises on the button path, through a shared toastSaveFailure. Without this, opting the editors' writes out would have left the Enter path silent.
  • BulkArchiveBar and EntityDeleteDialog take a describeFailure, as BulkDeleteBar already did, so their one toast keeps the refusal's words once the row's write stays quiet.
  • services/ui-docs settings-page pattern: submit reports a server failure, and the persistence call's own toast stays quiet.

Platform

  • Every caller reports the failure → the hook passes errorToast: false, with a comment naming who reports. This covers conversations, contacts/products imports, knowledge entries, websites, documents and folders, the upload writes, projects, governance, data residency, enterprise SSO, notifications, WebDAV, sandboxes, the connector and provider credential writes (whose header comments already claimed this), and tasks.
  • Mixed callers → the hook forwards the option, and only the reporting call sites pass it:
    • useUpsertGovernancePolicy (19 call sites);
    • useUpdateTask and useCancelTaskAgentRun (the board card, list row and status move keep the default);
    • useRemoveMember (the bulk bar opts out; the single remove dialog keeps the default);
    • useSaveImage (the upload field opts out; the logo's derived favicon keeps the default).
  • Where a caller's toast only said "Something went wrong", the caller leaves the report to the write instead: the task comment thread, request-changes, the watch toggle, the assignee hand-off, and the task modal's assignee picker, whose failure useAssignTask's toast already names.
  • A caller's fallback toast that became the only report now says why (failureDetail). A refusal it already names by code keeps its house sentence.
  • The bulk bars and delete dialogs of contacts, products, knowledge entries, websites, members, projects and API keys pass describeFailure (firstFailureDetail, now shared with the teams table).
  • Cloud picker listings: the brief assumed the import dialogs render the listing error inline, but they don't; they only use it to hand a lapsed grant to the connect dialog. So the listing writes stay quiet (a query retries them twice, which used to mean one toast per attempt), and the dialog raises one toast for the query's final error through useListingFailureToast, skipping the lapsed-grant hand-off. A listing answered with success: false used to raise no toast at all; it now raises that one.
  • The uploads panel's createOrAdopt no longer shows a failure toast for a folder it adopts.
  • Comments corrected: the members table's "single batch toast" (each failed row toasted), useProposeDsarPolicy ("its editor toasts", while it didn't opt out), and the provider/connector hooks' header comments (now true).

Guard: services/platform/tests/guards/single-failure-toast.guard.test.ts parses services/platform/app with the TypeScript compiler.

  • It indexes every write that toasts on failure: direct calls, hooks (resolving option-forwarding hooks by their call-site argument), hooks returning a function that rethrows one, and adapter-object hooks (mutations: { useUpdate }).
  • It follows each invocation's rejection through awaits, returns, rethrowing catches, local functions and their callers.
  • It fails on a second report: a catch, .catch or onError toast, a batch summary toast that reads the recorded failures, EditorActions / useFormEditor for a rejected save, the bulk bars, EntityDeleteDialog, EnvVarListEditor, or a query's queryFn.
  • Each report names the write and the caller. It has a counted allowlist with a stale-entry check, and sample tests for every shape it catches or allows. .agents/repo.md states the rule.

Coordination with other PRs

How I verified

  • Guard: on today's main (a6f7d09) it finds 183 pairs, 178 unexempted, so it fails. The 183 are the 182 of before feat(platform): let admins reserve organization-wide skill sharing #3801 plus feat(platform): let admins reserve organization-wide skill sharing #3801's new editor. On this branch it finds 5, all allowlisted against fix(platform): make Inbox assignment, selection and activity reliable #3784, and all 30 of its tests pass. Before the rebase, the list on d7f1ee080 matched the brief's pairs area by area, plus two it lacked (conversation-assignee-picker's onError beside useAssignConversation / useAssignConversationTeam).

  • New tests, each red on the old code and green now:

    • use-form-editor.test.tsx (submit: one toast, never a payload, quiet on validation, cancel and mapped field errors);
    • data-table-bulk-actions.test.tsx and entity-delete-dialog.test.tsx (describeFailure);
    • account-form.name.test.tsx (one toast on Enter).

    Also new: use-listing-failure-toast.test.ts, adapters.test.ts (firstFailureDetail), and updated toast expectations in the account, create-folder and team-tags tests.

  • Locally, all passing. On the pre-rebase base (d7f1ee080):

    • vitest.ui.config.ts on the 167 test files importing a changed module (1,571 tests);
    • the server-project suites;
    • packages/ui editor, data-table and entity suites (157 tests);
    • the 17 affected browser suites (117 tests);
    • the connectors, credentials and providers suites.

    After the rebases (onto feat(platform): show who created and last edited a skill #3786, then feat(platform): let admins reserve organization-wide skill sharing #3801): the guard suites, the skills suites and the new skill-sharing editor's suite. CI runs the rest on the rebased tree.

  • oxlint --type-aware --type-check is clean on every changed file.

  • A companion audit that follows the quiet writes finds no new path where a failure reaches neither a toast, an inline error nor a summary. It reports the same 14 candidate paths as base main, all pre-existing and outside this change.

  • Real browser, on a local stack (Postgres, backend and Vite; the backend is the same for both runs, since this PR changes no backend code). A Playwright script refuses one write per flow with a 409 {error, message}, and a MutationObserver records every toast the app inserts:

    Flow main (62f8204) this branch
    Governance editor, header Save "Save — Couldn't save password policy" same
    Same editor, Enter in the field "Couldn't finish that action — Try again." (the write's generic toast) "Save — Couldn't save password policy"
    Project create dialog "Couldn't create project" "Couldn't create project — Refused by the smoke test"
    Projects bulk archive, 2 refused rows "Couldn't archive some items" "Couldn't archive some items — Refused by the smoke test"

    The toaster shows one toast at a time (TOAST_LIMIT = 1), and React batches toasts raised in the same tick. So on main the write's default toast was usually replaced before it painted, and the person saw the caller's toast without the reason the default toast had carried. The double still shows wherever the two toasts land in separate ticks: a query's retries, rows settling at different times. On main, one run also caught an unrelated "Tale is ready to work offline." PWA toast.

Left open

A save through `useFormEditor`'s `submit` (Enter in a field, a
`type="submit"` Save) only logged a server failure: the write's own
toast was its only report, so a write that stays quiet left the failure
silent. `submit` now raises the one toast `EditorActions` raises on the
button path, through a shared `toastSaveFailure`.

`BulkArchiveBar` and `EntityDeleteDialog` take a `describeFailure`, as
`BulkDeleteBar` does, so their one failure toast can carry the refusal's
words once the row's own write stays quiet.
`firstFailureDetail` reads a batch surface's refusals the way the teams
table's local helper did: the first refusal's words, through
`failureDetail`. The bulk bars of the other tables pass it too once their
rows' writes stay quiet.
Closing, reopening, spam, delete, assignment, the outbound-message undo,
retry and discard, and the improve-message action each raised the write's
default toast beside the header's, the panel's, the picker's or the
editor's own. Those writes keep their toast quiet now, and the callers'
toasts say why. The connector send stays quiet at the hook: the editor
and the bulk send's summary toast report it.
A knowledge entry's or a website's create, edit or delete, and a contact
or product import, raised the write's default toast beside the dialog's,
the delete dialog's or the bulk bar's own. Those writes keep their toast
quiet now. The delete dialogs and bulk bars of contacts, products,
knowledge entries, websites and API keys pass `describeFailure`, so their
one toast names the refusal.
A folder create, a retried index, a stopped sync, a folder's teams, a
cloud disconnect, an automation settings save and the upload writes of
the uploads panel, the chat and task attachments raised the write's
default toast beside the caller's own toast or batch summary. Those
writes keep their toast quiet now, and the callers' toasts say why; a
folder the uploads panel adopts because it already exists no longer
toasts a failure at all.

The cloud pickers' listings run their write as a query that retries it
twice, so one failed folder raised up to three toasts, and a listing the
backend answered with `success: false` raised none. Their writes stay
quiet, and the import dialog raises one toast for the query's final
error (`useListingFailureToast`), leaving a lapsed grant to the connect
dialog.
Every project write raised its default toast beside the dialog's, the
tab's, the row menu's, the Save cluster's or the bulk archive bar's own
report of the same failure. The project hooks and the files tab's upload
and re-index writes keep their toast quiet now. A caller's fallback toast
says why, a refusal it knows by code keeps its house sentence, and the
projects table's bulk archive names the first refusal.
`useUpsertGovernancePolicy` already took `errorToast`, but 19 of its 22
callers left it on while reporting the failure themselves: a toggle's or
a section's own toast, or the Save cluster for the editors whose `save`
rethrows. They pass `errorToast: false` now. The DSAR proposal (whose
comment already said its editor toasts), the retention save, the
moderation key, the bounds proposal, the legal-hold and data-subject
request dialogs, the trash restore and the pending-retention cancel keep
their toast quiet at the hook for the same reason.
The profile name, branding, data-residency and enterprise SSO saves
raised the write's toast beside the Save cluster's, and their removals,
tests, imports and tokens, the notification toggles, member adds, WebDAV
app passwords, sandbox controls and the SSO app reuse beside the page's
own toast. Those writes keep their toast quiet now, and the pages' toasts
say why. The connector and provider credential writes opt out as the
header comments of their hooks already claimed: the dialogs show a
refusal inline, the row menu in its own toast.

Where some callers only log, the hook takes the option instead: the
members table's bulk remove and the image upload field pass
`errorToast: false`, while the single remove dialog and the logo's
derived favicon keep the default toast. The members table's comment
promised one batch toast while each failed row raised its own.
The task modal, the subject panel, the dependency, label, archive and
delete dialogs, the agent-run controls and the attachment uploads each
toasted a failure the write had already toasted. Those writes keep their
toast quiet now, and the callers' fallback toasts say why.

Where a caller only said "Something went wrong", it leaves the report to
the write instead: the comment thread, the request-changes box, the watch
toggle and the assignee hand-off, and the modal's assignee picker, whose
failure `useAssignTask`'s toast already names (a live run holding the
task). `useUpdateTask` and `useCancelTaskAgentRun` take the option, since
the board card, the list row and a status move still rely on the
default toast.
The skill detail pane's save and delete and the upload pane toasted a
failure the write had already toasted: the save's publish-refusal
feedback, the delete's default toast, and one from each of the bundle
upload's three hops. `useSaveSkill` takes `errorToast: false`, spread
after its refusal feedback so the opt-out wins while a refused audience
still refreshes the listing; the detail pane passes it and names the
refusal in its own toast. The delete and the upload hops keep their toast
quiet, and the delete toast says why. The skills hook test now pins the
upload hop's opt-out.
A failed `useBackendMutation` / `useBackendAction` raises its own
destructive toast unless the call passes `errorToast: false`, and 182
callers on main reported the same failure again: their catch, `.catch`
or `onError` toast, a batch summary toast, `EditorActions` for a
rejected editor `save`, the bulk bars or `EntityDeleteDialog` for a
rejected callback, or a query retrying the write.

The guard parses every app source file with the TypeScript compiler,
indexes each write that toasts on failure (a direct call, a hook
returning one, resolving option-forwarding hooks by their call-site
argument, a hook returning a function that rethrows one, and a hook an
adapter object names), and follows each invocation's rejection through
awaits, returns, rethrowing catches, local functions and their callers
to the place that reports it. It fails on a second toast, naming the
write and the caller. Five pairs stay allowlisted with #3784, which
fixes its bulk verbs; the entries turn stale when it lands.
`.agents/repo.md` states the rule.
@yannickmonney
yannickmonney force-pushed the fix/one-failure-one-toast branch from 2113f35 to 0627d95 Compare September 29, 2026 05:31
The header, the panel and the assignee picker reported a refused close,
reopen, spam mark, delete, undo, retry, discard or assignment only from
`mutate(args, { onError })`, with the write's own toast quiet. React
Query drops that callback once another `mutate` starts on the same hook,
or once the caller unmounts before the write settles: Retry on two
failed messages with the first refused, or a second pick in the picker,
said nothing.

Each of these writes now raises its own failure toast, under the verb's
title with the refusal's words, which fires for every call; the callers
drop their own.
A write that opts out of its own toast was reported by the caller's
`mutate(args, { onError })` alone in the knowledge-entry, product and
website dialogs, the document and folder deletes, the OAuth app reuse
and remove, and the voice-output and routing-rule saves. React Query
drops that callback once another `mutate` starts on the same hook or the
caller unmounts first, so a quick second toggle, or a dialog closed
while it saved, left the refusal unreported (and a refused routing rule
unreverted).

Each now reads the outcome from its call's own promise,
`mutateAsync(args).then(onSuccess, onError)`, which always settles.
A cloud listing the provider answered `success: false` threw a plain
Error carrying `result.error`, which the backend builds from the
provider's raw response (`OneDrive API error: 403 {…}`). The listing
toast read it as a sentence meant for display, so a Graph or Drive
refusal put its English body under the localized "Couldn't load items".

The listings now throw a `CloudListingError`: its message keeps the raw
answer for the log and the lapsed-grant check, and the toast carries its
title alone. A refusal the door answered still says why.
The Microsoft 365 picker handed a lapsed grant to the connect dialog only
when the files or the SharePoint sites listing saw it. One that first
showed on the drives or the SharePoint files listing was skipped by the
listing toast and never handed off, so the picker said nothing.

The dialog test runs the real listings, their retries and the adapter
rows: a failed listing raises one toast after three attempts (the title
alone for a `success: false` answer, the words of a refusal), and a
lapsed grant, on the drives listing too, opens the connect dialog with
no toast.
A failed cancel on a task's agent run said "The agent run could not
start" (`agentRun.notStarted`). That toast is the failure's one report,
so it now reads `agentRun.cancelFailed` in en, de and fr, with the
refusal's words beneath.
The single-failure-toast guard counted a `mutate` call-site `onError` as
the caller's report, so it could not see a quiet write whose only report
React Query drops once another call starts or the caller unmounts. It
now fails on a quiet write reported only from `mutate`'s `onError`, and
on a `BulkDeleteBar`, `BulkArchiveBar` or `EntityDeleteDialog` handed no
`describeFailure`: removing one used to fail no test. A hand-written
controller declared an `EditorController` counts as an editor even
without `reset`, and the sample table holds one.

The member table's bulk remove proves the wiring end to end: two refused
rows raise one toast naming the first refusal's words.
The rule named the bulk bars, the delete dialog and `EditorActions` as a
caller's report, but the guard also follows `EnvVarListEditor` and a
write run as a query's `queryFn`. It now names both, a hand-written
`EditorController`, and says a write that opts out is reported from its
call's own promise or keeps its own toast, never from `mutate`'s
`onError` alone.
SET-B22 judges a save refused on Enter in one toast with its reason, and
KNOW-B16 a failed cloud listing in one localized toast, never one per
retry nor the provider's own answer: the toaster shows one toast at a
time, so a second one taking the first's place is judged by hand.
automation.md names the specs that own the rest, and the guard.
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