From 1bc12d23a651a7934b9130008473cc978f7e0d58 Mon Sep 17 00:00:00 2001 From: "dong.nguyen" Date: Sat, 24 Oct 2026 13:37:32 +0700 Subject: [PATCH] feat(edit): pick a project's category in the record settings category had no edit control anywhere: the settings popover covered featured + sections only, the badge is display-only, and a new project silently got category 'experiment' from the draft template. ProjectSettingsPanel now renders a category select whose options are the label map of ui/projects.json (the vocabulary rule 7 checks a project against) with the project's current value appended, so opening the panel never rewrites a project whose label is missing; the write goes through setStructured('projects', '[i].category', ...), the path smoke-draft check 11 already gates. ui.edit.label added to both languages. .record-settings-field select joins the field-control rule in App.css, which also styles the timeline variant select that had none. Out of scope by design: a category with no labels - UI documents stay read-only in v4, so its labels are a repository edit. Docs: inline-editing spec 2.4 + component inventory + progress rows 10 (the add-button fix) and 11; spec-v5 5.4 links the picker to rule 7; AGENTS.md editable-surface bullet corrected (category is a single structure value, not a chip list). Verified: pnpm build, pnpm validate:content, pnpm lint (5 pre-existing warnings only), smoke-draft 11/11. --- AGENTS.md | 2 +- .../design/specs/v4/spec-v4-inline-editing.md | 6 +++-- .../specs/v5/spec-v5-generated-content-ids.md | 2 ++ src/App.css | 3 ++- src/components/ui/RecordSettings.tsx | 25 +++++++++++++++++-- src/i18n/locales/en/ui/edit.json | 1 + src/i18n/locales/vi/ui/edit.json | 1 + 7 files changed, 34 insertions(+), 6 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 5c8cef2..2f297ef 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -93,7 +93,7 @@ Content is split once, at authoring time, into language-neutral **structure docu - `src/i18n/draft.ts` — `DraftStore`: baselines (`data` + blob `sha`) of the 12 writable documents (4 structure + 8 text), copy-on-write draft, leaf-path diff, cross-document validation on every accepted edit, three-way rebase on save conflicts (Gitea 28 reports a blob-sha mismatch as 422 with a "does not match" message; older deployments answered 412 — both are handled; origin / base / working kept separate), draft persisted to sessionStorage `portfolio-draft`, sequential-PUT save (one commit per touched document, resume from the first unwritten one on failure). Edit mode writes JSON only: the id-union leg was deleted when spec-v5 made the unions generated, and the store is handed the branch's category labels (read-only `ui/projects.json` fetches) for rule 7 — `null` when they cannot be read, in which case the rule is skipped and the EditBar says so - `src/components/ui/EditableText.tsx` — the site's own element (`as` = the tag or motion component it renders today) becomes the inline editor only in edit mode; commit on blur only (Vietnamese IME-safe), Esc cancels, Enter commits single-line fields, paste is plain-text, empty required values are rejected at commit; without an `EditContext` provider it renders byte-identical markup to the plain element - `src/components/layout/EditBar.tsx` — fixed save bar: per-path diff with revert and "appears on" page annotations (computed from the page manifests via `manifestsClaiming`, never from component code), conflict resolution (rebase / take-theirs / per-field keep-mine–keep-theirs), per-document save status, partial-save resume, exit confirm -- Editable surface: content text inline (pencil-triggered, click never edits) **and** structure — chip-level tag editors (technologies, categories, interests, roles, keywords, tagline emphasis), ghost add/delete/move on every record surface, per-record settings popover (`featured`, project section list + type picker, `variant`, location, logo), ids auto-generated from title slugs, social links handle-only with URLs derived in the loaders. Implemented 2026-10-23 (`spec-v4-inline-editing.md` + `spec-v4-data-organization.md`); the JSON panel is deleted. UI documents stay read-only in v4. Field provenance: hovering any pencil shows `document → pointer` (`describeField()` names the per-entity file automatically); the EditBar diff line and a `validate:content` error for the same field read identically +- Editable surface: content text inline (pencil-triggered, click never edits) **and** structure — chip-level tag editors for every tag array (`technologies`, `metrics`, `skills`, `interests`, `roles`, `keywords`, `responsibilities`, quote details, tagline segments), ghost add/delete/move on every record surface, per-record settings popover (`featured`, the project `category` picker, project section list + type picker, `variant`, location, logo), ids auto-generated from title slugs, social links handle-only with URLs derived in the loaders. Implemented 2026-10-23 (`spec-v4-inline-editing.md` + `spec-v4-data-organization.md`); the JSON panel is deleted. UI documents stay read-only in v4. `category` is a single structure value, not a chip list: the picker offers exactly the label map of `ui/projects.json` — the vocabulary rule 7 checks a project against — so a category with no label in both languages cannot be chosen from the UI; a brand-new category means adding its labels in the repository first. Field provenance: hovering any pencil shows `document → pointer` (`describeField()` names the per-entity file automatically); the EditBar diff line and a `validate:content` error for the same field read identically - Dev parity: `vite.config.ts` builds the `/api/content/` dev proxy from the same `GITEA_CONTENTS_API` value production nginx renders — run `pnpm dev` with `GITEA_TOKEN` + `GITEA_CONTENTS_API` set (local `.env`); without them edit mode falls to the offline state (bundled content, save disabled) - Spec: `docs/design/specs/v4/spec-v4-live-edit.md` §5–§6 diff --git a/docs/design/specs/v4/spec-v4-inline-editing.md b/docs/design/specs/v4/spec-v4-inline-editing.md index 01709e1..5b7ed23 100644 --- a/docs/design/specs/v4/spec-v4-inline-editing.md +++ b/docs/design/specs/v4/spec-v4-inline-editing.md @@ -37,7 +37,7 @@ Each chip is an edit unit: pencil per chip (inline text edit), `×` on hover to ### 2.4 Record settings popover (E2) Gear icon on cards/entries opens a small popover anchored to the record: -- project card: `featured` toggle, sections list (type picker, move, delete — add lives inline at §2.3); +- project card: `featured` toggle, `category` select (added 2026-10-24: the options are the label map of `ui/projects.json`, i.e. the vocabulary rule 7 checks a project against — a category with no label in both languages cannot be chosen, and a brand-new one needs its labels added in the repository first, since UI documents stay read-only in v4), sections list (type picker, move, delete — add lives inline at §2.3); - timeline entry: `variant` select (none / current / gap), `logo` path text input; - nothing else needs a popover — every other field has an inline home. @@ -75,7 +75,7 @@ Page manifests (`spec-v4-data-organization.md` §5) are **read-only in the app** |---|---|---| | Upgrade | `EditableText.tsx` | wrapper zone + pencil trigger (icon-only editing), inline error display, provenance tooltip + chip (E7) | | New | `TagListEditor.tsx` | per-chip edit/delete/move + ghost add; emphasis toggle for tagline | -| New | `RecordSettings.tsx` | popover form: featured, variant, logo, section list | +| New | `RecordSettings.tsx` | popover form: featured, variant, logo, section list — plus the project `category` select (follow-up 11) | | New | `AddRecord.tsx` | ghost affordance + template trigger + (sections) type picker | | New | move controls | ↑/↓ buttons shared by `TagListEditor` and record cards | | Delete | `JsonPanel.tsx` | removed outright — no fallback drawer, no advanced mode | @@ -116,3 +116,5 @@ Page manifests (`spec-v4-data-organization.md` §5) are **read-only in the app** | 8 | Remove `JsonPanel` + panel labels | ✅ Done 2026-10-23 — `JsonPanel.tsx` deleted (already orphaned by the inline wiring; no imports remained); panel labels removed from both UI documents: `openPanel`, `closePanel`, `handMerge`, the whole `edit.panel.*` namespace | | 9 | Docs superseded notes | ✅ Done 2026-10-23 — superseded notes at live-edit §5.1 (panel shape) and §12 row 14; AGENTS.md "Live Edit Mode" + "Component Structure" rewritten for the inline surface | | — | Acceptance §6 | 🟡 Partial — `pnpm build`, `pnpm validate:content`, `pnpm lint` (no new warnings), `pnpm tsx scripts/smoke-draft.ts`, `pnpm build:resume-all` pass 2026-10-23; browser verification of the edit surfaces pending (user verifies in a real browser) | +| 10 | Fix (owner-reported 2026-10-24): clicking "add technology" on a project card opened the project instead of adding a tag | ✅ Done 2026-10-24 (automated) — root cause: the card body IS a link (`MotionLink` at `Projects.tsx:49`, `ProjectsListPage.tsx:39`), and the add chip was the one edit control inside it without a guard. The chips themselves are safe because they render through `EditableText`, whose edit-mode `onClick` does `preventDefault + stopPropagation` (`EditableText.tsx:239-242`) — that is why ↑/↓/🗑 worked — and the pencil suppresses its own mousedown. `TagListEditor`'s add button now carries both guards (`TagListEditor.tsx:126-138`): mousedown stopped, then `preventDefault + stopPropagation` on click before `write([...items, s.edit.newTag])`. Covers the technologies *and* the metrics add on both card surfaces; the same control in `Hero.tsx` (tagline), `Expertise.tsx`, `AboutPage`, `ExperiencePage`, `PhilosophyPage`, `ProjectDetailPage` and the settings popovers sits outside any anchor and is untouched. Verified: `pnpm build` ✓, `pnpm lint` (only the five pre-existing warnings). ⬜ Browser: `?edit` → add a technology on a card → a new chip appears, no navigation | +| 11 | Fix (owner-reported 2026-10-24): a project's `category` had no edit control at all — the settings popover covered `featured` + sections only, the badge is display-only, and a new project silently gets `category: 'experiment'` (`draft.ts:546`) | ✅ Done 2026-10-24 (automated) — `ProjectSettingsPanel` now renders a `category` ` edit.setStructured('projects', `[${index}].category`, event.target.value)} + > + {categoryIds.map((id) => ( + + ))} + + +
{s.edit.sections}