Skip to content

feat(frontend): implement optimistic state rollback on network failur… - #1683

Merged
emdevelopa merged 1 commit into
emdevelopa:mainfrom
Thosine-01:feature/fe-implement-optimistic-state-rollback-on-network-failure-in-webhook-logs-table
Oct 24, 2026
Merged

emdevelopa merged 1 commit into
emdevelopa:mainfrom
Thosine-01:feature/fe-implement-optimistic-state-rollback-on-network-failure-in-webhook-logs-table

Conversation

@Thosine-01

@Thosine-01 Thosine-01 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #1514

Adds optimistic updates with full rollback to bulk retry in the Webhook Logs table. Rows show a "Retrying…" state as soon as the user clicks. If the request fails, the table goes back exactly to its previous state and the user gets clear feedback and a way to try again.

What changed

Optimistic update

  • Selected rows immediately show a Retrying… badge, are dimmed, and set aria-busy
  • Their checkboxes are cleared and locked so the same logs can't be submitted twice while a request is in flight

Rollback on failure (network error or non-2xx response)

  • Each row's retry state and the user's selection are restored from a snapshot taken before the request
  • Affected rows get a red highlight and a Retry not queued badge for 4s
  • An inline role="alert" banner explains what happened and offers Try again, which re-sends the same logs, and Dismiss
  • A network failure (TypeError from fetch) shows a clear "Network error" message. Other failures show the server's error message.

Partial success

  • Rows listed in the backend's queued_log_ids change to Retry queued and stay locked until the next refresh
  • Rows the server skipped are rolled back individually and highlighted

Accessibility

  • A visually hidden aria-live="polite" region announces when a retry starts, succeeds or fails
  • The spinner uses motion-safe:animate-spin, so it doesn't spin for users with reduced motion enabled
  • The banner's buttons are keyboard accessible and have visible focus rings

Responsive

  • The alert's actions stack full width on mobile and sit inline from sm: up

Files

  • frontend/src/components/WebhookLogs.tsx: optimistic state, rollback logic, alert UI, live region
  • frontend/src/components/WebhookLogs.test.tsx: 6 new tests. The react-hot-toast mock is now callable, because the "logs skipped" path calls toast() directly.

Testing

npx vitest run src/components/WebhookLogs.test.tsx: 10/10 passing. Type check and lint are clean.

New test coverage:

  • Pending state while the request is in flight, then the queued state on success
  • Network failure rolls back row state and restores the selection
  • A non-2xx response rolls back and shows the server's error message
  • Partial success rolls back only the skipped rows
  • Try again re-sends the rolled-back logs and clears the alert
  • The alert can be dismissed

Manual testing

To reproduce a network failure: load /webhook-logs, select a failed delivery, stop the backend, then click Retry Selected.

  • Desktop: Chrome / Firefox / Safari
  • Mobile viewport (375px)
  • Lighthouse / axe accessibility audit

Screenshots

State Desktop Mobile
Retrying… (optimistic)
Rolled back + alert
Retry queued

🤖 Generated with Claude Code

…e in Webhook Logs Table

- Optimistically mark selected rows as "Retrying…" when a bulk retry is sent
- On network failure or non-2xx response, restore the exact prior row state
  and selection, highlight affected rows, and show an inline alert with
  "Try again" / "Dismiss" actions
- Roll back individual rows the server skipped; keep queued rows locked
- Announce progress and failures via an aria-live status region
- Add tests covering pending, network/server failure, partial skip and retry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@Thosine-01 is attempting to deploy a commit to the Emmanuel's projects Team on Vercel.

A member of the Team first needs to authorize it.

@emdevelopa
emdevelopa merged commit 62c41e9 into emdevelopa:main Oct 24, 2026
1 of 5 checks passed
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.

[Frontend] Implement optimistic state rollback on network failure in Webhook Logs Table

2 participants