mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-23 00:20:40 +07:00
fix(edit): probe a file that is not a draft document
The auth probe fetched src/data/profile.json, which every page manifest claims (the footer renders profile.name on every route), so the probe and the page's own document read hit the identical URL twice per session. PROBE_FILE is now AGENTS.md — a stable tracked file outside the draft scope. Spec row 27 records the fix and why nginx caching was rejected.
This commit is contained in:
1 parent
fcf8768d1a
commit
3fafbefe24
2 files changed
+8
-1
No files matched your search
@@ -611,3 +611,4 @@ Deferred (not v4):
|
||||
| 24 | Edit mode survives navigation (owner request 2026-10-24): "if in edit mode, keep the mode when clicking any link; only Exit returns to normal mode" | 3 | ✅ Done 2026-10-24 (automated) — `src/i18n/edit-session.ts` (new, dependency-free): `?edit` parsing, the session flag, the branch flag and rules moved out of `edit-mode.ts`, which is now the Basic-auth handshake alone; `App.tsx` `MaybeEditMode` gates on `editRequested(search) \|\| hasEditFlag()`; `EditModeShell` re-attaches `edit` after a route change that dropped it (replace-navigation, skipped while authenticating so a failed auth is never fought) and its initialization no longer depends on `location.search` (entry URL from a ref, `stripEditQuery` reads `window.location`), so a navigation neither re-authenticates nor re-fetches nor re-restores the draft. `EditBar.tsx` imports `DEFAULT_BRANCH` from the new module. Verified: `tsc -b`, `pnpm build` (entry chunk carries no `probe` literal → the auth handshake stays lazy; `EditModeShell` is still a separate 10.5 kB chunk; the draft module's presence in the entry chunk is pre-existing, via `Hero → EditableText → draft`), `pnpm lint` (no new warnings), throwaway session-semantics smoke 17/17 — gate on query/flag, branch tri-state incl. `?edit=` and an illegal name, flag+branch cleared on exit, cached-credential auth across the new module boundary — deleted after the run. ⬜ Browser: `?edit` → click through Home/About/Experience/Projects/Contact/Philosophy → EditBar and the draft stay; reload reopens the session; Exit → clean URL, visitor site |
|
||||
| 25 | Edit-mode initialization is one concurrent request wave (owner report 2026-10-24: opening edit mode fetched every document one after another) | 3 | ✅ Done 2026-10-24 (automated) — `EditModeShell.tsx` §5.1 initialization: the 12 draft documents and the 2 label files are issued as two concurrent `Promise.all` requests whose success/failure handlers are attached in the same tick they are created, so a label rejection landing while the documents are still in flight is not an unhandled rejection; the failure split is unchanged (a document failure is the offline state, a label failure only disables rule 7). Measured through the dev proxy, same transport as the app: 12 documents sequential 902 ms → 210 ms for the whole 14-request wave, 38 768 bytes and 12 distinct payloads byte-identical to the sequential loop. Verified: `tsc -b` 0, `pnpm lint` no new warnings, `pnpm build` OK, `smoke-draft.ts` 11/11, throwaway wave probe 6/6 (same bytes as the loop, both failure branches, both-success path, no unhandled rejection) — probe deleted. Paired infra half: `spec-v4-deploy-infra.md` D14 / row 10 — `/api/content/` now proxies to Gitea over HTTP/2, so the wave multiplexes over one pooled upstream connection instead of one HTTP/1.1 connection per in-flight request. ⬜ Browser: edit-mode load on the deployed site |
|
||||
| 26 | Edit mode reads only what the current page needs (owner report 2026-10-24: `/philosophy?edit` fetched all 14 documents while the page renders profile text alone) | 3 | ✅ Done 2026-10-24 (automated) — `src/i18n/edit-scope.ts` (new): `manifestForPath` + `scopeForPath` derive the needed documents from the page manifests — a claim names a joined record, an entity owns its structure document plus its two text documents, and those are always read as one unit (a half-loaded entity would make the validator compare a live document against a bundled one); the label documents follow the projects scope. `EditModeShell`: the entry fetch is the entry route's scope plus anything a restored draft touched; an effect on `location.pathname` reads only the documents still missing and adopts them through `DraftStore.adoptBase`, which refuses a document the draft has already changed. `saveDraft` never PUTs a bundle-seeded baseline (an empty sha is a create for Gitea 28): it reads the branch first and reports a conflict, or a failure when that read fails. Every manifest now claims `profile.name` — the footer renders it on every route — which also makes the EditBar "appears on" annotation for that field truthful. Verified: `tsc -b`, `pnpm build` (EditModeShell stays a separate lazy chunk), `pnpm lint` (no new warnings), `pnpm validate:content`, `scripts/smoke-draft.ts` 13/13 (new checks 12–13: `adoptBase` replaces an untouched baseline and refuses a touched one; a bundle-seeded document is never written). Throwaway scope probe over all 7 routes + an unknown path + trailing-slash forms (deleted after the run): `/` 12 documents, `/about` 6, `/experience` 6, `/projects` and `/projects/:id` 6 + labels, `/contact` 3, `/philosophy` 3, unknown route 0. ⬜ Browser: `/philosophy?edit` → 3 document GETs; navigating to `/projects` brings the project documents; an edit made before they land goes through the conflict flow instead of overwriting the branch |
|
||||
| 27 | Auth probe no longer re-fetches a draft document (owner report 2026-10-25: `/philosophy?edit` loaded `src/data/profile.json?ref=master` twice — the auth probe and the page's own document read hit the identical URL) | 3 | ✅ Done 2026-10-25 (automated) — `edit-mode.ts`: `PROBE_FILE` switched from `src/data/profile.json` to `AGENTS.md`. Every page manifest claims `profile` (the footer renders `profile.name` on every route), so the probe file was inside every route's read scope and the duplicate existed on all seven routes; the scope machinery (`liveDocsRef`) was correct — the collision was probe-vs-document, not a double scope read. nginx cache was considered and rejected: a cached re-read after a PUT would serve the pre-save body+sha into the conflict flow (`draft.ts` `resetBase`), and purge-on-write needs a module the official image lacks. Verified: `git ls-files` confirms `AGENTS.md` tracked; Gitea Contents API answers `AGENTS.md?ref=master` → 200 with the same `Authorization: token` header nginx sends; `pnpm build` (tsc + bundle) and `pnpm lint` clean — no new warnings. ⬜ Browser: `/philosophy?edit` Network panel shows `profile.json?ref=master` exactly once — owner verifies |
|
||||
@@ -6,7 +6,13 @@
|
||||
import { PROXY_BASE } from './draft';
|
||||
import { hasEditFlag } from './edit-session';
|
||||
|
||||
const PROBE_FILE = 'src/data/profile.json';
|
||||
// The probe must not be a draft document: every page manifest claims `profile`
|
||||
// (the footer renders `profile.name` on every route), so probing
|
||||
// `src/data/profile.json` made the auth check and the page's own document read
|
||||
// fetch the identical URL twice per session (owner report 2026-10-25). AGENTS.md
|
||||
// is a stable, tracked file on every branch, and the proxy passes any repository
|
||||
// path through unchanged.
|
||||
const PROBE_FILE = 'AGENTS.md';
|
||||
|
||||
function probeUrl(branch: string, cacheBust: boolean): string {
|
||||
const url = new URL(`${PROXY_BASE}${PROBE_FILE}`, window.location.origin);
|
||||
|
||||
Reference in new issue
Block a user