Skip to content

Architecture fixes: mutation ownership, error surfacing, editor unification - #10

Merged
Emp1500 merged 9 commits into
mainfrom
worktree-architecture-fixes
Jul 16, 2026
Merged

Architecture fixes: mutation ownership, error surfacing, editor unification#10
Emp1500 merged 9 commits into
mainfrom
worktree-architecture-fixes

Conversation

@Emp1500

@Emp1500 Emp1500 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

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_url schema/type field.

  • Shared typed API client (lib/api-client.ts) — replaces scattered raw fetch calls with typed functions that reject with a common ApiError.
  • Toast notification system (components/ui/toast.tsx) — every mutation failure now surfaces to the user instead of failing silently.
  • Unified editor pages into a shared useFlowchartEditor hook — eliminates ~250 lines of duplicated state/handler logic and fixes a drift bug where
    the 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-page
    navigation).
  • Ownership hardening on PUT/PATCH/DELETE/share mutation routes — every route now explicitly scopes by user_id instead of relying on RLS
    alone.
  • Decoupled version pruning from save — a pruning failure now logs instead of turning a successful save into a 500.
  • Capped unbounded list queries at 100 rows (API route + dashboard page).
  • Removed dead code — unused createServiceClient and the never-read/written thumbnail_url field.

Emp1500 added 9 commits July 14, 2026 07:26
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
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
code2flow Ready Ready Preview, Comment Jul 16, 2026 8:32am

@Emp1500
Emp1500 merged commit ecb68e4 into main Jul 16, 2026
3 checks passed
@Emp1500
Emp1500 deleted the worktree-architecture-fixes branch July 16, 2026 08:43
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