Architecture fixes: mutation ownership, error surfacing, editor unification - #10
Merged
Conversation
The id state was only ever initialized from initialId via useState and never re-synced when initialId changed after mount. The fetch effect (keyed on [initialId]) refreshed title/code/savedCode/isPublic/shareId on an id change but never called setId(initialId), so handleSave's update branch could PUT edited content onto the wrong flowchart id if the hook instance were ever reused across an id transition (including transitioning to/from undefined on the new-flowchart page). Not reachable via any current navigation path, but a real latent bug flagged in Task 3 review.
…on pruning from save, remove dead service client
…e-in-depth consistency
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Addresses 8 findings from an architecture audit: silent mutation failures with no error UI, duplicated editor pages with divergent behavior, missing
per-request ownership checks on mutation routes, zero test coverage on mutation routes, no shared API client, unbounded list queries, version-pruning
coupled into save, and a dead
thumbnail_urlschema/type field.lib/api-client.ts) — replaces scattered rawfetchcalls with typed functions that reject with a commonApiError.components/ui/toast.tsx) — every mutation failure now surfaces to the user instead of failing silently.useFlowchartEditorhook — eliminates ~250 lines of duplicated state/handler logic and fixes a drift bug wherethe new-flowchart page was missing keyboard shortcuts. Includes a follow-up fix for a latent
id-resync bug (state could go stale across a same-pagenavigation).
PUT/PATCH/DELETE/share mutation routes — every route now explicitly scopes byuser_idinstead of relying on RLSalone.
createServiceClientand the never-read/writtenthumbnail_urlfield.