Skip to content

Fix undo/delete race condition; restructure README - #54

Merged
markadams31 merged 2 commits into
mainfrom
fix/undo-race-condition
Jul 4, 2026
Merged

Fix undo/delete race condition; restructure README#54
markadams31 merged 2 commits into
mainfrom
fix/undo-race-condition

Conversation

@markadams31

Copy link
Copy Markdown
Owner

Summary

Bug fix: the delete-with-undo toast kept its Undo button clickable all the way through the delete commit and success states. If a user clicked Undo after the countdown had already fired the real DELETE (or during the brief success-toast window), the row was restored in the client cache while it stayed permanently deleted in the database — a false "restored" state that the next background refetch would silently contradict.

Fix: undo() now no-ops once commit() has started, and the toast explicitly clears its action at that point (Sonner merges toast updates shallowly, so simply omitting action on the update wasn't enough — the old button persisted).

Docs: restructured README.md so the strongest technical decisions (zero-trust SQL-enforced authorization, the reflection layer's twice-run golden-snapshot tests, the OpenTelemetry silent-failure catch) surface in a new Highlights section right after the intro, instead of several hundred lines down. Added a one-line tech-stack callout. All existing technical content preserved, just reordered/tightened.

Test plan

  • Added a regression test in use-undoable-delete.test.ts reproducing the race with fake timers — asserts a stale Undo click after commit does not restore the row
  • Full frontend suite passes (105 tests)
  • Verified live in a browser against the dev database (local backend + dev-auth-proxy + Vite): reproduced the bug pre-fix (Undo button visible and clickable through the "Deleted" toast state), then confirmed post-fix the Undo button disappears the instant the countdown ends and stays gone through success
  • Confirmed the legitimate cancel-within-window path is unaffected: Undo during the 5s countdown still restores the row with zero server round-trip (no DELETE sent)
  • npm run lint and tsc clean; pre-commit/pre-push hooks passed

🤖 Generated with Claude Code

markadams31 and others added 2 commits July 5, 2026 09:09
…y committed

The Undo action stayed wired up through the entire delete commit and
success-toast lifecycle, so a click landing after the server DELETE had
already succeeded would restore the row in the client cache while it stayed
permanently deleted in the database — a false "restored" state contradicted
by the next background refetch.

Undo now no-ops once commit() starts, and the toast explicitly clears its
action at that point (Sonner merges toast updates shallowly, so omitting
`action` isn't enough — the previous button would otherwise persist).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Reorders sections so the strongest technical decisions (zero-trust SQL
authorization, the twice-run golden-snapshot integration tests, the
OpenTelemetry silent-failure catch) surface in a new Highlights section
right after the intro, rather than several hundred lines down. Adds a
one-line tech-stack callout for scanners. All existing technical content
is preserved, just reordered and tightened.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@markadams31
markadams31 merged commit d582387 into main Jul 4, 2026
20 checks passed
@markadams31
markadams31 deleted the fix/undo-race-condition branch July 4, 2026 23:15
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