Mapa level-up spec, revision 1: Contexto with Página's rail, and a WYSIWYG page over Markdown
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Human
Prompt
Phase 0 of the Mapa level-up (Paul, 2026-11-14: "Let's do it Contexto, with Página's rail."): write docs/superpowers/specs/2026-11-14-mapa-level-up.md covering the chosen design, per-screen changes, the editor architecture and Markdown fidelity plan, the gates and the phasing; note departures from the mock-ups and the base spec; then stop for review.
From this commit's own message. The prompt ledger has no entries for it — which is what a squashed, rebased or amended commit looks like, and what every commit looks like in a repo without a ledger.
Summary
Adds the level-up spec: I2 header, sidebar with Página's rail, Links panel with map, day navigation, history panel, Cmd-K (phase 1); a ProseMirror editor over Mapa's own Markdown subset with block-source re-emission and gates L1-L12 (phase 2); departures D1-D11 and four questions for Paul.
Agent notes
No code changed. Key design calls for the reviewer: JS port of markup/blocks.go+spans.go instead of prosemirror-markdown; untouched = same PM node object + same context (WeakMap); reparse-on-edit; GET /p/{id}/rebase; pagehide commit=1 (D3).
1 file changed,
+603
−0
docs/superpowers/specs/2026-11-14-mapa-level-up.md+603 −0
CI passed — run details
CI log
=== vet === go vet ./... go vet -tags browser ./internal/mapatest/ === fmt === === code === go tool rastrillo budget code The base has no .rastrillo/code.txt: skipping the check that records only go down. budget code: within the limits. === test === CGO_ENABLED=0 go test ./... ? amadan.net/oficina/mapa/cmd/mapa [no test files] ok amadan.net/oficina/mapa/internal/mapa (cached) ? amadan.net/oficina/mapa/internal/mapa/icons [no test files] ok amadan.net/oficina/mapa/internal/mapa/markup (cached) ok amadan.net/oficina/mapa/internal/mapa/seal (cached) ok amadan.net/oficina/mapa/internal/mapatest 8.212s ? amadan.net/oficina/mapa/scripts/mutate [no test files] ? amadan.net/oficina/mapa/scripts/preview [no test files] === migration-check === go tool rastrillo migration check rastrillo migration check: models and migrations agree
diff --git a/docs/superpowers/specs/2026-11-14-mapa-level-up.md b/docs/superpowers/specs/2026-11-14-mapa-level-up.md| new file mode 100644 |
| index 0000000..954ce13 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-11-14-mapa-level-up.md |
| @@ -0,0 +1,603 @@ |
| +# Mapa level-up: Contexto with Página's rail, and a page you write on |
| + |
| +**Status:** revision 1, 2026-11-14, for review. Nothing is built. |
| +**Branch:** `design/level-up` (Mapa). Later, an estilo branch for the floating panel (§9). |
| +**Base spec:** `2026-11-12-mapa-design.md`, approved. It still binds. This spec changes the surface (base §6) and the editor. It changes no trust property. §10 lists every place it departs from the base spec or the mock-ups. |
| +**Mock-ups:** `oficina/polish-audit/mapa-ux/` (`c.html`, `a.html`, `README.md`, `shots/`). They are the reference for look and measurement. They move things with script and fake their data; the build renders everything on the server. |
| + |
| +## 1. Why |
| + |
| +Paul, 2026-11-14, after using the slice 1 preview: *"it needs some serious levelling up. It should have WYSIWYG. Let's not copy Notion outright, but the page should be full-screen, the sidebar icons should line up etc. etc. It needs a serious UX pass."* |
| + |
| +He was shown three directions (Página, Estante, Contexto) and ruled: **"Let's do it Contexto, with Página's rail."** He accepted the small map that comes with Contexto. |
| + |
| +## 2. What was chosen |
| + |
| +- **Header:** Docs' and Slides' I2 stacked header (estilo `Bar.Menubar` and `Bar.Lead`, from `39792ae`): Mapa's mark, the title with rename in place, and the Page, Edit, Insert, View and Help menus. |
| +- **Sidebar:** Today, Search ⌘K, All pages, Scratch, then Pinned and Recent, and "New team page" at the foot. Every row is one grid: a 16px icon column and a label, centred on one axis. ⌘\ folds it to Página's 56px icon rail, and back. |
| +- **The page is the window:** full-width white, a 42rem measure, a large title, and WYSIWYG writing. There is no form, no label and no Save button. Autosave goes through the existing drafts (base §5). |
| +- **Links panel:** Docs' floating glass inspector, toggled from the header. It holds "Around this page" (the map), Linked from (with each sentence), Mentioned without a link (with Link it) and Links out. On a daily note it is the week. |
| +- **Day navigation:** ‹ Today › and a month calendar. |
| +- **History:** a side panel. Choosing a version shows its diff, with Restore. |
| +- **⌘K:** one box over titles, aliases, text and dates. |
| +- **Phone:** the Links panel becomes a sheet with a peek line. |
| + |
| +The work comes in two phases. **Phase 1** builds the chrome around today's editor. **Phase 2** replaces the textarea with a ProseMirror editor that stores Markdown (§6). |
| + |
| +## 3. The shell |
| + |
| +### 3.1 Header |
| + |
| +- **estilo's stacked `Bar`**, exactly as Docs uses it: |
| + - `Bar.Menubar` holds Page, Edit, Insert, View and Help (§3.4). |
| + - `Bar.Lead` holds presence ("Ana is editing", team pages only, base §5), then estilo's `savestatus`, then the day pill on daily notes (§4.4). |
| + - The actions are Search ⌘K, History and Links. Links is a `WideOnly` toggle action with `aria-expanded` and `aria-controls`, like Docs' Format. |
| + - The account comes last, after estilo's divider. |
| +- **Mark and hue:** Mapa's own mark at hue 125, from estilo `f724edb`. The Oficina fallback in `render.go`'s `themeSlug` goes, and so does the AGENTS.md follow-up about it. |
| +- **Title row:** |
| + - A team page's title is estilo's sized title field, renamed in place. It posts the existing `POST /p/{id}/rename`, so the old title becomes an alias (base §3.4). |
| + - A daily note shows its long date ("Saturday 14 November") as plain text. A scratch page shows its first line as plain text. Neither has a title in the namespace (base §3.3), so neither can be renamed. |
| +- **Below 800px:** estilo's second row, untouched (estilo review #34). |
| + |
| +### 3.2 Sidebar and rail |
| + |
| +- **Rows:** |
| + - Places: Today, Search ⌘K, All pages, Scratch. |
| + - **Pinned:** the viewer's pins (§10, D1). |
| + - **Recent:** the six pages the viewer last committed a revision to, team pages and their own (§10, D2). |
| + - At the foot: **New team page**. |
| +- **Alignment:** each row is `display: grid; grid-template-columns: 16px 1fr; align-items: center`. Today's misalignment comes from rastrillo's `[rst-shell-nav] a`: it is not a flex row, so the icon sits on the text's baseline about 3px high. Mapa stops using `rst-shell-sidebar`. The estilo bar sits on top, and Mapa's own `[mapa-side]` sits below it. The rastrillo bug is reported upstream, because Fichas still has it. |
| +- **The rail:** |
| + - 56px wide, with the same rows drawn as icons only, each a 40×38px target. |
| + - Labels stay in the accessibility tree, visually hidden, and show as a tooltip on hover and focus. |
| + - The current place has a 3px accent bar at the inline start. Pinned and Recent are hidden in the rail. |
| + - A fold button sits at the rail's foot. |
| +- **Folding:** |
| + - ⌘\ (Ctrl+\ elsewhere) folds the sidebar to the rail and opens it again. So do View → Sidebar and the fold button. |
| + - The state is the cookie `mapa-sidebar`, set to `open` or `rail`. The server renders it, so first paint is already right. |
| + - With no cookie, CSS decides: open from 80rem, the rail below that. |
| + - Without script, the fold button is a form that sets the cookie and redirects back. It is a view preference: it writes no row and logs no event. |
| + |
| +### 3.3 Breakpoints |
| + |
| +These follow estilo's breakpoints (I2 revision 2, P1.3). |
| + |
| +| Width | Sidebar | Links | Day pill | |
| +|---|---|---|---| |
| +| 64rem and wider | open or rail (cookie) | floating panel, toggled (cookie `mapa-links`, open by default) | lead slot | |
| +| 800px to 64rem | rail by default; the cookie may open it | at the page's foot; the toggle is hidden (`WideOnly`) | lead slot | |
| +| Below 800px | none; its places are rows in estilo's Menu sheet | a bottom sheet with a peek line | the page's kicker line | |
| + |
| +When the panel is off, at any width, the same lists render at the page's foot. Nothing about the page is ever out of reach. |
| + |
| +### 3.4 Menus |
| + |
| +The menus are estilo's `menubar`, with keyboard shortcuts shown. An entry that does not apply is not drawn; it is never shown disabled with no reason. |
| + |
| +- **Page:** |
| + - New team page, New scratch page. |
| + - Rename (team), Pin / Unpin. |
| + - Make team page (private notes). |
| + - Link to this block (team). |
| + - History, Delete…, Deleted pages. |
| +- **Edit:** Undo, Redo, Select all. |
| +- **Insert:** the `/` menu's blocks (§6.6), with their Markdown shortcuts shown. |
| +- **View:** |
| + - Sidebar ⌘\. |
| + - Links. |
| + - Edit as Markdown: the scriptless textarea, kept as the floor (§6.10). |
| +- **Help:** Keyboard shortcuts, "Markdown in Mapa" (the subset), and Colophon (with ProseMirror once Phase 2 ships). |
| + |
| +## 4. The screens |
| + |
| +### 4.1 A page |
| + |
| +- **Kicker line**, muted and above the title. It is one of: |
| + - "Team page · Edited by Ana at 11:40 · Also called Brightwater"; |
| + - "Your note. Only you can open it."; |
| + - "Scratch. Only you can open it." |
| +- **Title:** an H1 at 2.5rem, or 1.875rem on a phone. |
| + - A team page's in-page title edits through the same rename POST as the header. One pending state covers both, so nobody renames twice (mock-up risk 9). |
| + - After a rename, "Update links to the new title" becomes a notice on the page with its own POST. Its count follows base §3.4 and is unchanged. |
| +- **Body:** |
| + - The rendered Markdown in Phase 1. The editor in Phase 2. |
| + - An empty body shows a placeholder: "Write, or type / for blocks and [[ to link". It is drawn by CSS on the server's own empty paragraph, so it causes no shift. |
| +- **The draft offer** (base §5) stays. In Phase 2 the editor mounts over the draft's text, with the offer above it as a bar (§6.8). |
| +- **"Make team page":** |
| + - Phase 1 keeps today's form, restyled. |
| + - Phase 2 starts it from a selection (§6.7). |
| +- **Layout:** |
| + - The page column is centred. |
| + - It moves left only when the open panel needs the room. This is Docs' sheet-centring rule, measured on the container, not `100vw`. |
| + |
| +### 4.2 Chips (the server renders them in Phase 1) |
| + |
| +Links render as chips. Phase 2's editor draws the same markup (§6.9). |
| + |
| +| Kind | Look | Accessible name | |
| +|---|---|---| |
| +| Team page | a pill; the page glyph in Mapa's accent; ink text | "Halden Robotics, team page" | |
| +| Through an alias | as a team page; the title shows as typed; a tooltip "Now called Halden Robotics" | "Halden Automation, now called Halden Robotics" | |
| +| Pending | no fill, a dashed rim, a "page +" glyph, muted text: three cues | "Pricing 2027, page not written yet" | |
| +| Date | a calendar glyph and "Thursday 12 November", never the ISO text | "Thursday 12 November, your note" | |
| +| Block link | a team chip with a ¶ glyph; "block removed" when the block has gone (base §3.2) | "…, a block in Acme" | |
| +| Broken date (`[[2026-02-30]]`) | plain text, as today | | |
| +| Embed (slice 1) | a quiet chip showing the reference (`fichas:…`) | "Embedded item, not shown yet" | |
| + |
| +Slice 2's estilo card partial replaces the embed chip. The mock-up's Fichas card waits for slice 2 (§10, D7). |
| + |
| +### 4.3 The Links panel |
| + |
| +- **Panel:** |
| + - 312px wide, glass, 12px under the header and 12px in from the inline end. Docs' inspector recipe: a 14px radius, the rim, the shadow, and much fainter in dark. |
| + - It is `<aside aria-label="Links">`. Its state lives in the cookie `mapa-links`: open by default, closed only for an exact `closed`, and rendered by the server. |
| +- **Sections, in order:** |
| + 1. **Around this page**, the map (below). |
| + 2. **Linked from N**, grouped by source page, with each block that links here. The link is marked inside the sentence. The viewer's own private notes carry "Only you" and a lock glyph. |
| + 3. **Mentioned without a link N**, each with the sentence and a Link it button (the existing POST). |
| + 4. **Links out N**: chips, pending ones included, in body order with duplicates removed. |
| +- **On a daily note:** |
| + - **This week** comes first: Monday to Sunday (Europe/Dublin, or the viewer's zone), with ‹ › for the week. A dot marks a day the viewer wrote a note, today is ringed, and the day on screen is filled. |
| + - A "November" button opens the month (§4.4). |
| + - Then Links out, then Linked from ("No page links to this day yet…"). |
| +- **The map:** |
| + - An SVG drawn by the server, not a simulation. This page sits at the centre and its neighbours sit on a ring. |
| + - Neighbours are the pages in Linked from, Links out (pending ones as dashed circles) and Mentioned. Linked pages come first, in a stable order (by public id), capped at 12. Past that there is no node and no count. The lists below are complete. |
| + - **Edges:** solid for a link, dashed for a link to a page not written yet, dotted for a mention. Edges between two neighbours are drawn when one links to the other in the viewer's scope. |
| + - Only "here" carries the accent (Calma). |
| + - It is `role="img"`, with a label that names the counts and the neighbours. Its nodes are pointer shortcuts to links that are also in the lists, so they take no tab stop (`tabindex="-1"`). |
| + - A key below it reads "Linked", "Not written" and "Mentioned", drawn in the edge styles. |
| +- **Scope:** every list, count, node and edge is read from the in-memory index under the viewer's scope (base §3.3 and §6.3). The panel is inside gate 1 (§7, L6). |
| +- **Phone:** a bottom sheet with a grabber and a peek line ("Linked from 3, mentioned in 1", or "This week, and links out" on a daily note). |
| + - Its counts are scoped like the lists. |
| + - Tapping the line or dragging it opens the sheet to 74% of the height. It is a modal `<dialog>` while open, and closes on Esc or a drag down. |
| + - It is hidden while the keyboard is up. |
| + |
| +### 4.4 Day navigation and the calendar |
| + |
| +- **The day pill:** ‹ Today › on daily notes. "Today" shows the date when you are on another day. |
| + - It sits in the lead slot from 800px, and in the kicker line on phones. |
| + - ‹ and › are links to `/d/<date>`. |
| + - The pill stays in the header when the panel's week strip is open, because the strip leaves when Links is off (§10, D5). |
| +- **The calendar:** |
| + - The pill's middle opens a month calendar that starts on Monday. So does "November" in the week strip. |
| + - Dots, the ring and the fill mean what they mean in the week strip. Its foot holds "• A note you wrote" and Today. |
| + - It is a server-rendered `<details>` popover: a grid of links, with ‹ › month links (`?month=2026-10`). |
| + - With script it has a roving tabindex, arrow keys and Esc. Without script it still works. |
| + - It is styled like rastrillo's `calendar.js` month grid, but it is navigation, not a date field, so it does not reuse that script. |
| + - Dots are the viewer's own daily notes only, from their own partition of the index. |
| + |
| +### 4.5 History |
| + |
| +- **The panel:** |
| + - History in the header opens a side panel, 360px, full height under the header. It replaces the Links panel while open, and the Links toggle shows unpressed. |
| + - Without script, the same panel is the page `/p/{id}/history`, laid out beside the page. With script, it is fetched as a fragment (`?panel=1`) under Docs' rule: a request with `Sec-Fetch-Dest: document`, or with no `Sec-Fetch-*`, gets the full page. |
| +- **The list:** |
| + - Versions grouped by day. Each shows the author ("You" for the viewer), the time, and a one-line summary. |
| + - Summaries are worked out on the server by diffing each revision against the one before. The forms are "Edited <the nearest heading above the first changed block>", "Added <n> blocks", "Removed …", "Restored a version from …" and "Created". |
| + - The first 30 versions are summarised. "Show older" pages on from there. |
| + - The oldest version reads "Created this page" (§10, D8). |
| +- **Choosing a version:** |
| + - The page shows that version, with a banner: "Bo's version, Friday 13 November at 16:15. Marked: what changed from the version before" and **Back to current**. |
| + - The diff is per block (the merge's alignment, `markup/merge.go`), then per word inside a changed block. Insertions are underlined and tinted. Deletions are struck through and tinted. Underline and strike carry the meaning, so colour never carries it alone. A chip is diffed as one word. |
| + - The panel's foot holds **Back to current** and **Restore this version**. Restore is the existing POST: a new revision, held for 650ms (the busy rule). |
| +- **The editor during history:** it is read-only while an old version is on screen. Back to current returns the editor and the caret. |
| + |
| +### 4.6 ⌘K |
| + |
| +- **The box:** ⌘K (Ctrl+K) opens a modal `<dialog>`. Today's `mapa.js` palette is restyled into one box with groups: |
| + - **Pages:** titles and aliases, with alias hits labelled "Old title of …". |
| + - **In the text:** the block, with the match marked. |
| + - **Your notes:** daily and scratch, labelled "Only you see these". |
| +- **The last row:** "Create '<query>'", shown only when nothing in scope matches the title exactly. This is base §6.3, unchanged. |
| +- **Keyboard:** ↑ ↓ to move, ↵ to open, ⌘↵ to create. The hints are in the foot, which phones hide. |
| +- **Typed dates:** "today", "yesterday", "tomorrow", a weekday ("friday" is the most recent Friday, today included; "next friday" is the coming one), "12 nov" and ISO dates. They resolve in the viewer's zone, on the server, and add one row: "Friday 13 November, your note". |
| +- **Without script:** `GET /search?q=` as a page in the new shell, as now. |
| +- **Endpoint:** the existing `/search/suggest`, which already answers within base §6.1's budget, gains the groups and the date row. |
| + |
| +### 4.7 The other screens |
| + |
| +- **Inside the new shell, restyled:** All pages, Scratch, Search, Settings, Deleted pages, and every confirm page (delete, free alias, restore deleted, conflict, the textarea editor). |
| +- **New team page:** |
| + - A popover from the sidebar foot or the Page menu holds one title field. It posts the existing `POST /pages` (650ms), then opens the new page with the caret in its body. |
| + - Because the page now exists before its first keystroke, its text autosaves from the start. That retires build note 25 for team pages. |
| + - Without script it is `/new`. |
| +- **New scratch page:** |
| + - It opens the empty editor. |
| + - Its first autosave is the commit that creates it (base build note 13: it is "created by its first save"). Every later autosave is a draft. |
| + - So a scratch page that is never typed into leaves no row. |
| + |
| +## 5. Phase 1 on the existing editor |
| + |
| +Phase 1 ships everything in §3 and §4 around today's textarea: |
| + |
| +- **The page:** the rendered body, with chips. The editing screen `/p/{id}/edit` and the daily note's edit state move into the full-window layout: a borderless textarea at the page's measure, in the body's face and size, with no "Text" label, and Insert putting Markdown in at the caret. Autosave, the commit after two minutes idle, ⌘S and Save are as now. Save shows in the lead slot without script, and the status is estilo's `savestatus`. |
| +- **The server's HTML is final in Phase 1.** It is the markup the Phase 2 editor draws (§6.9). |
| + - Chips, as in §4.2. |
| + - Date links in their long form. |
| + - List items as `<li><p>`. |
| + - The body under `white-space: pre-wrap`, so a reader sees exactly the spaces the editor will. Today's renderer collapses them (§10, D9). |
| + - So Phase 2 changes no reader's view and moves nothing on mount. |
| + |
| +## 6. The editor (Phase 2) |
| + |
| +### 6.1 The rule |
| + |
| +**Markdown is the stored format, and the editor owns no other format.** Drafts, revisions, the block merge, S3 and export see Markdown, exactly as now. The editor reads Markdown when it mounts and writes Markdown when it saves. |
| + |
| +**The grammar is Mapa's own subset, not CommonMark** (base build note 10, `markup/blocks.go` and `spans.go`). There is no Markdown library: |
| + |
| +- Mapa's blocks are not CommonMark's. A list item is its own block. A paragraph's line breaks are hard breaks. There is no indented code, no `_` emphasis and no escapes. |
| +- A CommonMark parser would disagree with the Go side on real pages. |
| + |
| +The editor carries a JavaScript port of those two Go files. A corpus gate holds the port to Go (§6.4). |
| + |
| +### 6.2 Build and bundle |
| + |
| +The bundle is built the way Docs builds its bundles, which Slides copied: |
| + |
| +- **Layout:** `editor/` at the repo root holds `package.json`, `package-lock.json`, `bundles.mjs` and `build-bundles.mjs`, plus the sources: |
| + - `markup.mjs`, the port; |
| + - `schema.mjs`; |
| + - `serialize.mjs`; |
| + - `editor-entry.js`; |
| + - the plugins. |
| +- **Output:** esbuild writes a minified bundle with its content hash in the name, `internal/mapa/static/editor.<hash>.js`, which is committed and embedded. The app runs no build step. |
| +- **Dependencies:** `prosemirror-model`, `-state`, `-view`, `-transform`, `-commands`, `-keymap`, `-history`, `-inputrules` and `-schema-list`, at the versions Docs pins. There is no `prosemirror-markdown`, no markdown-it and no Yjs. |
| +- **Size:** measured and recorded in the build note, not promised. Expect 60 to 80KB gzipped. |
| +- **Loading:** the bundle loads `defer`, only on a page the viewer may edit, so old versions, deleted pages and confirm pages do not load it. `mapa.js` stays a small classic script for the chrome: ⌘K, the sidebar fold, the panels, the calendar, and the time zone offer. |
| +- **CI:** CI runs `npm ci`, rebuilds, and fails on any byte of drift (Docs' `10-gate`), then runs `node --test`. **Mapa's CI gains Node**, which it does not need today. `.amadan/ci` and the Makefile (`make editor`, and `make ci` calling it) change with it. |
| +- **Colophon:** it gains the ProseMirror packages (MIT), through estilo's catalog, as Docs did. |
| + |
| +### 6.3 The schema |
| + |
| +The schema is deliberately the subset Mapa renders, and nothing else. |
| + |
| +| Mapa block (`markup.Block`) | Node | Attributes kept for fidelity | |
| +|---|---|---| |
| +| paragraph | `paragraph` (inline content, `hard_break` for `\n`) | none | |
| +| heading (`#` to `######`) | `heading`, drawn as `h2` to `h6`; the page title is the H1 | `level` | |
| +| list item | `list_item > paragraph` inside `bullet_list` or `ordered_list` | `indent` (exact), `bullet` (`-` `*` `+`), `number` and `delim` (`.` `)`), `task` and `checked` (`[ ]`, `[x]`, `[X]`) | |
| +| quote | `blockquote > paragraph` | `prefix` per line (`>` or `> `) | |
| +| code fence | `code_block` | `fence` (` ``` ` or `~~~`, and its length), `info`, `closed` | |
| +| rule | `horizontal_rule` | `source` (`---`, `* * *`…) | |
| + |
| +- **Marks:** `strong` and `em` (always `**` and `*`, the only ones the subset has), `code` and `link` (`[text](url)`, or `bare` for an autolink). |
| + - `code` excludes every other mark. |
| + - `link` excludes `strong` and `em`, because the Go renderer escapes a web link's text and draws no emphasis inside it. |
| +- **Mapa's inline atoms:** |
| + - `wikilink {target, anchor, shown, source}` serialises to `[[target#^anchor|shown]]`. An untouched link re-emits its `source`. |
| + - `datelink {date, source}` serialises to `[[2026-11-12]]`. |
| + - `embed {ref, source}` serialises to `![[app:item]]`. |
| +- **The block anchor:** `^id` is a `marker` attribute on every block that may carry one (not code, not rule). It serialises as ` ^id` at the end of the block's last line. |
| + - It is drawn as a ¶ handle on hover, with "Copy link to this block". |
| + - It is minted only by "Link to this block" on a team page, as an attributed edit to that page (base §3.2). |
| + - Markers are stripped from pasted blocks, so a paste cannot duplicate an id. |
| +- **Not representable** (a list item holding two paragraphs, a quote holding a list): |
| + - The schema forbids it. |
| + - Paste maps it onto the nearest thing the subset can say. |
| + - Text outside the subset (tables, raw HTML, footnotes) is already a paragraph to Mapa's parser, and stays one. Its pipes and angle brackets are text, drawn under `pre-wrap` (§10, D10). |
| + |
| +### 6.4 Markdown fidelity: re-emit by block |
| + |
| +**The danger.** A serialiser that normalises (list markers, numbering, indentation, blank lines, fence style, trailing spaces) rewrites blocks nobody touched on every save. That produces: |
| + |
| +- noise in history; |
| +- false conflicts in the block merge; |
| +- churn in S3; |
| +- a breach of doctrine §6.6 in spirit: one byte sequence per revision, and no needless revisions. |
| + |
| +**The mechanism. Untouched blocks are re-emitted from their source, byte for byte.** |
| + |
| +1. **On mount**, the editor parses the body with `markup.mjs`. That gives the same blocks, with `Start` and `End` in bytes, that Go's `markup.Parse` gives. It builds the document, with one textblock (or rule) per Mapa block. Then it records, in a `WeakMap` keyed by the **node object**, each block's index, its exact source, and its context (kind, level, list attributes). |
| +2. **ProseMirror shares structure.** A transaction that does not touch a node keeps the same node object. So "untouched" means: the node is the same object as at mount, **and** its context is unchanged (a re-indent changes the context without changing the node). |
| + - Chip state (team, alias, pending) lives in a plugin and a NodeView, never in node attributes. So a link's state changing, after a rename say, never makes a block look edited. |
| +3. **On serialise**, the editor walks the blocks in order: |
| + - An untouched block emits its recorded source. |
| + - Between two untouched blocks that were neighbours at mount, it emits the **original bytes between them**. |
| + - Anywhere else, it emits `markup.Join`'s rule: one blank line, or one newline between two list items. |
| + - The original leading and trailing bytes are kept while the first and last blocks are the original ones. |
| + - The result goes through `cleanBody`'s rule (`\n` line endings, trailing space trimmed), as every stored body does. |
| +4. **An edited block** is serialised from its node. Its block syntax comes from its kept attributes: the same bullet, number, indent, fence and quote prefix. Only the inline text is rewritten. Its untouched atoms re-emit their `source`. |
| +5. **Reparse on edit.** |
| + - After each transaction that edits a block, the editor serialises that block and parses it again with `markup.mjs`. |
| + - If the parse is not exactly that block, the block is replaced by what the parse says. That happens when the text now starts with `- ` after a hard break, or holds `*word*` typed literally. |
| + - So what the editor shows is always what the stored Markdown means. The textarea, the reader and the editor never disagree. |
| + - Mapa has no escapes, so `*word*` typed in the editor becomes emphasis, exactly as it does in the textarea (§10, D11). |
| +6. **Nothing commits nothing.** |
| + - The editor autosaves only when the serialised body differs from the last one it saved, and commits only when it differs from the base revision's body. |
| + - On the server, a commit whose body equals the current body, over the current revision, writes no revision. It just drops the draft. Today `tx.commit` would mint an identical revision. |
| + - Empty paragraphs (Enter twice) have no Markdown form and serialise as nothing. The editor keeps them on screen while you are there. |
| + |
| +**Parity hazards the port must not trip over,** each with a corpus case: |
| + |
| +- Go's RE2 `\s` and `\S` are ASCII, while JavaScript's are Unicode (NBSP, U+2028, U+3000). The port spells out ASCII classes. |
| +- Go's `strings.TrimSpace` and JavaScript's `trim()` trim different sets (U+0085, U+FEFF). |
| +- Go offsets are bytes and JavaScript's are UTF-16. `Start` and `End` are compared in UTF-8 bytes. |
| +- `strings.ReplaceAll(indent, "\t", " ")` decides list levels. |
| +- The emphasis regexes run over HTML-escaped text in Go. |
| + |
| +### 6.5 Saving: autosave, commit and rebase |
| + |
| +The base spec's §5 and gate 11 are unchanged, and the textarea's reviewed rules (`mapa.js`) carry over. |
| + |
| +- **Draft:** autosave 1.2s after typing stops, through `POST …/draft`, with the version check against other tabs. It never touches the page or its revision. |
| +- **Commit:** |
| + - On ⌘S, after two minutes idle, and when the person leaves the page inside Mapa (a link or the sidebar). The editor commits before it navigates. |
| + - Closing the tab is new: on `pagehide`, the editor sends one `keepalive` POST that writes the draft **and** commits it (`POST …/draft` with `commit=1`, one request so the order cannot be lost). If that commit cannot happen (a same-block conflict, or a beacon that never arrived), the draft stays, and the next visit offers it as Save or Discard, as now (§10, D3). |
| + - Browsers cap a `keepalive` body at 64KB. When the text not yet autosaved would pass that, the POST carries only `commit=1` and the draft version, and commits the last autosave. Anything typed in the final 1.2s is then lost on a very long page. That is measured, and noted as a limit. |
| +- **Status:** `savestatus` shows Saving…, Saved, Retrying and Failed. "Saved" means the text is stored. Teammates see it from the next commit, and see "Ana is editing" until then (base §5). |
| +- **Learning of a teammate's revision:** |
| + - Autosave's reply gains `revision`, the page's current revision. |
| + - When it differs from the editor's base, the editor asks `GET /p/{id}/rebase?base=R&version=V`. |
| + - That runs `Merge3(base body, the person's stored draft, current body)` and answers JSON: the merged body, or the hunks. It writes nothing, so it is inside gate 10. |
| +- **Clean merge:** |
| + - The editor applies the merged body as one transaction that replaces only the blocks the teammate changed, aligned by `markup.mjs`. |
| + - The caret, the selection and undo survive. |
| + - The base moves to the current revision, and the next autosave writes the draft with that base. |
| + - The fidelity map is rebuilt against the new base body. |
| +- **Same block:** |
| + - The editor shows that block's conflict inline: Yours, Theirs, or Both, yours first (base build note 24). |
| + - Until the person chooses, the base stays where it was, so no commit can overwrite the teammate. |
| + - Nothing is committed that nobody chose. |
| +- **A commit that merged** (outcome `Merged`, body returned, as today) follows the textarea's rule: |
| + - With nothing typed since the commit was sent, the editor takes the merged body by the same block transaction. |
| + - With typing since, it keeps its base, so the next commit merges again. |
| +- **Two tabs:** a stale tab is refused and loads the newer draft, as now (base build note 31). |
| + |
| +### 6.6 Typing: `[[`, `/`, input rules and the bubble |
| + |
| +- **`[[`** opens a combobox under the caret. It shows team titles, aliases ("Old title of Halden Robotics"), the viewer's own pending link texts (base §6.3 and build note 20), and the last row, "Link 'Hal', a page not written yet". |
| + - It uses `/links/suggest`, unchanged, so its scope is unchanged. |
| + - ↵ inserts a `wikilink`, and `|` lets you type shown text. |
| + - A typed `[[2026-11-12]]` or a picked date makes a `datelink`. |
| + - Backspace into a chip turns it back into its `[[text` source, for editing. |
| + - A plain click on a chip follows the link, as chips are links. |
| +- **`/`** at the start of an empty block, or after a space, opens the block menu. It offers: |
| + - Heading 1, 2 and 3 (`#`, `##`, `###`); |
| + - List (`-`), Numbered (`1.`), Checklist (`- [ ]`); |
| + - Quote (`>`), Code (```` ``` ````), Divider (`---`); |
| + - Link to a page (`[[`); |
| + - Date: a picker. Choosing a day inserts a `datelink`, which opens the viewer's own note for that day. |
| + - Card from Fichas is hidden until slice 2. |
| +- **Input rules:** the Markdown shortcuts above, typed at the start of a block, become those blocks. `**x**`, `*x*` and `` `x` `` become marks. A pasted or typed URL over a selection makes a link (today's paste rule). |
| +- **The selection bubble:** B, I, code and link, then **Make team page** (private notes only). |
| + - On fine pointers it sits above the selection. |
| + - On coarse pointers it sits below, clear of iOS's own callout (§6.11). |
| +- **Keys:** ⌘B, ⌘I, ⌘E (code), ⌘K is search (not link), ⌘⇧K is link, ⌘S, ⌘Z and ⌘⇧Z, and Tab and ⇧Tab to indent list items. |
| +- **Paste:** |
| + - `text/plain` is parsed as Mapa Markdown. |
| + - `text/html` is mapped onto the schema (headings, lists, emphasis, links, code), and anything else becomes text. |
| + - Markers are stripped. |
| + - Links pasted from Mapa's own pages arrive as `wikilink`s. |
| + |
| +### 6.7 Make team page from a selection |
| + |
| +1. **A selection is characters, and Make team page works on blocks.** |
| + - The command widens the selection to every block it touches, and tints those whole blocks before anything is confirmed. That is the mock-up's highlight. |
| + - A selection inside one paragraph therefore moves the whole paragraph, and the tint shows it. |
| +2. **The confirm popover:** |
| + - A title, prefilled from the first heading in the blocks, or the first words. |
| + - The sentence: "These blocks move to a new team page everyone can open. Your note keeps a link in their place. Nothing else in your note is shared." |
| + - Make team page, held for 650ms. |
| +3. **On confirm**, the editor commits the draft first (an ordinary commit by the person). Then it posts the existing `MakeTeamPage` with the block indices **and the revision they index**. |
| + - `MakeTeamPage` gains that `revision` and refuses a stale one. Today it takes indices into whatever the body is now. |
| + - A daily note that has never been committed is created by that first commit, as any first save creates it. |
| +4. **Refusals** are as today and gate 2's: |
| + - a taken title asks for another; |
| + - so does a date-shaped one. |
| + - Embeds the blocks carry get base §7.4's check once slice 2 exists. |
| +5. **Afterwards**, the note shows the link chip where the blocks were. Then "Moved to [[Pilot logins]]." stays as a notice until the page is next opened. |
| + |
| +### 6.8 The draft offer, and drafts in the editor |
| + |
| +- When the viewer has a draft on the page, the editor mounts over **the draft's text**, with its base revision. A bar above the page reads "Unsaved changes from 2 hours ago" with Save and Discard (the existing POSTs). |
| +- Typing continues the draft. |
| +- Without script, the page shows the committed text and today's offer. |
| + |
| +### 6.9 No shift, no flash |
| + |
| +- **The server's HTML is the editor's DOM.** Phase 1 changes the renderer to draw exactly the schema's `toDOM`: chips, `<li><p>`, `pre-wrap`, and `h2` to `h6` for the heading levels. |
| +- **Mount:** the editor mounts `{mount: article}` on the same element, so its first render replaces identical markup. |
| +- **Before mount:** the body is `contenteditable` only after mount. Before that it is the readable page, and the bundle loads with `defer`. |
| + - A key pressed before mount is not lost silently. The page is not yet a text field, and the caret appears on mount. |
| + - This window is measured, and the gate holds it under 100ms on a warm cache. |
| +- **Panels and the sidebar** come from their cookies at first paint. The lead slot's `savestatus` reserves its width, and so does the presence line. |
| +- **Never FOUT:** the system UI face only, `ui-monospace` for code, and no webfont, as now. The editor's CSS is in `mapa.css` and is never injected by script. |
| +- **Gate L5** (§7) measures it. |
| + |
| +### 6.10 The scriptless floor |
| + |
| +- **Without script:** a page reads as rendered Markdown. "Edit as Markdown" (View, and a link in the page's kicker) opens today's textarea with Save and its revision check. Every gate-7 walk still passes. |
| +- **With script:** View → Edit as Markdown is still there, for anyone who wants the source. It opens the same textarea screen. |
| +- **Agreement:** every Mapa node survives a trip through the textarea as text, because `[[ ]]`, `^id` and `![[ ]]` are plain text by design. |
| + |
| +### 6.11 iOS and touch |
| + |
| +Known quirks. Each one gets a WebKit case in `make browser` where that is possible, and a check by hand on a real iPhone through Safari's Web Inspector. `devicectl` hangs on this Mac (Calls notes), so automated device runs are not promised. |
| + |
| +1. **Composition and autocorrect next to atoms.** Chips are non-editable inline atoms. IME composition (kana, pinyin), dictation and autocorrect replacements next to them are a known ProseMirror and WebKit weak spot. |
| + - Test each against a chip on both sides. |
| + - Never act on Enter while `isComposing`. |
| +2. **The selection callout.** iOS draws Copy and Paste above the selection, so the bubble goes below it on coarse pointers. |
| +3. **The keyboard.** |
| + - `visualViewport` keeps the bubble, the `[[` and `/` lists and the accessory row above the keyboard. |
| + - The Links sheet hides while the keyboard is up. |
| + - The header stays put: no `100vh` traps, and `dvh` is used. |
| +4. **Zoom on focus.** Editable text is at least 16px on phones, or Safari zooms (the suite's iOS input-zoom fix). |
| +5. **Smart punctuation.** |
| + - iOS turns `--` into an en or em dash and straight quotes into curly ones. |
| + - The rule and code-fence input rules also accept `—-`, `–-` and the like. |
| + - The `/` menu is the dependable path. |
| +6. **Checkboxes:** task boxes are NodeView buttons with names ("Done: Send Tom the summary"). A tap toggles the box; it does not place the caret. |
| +7. **The accessory row.** Página's keyboard row is adopted on phones while writing (§10, D6). It holds `[[`, `/`, B, I, list, checklist, and Make team page on private notes. |
| + |
| +### 6.12 Accessibility |
| + |
| +- **The editor:** `role="textbox"`, `aria-multiline="true"`, and named "Page text, <title>". Chips carry the names in §4.2. A block's ¶ handle is a button named "Link to this block". |
| +- **`[[`, `/` and ⌘K:** combobox and listbox, with `aria-activedescendant`, `aria-expanded` and `aria-controls` on the editor while a list is open, and results announced in a polite live region ("3 pages"). |
| +- **Dialogs and regions:** |
| + - ⌘K and the phone sheet are modal `<dialog>`s. |
| + - The Links panel and History are labelled regions. |
| + - Esc closes, and focus returns to what opened it. |
| +- **The sidebar:** `<nav aria-label="Mapa">` with `aria-current`. The rail keeps its labels for assistive technology. |
| +- **History's diff:** insertions are `<ins>` and deletions `<del>`, so screen readers announce them, and underline and strike carry the meaning. |
| +- **General:** |
| + - Keyboard shortcuts are listed in Help. |
| + - Focus is always visible. |
| + - Targets are at least 24px, and 32px on coarse pointers. |
| + - The page reflows at 320px (SC 1.4.10). |
| + - Reduced motion removes the sheet's and the bubble's transitions. |
| + |
| +## 7. Gates |
| + |
| +**Base gates 1 to 12 keep passing, unchanged,** along with `make mutate`'s nine mutations. The new gates are numbered L1 to L12. They run in `make ci` unless they are marked browser. |
| + |
| +**The corpus.** The level-up gates read one shared corpus, `internal/mapa/markup/testdata/corpus/`: |
| + |
| +- every synthetic page `synthetic.go` writes; |
| +- every Markdown file in the Oficina repos at a pinned commit. That is real prose: specs, READMEs and AGENTS files, with tables, nested lists, HTML, fences, long lines and Unicode; |
| +- the CommonMark spec's examples (0.31.2), as hostile input; |
| +- hand-written edges: CRLF and lone CR, tabs in list indents, level skips, `1)`, `*` and `+` bullets, `[X]`, unclosed fences, `~~~`, `***` and `_ _ _` rules, `^id` on every block kind, wiki links with odd spacing and `|` and `#^`, `[[` with no close, empty bodies, a body that is only blank lines, NBSP, U+2028, U+0085, U+FEFF, emoji, RTL text, and zero-width joiners. |
| + |
| +**Fidelity (Node, against Go's output):** |
| + |
| +- **L1, untouched round trip.** For every corpus body, mount and then serialise gives `cleanBody(body)` byte for byte. |
| +- **L2, locality.** Editing one block, chosen at random in each body with a fixed seed, changes only the bytes `markup.Replace` would change. Inserting or deleting blocks changes bytes only at the seams, by `Join`'s rule. |
| +- **L3, stability.** Seeded random edits (typing, marks, splits, joins, list moves, chips) give `serialise(parse(serialise(doc))) = serialise(doc)`. Every edited block reparses, in JavaScript and in Go, to the editor's own content. |
| +- **L4, parity.** |
| + - `markup.mjs` equals Go's `Parse` and `Spans` on every corpus body: kinds, levels, markers, and byte offsets. |
| + - The editor's `toDOM` HTML equals Go's `Render` HTML. |
| + - Go writes the golden file (`go test -run Golden -update`), Node compares, and CI fails when the golden file is stale. |
| + |
| +**The page:** |
| + |
| +- **L5, no shift (browser).** Chromium and WebKit, light and dark, at 1440px, 1000px and 390px. |
| + - Every block's box is identical before and after mount. |
| + - No `layout-shift` entry is recorded from first paint through mount. |
| + - The cookies for sidebar and Links are honoured at first paint. |
| + - Mount happens within 100ms of `DOMContentLoaded` on a warm cache. |
| +- **L6, scope (extends gate 1).** Bo's output is byte-identical whether or not Ana's private notes hold the term, the link, the pending text or the block reference. That covers: |
| + - the Links panel's lists and counts, the map's nodes and edges, and the phone's peek line; |
| + - Recent and Pinned; |
| + - the calendar's and the week's dots; |
| + - ⌘K's groups and its date row; |
| + - `[[` suggestions; |
| + - the editor's link-resolution data; |
| + - history summaries. |
| + `make mutate` gains a mutation that drops the panel's scope check. |
| +- **L7, a GET writes nothing (extends gate 10).** Every new GET leaves the database file's bytes unchanged: the panel and history fragments, rebase, the calendar month, and the cookie redirects. So does mounting the editor and leaving without typing: no draft, no row, no event. |
| +- **L8, scriptless (extends gate 7).** With scripts off, `make browser` walks: |
| + - the sidebar and its fold form; |
| + - the day pill and the calendar's months; |
| + - the Links lists at the page's foot; |
| + - the History page and Restore; |
| + - ⌘K's search page; |
| + - rename in the header; |
| + - New team page; |
| + - Make team page; |
| + - Edit as Markdown and Save. |
| + |
| +**Saving:** |
| + |
| +- **L9, drafts and rebase (extends gate 11).** |
| + - A teammate's revision landing mid-edit merges by block without touching the block under the caret. |
| + - A same-block change shows the inline choice and commits nothing until the person chooses. |
| + - The `pagehide` commit writes and commits in one request. |
| + - A commit that changes nothing writes no revision. |
| + - A stale tab cannot overwrite a newer draft. |
| + - Make team page refuses a stale revision. |
| + |
| +**Quality:** |
| + |
| +- **L10, accessibility (browser).** |
| + - Chip names, roles and states. |
| + - A keyboard-only walk of `[[`, `/`, Make team page, ⌘K, the calendar, History and Restore, checking that focus returns. |
| + - Reflow at 320px. |
| + - axe-core, vendored at a pinned version with no network fetch, finds nothing serious. |
| +- **L11, the busy rule.** Rename, Restore, Make team page, New team page, Pin and Link it hold their spinner for 650ms. Links, the fold, the calendar and Appearance switch at once. |
| +- **L12, the bundle.** CI rebuilds from the lockfile and fails on byte drift. The size is logged on every run, and the gate fails if it passes 120KB gzipped. |
| + |
| +## 8. Server changes, in one list |
| + |
| +- **The renderer:** chips with their states, long-form date links, `<li><p>`, `pre-wrap`, and the empty-body placeholder (Phase 1). |
| +- **The sidebar's data:** |
| + - Recent, from the event log (`actor` = the viewer, the page live and in scope). |
| + - Pins, if Paul rules them per person (§11, Q1): a sealed list in the member record, with no new plaintext column. A POST changes it and logs an event on the member object (base build note 3). |
| +- **The Links panel:** the map's layout, and the week's and month's dots, from the in-memory index under the viewer's scope. |
| +- **History:** per-revision summaries and the word diff. `?panel=1` fragments under Docs' `Sec-Fetch-Dest` rule. |
| +- **`/search/suggest`:** groups and the typed-date row. |
| +- **New, a GET, JSON:** `GET /p/{id}/rebase`. |
| +- **Autosave:** its reply gains `revision`. `POST …/draft` gains `commit=1`. |
| +- **Commits:** a no-op commit writes no revision. `MakeTeamPage` takes the revision its indices refer to. |
| +- **Cookies:** `mapa-sidebar` and `mapa-links`, set by script or by a form POST that redirects back. |
| +- **Unchanged:** §4's plaintext list, the seal, S1, S2 and S3, the event vocabulary apart from what the pin event needs, and every refusal. |
| + |
| +## 9. estilo and rastrillo |
| + |
| +- **Re-pin estilo** to `f724edb` or later. That brings the bar-stack (`39792ae`) and Mapa's mark at 125. |
| +- **The floating glass panel moves to estilo.** Mapa is its second adopter after Docs' inspector, which is the "two implementations" rule. |
| + - An estilo branch extracts `[estilo-float]`: the glass, rim, shadow and dark values, and the centring helper. |
| + - Mapa adopts it. Docs adopts it when it next re-pins. |
| + - The panel needs no light (`light.js`) glow: the Links panel holds no controls that need the back-light. |
| +- **The sidebar's row grid and the rail** stay Mapa's until a second app wants them. Fichas' rail is the likely one. |
| +- **rastrillo's `[rst-shell-nav] a` alignment** is reported upstream to rastrillo. Mapa no longer uses that shell. |
| + |
| +## 10. Departures |
| + |
| +**From the mock-ups:** |
| + |
| +- **D1, Pinned.** The mock-up's Pinned has no owner and no storage. This spec proposes per-person pins, sealed in the member record (§11, Q1). |
| +- **D2, Recent.** "Recent" is **the pages you last wrote in**, not the pages you last opened. Remembering opens would make a GET write, which gate 10 forbids. The browser could keep visits instead, but the server could not render them at first paint without a shift. |
| +- **D5, the day pill.** The day pill is in the header on daily notes even when the panel's week strip is open. The C mock-up drops it there, but the strip leaves when Links is off. |
| +- **D6, the phone accessory row.** The phone keyboard row comes from Página. Contexto's mock-up has none, and without it a phone has no way to reach `[[`, `/` or Make team page. |
| +- **D7, embeds.** Embeds stay reference chips until slice 2. The Fichas card in the mock-up needs S10. |
| +- **D8, the oldest version.** History's oldest entry says "Created this page", not "Made this page from your note". Saying where a team page came from would need a new event verb in the plaintext log that marks a page as born from private writing, which is a new disclosure. |
| +- **The map's limits.** The map is capped at 12 neighbours and shows no "more" count. Its nodes take no tab stop, and the lists are the accessible route. |
| + |
| +**From the base spec, each for the reviewer:** |
| + |
| +- **D3, the tab-close commit.** Closing the tab now commits the draft, by one `keepalive` POST from the person's tab. Base §5 has a closed tab's draft wait for the next visit, which this keeps only as the fallback. The reason is that the page has no Save button, and "Saved" must not turn into "You have unsaved changes" an hour later. Every commit is still a POST made by the person's own tab, and nothing runs on the server (doctrine §13). |
| +- **D4, title-first team pages.** A new team page exists from its title, before its body. That is what `POST /pages` already does. It retires build note 25's known limit for team pages. Scratch pages keep it, now only as "the first autosave creates the page". |
| +- **D9, `pre-wrap`.** Reading views render under `pre-wrap`, so runs of spaces show as typed. That is a visible change for pages typed in the textarea with aligned spaces. |
| +- **D10, no source blocks.** The mock-up README proposed "source blocks" for tables and HTML. This spec drops them, because Mapa's own parser already reads those as paragraphs and stores them byte for byte. |
| +- **D11, no escapes.** Mapa has no escapes, so the editor cannot keep a literal `*word*` as text. That is how the textarea already behaves. Adding backslash escapes to the subset is possible, but it changes Go's renderer, search, S3 readers and the textarea together. It is left out, and the trigger to revisit it is someone needing literal asterisks. |
| +- **Two new rules:** a no-op commit writes no revision, and `MakeTeamPage` checks its revision. Both make an existing promise stricter. |
| +- **Unchanged:** decisions 1 to 15, the rungs and the namespace, the seal boundary (§4's list, unless Q1 is ruled per team), S1, S2 and S3, and slices 2 and 3. |
| + |
| +## 11. Open questions for Paul |
| + |
| +1. **Q1, Pinned: yours, or the team's?** The recommendation is yours: private, sealed, and never shown to anyone else. Team pins would need a team-visible setting, with history. |
| +2. **Q2, Recent means "what you last wrote in", not "what you last opened"** (D2). Is that acceptable? |
| +3. **Q3, closing the tab saves** (D3), so a closed tab no longer leaves "You have unsaved changes" behind except when a conflict or a failed send forces it. Yes? |
| +4. **Q4, the sidebar's default** with no cookie: open from 80rem and the rail below that. Or always open, or always the rail? |
| + |
| +## 12. Phasing |
| + |
| +**Phase 0:** this spec, reviewed. Then stop. |
| + |
| +**Phase 1: the chrome, on today's editor.** One commit per step, each green on `make ci` and `make browser`. |
| + |
| +1. Re-pin estilo; Mapa's mark and hue; drop `themeSlug`'s fallback. |
| +2. The shell: the stacked header with menus, lead and actions; the sidebar, rail, fold and cookie; the Menu sheet below 800px; New team page. |
| +3. The page: full window, kicker line, title, rename in both places, chips (the renderer, §4.2 and §5), `pre-wrap`, the textarea screen restyled. |
| +4. The Links panel: the lists, the map, the foot fallback, the phone sheet, the week on daily notes. Gate L6 for the panel. |
| +5. The day pill and the calendar. |
| +6. The History panel, its summaries and the word diff. |
| +7. ⌘K's groups and dates. |
| +8. Recent and Pins (after Q1). |
| +9. Gates L7, L8 and L11 for Phase 1, and a preview on its own tailnet port. |
| + |
| +**Phase 2: the editor.** |
| + |
| +1. `editor/` tooling, CI with Node, and an empty bundle served (L12). |
| +2. `markup.mjs` and the corpus with its Go golden file (L4, parsing). |
| +3. The schema, `toDOM` and the renderer's agreement (L4, HTML). |
| +4. The block-source serialiser and the reparse rule (L1 to L3). |
| +5. Mounting without a shift (L5), drafts in the editor, autosave, commit, `pagehide`, the no-op commit. |
| +6. Rebase and the inline conflict choice (L9). |
| +7. Chips, `[[`, `/`, input rules, the bubble, paste, block anchors. |
| +8. Make team page from a selection. |
| +9. iOS, the accessory row, and accessibility (L10). Then Edit as Markdown in View. |
| + |
| +Each phase ends in review on its branch before anything lands. Nothing is merged or deployed from here. |