mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
Edit mode is a session, not a URL state. MaybeEditMode mounts the shell on ?edit or on the session flag; while mounted, EditModeShell re-attaches ?edit after a route change that dropped it (replace navigation, skipped while authenticating so it never fights a failed auth). The session initializes once per mount - entry URL from a ref, stripEditQuery reads window.location - so navigation neither re-authenticates, re-fetches, nor re-restores the draft. ?edit parsing, the session/branch flags and the portfolio-draft key move to a dependency-free src/i18n/edit-session.ts so App.tsx can read the gate without pulling the Basic-auth probe (and through it draft.ts) into the entry chunk; edit-mode.ts is now the auth handshake alone. Verified: tsc -b, pnpm build (entry chunk carries no probe literal, EditModeShell stays a separate lazy chunk), pnpm lint (no new warnings), throwaway smokes for the session semantics (17/17) and the router behaviour behind the guard (5/5), both deleted after the run.