From 0b9cc6313c641fa68b385b8b88c75dc068f188a0 Mon Sep 17 00:00:00 2001 From: Daniel Rispler Date: Sat, 28 Nov 2026 19:02:34 +0200 Subject: [PATCH 1/4] Studio map: the scan screen folds its optional edits, so Draft the map stays in view On a repository with many loose folders (timburr: 36 rows, 75 buttons) the scan panel was 3,400 px tall and scrolled sideways, with Draft the map at its foot. The edits (ignore copies, loose files and tests, ignored folders) now wait in a closed "Adjust the grouping (optional)" fold with the loose-folder count; open, Draft the map keeps to the panel's foot. With claude found the copy-prompt sits in a closed "Or use your own agent" fold. Long folder paths wrap. Co-Authored-By: Claude Opus 5.5 --- docs/studio/behaviour/map.md | 2 +- scripts/snap/fixtures-map.ts | 15 +++++++++++++++ ui/map-scan.ts | 34 +++++++++++++++++++++++++++------- ui/style.css | 17 ++++++++++++++++- 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/docs/studio/behaviour/map.md b/docs/studio/behaviour/map.md index d9111b71..a0d919e1 100644 --- a/docs/studio/behaviour/map.md +++ b/docs/studio/behaviour/map.md @@ -260,7 +260,7 @@ At most 15 parts: while there are more, the deepest level's sibling folders fold A git repository whose map status is the empty state, with no map on the default branch, in the checkout or waiting on a PR, opens on the scan screen (`ui/map-scan.ts`, `server/src/map_scan.rs`, ticket #760), never a folder in no git repository or an Unreadable map. The page asks `map_scan` once each time the project's map opens, and says "Scanning this repository's folders…" until it answers. The server scans the main checkout, runs `system_map::check_text` on the skeleton in memory and adds the edges it computes to the skeleton as `import` links with no reason, one per pair of parts in the edge's direction; it answers with that map's text, each part's tracked file count, `read_languages`, `unread_languages`, and whether the runner would find `claude`. Nothing is written and no token is spent. -The canvas draws the skeleton's parts as grey plates (`.plate.draft`), each with its name and its folder and file count, and the links as lines from rim to rim. The plates are placed afresh on each draw and fitted to the canvas, with no fog, badges, footprints or marks, and no drag, pan or saved position. Beside them, the panel says the project has no `system-map.json` on its default branch and the teaching sentence, how many parts the scan proposes, then the languages line: the read languages with "links computed", then the unread ones with "no reader yet" ("TypeScript and Go: links computed. Ruby: no reader yet"; with none read, "no reader yet, so no links are drawn"). **Draft the map** follows, with a time hint of a quarter of a minute a part, a minute at least, and "Uses your Claude Code plan", never a dollar figure; the drafting run it starts is the Map draft's (#762). When `claude` is not found it is muted (`aria-disabled`) with a one-line reason, and the copy-prompt comes before it. The copy-prompt carries the skeleton as JSON and asks the user's own agent to write `system-map.json` at the main checkout's root, fill each part's name, caption and purpose from its files, and run `npx plotkeeper map check` until it passes; once the file is there, the window's next focus reads it from the checkout and draws the map in the scan's place. A scan that fails (git cannot list the files) leaves the plain "No map yet" screen and its prompt (#669). Below 1007 px the panel sits under the canvas. +The canvas draws the skeleton's parts as grey plates (`.plate.draft`), each with its name and its folder and file count, and the links as lines from rim to rim. The plates are placed afresh on each draw and fitted to the canvas, with no fog, badges, footprints or marks, and no drag, pan or saved position. Beside them, the panel says the project has no `system-map.json` on its default branch and the teaching sentence, how many parts the scan proposes, then the languages line: the read languages with "links computed", then the unread ones with "no reader yet" ("TypeScript and Go: links computed. Ruby: no reader yet"; with none read, "no reader yet, so no links are drawn"). Then the optional edits, in a fold that starts closed ("Adjust the grouping (optional)", with the count of loose folders), so a repository with many loose folders does not push the button down; with the fold open, the button keeps to the panel's foot. **Draft the map** follows, with a time hint of a quarter of a minute a part, a minute at least, and "Uses your Claude Code plan", never a dollar figure; the drafting run it starts is the Map draft's (#762). When `claude` is found the copy-prompt sits under it in a closed fold, "Or use your own agent"; when it is not found the button is muted (`aria-disabled`) with a one-line reason, and the copy-prompt comes before it, open. The copy-prompt carries the skeleton as JSON and asks the user's own agent to write `system-map.json` at the main checkout's root, fill each part's name, caption and purpose from its files, and run `npx plotkeeper map check` until it passes; once the file is there, the window's next focus reads it from the checkout and draws the map in the scan's place. A scan that fails (git cannot list the files) leaves the plain "No map yet" screen and its prompt (#669). Below 1007 px the panel sits under the canvas. ### Editing the skeleton diff --git a/scripts/snap/fixtures-map.ts b/scripts/snap/fixtures-map.ts index 017e9e99..060ea3d9 100644 --- a/scripts/snap/fixtures-map.ts +++ b/scripts/snap/fixtures-map.ts @@ -898,6 +898,11 @@ export const mapScanMerge = (): Fixture => const screen = document.querySelector("#map .map-scan"); if (!screen) return log("snap:fail no scan screen"); const side = screen.querySelector(".map-scan-panel"); + // The edits wait in a closed fold: open it, as the person would. + const adjust = side.querySelector(".map-scan-fold"); + if (!adjust || adjust.open) return log("snap:fail the edits are not in a closed fold"); + adjust.open = true; + await wait(50); side.style.maxBlockSize = "320px"; side.scrollTop = 120; const scrolled = side.scrollTop; @@ -978,6 +983,11 @@ export const mapScanIgnore = (): Fixture => const screen = document.querySelector("#map .map-scan"); if (!screen) return log("snap:fail no scan screen"); const side = screen.querySelector(".map-scan-panel"); + // The edits wait in a closed fold: open it, as the person would. + const adjust = side.querySelector(".map-scan-fold"); + if (!adjust || adjust.open) return log("snap:fail the edits are not in a closed fold"); + adjust.open = true; + await wait(50); window.__sent = []; const real = window.fetch; window.fetch = (url, init) => { @@ -1043,6 +1053,11 @@ export const mapScanParent = (): Fixture => const screen = document.querySelector("#map .map-scan"); if (!screen) return log("snap:fail no scan screen"); const side = screen.querySelector(".map-scan-panel"); + // The edits wait in a closed fold: open it, as the person would. + const adjust = side.querySelector(".map-scan-fold"); + if (!adjust || adjust.open) return log("snap:fail the edits are not in a closed fold"); + adjust.open = true; + await wait(50); window.__sent = []; const real = window.fetch; window.fetch = (url, init) => { diff --git a/ui/map-scan.ts b/ui/map-scan.ts index 03f2e31c..9e67ac67 100644 --- a/ui/map-scan.ts +++ b/ui/map-scan.ts @@ -32,6 +32,21 @@ let focusAfter: string | null = null; let panelFocus: { act: "ignore" | "unignore"; folder: string } | null = null; // The scan each screen's plates were drawn from. const canvasOf = new WeakMap(); +// The panel's folds the person opened, by key: a redraw's `patch` sets the attributes the new draw gives, so `open` is drawn from here. +const openFolds = new Set(); + +// A fold of the panel, closed until pressed, that remembers being open across redraws. +function fold(key: string, summary: string, tip: string, body: Node[]): HTMLDetailsElement { + const details = text("details", "", "map-scan-fold"); + details.dataset.key = key; + if (openFolds.has(key)) details.open = true; + details.addEventListener("toggle", () => (details.open ? openFolds.add(key) : openFolds.delete(key))); + const head = text("summary", summary); + head.dataset.key = `${key} summary`; + hint(head, tip); + details.append(head, ...body); + return details; +} // A plate's actions: Merge into… the other parts, and Split by subfolders, muted with a reason when its folders have none to split by. function plateActions(menu: HTMLElement, doc: Doc, scan: MapScan, id: string, acts: ScanActs) { @@ -334,18 +349,23 @@ function panelOf(state: MapState, doc: Doc, scan: MapScan, acts: ScanActs): HTML ); const languages = languagesLine(scan.read_languages, scan.unread_languages); if (languages) panel.append(said(languages, "map-scan-languages", "scan languages")); - // The edits are optional (#753, story 10): Draft the map needs none of them. - if (count) panel.append(said("Fix the grouping first if you like; none of it is needed. Press a plate to merge or split it.", "map-scan-note", "scan edits")); if (acts.note) { const note = said(`That change did not apply: ${acts.note}. Try it again, or draft the map as it is.`, "map-scan-why", "scan failed"); note.setAttribute("role", "status"); panel.append(note); } - const edits = [ignoreBlock(scan, acts), looseBlock("files", scan.loose_files, doc, acts), looseBlock("tests", scan.loose_tests, doc, acts), ignoredBlock(scan, acts)]; - panel.append(...edits.filter((node) => node !== null)); - // Without `claude` the copy-prompt leads (#753, story 12). - const [draft, prompt] = [draftBlock(count, scan.claude, acts), promptBlock(scan.map, !scan.claude)]; - panel.append(...(scan.claude ? [draft, prompt] : [prompt, draft])); + // The edits are optional (#753, story 10): Draft the map needs none of them, so they wait in a closed fold, and the button stays in view. + const edits = [ignoreBlock(scan, acts), looseBlock("files", scan.loose_files, doc, acts), looseBlock("tests", scan.loose_tests, doc, acts), ignoredBlock(scan, acts)].filter((node) => node !== null); + if (count || edits.length) { + const loose = looseGroups(scan.loose_files, doc.parts).length + looseGroups(scan.loose_tests, doc.parts).length; + const summary = loose ? `Adjust the grouping (optional) · ${loose} loose ${loose === 1 ? "folder" : "folders"}` : "Adjust the grouping (optional)"; + const note = count ? [said("Press a plate to merge or split it.", "map-scan-note", "scan edits")] : []; + panel.append(fold("scan adjust", summary, "Show the folders no part holds yet, and the copies left out; Draft the map needs none of it", [...note, ...edits])); + } + // Without `claude` the copy-prompt leads, open (#753, story 12); with it, the prompt waits in a fold under Draft the map. + const draft = draftBlock(count, scan.claude, acts); + if (scan.claude) panel.append(draft, fold("scan prompt fold", "Or use your own agent", "Show a prompt to paste into your own agent in the project, instead of Draft the map", [promptBlock(scan.map, false)])); + else panel.append(promptBlock(scan.map, true), draft); return panel; } diff --git a/ui/style.css b/ui/style.css index 26ea188f..53696905 100644 --- a/ui/style.css +++ b/ui/style.css @@ -722,6 +722,10 @@ body.panel-open .map-empty { inset-inline-start: calc(var(--inset) + var(--panel .map-scan-panel .map-empty-title, .map-scan-panel .empty, .map-scan-languages, .map-scan-time, .map-scan-why { margin: 0; } .map-scan-languages, .map-scan-time, .map-scan-why { font-size: var(--size-small); color: var(--muted); } .map-scan-draft { display: flex; flex-direction: column; align-items: start; gap: var(--sp-2); } +/* With the edits' fold open, Draft the map stays at the panel's foot. */ +.map-scan-panel:has(.map-scan-fold[open]) { scroll-padding-block-end: 7rem; } +.map-scan-fold[open] ~ .map-scan-draft { position: sticky; inset-block-end: calc(-1 * var(--sp-6)); z-index: 1; padding-block: var(--sp-3) var(--sp-6); + background: var(--bg); border-block-start: var(--hair) solid var(--line); } .map-scan-draft .primary { background: var(--selected); } .map-scan-prompt { display: flex; flex-direction: column; gap: var(--sp-2); min-height: 0; } .map-scan .map-draft-row { min-width: 0; } @@ -739,7 +743,18 @@ body.panel-open .map-empty { inset-inline-start: calc(var(--inset) + var(--panel .map-scan-set legend { padding: 0; margin-block-end: var(--sp-1); font-weight: 600; } .map-scan-check { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; cursor: pointer; } .map-scan-check input { margin: 0; cursor: pointer; } -.map-scan-check code, .map-scan-where code, .map-scan-ignored code { font-family: var(--mono); font-size: var(--size-small); overflow-wrap: anywhere; } +.map-scan-check code, .map-scan-where code, .map-scan-ignored code { font-family: var(--mono); font-size: var(--size-small); white-space: normal; overflow-wrap: anywhere; } +/* The panel's folds: the optional edits and the copy-prompt, closed until pressed, so Draft the map stays in view. */ +.map-scan-fold { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; } +.map-scan-fold > summary { display: flex; align-items: center; gap: var(--sp-2); list-style: none; cursor: pointer; color: var(--muted); + font-size: var(--size-small); border-radius: var(--radius-small); } +.map-scan-fold > summary::-webkit-details-marker { display: none; } +.map-scan-fold > summary::before { content: "▸"; display: inline-block; rotate: 0deg; } +.map-scan-fold[open] > summary::before { rotate: 90deg; } +.map-scan-fold > summary:hover { color: var(--fg); } +.map-scan-fold[open] > summary { color: var(--fg); margin-block-end: var(--sp-3); } +.map-scan-fold .map-scan-set + .map-scan-set { margin-block-start: var(--sp-4); } +@media (prefers-reduced-motion: no-preference) { .map-scan-fold > summary::before { transition: rotate 0.15s; } } .map-scan-loose { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--sp-1) var(--sp-2); } .map-scan-loose { margin-inline-start: calc(var(--depth, 0) * var(--sp-5)); } .map-scan-parent { grid-template-columns: minmax(0, 1fr) auto; } From 655ab80238ae4b949e5ab7ddcf271147987a3f60 Mon Sep 17 00:00:00 2001 From: Daniel Rispler Date: Sat, 28 Nov 2026 19:06:56 +0200 Subject: [PATCH 2/4] Studio map: scan folds keyed by project, set on press; the plate hint stays out of the fold Co-Authored-By: Claude Opus 5.5 --- docs/studio/behaviour/map.md | 2 +- ui/map-scan.ts | 10 ++++++---- ui/style.css | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/studio/behaviour/map.md b/docs/studio/behaviour/map.md index a0d919e1..63aa79fa 100644 --- a/docs/studio/behaviour/map.md +++ b/docs/studio/behaviour/map.md @@ -260,7 +260,7 @@ At most 15 parts: while there are more, the deepest level's sibling folders fold A git repository whose map status is the empty state, with no map on the default branch, in the checkout or waiting on a PR, opens on the scan screen (`ui/map-scan.ts`, `server/src/map_scan.rs`, ticket #760), never a folder in no git repository or an Unreadable map. The page asks `map_scan` once each time the project's map opens, and says "Scanning this repository's folders…" until it answers. The server scans the main checkout, runs `system_map::check_text` on the skeleton in memory and adds the edges it computes to the skeleton as `import` links with no reason, one per pair of parts in the edge's direction; it answers with that map's text, each part's tracked file count, `read_languages`, `unread_languages`, and whether the runner would find `claude`. Nothing is written and no token is spent. -The canvas draws the skeleton's parts as grey plates (`.plate.draft`), each with its name and its folder and file count, and the links as lines from rim to rim. The plates are placed afresh on each draw and fitted to the canvas, with no fog, badges, footprints or marks, and no drag, pan or saved position. Beside them, the panel says the project has no `system-map.json` on its default branch and the teaching sentence, how many parts the scan proposes, then the languages line: the read languages with "links computed", then the unread ones with "no reader yet" ("TypeScript and Go: links computed. Ruby: no reader yet"; with none read, "no reader yet, so no links are drawn"). Then the optional edits, in a fold that starts closed ("Adjust the grouping (optional)", with the count of loose folders), so a repository with many loose folders does not push the button down; with the fold open, the button keeps to the panel's foot. **Draft the map** follows, with a time hint of a quarter of a minute a part, a minute at least, and "Uses your Claude Code plan", never a dollar figure; the drafting run it starts is the Map draft's (#762). When `claude` is found the copy-prompt sits under it in a closed fold, "Or use your own agent"; when it is not found the button is muted (`aria-disabled`) with a one-line reason, and the copy-prompt comes before it, open. The copy-prompt carries the skeleton as JSON and asks the user's own agent to write `system-map.json` at the main checkout's root, fill each part's name, caption and purpose from its files, and run `npx plotkeeper map check` until it passes; once the file is there, the window's next focus reads it from the checkout and draws the map in the scan's place. A scan that fails (git cannot list the files) leaves the plain "No map yet" screen and its prompt (#669). Below 1007 px the panel sits under the canvas. +The canvas draws the skeleton's parts as grey plates (`.plate.draft`), each with its name and its folder and file count, and the links as lines from rim to rim. The plates are placed afresh on each draw and fitted to the canvas, with no fog, badges, footprints or marks, and no drag, pan or saved position. Beside them, the panel says the project has no `system-map.json` on its default branch and the teaching sentence, how many parts the scan proposes, then the languages line: the read languages with "links computed", then the unread ones with "no reader yet" ("TypeScript and Go: links computed. Ruby: no reader yet"; with none read, "no reader yet, so no links are drawn"). Then the optional edits, in a fold that starts closed for each project ("Adjust the grouping (optional)", with the count of loose folders), so a repository with many loose folders does not push the button down; with the fold open, the button keeps to the panel's foot. **Draft the map** follows, with a time hint of a quarter of a minute a part, a minute at least, and "Uses your Claude Code plan", never a dollar figure; the drafting run it starts is the Map draft's (#762). When `claude` is found the copy-prompt sits under it in a closed fold, "Or use your own agent"; when it is not found the button is muted (`aria-disabled`) with a one-line reason, and the copy-prompt comes before it, open. The copy-prompt carries the skeleton as JSON and asks the user's own agent to write `system-map.json` at the main checkout's root, fill each part's name, caption and purpose from its files, and run `npx plotkeeper map check` until it passes; once the file is there, the window's next focus reads it from the checkout and draws the map in the scan's place. A scan that fails (git cannot list the files) leaves the plain "No map yet" screen and its prompt (#669). Below 1007 px the panel sits under the canvas. ### Editing the skeleton diff --git a/ui/map-scan.ts b/ui/map-scan.ts index 9e67ac67..56d5ada5 100644 --- a/ui/map-scan.ts +++ b/ui/map-scan.ts @@ -44,6 +44,8 @@ function fold(key: string, summary: string, tip: string, body: Node[]): HTMLDeta const head = text("summary", summary); head.dataset.key = `${key} summary`; hint(head, tip); + // A press sets the state at once: a redraw before the toggle event would otherwise draw the fold as it was. + head.addEventListener("click", () => (details.open ? openFolds.delete(key) : openFolds.add(key))); details.append(head, ...body); return details; } @@ -356,15 +358,15 @@ function panelOf(state: MapState, doc: Doc, scan: MapScan, acts: ScanActs): HTML } // The edits are optional (#753, story 10): Draft the map needs none of them, so they wait in a closed fold, and the button stays in view. const edits = [ignoreBlock(scan, acts), looseBlock("files", scan.loose_files, doc, acts), looseBlock("tests", scan.loose_tests, doc, acts), ignoredBlock(scan, acts)].filter((node) => node !== null); - if (count || edits.length) { + if (count) panel.append(said("Press a plate to merge or split it.", "map-scan-note", "scan edits")); + if (edits.length) { const loose = looseGroups(scan.loose_files, doc.parts).length + looseGroups(scan.loose_tests, doc.parts).length; const summary = loose ? `Adjust the grouping (optional) · ${loose} loose ${loose === 1 ? "folder" : "folders"}` : "Adjust the grouping (optional)"; - const note = count ? [said("Press a plate to merge or split it.", "map-scan-note", "scan edits")] : []; - panel.append(fold("scan adjust", summary, "Show the folders no part holds yet, and the copies left out; Draft the map needs none of it", [...note, ...edits])); + panel.append(fold(`${state.project} scan adjust`, summary, "Show the folders no part holds yet, and the copies left out; Draft the map needs none of it", edits)); } // Without `claude` the copy-prompt leads, open (#753, story 12); with it, the prompt waits in a fold under Draft the map. const draft = draftBlock(count, scan.claude, acts); - if (scan.claude) panel.append(draft, fold("scan prompt fold", "Or use your own agent", "Show a prompt to paste into your own agent in the project, instead of Draft the map", [promptBlock(scan.map, false)])); + if (scan.claude) panel.append(draft, fold(`${state.project} scan prompt fold`, "Or use your own agent", "Show a prompt to paste into your own agent in the project, instead of Draft the map", [promptBlock(scan.map, true)])); else panel.append(promptBlock(scan.map, true), draft); return panel; } diff --git a/ui/style.css b/ui/style.css index 53696905..86ee7e33 100644 --- a/ui/style.css +++ b/ui/style.css @@ -753,7 +753,7 @@ body.panel-open .map-empty { inset-inline-start: calc(var(--inset) + var(--panel .map-scan-fold[open] > summary::before { rotate: 90deg; } .map-scan-fold > summary:hover { color: var(--fg); } .map-scan-fold[open] > summary { color: var(--fg); margin-block-end: var(--sp-3); } -.map-scan-fold .map-scan-set + .map-scan-set { margin-block-start: var(--sp-4); } +.map-scan-fold > :not(summary) + :not(summary) { margin-block-start: var(--sp-4); } @media (prefers-reduced-motion: no-preference) { .map-scan-fold > summary::before { transition: rotate 0.15s; } } .map-scan-loose { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--sp-1) var(--sp-2); } .map-scan-loose { margin-inline-start: calc(var(--depth, 0) * var(--sp-5)); } From 6ca8c285d0b2316ef447b6047da87df8d68c264b Mon Sep 17 00:00:00 2001 From: Daniel Rispler Date: Sat, 28 Nov 2026 19:12:15 +0200 Subject: [PATCH 3/4] Studio map: the scan panel says one line and recommends Draft the map MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The panel was title, four lines of prose, a languages line and a hint before the button. It is now the title, one line ("Claude can draft it from these N parts."), Draft the map with "Recommended · about N minutes", and two closed folds: "Adjust parts first" (the plate hint, the languages line and the edits) and "Use your own agent instead". Co-Authored-By: Claude Opus 5.5 --- docs/studio/behaviour/map.md | 2 +- scripts/snap/fixtures-map.ts | 9 ++++----- ui/map-scan.ts | 31 ++++++++++++++++--------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/studio/behaviour/map.md b/docs/studio/behaviour/map.md index 63aa79fa..f5069057 100644 --- a/docs/studio/behaviour/map.md +++ b/docs/studio/behaviour/map.md @@ -260,7 +260,7 @@ At most 15 parts: while there are more, the deepest level's sibling folders fold A git repository whose map status is the empty state, with no map on the default branch, in the checkout or waiting on a PR, opens on the scan screen (`ui/map-scan.ts`, `server/src/map_scan.rs`, ticket #760), never a folder in no git repository or an Unreadable map. The page asks `map_scan` once each time the project's map opens, and says "Scanning this repository's folders…" until it answers. The server scans the main checkout, runs `system_map::check_text` on the skeleton in memory and adds the edges it computes to the skeleton as `import` links with no reason, one per pair of parts in the edge's direction; it answers with that map's text, each part's tracked file count, `read_languages`, `unread_languages`, and whether the runner would find `claude`. Nothing is written and no token is spent. -The canvas draws the skeleton's parts as grey plates (`.plate.draft`), each with its name and its folder and file count, and the links as lines from rim to rim. The plates are placed afresh on each draw and fitted to the canvas, with no fog, badges, footprints or marks, and no drag, pan or saved position. Beside them, the panel says the project has no `system-map.json` on its default branch and the teaching sentence, how many parts the scan proposes, then the languages line: the read languages with "links computed", then the unread ones with "no reader yet" ("TypeScript and Go: links computed. Ruby: no reader yet"; with none read, "no reader yet, so no links are drawn"). Then the optional edits, in a fold that starts closed for each project ("Adjust the grouping (optional)", with the count of loose folders), so a repository with many loose folders does not push the button down; with the fold open, the button keeps to the panel's foot. **Draft the map** follows, with a time hint of a quarter of a minute a part, a minute at least, and "Uses your Claude Code plan", never a dollar figure; the drafting run it starts is the Map draft's (#762). When `claude` is found the copy-prompt sits under it in a closed fold, "Or use your own agent"; when it is not found the button is muted (`aria-disabled`) with a one-line reason, and the copy-prompt comes before it, open. The copy-prompt carries the skeleton as JSON and asks the user's own agent to write `system-map.json` at the main checkout's root, fill each part's name, caption and purpose from its files, and run `npx plotkeeper map check` until it passes; once the file is there, the window's next focus reads it from the checkout and draws the map in the scan's place. A scan that fails (git cannot list the files) leaves the plain "No map yet" screen and its prompt (#669). Below 1007 px the panel sits under the canvas. +The canvas draws the skeleton's parts as grey plates (`.plate.draft`), each with its name and its folder and file count, and the links as lines from rim to rim. The plates are placed afresh on each draw and fitted to the canvas, with no fog, badges, footprints or marks, and no drag, pan or saved position. Beside them, the panel is kept short: the title "No map yet" and one line, "Claude can draft it from these N parts." ("Give the prompt below to your own agent." without `claude`; "The scan found no code to propose parts from." with no parts). Then a fold that starts closed for each project, "Adjust parts first" with the count of loose folders, holding "Press a plate to merge or split it.", the languages line (the read languages with "links computed", then the unread ones with "no reader yet": "TypeScript and Go: links computed. Ruby: no reader yet"; with none read, "no reader yet, so no links are drawn") and the optional edits; with the fold open, the button keeps to the panel's foot. **Draft the map** follows, with "Recommended · about N minutes" (a quarter of a minute a part, a minute at least), and its hover says it runs on the Claude Code plan, never a dollar figure; the drafting run it starts is the Map draft's (#762). With `claude` found the copy-prompt sits under it in a closed fold, "Use your own agent instead"; when it is not found the button is muted (`aria-disabled`), with no time hint, and "Needs the claude CLI, which is not on your PATH.", and the copy-prompt comes before it, open. The copy-prompt carries the skeleton as JSON and asks the user's own agent to write `system-map.json` at the main checkout's root, fill each part's name, caption and purpose from its files, and run `npx plotkeeper map check` until it passes; once the file is there, the window's next focus reads it from the checkout and draws the map in the scan's place. A scan that fails (git cannot list the files) leaves the plain "No map yet" screen and its prompt (#669). Below 1007 px the panel sits under the canvas. ### Editing the skeleton diff --git a/scripts/snap/fixtures-map.ts b/scripts/snap/fixtures-map.ts index 060ea3d9..72cc8519 100644 --- a/scripts/snap/fixtures-map.ts +++ b/scripts/snap/fixtures-map.ts @@ -822,7 +822,7 @@ export const mapFresh = (): Fixture => /** * A git repository without a map opens on the free scan (#753, ticket #760): its parts as grey plates, each with its folder and file count, no * fog, badges or footprints, the computed import links as lines, the languages line, Draft the map with its time hint, and the copy-prompt that - * carries the skeleton. Nothing on it is a colour, and the teaching sentence follows the "no system-map.json" line. + * carries the skeleton. Nothing on it is a colour, and one lead line follows the title. */ export const mapScan = (): Fixture => mapBaseOf(` @@ -846,13 +846,12 @@ export const mapScan = (): Fixture => } const languages = screen.querySelector(".map-scan-languages")?.textContent; if (languages !== "TypeScript and Go: links computed. Ruby: no reader yet") log("snap:fail the languages line says " + languages); - const lines2 = [...screen.querySelectorAll(".empty")].map((p) => p.textContent); - const at = lines2.findIndex((line) => line.includes("has no system-map.json")); - if (at < 0 || lines2[at + 1] !== "A map names your parts and their rules; changes light them up.") log("snap:fail no teaching sentence after the no-map line: " + JSON.stringify(lines2)); + const lead = screen.querySelector(".map-empty-title + .empty")?.textContent; + if (lead !== "Claude can draft it from these 3 parts.") log("snap:fail the lead line says " + JSON.stringify(lead)); const draft = [...screen.querySelectorAll("button")].find((b) => b.textContent === "Draft the map"); if (!draft || draft.getAttribute("aria-disabled") === "true") return log("snap:fail Draft the map is missing or muted with claude found"); const time = screen.querySelector(".map-scan-time")?.textContent ?? ""; - if (time !== "About 1 minute · Uses your Claude Code plan") log("snap:fail the time hint says " + JSON.stringify(time)); + if (time !== "Recommended · about 1 minute") log("snap:fail the time hint says " + JSON.stringify(time)); if (screen.textContent.includes("$")) log("snap:fail the scan screen shows a dollar figure"); const prompt = screen.querySelector(".map-draft"); if (!prompt?.textContent.includes('"src/lib/"') || !prompt.textContent.includes("npx plotkeeper map check")) log("snap:fail the copy-prompt lacks the skeleton or the check: " + prompt?.textContent); diff --git a/ui/map-scan.ts b/ui/map-scan.ts index 56d5ada5..d87b3502 100644 --- a/ui/map-scan.ts +++ b/ui/map-scan.ts @@ -21,7 +21,6 @@ export type ScanActs = { edit: (edit: ScanEdit) => void; note: string | null; dr // The gutter kept around the plates when they are fitted to the canvas: `--map-gutter` in tokens.css. const gutter = 32; -const name = (path: string) => path.split("/").filter(Boolean).pop() ?? path; const filesWord = (n: number) => `${n} ${n === 1 ? "file" : "files"}`; // "a/, b/ and c/". const listed = (items: string[]) => (items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`); @@ -303,9 +302,10 @@ function draftBlock(parts: number, claude: boolean, acts: ScanActs): HTMLElement if (!isUnavailable(button)) acts.draft(); }); button.dataset.key = "scan draft button"; - const why = claude ? null : "Draft the map needs the claude CLI, which plotkeeper did not find on your PATH. Give the prompt to your own agent instead."; - availability(button, "Name and describe these parts with Claude Code, in the background; nothing is written until you accept", why); - block.append(button, text("p", `${draftTime(parts)} · Uses your Claude Code plan`, "map-scan-time")); + const why = claude ? null : "Needs the claude CLI, which is not on your PATH."; + availability(button, "Name and describe these parts with Claude Code, in the background, on your Claude Code plan; nothing is written until you accept", why); + block.append(button); + if (claude) block.append(text("p", `Recommended · ${draftTime(parts).toLowerCase()}`, "map-scan-time")); if (why) block.append(text("p", why, "map-scan-why")); if (acts.refused) { const refused = text("p", `Draft the map did not start: ${acts.refused}`, "map-scan-why"); @@ -329,7 +329,7 @@ function promptBlock(skeleton: string, leads: boolean): HTMLElement { const copy = copyButton("Copy the prompt", "Copy this prompt, to paste into your own agent in the project", () => row.querySelector("pre")?.textContent ?? prompt); copy.dataset.key = "scan copy"; row.append(pre, copy); - block.append(text("p", leads ? "Give this to your own agent in the project:" : "Or give this to your own agent in the project:", "empty"), row); + block.append(text("p", leads ? "Paste into your agent in the project:" : "Or paste into your agent in the project:", "empty"), row); return block; } @@ -345,12 +345,12 @@ function panelOf(state: MapState, doc: Doc, scan: MapScan, acts: ScanActs): HTML }; panel.append( said("No map yet", "map-empty-title", "scan title"), - said(`${name(state.project)} has no system-map.json on ${state.reference ?? "the default branch"}.`, "empty", "scan none"), - said("A map names your parts and their rules; changes light them up.", "empty", "scan teach"), - said(count ? `A free scan of its folders proposes ${count === 1 ? "this part" : `these ${count} parts`}, with the links its imports show. Nothing is written until you draft.` : "A free scan of its folders found no code to propose parts from.", "empty", "scan proposes"), + said( + !count ? "The scan found no code to propose parts from." : scan.claude ? `Claude can draft it from these ${count === 1 ? "part" : `${count} parts`}.` : "Give the prompt below to your own agent.", + "empty", + "scan lead", + ), ); - const languages = languagesLine(scan.read_languages, scan.unread_languages); - if (languages) panel.append(said(languages, "map-scan-languages", "scan languages")); if (acts.note) { const note = said(`That change did not apply: ${acts.note}. Try it again, or draft the map as it is.`, "map-scan-why", "scan failed"); note.setAttribute("role", "status"); @@ -358,15 +358,16 @@ function panelOf(state: MapState, doc: Doc, scan: MapScan, acts: ScanActs): HTML } // The edits are optional (#753, story 10): Draft the map needs none of them, so they wait in a closed fold, and the button stays in view. const edits = [ignoreBlock(scan, acts), looseBlock("files", scan.loose_files, doc, acts), looseBlock("tests", scan.loose_tests, doc, acts), ignoredBlock(scan, acts)].filter((node) => node !== null); - if (count) panel.append(said("Press a plate to merge or split it.", "map-scan-note", "scan edits")); - if (edits.length) { + const languages = languagesLine(scan.read_languages, scan.unread_languages); + const about = [count ? said("Press a plate to merge or split it.", "map-scan-note", "scan edits") : null, languages ? said(languages, "map-scan-languages", "scan languages") : null].filter((node) => node !== null); + if (edits.length || about.length) { const loose = looseGroups(scan.loose_files, doc.parts).length + looseGroups(scan.loose_tests, doc.parts).length; - const summary = loose ? `Adjust the grouping (optional) · ${loose} loose ${loose === 1 ? "folder" : "folders"}` : "Adjust the grouping (optional)"; - panel.append(fold(`${state.project} scan adjust`, summary, "Show the folders no part holds yet, and the copies left out; Draft the map needs none of it", edits)); + const summary = loose ? `Adjust parts first · ${loose} loose ${loose === 1 ? "folder" : "folders"}` : "Adjust parts first"; + panel.append(fold(`${state.project} scan adjust`, summary, "Show the folders no part holds yet, and the copies left out; Draft the map needs none of it", [...about, ...edits])); } // Without `claude` the copy-prompt leads, open (#753, story 12); with it, the prompt waits in a fold under Draft the map. const draft = draftBlock(count, scan.claude, acts); - if (scan.claude) panel.append(draft, fold(`${state.project} scan prompt fold`, "Or use your own agent", "Show a prompt to paste into your own agent in the project, instead of Draft the map", [promptBlock(scan.map, true)])); + if (scan.claude) panel.append(draft, fold(`${state.project} scan prompt fold`, "Use your own agent instead", "Show a prompt to paste into your own agent in the project, instead of Draft the map", [promptBlock(scan.map, true)])); else panel.append(promptBlock(scan.map, true), draft); return panel; } From 213f4741fc788c4627a0201ba595a887ce4d6c88 Mon Sep 17 00:00:00 2001 From: Daniel Rispler Date: Sat, 28 Nov 2026 19:48:07 +0200 Subject: [PATCH 4/4] Studio map: the scan screen is a centred card, its edits a drawer by recommendation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Daniel picked the centre card from three prototyped layouts (branch prototype/map-scan-variants). The scan's plates fill the canvas under a card: "No map yet", one line, Draft the map with "Recommended · about N minutes", and two openers. "Adjust parts (optional)" opens a drawer that offers the edits by recommendation, one row a top-level folder (`looseAreas`, replacing `looseGroups` and its parent rows, #790): folders with no code and the copies as chips with one "Leave out these N", the code no part holds with a part picker that applies on change, and the folders left out with Undo. "Use your own agent" opens the copy-prompt's drawer; without claude it is the card's strong button. Co-Authored-By: Claude Opus 5.5 --- docs/studio/behaviour/map.md | 15 +- scripts/snap/fixtures-map.ts | 228 +++++++++------------- scripts/snap/fixtures.ts | 6 +- ui/map-model.ts | 52 ++--- ui/map-scan.ts | 368 ++++++++++++++++++----------------- ui/style.css | 70 ++++--- ui/tests/map.test.mjs | 49 ++--- 7 files changed, 369 insertions(+), 419 deletions(-) diff --git a/docs/studio/behaviour/map.md b/docs/studio/behaviour/map.md index f5069057..17aec561 100644 --- a/docs/studio/behaviour/map.md +++ b/docs/studio/behaviour/map.md @@ -260,15 +260,20 @@ At most 15 parts: while there are more, the deepest level's sibling folders fold A git repository whose map status is the empty state, with no map on the default branch, in the checkout or waiting on a PR, opens on the scan screen (`ui/map-scan.ts`, `server/src/map_scan.rs`, ticket #760), never a folder in no git repository or an Unreadable map. The page asks `map_scan` once each time the project's map opens, and says "Scanning this repository's folders…" until it answers. The server scans the main checkout, runs `system_map::check_text` on the skeleton in memory and adds the edges it computes to the skeleton as `import` links with no reason, one per pair of parts in the edge's direction; it answers with that map's text, each part's tracked file count, `read_languages`, `unread_languages`, and whether the runner would find `claude`. Nothing is written and no token is spent. -The canvas draws the skeleton's parts as grey plates (`.plate.draft`), each with its name and its folder and file count, and the links as lines from rim to rim. The plates are placed afresh on each draw and fitted to the canvas, with no fog, badges, footprints or marks, and no drag, pan or saved position. Beside them, the panel is kept short: the title "No map yet" and one line, "Claude can draft it from these N parts." ("Give the prompt below to your own agent." without `claude`; "The scan found no code to propose parts from." with no parts). Then a fold that starts closed for each project, "Adjust parts first" with the count of loose folders, holding "Press a plate to merge or split it.", the languages line (the read languages with "links computed", then the unread ones with "no reader yet": "TypeScript and Go: links computed. Ruby: no reader yet"; with none read, "no reader yet, so no links are drawn") and the optional edits; with the fold open, the button keeps to the panel's foot. **Draft the map** follows, with "Recommended · about N minutes" (a quarter of a minute a part, a minute at least), and its hover says it runs on the Claude Code plan, never a dollar figure; the drafting run it starts is the Map draft's (#762). With `claude` found the copy-prompt sits under it in a closed fold, "Use your own agent instead"; when it is not found the button is muted (`aria-disabled`), with no time hint, and "Needs the claude CLI, which is not on your PATH.", and the copy-prompt comes before it, open. The copy-prompt carries the skeleton as JSON and asks the user's own agent to write `system-map.json` at the main checkout's root, fill each part's name, caption and purpose from its files, and run `npx plotkeeper map check` until it passes; once the file is there, the window's next focus reads it from the checkout and draws the map in the scan's place. A scan that fails (git cannot list the files) leaves the plain "No map yet" screen and its prompt (#669). Below 1007 px the panel sits under the canvas. +The canvas draws the skeleton's parts as grey plates (`.plate.draft`), each with its name and its folder and file count, and the links as lines from rim to rim. The plates are placed afresh on each draw and fitted to the canvas, with no fog, badges, footprints or marks, and no drag, pan or saved position. A card sits centred on the canvas over the plates (`.map-scan-card`), which keep their full contrast. The card holds the title "No map yet", one line, "Claude can draft it from these N parts." ("Give the prompt to your own agent." without `claude`; "The scan found no code to propose parts from." with no parts), **Draft the map** with "Recommended · about N minutes" under it (a quarter of a minute a part, a minute at least; its hover says it runs on the Claude Code plan, never a dollar figure), and two openers: "Adjust parts (optional)" and "Use your own agent". Each opens a drawer at the screen's right edge (a light-dismissed popover with its title and Close); the drafting run Draft the map starts is the Map draft's (#762). When `claude` is not found, "Use your own agent" is the card's strong button above Draft the map, which is muted (`aria-disabled`), with no time hint, and "Needs the claude CLI, which is not on your PATH." under it. The copy-prompt carries the skeleton as JSON and asks the user's own agent to write `system-map.json` at the main checkout's root, fill each part's name, caption and purpose from its files, and run `npx plotkeeper map check` until it passes; once the file is there, the window's next focus reads it from the checkout and draws the map in the scan's place. A scan that fails (git cannot list the files) leaves the plain "No map yet" screen and its prompt (#669). Below 1007 px the panel sits under the canvas. ### Editing the skeleton -Before drafting, the person may fix the scan's grouping on the scan screen (ticket #761, stories 7-10); none of it is needed, and nothing is written. The skeleton is a value the page holds: each edit sends it with the edit to the server (`map_scan_edit`), which makes the edit in memory, runs `check_text` on the result and answers with the same reply as `map_scan`, its links computed again. Edits go one after another, each with the skeleton the one before left; an edit that fails keeps the skeleton and says why in the panel. Draft the map starts from the skeleton as the page holds it then (#762). The reply also carries the scan's reference-copy candidates, each ticked while the skeleton's `ignored` holds it, the loose files and tests (tracked files, code or not, that no part owns and no ignored folder holds), and, by part, the subfolders Split by subfolders would make parts of. +Before drafting, the person may fix the scan's grouping in the Adjust drawer and on the plates (ticket #761, stories 7-10); none of it is needed, and nothing is written. The skeleton is a value the page holds: each edit sends it with the edit to the server (`map_scan_edit`), which makes the edit in memory, runs `check_text` on the result and answers with the same reply as `map_scan`, its links computed again. Edits go one after another, each with the skeleton the one before left; an edit that fails keeps the skeleton and says why in the panel. Draft the map starts from the skeleton as the page holds it then (#762). The reply also carries the scan's reference-copy candidates, each ticked while the skeleton's `ignored` holds it, the loose files and tests (tracked files, code or not, that no part owns and no ignored folder holds), and, by part, the subfolders Split by subfolders would make parts of. + +The Adjust drawer says "Optional. The draft works without this." and offers the edits by recommendation, one row a top-level folder of the loose files and tests together (the root's own files are one row, shown only when they hold code): + +- **Recommended: leave out.** The folders with no code (no file a reader reads, by extension) whose leaving out the server allows, and the copies the scan found and left unticked, as chips with their file count, and one button, "Leave out these N", that sends an `ignore-folder` edit for each folder and an `ignore` edit for each copy, one after another. A chip's × keeps that folder in the map for the session: it moves down among the code. The root, and a folder holding a part's path, are never suggested, as `ignored` wins over the parts' paths. +- **Code no part holds yet.** One row a top-level folder, with its file count ("· no code" when it holds none) and a part picker: "Leave as is", "New part" or any part. Choosing one sends `home` with the folder's files at once, no Add to press; the files go to the part chosen, or to a new part named after their folder ("Root" for the root's own files): as their folder whole when no part's path is inside it, else each by its own path. +- **Left out.** The folders left out and the copies ticked, as chips, each with Undo, which takes it out of `ignored` and leaves its files loose again, making no part. After a press the focus goes to the first left-out folder's Undo, to the next row's picker, or to Leave out, else to the drawer's Close. + +The drawer's foot holds "Tip: press a plate on the map to merge or split it." and the languages line. -- **Ignore.** The panel lists the candidates as checkboxes, ticked as the scan set them. Ticking one adds it to `ignored` and drops every part path inside it, a part left with none going; unticking it takes it out of `ignored`, and the folder, when no part's path covers it and it holds code, becomes a part of its own. -- **Loose files and tests.** One row a folder, naming its files (three, then "and N more"), with a choice of "A new part" or any part and Add. The files go to the part chosen, or to a new part named after their folder ("Root" for the root's own files): as their folder whole when no part's path is inside it, else each by its own path. -- **Ignore a loose folder.** Each loose row offers Ignore beside Add (`ignore-folder`): its folder goes into the skeleton's `ignored`, so its files leave the loose lists and the check needs no part for them, `check_text` and `plotkeeper map check` alike. Ignore is muted with its reason, and the server refuses it, on the root and on a folder that holds a part's files, as `ignored` wins over the parts' paths. The folders so ignored (the skeleton's `ignored` that are not candidates) are listed under Ignored folders, each with Unignore, which takes the folder out of `ignored` and leaves its files loose again, making no part. After either, the focus goes to that folder's Unignore, or to the first Ignore of its rows again. A folder with no loose files of its own that holds two or more rows (folders, or other parent rows) gets a **parent row** above them, indented, at every level (#790): it shows the folder and how many rows are right below it, and has Ignore alone, no Give to or Add, muted as a row's is when the folder holds a part's files. One press ignores the whole folder, and the server drops the `ignored` patterns inside it, so its Unignore brings every folder back, one ignored earlier on its own too. A folder with one row below it gets no parent row, since that row's Ignore does the job. - **Merge into… and Split by subfolders.** A plate's press opens its actions beside it. Merge into… moves the part's paths into the part chosen. Split by subfolders makes a part of each subfolder holding the part's code; the part keeps its file paths, the files right in its folders and the subfolders with no code, and goes when it keeps nothing. It is offered when that leaves two parts owning code, else it is muted with the reason. The parts' paths never nest, so which part owns a file never hangs on their order. A new part's id is its folder's name, with its parents' names added while the id is taken, then a number; its name is the folder's words. Each answer redraws the plates and lines; the panel is patched in place, so it stays open at its scroll and a focused box or button keeps the focus, and after a merge or a split the focus goes to the plate merged into or split. A draw of the same scan (a focus, a session's event) keeps the plates, and an open plate's actions with them. diff --git a/scripts/snap/fixtures-map.ts b/scripts/snap/fixtures-map.ts index 72cc8519..2e849c39 100644 --- a/scripts/snap/fixtures-map.ts +++ b/scripts/snap/fixtures-map.ts @@ -862,20 +862,30 @@ export const mapScan = (): Fixture => copy.click(); await wait(150); if (window.__copied !== prompt.textContent) log("snap:fail the clipboard holds " + JSON.stringify(window.__copied) + ", not the prompt"); - // The skeleton's optional edits (#761): the copies to ignore, ticked as the scan set them, and the loose files and tests by folder, each - // offered a part or a new part. - const checks = [...screen.querySelectorAll(".map-scan-check")].map((row) => [row.textContent, row.querySelector("input[type=checkbox]")?.checked]); - if (JSON.stringify(checks) !== JSON.stringify([["reference-copy/", false], ["vendor/", true]])) log("snap:fail the ignore checkboxes: " + JSON.stringify(checks)); - const legends = [...screen.querySelectorAll(".map-scan-set legend")].map((l) => l.textContent); - if (JSON.stringify(legends) !== JSON.stringify(["Copies and vendored code", "Loose files", "Loose tests"])) log("snap:fail the edits' groups: " + JSON.stringify(legends)); - const rows = [...screen.querySelectorAll(".map-scan-loose")].map((row) => row.querySelector(".map-scan-where").textContent); - if (JSON.stringify(rows) !== JSON.stringify(["src/ · index.ts and main.ts", "tests/ · app.test.ts"])) log("snap:fail the loose rows: " + JSON.stringify(rows)); - const offered = [...(screen.querySelector(".map-scan-loose select")?.options ?? [])].map((o) => o.textContent); - if (JSON.stringify(offered) !== JSON.stringify(["A new part", "App", "Cli", "Lib"])) log("snap:fail a loose row offers " + JSON.stringify(offered)); - for (const pick of screen.querySelectorAll(".map-scan-panel select")) if (!pick.labels?.length) log("snap:fail a select has no label"); - if (draft.compareDocumentPosition(screen.querySelector(".map-scan-set")) & Node.DOCUMENT_POSITION_FOLLOWING) log("snap:fail the edits come after Draft the map"); + // The card sits over the dimmed plates, the drawers closed until pressed. + const card = screen.querySelector(".map-scan-card"); + const box = card?.getBoundingClientRect(); + if (!box || Math.abs((box.left + box.right) / 2 - (area.left + area.right) / 2) > 2) log("snap:fail the card is not centred on the canvas"); + if (screen.querySelector(".map-scan-drawer:popover-open")) log("snap:fail a drawer is open before any press"); + if (draft.compareDocumentPosition(card.querySelector(".map-scan-links")) & Node.DOCUMENT_POSITION_PRECEDING) log("snap:fail the drawers' openers come before Draft the map"); frame("on the scan"); checkColours("on the scan"); + // The Adjust drawer (#761): the copy to leave out as a chip, the loose code by top-level folder with a part picker, the copy left out. + [...card.querySelectorAll(".map-scan-links button")].find((b) => b.textContent === "Adjust parts (optional)")?.click(); + await wait(100); + const adjust = screen.querySelector(".map-scan-drawer:popover-open"); + if (!adjust) return log("snap:fail Adjust parts opens no drawer"); + const chips = [...adjust.querySelectorAll(".map-scan-sec[data-key='scan leave'] .map-scan-chip")].map((c) => c.querySelector("code").textContent); + if (JSON.stringify(chips) !== JSON.stringify(["reference-copy"])) log("snap:fail the leave-out chips: " + JSON.stringify(chips)); + const rows = [...adjust.querySelectorAll(".map-scan-row")].map((row) => [row.querySelector(".map-scan-name").textContent, row.querySelector(".map-scan-count").textContent]); + if (JSON.stringify(rows) !== JSON.stringify([["src", "2 files"], ["tests", "1 file"]])) log("snap:fail the loose rows: " + JSON.stringify(rows)); + const offered = [...(adjust.querySelector(".map-scan-pick")?.options ?? [])].map((o) => o.textContent); + if (JSON.stringify(offered) !== JSON.stringify(["Leave as is", "New part", "App", "Cli", "Lib"])) log("snap:fail a loose row offers " + JSON.stringify(offered)); + for (const pick of adjust.querySelectorAll("select")) if (!pick.labels?.length) log("snap:fail a select has no label"); + const gone = [...adjust.querySelectorAll(".map-scan-chip.out code")].map((c) => c.textContent); + if (JSON.stringify(gone) !== JSON.stringify(["vendor"])) log("snap:fail the left-out chips: " + JSON.stringify(gone)); + frame("with the Adjust drawer open"); + checkColours("with the Adjust drawer open"); log("base ok");`, { map_state: mapState({ status: "none", source: null, from: null }), map_scan: mapScanOf() }); // The base scan with App merged into Lib: Lib holds both folders, and Cli's line to Lib is the one left. const mergedScan = (() => { @@ -889,23 +899,14 @@ const mergedScan = (() => { /** * Merge into… on a scan's plate (#753, story 9; ticket #761): App's press opens its actions beside it, with the other parts to merge into and * Split by subfolders muted, as its folder has none. Merging it into Lib sends the held skeleton and the edit; the answer redraws the plates - * and lines (Cli's line to Lib alone) while the panel stays open, the same node at the same scroll, and focus lands on Lib's plate. A tick - * in the panel then keeps its focus across the redraw. + * and lines (Cli's line to Lib alone) while the card stays, the same node, and focus lands on Lib's plate. Leave out in the drawer then keeps + * the focus in the drawer across the redraw. */ export const mapScanMerge = (): Fixture => mapBaseOf(` const screen = document.querySelector("#map .map-scan"); if (!screen) return log("snap:fail no scan screen"); const side = screen.querySelector(".map-scan-panel"); - // The edits wait in a closed fold: open it, as the person would. - const adjust = side.querySelector(".map-scan-fold"); - if (!adjust || adjust.open) return log("snap:fail the edits are not in a closed fold"); - adjust.open = true; - await wait(50); - side.style.maxBlockSize = "320px"; - side.scrollTop = 120; - const scrolled = side.scrollTop; - if (!(scrolled > 0)) log("snap:fail the panel does not scroll, so its scroll is not tested"); window.__sent = []; const real = window.fetch; window.fetch = (url, init) => { @@ -938,7 +939,6 @@ export const mapScanMerge = (): Fixture => const after = document.querySelector("#map .map-scan"); if (after !== screen) log("snap:fail the scan screen was drawn anew"); if (after.querySelector(".map-scan-panel") !== side) log("snap:fail the panel was drawn anew, not kept open"); - if (side.scrollTop !== scrolled) log("snap:fail the panel's scroll moved from " + scrolled + " to " + side.scrollTop); const plates = [...after.querySelectorAll(".plate")].map((p) => p.dataset.id); if (JSON.stringify(plates) !== JSON.stringify(["cli", "lib"])) log("snap:fail the plates after the merge: " + JSON.stringify(plates)); const lines = [...after.querySelectorAll(".map-links line.link")].map((l) => l.dataset.link); @@ -948,159 +948,125 @@ export const mapScanMerge = (): Fixture => if (lib?.querySelector(".plate-caption")?.textContent !== "src/lib/ +1 · 42 files") log("snap:fail Lib's plate says " + lib?.textContent); if (document.activeElement !== lib?.querySelector(".plate-open")) log("snap:fail focus is not on the part merged into, but on " + document.activeElement?.outerHTML.slice(0, 80)); if (!side.querySelector(".map-draft")?.textContent.includes('"src/app/"') || side.querySelector(".map-scan-proposes")) log("snap:fail the copy-prompt lost the merged folder"); - const offered = [...side.querySelector(".map-scan-loose select").options].map((o) => o.textContent); - if (JSON.stringify(offered) !== JSON.stringify(["A new part", "Cli", "Lib"])) log("snap:fail a loose row still offers " + JSON.stringify(offered)); + const offered = [...side.querySelector(".map-scan-pick").options].map((o) => o.textContent); + if (JSON.stringify(offered) !== JSON.stringify(["Leave as is", "New part", "Cli", "Lib"])) log("snap:fail a loose row still offers " + JSON.stringify(offered)); if (!side.textContent.includes("these 2 parts")) log("snap:fail the panel still counts three parts"); frame("after the merge"); checkColours("after the merge"); - // A tick in the panel is sent, and the redraw keeps the box focused. - const box = side.querySelector(".map-scan-check input"); - box.focus(); - box.click(); + // Leave out in the drawer is sent, and the redraw keeps the focus in the drawer. + [...side.querySelectorAll(".map-scan-links button")].find((b) => b.textContent === "Adjust parts (optional)")?.click(); + await wait(100); + const leave = side.querySelector(".map-scan-drawer:popover-open .map-scan-all"); + if (!leave) return log("snap:fail no Leave out in the open drawer"); + leave.focus(); + leave.click(); await wait(300); const tick = window.__sent[1]; - if (tick?.edit?.kind !== "ignore" || tick.edit.folder !== "reference-copy/" || tick.edit.ignored !== true) log("snap:fail the tick sent " + JSON.stringify(tick)); - if (document.activeElement !== box || !box.isConnected) log("snap:fail the tick's box lost its focus in the redraw"); + if (tick?.edit?.kind !== "ignore" || tick.edit.folder !== "reference-copy/" || tick.edit.ignored !== true) log("snap:fail Leave out sent " + JSON.stringify(tick)); + if (!document.activeElement?.closest(".map-scan-drawer:popover-open")) log("snap:fail the focus left the drawer in the redraw: " + document.activeElement?.outerHTML.slice(0, 80)); log("base ok");`, { map_state: mapState({ status: "none", source: null, from: null }), map_scan: mapScanOf(), map_scan_edit: mapScanOf({ map: mergedScan, files: { cli: 1, lib: 42 } }), }); -// The base scan with the loose tests' folder ignored: no loose tests are left, and tests/ is in the skeleton's `ignored`. -const testsIgnored = (() => { +// The base scan with docs/ and the copy left out: docs/ and reference-copy/ join vendor/ in the skeleton's `ignored`. +const leftOut = (() => { const map = JSON.parse(mapScanOf().map); - map.ignored = ["tests/", "vendor/"]; + map.ignored = ["docs/", "reference-copy/", "vendor/"]; return JSON.stringify(map); })(); +const docsFiles = ["docs/a.md", "docs/b.md", "src/index.ts", "src/main.ts"]; /** - * Ignore on a loose row (#753): each folder's row offers Ignore beside Add, muted with its reason on src/, whose ignoring would take the parts' - * files, so its press sends nothing. Ignore on tests/ sends the held skeleton with the edit; the answer leaves no loose tests and lists tests/ - * under Ignored folders with Unignore, which takes the focus, and whose press sends the edit back. + * Leave out in the Adjust drawer (#753, story 7): docs/, which holds no code, and the copy reference-copy/ are chips under "Recommended: leave + * out"; src/, whose leaving out would take the parts' files, is no chip but a row to give a part. One press sends an edit for each with the + * held skeleton; the answer lists them under "Left out", each with Undo, the focus on docs/'s, whose press sends the edit back. */ export const mapScanIgnore = (): Fixture => mapBaseOf(` const screen = document.querySelector("#map .map-scan"); if (!screen) return log("snap:fail no scan screen"); const side = screen.querySelector(".map-scan-panel"); - // The edits wait in a closed fold: open it, as the person would. - const adjust = side.querySelector(".map-scan-fold"); - if (!adjust || adjust.open) return log("snap:fail the edits are not in a closed fold"); - adjust.open = true; - await wait(50); window.__sent = []; const real = window.fetch; window.fetch = (url, init) => { if (String(url).endsWith("/map_scan_edit")) window.__sent.push(JSON.parse(init.body)); return real(url, init); }; - const hintText = (node) => document.getElementById(node?.getAttribute("interestfor") ?? node?.getAttribute("data-hint") ?? "")?.textContent; - const ignoreOf = (folder) => [...side.querySelectorAll(".map-scan-loose button")].find((b) => b.textContent === "Ignore" && b.closest(".map-scan-loose").querySelector(".map-scan-where code").textContent === folder); - const src = ignoreOf("src/"); - if (src?.getAttribute("aria-disabled") !== "true") return log("snap:fail src/'s Ignore is missing or not muted, though src/ holds the parts"); - if (hintText(src) !== "Ignoring src/ would leave out the files of App, Cli and Lib") log("snap:fail src/'s Ignore says " + JSON.stringify(hintText(src))); - src.click(); + [...side.querySelectorAll(".map-scan-links button")].find((b) => b.textContent === "Adjust parts (optional)")?.click(); await wait(100); - if (window.__sent.length) log("snap:fail a muted Ignore was sent"); - const tests = ignoreOf("tests/"); - if (!tests || tests.getAttribute("aria-disabled") === "true") return log("snap:fail tests/'s Ignore is missing or muted"); - if (tests.type !== "button") log("snap:fail Ignore submits its row's form"); - if (tests.getAttribute("aria-label") !== "Ignore tests/") log("snap:fail tests/'s Ignore is named " + tests.getAttribute("aria-label")); - if (side.querySelector(".map-scan-ignored")) log("snap:fail an ignored folder shows before any Ignore"); - frame("with Ignore on each loose row"); - checkColours("with Ignore on each loose row"); - tests.focus(); - tests.click(); - await wait(300); - const sent = window.__sent[0]; - if (sent?.edit?.kind !== "ignore-folder" || sent.edit.folder !== "tests/" || sent.edit.ignored !== true || !sent.map?.includes('"src/lib/"')) log("snap:fail the Ignore sent " + JSON.stringify(sent)); - if (window.__sent.some((call) => call.edit?.kind === "home")) log("snap:fail Ignore gave the files a part"); - if (document.querySelector("#map .map-scan-panel") !== side) log("snap:fail the panel was drawn anew, not kept open"); - const legends = [...side.querySelectorAll(".map-scan-set legend")].map((l) => l.textContent); - if (JSON.stringify(legends) !== JSON.stringify(["Copies and vendored code", "Loose files", "Ignored folders"])) log("snap:fail the edits' groups after Ignore: " + JSON.stringify(legends)); - const ignored = [...side.querySelectorAll(".map-scan-ignored")].map((row) => row.textContent); - if (JSON.stringify(ignored) !== JSON.stringify(["tests/Unignore"])) log("snap:fail the ignored rows: " + JSON.stringify(ignored)); - const undo = side.querySelector(".map-scan-ignored button"); - if (undo?.getAttribute("aria-label") !== "Unignore tests/") log("snap:fail Unignore is named " + undo?.getAttribute("aria-label")); - if (document.activeElement !== undo) log("snap:fail focus is not on Unignore, but on " + document.activeElement?.outerHTML.slice(0, 80)); - if (!side.querySelector(".map-draft")?.textContent.includes('"tests/"')) log("snap:fail the copy-prompt's skeleton does not ignore tests/"); - frame("after Ignore"); - checkColours("after Ignore"); + const drawer = side.querySelector(".map-scan-drawer:popover-open"); + if (!drawer) return log("snap:fail Adjust parts opens no drawer"); + const chips = [...drawer.querySelectorAll(".map-scan-sec[data-key='scan leave'] .map-scan-chip code")].map((c) => c.textContent); + if (JSON.stringify(chips) !== JSON.stringify(["docs", "reference-copy"])) log("snap:fail the leave-out chips: " + JSON.stringify(chips)); + const rows = [...drawer.querySelectorAll(".map-scan-row .map-scan-name")].map((c) => c.textContent); + if (JSON.stringify(rows) !== JSON.stringify(["src"])) log("snap:fail the rows to give a part: " + JSON.stringify(rows)); + const all = drawer.querySelector(".map-scan-all"); + if (all?.textContent !== "Leave out these 2") return log("snap:fail Leave out says " + all?.textContent); + frame("with the leave-out chips"); + checkColours("with the leave-out chips"); + all.focus(); + all.click(); + await wait(400); + const edits = window.__sent.map((call) => call.edit); + if (JSON.stringify(edits) !== JSON.stringify([{ kind: "ignore-folder", folder: "docs/", ignored: true }, { kind: "ignore", folder: "reference-copy/", ignored: true }])) log("snap:fail Leave out sent " + JSON.stringify(edits)); + if (!window.__sent[0]?.map?.includes('"src/lib/"')) log("snap:fail Leave out did not send the held skeleton"); + if (document.querySelector("#map .map-scan-panel") !== side) log("snap:fail the card was drawn anew, not kept"); + const gone = [...drawer.querySelectorAll(".map-scan-chip.out code")].map((c) => c.textContent); + if (JSON.stringify(gone) !== JSON.stringify(["docs", "reference-copy", "vendor"])) log("snap:fail the left-out chips: " + JSON.stringify(gone)); + if (drawer.querySelector(".map-scan-sec[data-key='scan leave']")) log("snap:fail the leave-out section stays with nothing to leave out"); + const undo = drawer.querySelector(".map-scan-chip.out button"); + if (undo?.getAttribute("aria-label") !== "Put docs/ back in the map") log("snap:fail Undo is named " + undo?.getAttribute("aria-label")); + if (document.activeElement !== undo) log("snap:fail focus is not on docs/'s Undo, but on " + document.activeElement?.outerHTML.slice(0, 80)); + frame("after Leave out"); + checkColours("after Leave out"); + const sentSoFar = window.__sent.length; undo.click(); await wait(300); - const back = window.__sent[1]; - if (back?.edit?.kind !== "ignore-folder" || back.edit.folder !== "tests/" || back.edit.ignored !== false || !back.map?.includes('"tests/"')) log("snap:fail the Unignore sent " + JSON.stringify(back)); + const back = window.__sent[sentSoFar]; + if (back?.edit?.kind !== "ignore-folder" || back.edit.folder !== "docs/" || back.edit.ignored !== false) log("snap:fail Undo sent " + JSON.stringify(back)); log("base ok");`, { map_state: mapState({ status: "none", source: null, from: null }), - map_scan: mapScanOf(), - map_scan_edit: mapScanOf({ map: testsIgnored, loose_tests: [] }), + map_scan: mapScanOf({ loose_files: docsFiles, loose_tests: [] }), + map_scan_edit: mapScanOf({ map: leftOut, loose_files: docsFiles.slice(2), loose_tests: [], ignore_candidates: [{ path: "reference-copy/", ticked: true }, { path: "vendor/", ticked: true }] }), }); -// The loose files of two parent rows (#790): .claude/skills/ over its two folders, and src/, over two folders beside the parts' own. -const parentFiles = [".claude/skills/a/s.md", ".claude/skills/b/s.md", "src/x/x.ts", "src/y/y.ts"]; -const parentIgnored = (() => { - const map = JSON.parse(mapScanOf().map); - map.ignored = [".claude/skills/", "vendor/"]; - return JSON.stringify(map); -})(); /** - * A loose folder holding only folders gets one Ignore (#790): `.claude/skills/` shows a parent row above its two folders' rows, indented, with - * Ignore alone and no Give to or Add, and `src/` shows one muted, since the parts hold files there. The muted press sends nothing; the parent's - * sends `ignore-folder` for `.claude/skills/`, the answer leaves only the `src/` rows, lists the folder under Ignored folders and puts the - * focus on its Unignore, whose press sends the edit back. + * A loose folder given a part in the Adjust drawer (#753, story 8): tests/'s picker sends `home` with its files and the part chosen as soon as + * it changes, with no Add to press; the answer leaves src/ alone among the rows, the focus on its picker. */ -export const mapScanParent = (): Fixture => +export const mapScanGive = (): Fixture => mapBaseOf(` const screen = document.querySelector("#map .map-scan"); if (!screen) return log("snap:fail no scan screen"); const side = screen.querySelector(".map-scan-panel"); - // The edits wait in a closed fold: open it, as the person would. - const adjust = side.querySelector(".map-scan-fold"); - if (!adjust || adjust.open) return log("snap:fail the edits are not in a closed fold"); - adjust.open = true; - await wait(50); window.__sent = []; const real = window.fetch; window.fetch = (url, init) => { if (String(url).endsWith("/map_scan_edit")) window.__sent.push(JSON.parse(init.body)); return real(url, init); }; - const hintText = (node) => document.getElementById(node?.getAttribute("interestfor") ?? node?.getAttribute("data-hint") ?? "")?.textContent; - const rowOf = (folder) => [...side.querySelectorAll(".map-scan-loose")].find((r) => r.querySelector(".map-scan-where code").textContent === folder); - const folders = [...side.querySelectorAll(".map-scan-loose .map-scan-where code")].map((c) => c.textContent); - if (JSON.stringify(folders) !== JSON.stringify([".claude/skills/", ".claude/skills/a/", ".claude/skills/b/", "src/", "src/x/", "src/y/"])) return log("snap:fail the loose rows: " + JSON.stringify(folders)); - const parent = rowOf(".claude/skills/"); - if (!parent?.classList.contains("map-scan-parent") || parent.querySelector("select, .map-scan-pick") || [...parent.querySelectorAll("button")].map((b) => b.textContent).join() !== "Ignore") log("snap:fail the parent row is not an Ignore alone"); - if (!parent.querySelector(".map-scan-names")?.textContent.includes("2 folders")) log("snap:fail the parent says " + parent.textContent); - if (rowOf(".claude/skills/a/").querySelector(".map-scan-parent") || !rowOf(".claude/skills/a/").querySelector("select")) log("snap:fail a folder's row lost its Give to"); - if (parseFloat(getComputedStyle(rowOf(".claude/skills/a/")).marginInlineStart) <= parseFloat(getComputedStyle(parent).marginInlineStart)) log("snap:fail the folders are not indented under their parent"); - const held = rowOf("src/").querySelector("button"); - if (held?.getAttribute("aria-disabled") !== "true" || hintText(held) !== "Ignoring src/ would leave out the files of App, Cli and Lib") log("snap:fail src/'s Ignore: " + JSON.stringify(hintText(held))); - held.click(); + [...side.querySelectorAll(".map-scan-links button")].find((b) => b.textContent === "Adjust parts (optional)")?.click(); await wait(100); - if (window.__sent.length) log("snap:fail a muted Ignore was sent"); - frame("with a parent row"); - checkColours("with a parent row"); - const ignore = parent.querySelector("button"); - if (ignore.getAttribute("aria-label") !== "Ignore .claude/skills/") log("snap:fail the parent's Ignore is named " + ignore.getAttribute("aria-label")); - ignore.focus(); - ignore.click(); + const drawer = side.querySelector(".map-scan-drawer:popover-open"); + if (!drawer) return log("snap:fail Adjust parts opens no drawer"); + if (drawer.querySelector(".map-scan-row button")) log("snap:fail a row to give a part has a button to press"); + const pick = [...drawer.querySelectorAll(".map-scan-row")].find((row) => row.querySelector(".map-scan-name").textContent === "tests")?.querySelector("select"); + if (!pick) return log("snap:fail tests/ has no part picker"); + pick.focus(); + pick.value = "lib"; + pick.dispatchEvent(new Event("change")); await wait(300); const sent = window.__sent[0]; - if (sent?.edit?.kind !== "ignore-folder" || sent.edit.folder !== ".claude/skills/" || sent.edit.ignored !== true) log("snap:fail the Ignore sent " + JSON.stringify(sent)); - if (JSON.stringify([...side.querySelectorAll(".map-scan-loose .map-scan-where code")].map((c) => c.textContent)) !== JSON.stringify(["src/", "src/x/", "src/y/"])) log("snap:fail the rows after Ignore"); - const undo = side.querySelector(".map-scan-ignored button"); - if (undo?.getAttribute("aria-label") !== "Unignore .claude/skills/") log("snap:fail Unignore is named " + undo?.getAttribute("aria-label")); - if (document.activeElement !== undo) log("snap:fail focus is not on Unignore, but on " + document.activeElement?.outerHTML.slice(0, 80)); - frame("after the parent's Ignore"); - undo.click(); - await wait(300); - const back = window.__sent[1]; - if (back?.edit?.kind !== "ignore-folder" || back.edit.folder !== ".claude/skills/" || back.edit.ignored !== false) log("snap:fail the Unignore sent " + JSON.stringify(back)); + if (sent?.edit?.kind !== "home" || sent.edit.part !== "lib" || JSON.stringify(sent.edit.files) !== JSON.stringify(["tests/app.test.ts"])) log("snap:fail the picker sent " + JSON.stringify(sent)); + const rows = [...drawer.querySelectorAll(".map-scan-row .map-scan-name")].map((c) => c.textContent); + if (JSON.stringify(rows) !== JSON.stringify(["src"])) log("snap:fail the rows after giving tests/ a part: " + JSON.stringify(rows)); + if (document.activeElement !== drawer.querySelector(".map-scan-pick")) log("snap:fail focus is not on src/'s picker, but on " + document.activeElement?.outerHTML.slice(0, 80)); + frame("after giving tests/ a part"); log("base ok");`, { map_state: mapState({ status: "none", source: null, from: null }), - map_scan: mapScanOf({ loose_files: parentFiles, loose_tests: [] }), - map_scan_edit: mapScanOf({ map: parentIgnored, loose_files: parentFiles.slice(2), loose_tests: [] }), + map_scan: mapScanOf(), + map_scan_edit: mapScanOf({ loose_tests: [] }), }); -/** Draft the map muted when `claude` is not found (#753, story 12): aria-disabled with its one-line reason, a press starts nothing, and the copy-prompt leads. */ +/** Draft the map muted when `claude` is not found (#753, story 12): aria-disabled with its one-line reason, a press starts nothing, and the copy-prompt's opener leads, as the card's strong button. */ export const mapScanNoClaude = (): Fixture => mapOpened(` const screen = document.querySelector("#map .map-scan"); @@ -1109,8 +1075,8 @@ export const mapScanNoClaude = (): Fixture => if (draft?.getAttribute("aria-disabled") !== "true") return log("snap:fail Draft the map is not muted without claude"); const why = screen.querySelector(".map-scan-why")?.textContent ?? ""; if (!why.includes("claude")) log("snap:fail the muted button gives no reason: " + JSON.stringify(why)); - const prompt = screen.querySelector(".map-draft"); - if (!prompt || !(draft.compareDocumentPosition(prompt) & Node.DOCUMENT_POSITION_PRECEDING)) log("snap:fail the copy-prompt does not lead without claude"); + const own = screen.querySelector(".map-scan-own"); + if (own?.textContent !== "Use your own agent" || !(draft.compareDocumentPosition(own) & Node.DOCUMENT_POSITION_PRECEDING)) log("snap:fail the copy-prompt's opener does not lead without claude"); log("no claude ok");`, { map_state: mapState({ status: "none", source: null, from: null }), map_scan: mapScanOf({ claude: false }) }); /** * The layout follows the payload while the Map view stays open (#760): a repository with no map shows a quiet line while its scan runs, then the @@ -1192,7 +1158,7 @@ export const mapDraftSteps = (): Fixture => const scan = body.querySelector(".map-scan"); if (!scan || scan.classList.contains("map-drafting")) return log("snap:fail the scan does not show first: " + body.textContent.replace(/\\s+/g, " ").slice(0, 200)); // An edit on its way when Draft the map is pressed: the draft starts from the skeleton it leaves. - scan.querySelector(".map-scan-check input").click(); + scan.querySelector(".map-scan-all").click(); button(scan, "Draft the map").click(); await wait(800); const order = sent.map(([c]) => c).filter((c) => c === "map_scan_edit" || c === "map_draft_start"); @@ -1201,7 +1167,7 @@ export const mapDraftSteps = (): Fixture => if (started?.project !== "/w/plotkeeper" || !JSON.parse(started.skeleton ?? "{}").ignored?.includes("reference-copy/")) log("snap:fail Draft the map sent " + JSON.stringify(started)); const screen = body.querySelector(".map-scan.map-drafting"); if (!screen) return log("snap:fail the Map draft does not show after Draft the map: " + body.textContent.replace(/\\s+/g, " ").slice(0, 200)); - if (body.querySelector(".map-scan-check, .map-scan-prompt")) log("snap:fail the scan's edits stay on the Map draft"); + if (body.querySelector(".map-scan-card, .map-scan-prompt")) log("snap:fail the scan's card stays on the Map draft"); if (!document.getElementById("map-legend").hidden) log("snap:fail the map's legend shows on the Map draft"); const states = () => ["app", "cli", "lib"].map((id) => plate(id)?.querySelector(".plate-state")?.textContent ?? "none"); if (JSON.stringify(states()) !== JSON.stringify(["Being written…", "Being written…", "Being written…"])) log("snap:fail the plates being written say " + JSON.stringify(states())); diff --git a/scripts/snap/fixtures.ts b/scripts/snap/fixtures.ts index af36e775..d15293b9 100644 --- a/scripts/snap/fixtures.ts +++ b/scripts/snap/fixtures.ts @@ -7,7 +7,7 @@ import type { Fixture } from "./base.ts"; import { railFixtures } from "./rail-fixtures.ts"; import { list, withSaved } from "./fixtures-shared.ts"; import { alerts, cutText, cutTextStill, hints, listClearLanded, listHeld, listHints, listNarrow, listSecondLines, logDone, logFixture, logos, noticeErrors, notRecording, paletteFocus, paletteOpen, projectChevron, projectMenuScript, projectsSaved, recording, skipLink, snapRealKeys, toastKeys, whatsNewToast } from "./fixtures-page.ts"; -import { mapBadgeList, mapBase, mapCheckout, mapDefaultNoBanner, mapNotGit, mapBriefPairLight, mapBriefSwitch, mapBroken, mapBusy, mapCalm, mapCamera, mapDotsOrder, mapDotsRetry, mapEmpty, mapFog, mapFogPlates, mapFresh, mapGlassMotion, mapGoneFocus, mapHeaderDot, mapMarkHints, mapMarks, mapScan, mapScanIgnore, mapScanMerge, mapScanParent, mapScanNoClaude, mapScanSwitch, mapDraftSteps, mapDrafting, mapDraftReview, mapDraftRedraft, mapDraftAccept, mapDraftPr, mapDraftPrMuted, mapDraftReplace, mapDraftWrite, mapKeepCurrent, mapPendingClosed, mapPendingOpen, mapPendingSteps, mapPartKeys, mapPartRedraw, mapProjectGone, mapProjectRemoved, mapRefresher, mapPurposeMore, mapCaughtUp, mapCatchUpOlder, mapReview, mapScrubbed, mapSmallGaps, mapSpotlight, mapStale, mapSwitchSavesViews, mapTalksTo, readmeHero } from "./fixtures-map.ts"; +import { mapBadgeList, mapBase, mapCheckout, mapDefaultNoBanner, mapNotGit, mapBriefPairLight, mapBriefSwitch, mapBroken, mapBusy, mapCalm, mapCamera, mapDotsOrder, mapDotsRetry, mapEmpty, mapFog, mapFogPlates, mapFresh, mapGlassMotion, mapGoneFocus, mapHeaderDot, mapMarkHints, mapMarks, mapScan, mapScanIgnore, mapScanMerge, mapScanGive, mapScanNoClaude, mapScanSwitch, mapDraftSteps, mapDrafting, mapDraftReview, mapDraftRedraft, mapDraftAccept, mapDraftPr, mapDraftPrMuted, mapDraftReplace, mapDraftWrite, mapKeepCurrent, mapPendingClosed, mapPendingOpen, mapPendingSteps, mapPartKeys, mapPartRedraw, mapProjectGone, mapProjectRemoved, mapRefresher, mapPurposeMore, mapCaughtUp, mapCatchUpOlder, mapReview, mapScrubbed, mapSmallGaps, mapSpotlight, mapStale, mapSwitchSavesViews, mapTalksTo, readmeHero } from "./fixtures-map.ts"; import { mapFootprint, mapLatePlace, mapPanelBrief, mapPanelDiff, mapNotPlacedHint, mapPanelFieldHints, mapPanelFocus, mapPanelHead, mapPanelHistory, mapPanelLine2, mapPanelNoSession, mapPanelPeel, mapListFold, mapPanelSettings, mapPanelStory, mapPanelToggle, mapSheetClose, mapSheetExplained, mapSheetHere, mapSheetHolds, mapSheetKeptWidth, mapSheetResizeRedraw, mapSheetScrollShort, mapSheetStill, mapSheetUnratified, mapSheetWidth, mapToastBeside, mapTurnLight, mapPanelPatched, mapPanelAskStays, mapPanelBriefFoot } from "./fixtures-panel.ts"; import { mapBackLaw, mapMicroWorld, mapMicroWorldBuilding, mapPreFlight, mapPreFlightOutside, mapPreFlightOutsideKept, mapPreFlightPalette, mapPreFlightPick, mapPreFlightStatus, mapRuns, mapRunsAnnounced, mapRunsBesideSheet, mapRunsPaused, mapTray, mapTrayAfterPush } from "./fixtures-runs.ts"; import { mapBriefAlsoGroups, mapBriefAnnounce, mapBriefBar, mapBriefBold, mapBriefBoldUnpaired, mapBriefChapterLast, mapBriefChapterMid, mapBriefChapters, mapBriefCopied, mapBriefCopyByHand, mapBriefExplainBack, mapBriefExplained, mapBriefFigure, mapBriefGuard, mapBriefHeights, mapBriefMapCheck, mapBriefNoFacts, mapBriefReview, mapBriefStillTrue, mapBriefNoStaleBase, mapBriefOrderRight, mapBriefOrderSlots, mapBriefOrderWrong, mapBriefOverturn, mapBriefPartialFacts, mapBriefPick, mapBriefRatify, mapBriefRatifyDetail, mapBriefRatifyEvidence, mapBriefShort, mapBriefSince, mapBriefStaleBase, mapBriefStart, mapBriefStepCode, mapBriefStory, mapBriefTall, mapBriefTaller, mapBriefTallScroll, mapBriefUnconfirmed, mapBriefWhy, mapBriefWhyDecision, mapBriefWriting, mapCatchUp, mapCatchUpBold, mapCatchUpCard, mapCatchUpStage, mapCatchUpSummarising, mapCatchUpWriting, mapDiffClosed, mapDiffLitGhost, mapDiffRatifyLit, mapDiffRemoval, mapDiffRemovalBrief, mapDiffSplit, mapDiffSplitBrief, listBriefMark, railBriefReady } from "./fixtures-brief.ts"; @@ -257,8 +257,8 @@ export const fixtures = { mapScanMerge, mapScanIgnore, mapScanIgnoreNarrow: mapScanIgnore, - mapScanParent, - mapScanParentNarrow: mapScanParent, + mapScanGive, + mapScanGiveNarrow: mapScanGive, mapScanNoClaude, mapScanSwitch, // The Map draft (#763): the layout steps from scan to review, drafting with a group in, one checking and one failed, the review screen diff --git a/ui/map-model.ts b/ui/map-model.ts index e8632343..ca2dbde2 100644 --- a/ui/map-model.ts +++ b/ui/map-model.ts @@ -186,53 +186,29 @@ export function draftTime(parts: number): string { } /** One row of the scan's loose list: a folder's own files, or a parent row (#790) over the rows below it, which holds no files to give. */ -export type LooseRow = { folder: string; label: string; names: string; files: string[]; muted: string | null; parent: boolean; depth: number }; +// The files a reader could read: a folder holding none of them is suggested to leave out of the map. +const codeFile = /\.(dart|ts|tsx|mts|js|jsx|mjs|cjs|py|rs|go|kt|kts|java|swift|c|cc|cpp|h|hpp|cs|rb|php|sql|sh)$/; + +export type LooseArea = { folder: string; label: string; files: string[]; code: number; muted: string | null; leave: boolean }; /** - * The loose files or tests of a scan (#761) as the panel offers them: one row a folder, its label, the names of its files, and why Ignore is - * muted on it, or null: the root, and a folder holding a path of one of `parts`, whose files `ignored` would take (`map_scan.rs` refuses it). - * A folder with no files of its own that holds two or more rows gets a parent row above them (#790), so one Ignore takes them all; `depth` - * counts the parent rows a row sits under, and a parent row's `names` counts the rows right below it. + * The loose files or tests of a scan as the scan screen's Adjust drawer offers them: one row a top-level folder (the root's own files are + * one row), how many of its files are code, why leaving it out is muted, or null (the root, and a folder holding a path of one of `parts`, + * whose files `ignored` would take: `map_scan.rs` refuses it), and whether it is suggested to leave out: a folder with no code that may be. */ -export function looseGroups(files: string[], parts: { name: string; paths: string[] }[] = []): LooseRow[] { +export function looseAreas(files: string[], parts: { name: string; paths: string[] }[] = []): LooseArea[] { const byFolder = new Map(); for (const file of files) { - const cut = file.lastIndexOf("/") + 1; + const cut = file.indexOf("/") + 1; const folder = file.slice(0, cut); byFolder.set(folder, [...(byFolder.get(folder) ?? []), file]); } - // The rows, the deepest candidate parents first, so each counts the rows below it as they stand. The root never gets a parent row. - const rows = new Set(byFolder.keys()); - const below = new Map(); - const ancestors = new Set(); - for (const folder of byFolder.keys()) { - for (let cut = folder.indexOf("/") + 1; cut > 0 && cut < folder.length; cut = folder.indexOf("/", cut) + 1) ancestors.add(folder.slice(0, cut)); - } - const depthOf = (folder: string) => folder.split("/").length; - for (const ancestor of [...ancestors].filter((a) => !byFolder.has(a)).sort((a, b) => depthOf(b) - depthOf(a))) { - const inside = [...rows].filter((row) => row !== ancestor && row.startsWith(ancestor)); - const direct = inside.filter((row) => !inside.some((other) => other !== row && row.startsWith(other))); - if (direct.length < 2) continue; - rows.add(ancestor); - below.set(ancestor, direct.length); - } - const sorted = [...rows].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)); - return sorted.map((folder) => { - const group = byFolder.get(folder) ?? []; - const names = group.map((file) => file.slice(folder.length)).sort(); - const shown = names.length > 4 ? [...names.slice(0, 3), `${names.length - 3} more`] : names; + return [...byFolder.keys()].sort().map((folder) => { + const list = (byFolder.get(folder) ?? []).sort(); const held = parts.filter((part) => part.paths.some((path) => path.startsWith(folder))).map((part) => part.name); - const muted = !folder ? "Ignoring the root would leave out the whole repository" : held.length ? `Ignoring ${folder} would leave out the files of ${listed(held)}` : null; - const parent = below.has(folder); - return { - folder, - label: folder || "The root", - names: parent ? `${below.get(folder)} folders` : listed(shown), - files: [...group].sort(), - muted, - parent, - depth: sorted.filter((other) => other && other !== folder && folder.startsWith(other) && below.has(other)).length, - }; + const muted = !folder ? "Leaving out the root would leave out the whole repository" : held.length ? `Leaving out ${folder} would leave out the files of ${listed(held)}` : null; + const code = list.filter((file) => codeFile.test(file)).length; + return { folder, label: folder ? folder.slice(0, -1) : "Root files", files: list, code, muted, leave: !muted && code === 0 }; }); } diff --git a/ui/map-scan.ts b/ui/map-scan.ts index d87b3502..aabf9a04 100644 --- a/ui/map-scan.ts +++ b/ui/map-scan.ts @@ -1,14 +1,15 @@ // The scan screen (spec danielrispler/plotkeeper#753, "The free scan"; tickets #760, #761): a git repository with no map opens on its free scan. The // proposed parts are grey plates, each with its folder and file count, with no fog, badges or footprints, and the import links the readers -// computed are lines between them. The panel beside them holds the languages line, the skeleton's optional edits (the folders to ignore, the -// loose files and tests to give a part or ignore by folder, and the folders so ignored), Draft the map with its time hint, and the copy-prompt for another agent. A plate's press opens its +// computed are lines between them, under a card: the title, one line, Draft the map with its recommendation, and two drawers' openers. +// The Adjust drawer holds the skeleton's optional edits (the folders with no code and the copies to leave out, the loose code to give a part by +// top-level folder, and the folders left out); the other holds the copy-prompt for another agent. A plate's press opens its // Merge into… and Split by subfolders. Each edit goes to the server, which computes the lines again (`map_scan_edit`); its answer redraws the // plates and lines and patches the panel in place, so the panel keeps its scroll and its focus. Nothing here is saved: the skeleton is the // value `map.ts` holds, the plates are placed afresh on each draw, and the camera only fits them in the canvas. `map-model.ts` holds its words. import { availability, hint, isUnavailable, patch, pressable, svg, text } from "./dom.js"; import { fitCamera } from "./map-camera.js"; -import { autoPlace, draftTime, ignoredFolders, languagesLine, linkLines, looseGroups, type LooseRow, type MapDoc, parseMap, plateSize, rimPoint, scanPrompt } from "./map-model.js"; +import { autoPlace, draftTime, ignoredFolders, languagesLine, linkLines, looseAreas, type LooseArea, type MapDoc, parseMap, plateSize, rimPoint, scanPrompt } from "./map-model.js"; import { copyButton } from "./copy-button.js"; import type { MapScan, MapState, ScanEdit } from "./types.js"; @@ -26,28 +27,13 @@ const filesWord = (n: number) => `${n} ${n === 1 ? "file" : "files"}`; const listed = (items: string[]) => (items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`); // The plate to focus once the next draw is in: a merge's target, or the split part; its plate's key. let focusAfter: string | null = null; -// The panel's button to focus once the next scan is drawn, after Ignore or Unignore took the pressed one away: the folder's Unignore, or the -// first Ignore of a row inside the folder. -let panelFocus: { act: "ignore" | "unignore"; folder: string } | null = null; +// The drawer's control to focus once the next scan is drawn, after a press took the pressed one away: its `data-focus`, or, with none +// such, the open drawer's Close. +let panelFocus: string | null = null; // The scan each screen's plates were drawn from. const canvasOf = new WeakMap(); -// The panel's folds the person opened, by key: a redraw's `patch` sets the attributes the new draw gives, so `open` is drawn from here. -const openFolds = new Set(); - -// A fold of the panel, closed until pressed, that remembers being open across redraws. -function fold(key: string, summary: string, tip: string, body: Node[]): HTMLDetailsElement { - const details = text("details", "", "map-scan-fold"); - details.dataset.key = key; - if (openFolds.has(key)) details.open = true; - details.addEventListener("toggle", () => (details.open ? openFolds.add(key) : openFolds.delete(key))); - const head = text("summary", summary); - head.dataset.key = `${key} summary`; - hint(head, tip); - // A press sets the state at once: a redraw before the toggle event would otherwise draw the fold as it was. - head.addEventListener("click", () => (details.open ? openFolds.delete(key) : openFolds.add(key))); - details.append(head, ...body); - return details; -} +// The folders the person kept in the map against the leave-out suggestion, as " ". +const kept = new Set(); // A plate's actions: Merge into… the other parts, and Split by subfolders, muted with a reason when its folders have none to split by. function plateActions(menu: HTMLElement, doc: Doc, scan: MapScan, id: string, acts: ScanActs) { @@ -176,123 +162,6 @@ function drawCanvas(doc: Doc, scan: MapScan, acts: ScanActs): HTMLElement { return plateCanvas(doc, (part) => plateOf(part, scan.files[part.id] ?? 0, press), menu); } -// The folders that look like copies or vendored code, ticked while the skeleton ignores them (#753, story 7). -function ignoreBlock(scan: MapScan, acts: ScanActs): HTMLElement | null { - if (!scan.ignore_candidates.length) return null; - const set = text("fieldset", "", "map-scan-set"); - set.dataset.key = "scan ignore"; - set.append(text("legend", "Copies and vendored code"), text("p", "Ticked folders are left out of the map.", "map-scan-note")); - for (const candidate of scan.ignore_candidates) { - const row = text("label", "", "map-scan-check"); - row.dataset.key = `scan ignore ${candidate.path}`; - const box = text("input", ""); - box.type = "checkbox"; - box.name = "ignore"; - box.value = candidate.path; - if (candidate.ticked) box.setAttribute("checked", ""); - box.checked = candidate.ticked; - box.addEventListener("change", () => acts.edit({ kind: "ignore", folder: candidate.path, ignored: box.checked })); - const path = text("code", candidate.path); - path.setAttribute("translate", "no"); - row.append(box, path); - set.append(row); - } - return set; -} - -// A loose row's Ignore, named for its folder and muted with the row's reason. -function ignoreButton(kind: "files" | "tests", group: LooseRow, acts: ScanActs): HTMLButtonElement { - const ignore = pressable(text("button", "Ignore", "btn small"), null, () => { - if (isUnavailable(ignore)) return; - panelFocus = { act: "unignore", folder: group.folder }; - acts.edit({ kind: "ignore-folder", folder: group.folder, ignored: true }); - }); - ignore.type = "button"; - // Each row has an Ignore: its name says which folder. - ignore.setAttribute("aria-label", `Ignore ${group.label}`); - ignore.dataset.key = `scan ignore-folder ${kind} ${group.folder}`; - ignore.dataset.folder = group.folder; - ignore.dataset.act = "ignore"; - availability(ignore, `Leave ${group.folder} out of the map: ${group.parent ? "its folders" : "its files"} need no part`, group.muted); - return ignore; -} - -// The loose files or tests, one row a folder, each offered a part or a new part (#753, story 8), or Ignore, muted where it would take a part's files. -function looseBlock(kind: "files" | "tests", files: string[], doc: Doc, acts: ScanActs): HTMLElement | null { - const groups = looseGroups(files, doc.parts); - if (!groups.length) return null; - const set = text("fieldset", "", "map-scan-set"); - set.dataset.key = `scan loose ${kind}`; - set.append( - text("legend", kind === "files" ? "Loose files" : "Loose tests"), - text("p", kind === "files" ? "No part holds these yet." : "No part holds these tests yet.", "map-scan-note"), - ); - groups.forEach((group, i) => { - const row = text("form", "", "map-scan-loose"); - row.dataset.key = `scan loose ${kind} ${group.folder}`; - // The files go with the form, so a row the panel keeps across a redraw sends what the latest draw listed. - row.dataset.files = JSON.stringify(group.files); - row.style.setProperty("--depth", String(group.depth)); - const where = text("p", "", "map-scan-where"); - const folder = text("code", group.label === "The root" ? group.label : group.folder); - folder.setAttribute("translate", "no"); - where.append(folder, text("span", ` · ${group.names}`, "map-scan-names")); - const ignore = ignoreButton(kind, group, acts); - // A parent row (#790) has only Ignore: the rows below it give their files a part. - if (group.parent) { - row.classList.add("map-scan-parent"); - row.append(where, ignore); - set.append(row); - return; - } - const pick = text("select", "", "map-scan-pick"); - pick.id = `map-scan-home-${kind}-${i}`; - pick.name = "part"; - pick.append(Object.assign(text("option", "A new part"), { value: "" }), ...doc.parts.map((part) => Object.assign(text("option", part.name), { value: part.id }))); - const label = text("label", "Give to", "map-scan-label"); - label.htmlFor = pick.id; - const add = Object.assign(pressable(text("button", "Add", "btn small"), null), { type: "submit" }); - add.dataset.key = `scan add ${kind} ${group.folder}`; - hint(add, kind === "files" ? "Give these files to the part chosen, or to a new part" : "Give these tests to the part chosen, or to a new part"); - row.append(where, label, pick, add, ignore); - row.addEventListener("submit", (event) => { - event.preventDefault(); - const form = event.currentTarget as HTMLFormElement; - const chosen = form.querySelector("select")?.value ?? ""; - acts.edit({ kind: "home", files: JSON.parse(form.dataset.files ?? "[]") as string[], part: chosen || null }); - }); - set.append(row); - }); - return set; -} - -// The folders Ignore left out of the loose rows, each with Unignore, which makes their files loose again (#753). -function ignoredBlock(scan: MapScan, acts: ScanActs): HTMLElement | null { - const folders = ignoredFolders(scan); - if (!folders.length) return null; - const set = text("fieldset", "", "map-scan-set"); - set.dataset.key = "scan ignored"; - set.append(text("legend", "Ignored folders"), text("p", "Left out of the map: their files need no part.", "map-scan-note")); - for (const folder of folders) { - const row = text("div", "", "map-scan-ignored"); - row.dataset.key = `scan ignored ${folder}`; - const path = text("code", folder); - path.setAttribute("translate", "no"); - const undo = pressable(text("button", "Unignore", "btn small"), null, () => { - panelFocus = { act: "ignore", folder }; - acts.edit({ kind: "ignore-folder", folder, ignored: false }); - }); - undo.setAttribute("aria-label", `Unignore ${folder}`); - undo.dataset.key = `scan unignore ${folder}`; - undo.dataset.folder = folder; - undo.dataset.act = "unignore"; - hint(undo, `Put the files of ${folder} back among the loose ones`); - row.append(path, undo); - set.append(row); - } - return set; -} - // Draft the map, its time hint, and why it is muted when `claude` was not found; it starts the drafting run (#762) with the skeleton // (#763), and says why when the server refused it. function draftBlock(parts: number, claude: boolean, acts: ScanActs): HTMLElement { @@ -333,42 +202,191 @@ function promptBlock(skeleton: string, leads: boolean): HTMLElement { return block; } -// The panel: what the scan found, the skeleton's optional edits, Draft the map and the copy-prompt; each node keyed, so a kept panel is patched. +// A drawer at the screen's right edge, light-dismissed, with its title and Close; `id` is the target of the buttons that open it. +function drawer(id: string, title: string, body: Node[]): HTMLElement { + const pane = text("div", "", "map-scan-drawer"); + pane.id = id; + pane.dataset.key = id; + pane.setAttribute("popover", "auto"); + pane.setAttribute("aria-label", title); + const head = text("div", "", "map-scan-drawer-head"); + const close = pressable(text("button", "✕", "btn map-scan-close"), null); + close.dataset.key = `${id} close`; + close.setAttribute("popovertarget", id); + close.setAttribute("popovertargetaction", "hide"); + close.setAttribute("aria-label", `Close ${title}`); + hint(close, "Close this drawer; Draft the map stays on the card"); + head.append(text("h2", title, "map-scan-drawer-title"), close); + pane.append(head, ...body); + return pane; +} + +// A button that opens the drawer `id`. +function opener(id: string, label: string, tip: string, className: string): HTMLButtonElement { + const button = pressable(text("button", label, className), null); + button.dataset.key = `${id} open`; + button.setAttribute("popovertarget", id); + hint(button, tip); + return button; +} + +// A drawer section: its heading, a line under it, and its body. +function section(key: string, heading: string, line: string | null, body: Node[]): HTMLElement { + const node = text("section", "", "map-scan-sec"); + node.dataset.key = key; + node.append(text("h3", heading, "map-scan-h"), ...(line ? [text("p", line, "map-scan-sub")] : []), ...body); + return node; +} + +// A chip: a folder's name, a few words after it, and its one button. +function chip(name: string, words: string, button: HTMLButtonElement, out = false): HTMLElement { + const node = text("span", "", out ? "map-scan-chip out" : "map-scan-chip"); + const path = text("code", name); + path.setAttribute("translate", "no"); + node.append(path, ...(words ? [text("span", words, "map-scan-count")] : []), button); + return node; +} + +// A chip's ×, which keeps `folder` in the map against the suggestion; `edit` changes nothing, and its answer draws the chip away. +function keepButton(state: MapState, folder: string, words: string, edit: ScanEdit, acts: ScanActs): HTMLButtonElement { + const keep = pressable(text("button", "×", "btn map-scan-chip-x"), null, () => { + kept.add(`${state.project} ${folder}`); + panelFocus = "leave all"; + acts.edit(edit); + }); + keep.dataset.key = `scan keep ${folder}`; + keep.setAttribute("aria-label", `Keep ${folder} in the map`); + hint(keep, words); + return keep; +} + +// "Recommended: leave out" (#753, story 7): the folders with no code and the copies as chips, and one press that leaves them all out. +function leaveSection(state: MapState, leave: LooseArea[], copies: { path: string }[], acts: ScanActs): HTMLElement | null { + if (!leave.length && !copies.length) return null; + const chips = text("div", "", "map-scan-chips"); + for (const area of leave) { + const keep = keepButton(state, area.folder, `Keep ${area.folder} in the map: it moves down among the folders to give a part`, { kind: "ignore-folder", folder: area.folder, ignored: false }, acts); + chips.append(chip(area.label, filesWord(area.files.length), keep)); + } + for (const candidate of copies) { + const keep = keepButton(state, candidate.path, `${candidate.path} looks like a copy of other code; this keeps it in the map`, { kind: "ignore", folder: candidate.path, ignored: false }, acts); + chips.append(chip(candidate.path.replace(/\/$/, ""), "copy", keep)); + } + const count = leave.length + copies.length; + const all = pressable(text("button", count === 1 ? "Leave it out" : `Leave out these ${count}`, "btn primary map-scan-all"), null, () => { + const first = leave[0]?.folder ?? copies[0]?.path; + panelFocus = first ? `undo ${first}` : null; + for (const area of leave) acts.edit({ kind: "ignore-folder", folder: area.folder, ignored: true }); + for (const candidate of copies) acts.edit({ kind: "ignore", folder: candidate.path, ignored: true }); + }); + all.dataset.key = "scan leave all"; + all.dataset.focus = "leave all"; + hint(all, "Leave these folders out of the map: no part needs their files"); + return section("scan leave", "Recommended: leave out", "No code here: docs, settings, assets, copies.", [chips, all]); +} + +// "Code no part holds yet" (#753, story 8): one row a top-level folder, with a part picker that sends `home` as soon as it changes. +function giveSection(doc: Doc, give: LooseArea[], acts: ScanActs): HTMLElement | null { + if (!give.length) return null; + const rows = give.map((area, i) => { + const row = text("div", "", "map-scan-row"); + row.dataset.key = `scan give ${area.folder}`; + const what = text("div", "", "map-scan-what"); + const name = text("code", area.label, "map-scan-name"); + name.setAttribute("translate", "no"); + what.append(name, text("span", `${filesWord(area.files.length)}${area.code ? "" : " · no code"}`, "map-scan-count")); + const pick = text("select", "", "map-scan-pick"); + pick.id = `map-scan-give-${i}`; + pick.name = "part"; + pick.dataset.focus = `give ${area.folder}`; + pick.append(Object.assign(text("option", "Leave as is"), { value: "-" }), Object.assign(text("option", "New part"), { value: "" }), ...doc.parts.map((part) => Object.assign(text("option", part.name), { value: part.id }))); + const label = text("label", `Part for ${area.label}`, "visually-hidden"); + label.htmlFor = pick.id; + pick.addEventListener("change", () => { + if (pick.value === "-") return; + const next = give[i + 1] ?? give[i - 1]; + panelFocus = next ? `give ${next.folder}` : null; + acts.edit({ kind: "home", files: area.files, part: pick.value || null }); + }); + row.append(what, label, pick); + return row; + }); + return section("scan give", "Code no part holds yet", "Pick a part, or leave it as it is.", rows); +} + +// "Left out": the folders left out and the copies ticked, each with Undo, which puts its files back among the loose ones. +function goneSection(state: MapState, scan: MapScan, acts: ScanActs): HTMLElement | null { + const gone = [...ignoredFolders(scan).map((folder) => ({ folder, copy: false })), ...scan.ignore_candidates.filter((c) => c.ticked).map((c) => ({ folder: c.path, copy: true }))]; + if (!gone.length) return null; + const chips = text("div", "", "map-scan-chips"); + for (const { folder, copy } of gone) { + const undo = pressable(text("button", "Undo", "btn map-scan-chip-x"), null, () => { + panelFocus = "leave all"; + kept.add(`${state.project} ${folder}`); + acts.edit(copy ? { kind: "ignore", folder, ignored: false } : { kind: "ignore-folder", folder, ignored: false }); + }); + undo.dataset.key = `scan undo ${folder}`; + undo.dataset.focus = `undo ${folder}`; + undo.setAttribute("aria-label", `Put ${folder} back in the map`); + hint(undo, `Put the files of ${folder} back among the loose ones`); + chips.append(chip(folder.replace(/\/$/, ""), "", undo, true)); + } + return section("scan gone", `Left out (${gone.length})`, null, [chips]); +} + +// The Adjust drawer (#753, stories 7-10), by recommendation: what to leave out, the code to give a part, what is left out, and its foot. +function adjustBody(state: MapState, doc: Doc, scan: MapScan, acts: ScanActs): Node[] { + const areas = looseAreas([...scan.loose_files, ...scan.loose_tests], doc.parts); + const isKept = (folder: string) => kept.has(`${state.project} ${folder}`); + const leave = areas.filter((area) => area.leave && !isKept(area.folder)); + const give = areas.filter((area) => !leave.includes(area) && (area.folder || area.code)); + const copies = scan.ignore_candidates.filter((candidate) => !candidate.ticked && !isKept(candidate.path)); + const nodes: Node[] = [text("p", "Optional. The draft works without this.", "map-scan-sub")]; + if (acts.note) { + const note = text("p", `That change did not apply: ${acts.note}. Try it again, or draft the map as it is.`, "map-scan-why"); + note.dataset.key = "scan failed"; + note.setAttribute("role", "status"); + nodes.push(note); + } + nodes.push(...[leaveSection(state, leave, copies, acts), giveSection(doc, give, acts), goneSection(state, scan, acts)].filter((node) => node !== null)); + const languages = languagesLine(scan.read_languages, scan.unread_languages); + const foot = text("div", "", "map-scan-foot"); + foot.dataset.key = "scan foot"; + if (doc.parts.length) foot.append(text("p", "Tip: press a plate on the map to merge or split it.", "map-scan-sub")); + if (languages) foot.append(text("p", languages, "map-scan-languages")); + if (foot.childElementCount) nodes.push(foot); + return nodes; +} + +// The card over the plates (#753): the title, one line, Draft the map with its recommendation, and the two drawers' openers; without +// `claude` the copy-prompt's opener leads (story 12) and Draft the map is muted. function panelOf(state: MapState, doc: Doc, scan: MapScan, acts: ScanActs): HTMLElement { - const panel = text("aside", "", "map-scan-panel"); + const panel = text("aside", "", "map-scan-panel map-scan-card"); panel.setAttribute("aria-label", "Free scan"); const count = doc.parts.length; - const said = (line: string, className: string, key: string) => { - const node = text("p", line, className); - node.dataset.key = key; - return node; - }; - panel.append( - said("No map yet", "map-empty-title", "scan title"), - said( - !count ? "The scan found no code to propose parts from." : scan.claude ? `Claude can draft it from these ${count === 1 ? "part" : `${count} parts`}.` : "Give the prompt below to your own agent.", - "empty", - "scan lead", - ), - ); + const id = (what: string) => `map-scan-${what}-${state.project.replace(/[^a-z0-9]/gi, "-")}`; + const lead = text("p", !count ? "The scan found no code to propose parts from." : scan.claude ? `Claude can draft it from these ${count === 1 ? "part" : `${count} parts`}.` : "Give the prompt to your own agent.", "empty"); + lead.dataset.key = "scan lead"; + const title = text("p", "No map yet", "map-empty-title"); + title.dataset.key = "scan title"; + panel.append(title, lead); if (acts.note) { - const note = said(`That change did not apply: ${acts.note}. Try it again, or draft the map as it is.`, "map-scan-why", "scan failed"); - note.setAttribute("role", "status"); + const note = text("p", "A change did not apply; the drawer says why.", "map-scan-why"); + note.dataset.key = "scan failed card"; panel.append(note); } - // The edits are optional (#753, story 10): Draft the map needs none of them, so they wait in a closed fold, and the button stays in view. - const edits = [ignoreBlock(scan, acts), looseBlock("files", scan.loose_files, doc, acts), looseBlock("tests", scan.loose_tests, doc, acts), ignoredBlock(scan, acts)].filter((node) => node !== null); - const languages = languagesLine(scan.read_languages, scan.unread_languages); - const about = [count ? said("Press a plate to merge or split it.", "map-scan-note", "scan edits") : null, languages ? said(languages, "map-scan-languages", "scan languages") : null].filter((node) => node !== null); - if (edits.length || about.length) { - const loose = looseGroups(scan.loose_files, doc.parts).length + looseGroups(scan.loose_tests, doc.parts).length; - const summary = loose ? `Adjust parts first · ${loose} loose ${loose === 1 ? "folder" : "folders"}` : "Adjust parts first"; - panel.append(fold(`${state.project} scan adjust`, summary, "Show the folders no part holds yet, and the copies left out; Draft the map needs none of it", [...about, ...edits])); + const own = opener(id("own"), "Use your own agent", "Show a prompt to paste into your own agent in the project, instead of Draft the map", scan.claude ? "btn map-scan-link" : "btn primary map-scan-own"); + const adjust = opener(id("adjust"), "Adjust parts (optional)", "Leave out folders with no code, and give loose code a part; Draft the map needs none of it", "btn map-scan-link"); + const links = text("div", "", "map-scan-links"); + links.dataset.key = "scan links"; + if (scan.claude) { + links.append(adjust, own); + panel.append(draftBlock(count, true, acts), links); + } else { + links.append(adjust); + panel.append(own, draftBlock(count, false, acts), links); } - // Without `claude` the copy-prompt leads, open (#753, story 12); with it, the prompt waits in a fold under Draft the map. - const draft = draftBlock(count, scan.claude, acts); - if (scan.claude) panel.append(draft, fold(`${state.project} scan prompt fold`, "Use your own agent instead", "Show a prompt to paste into your own agent in the project, instead of Draft the map", [promptBlock(scan.map, true)])); - else panel.append(promptBlock(scan.map, true), draft); + panel.append(drawer(id("adjust"), "Adjust parts", adjustBody(state, doc, scan, acts)), drawer(id("own"), "Use your own agent", [promptBlock(scan.map, true)])); return panel; } @@ -390,21 +408,23 @@ export function drawScan(body: HTMLElement, state: MapState, scan: MapScan, acts const kept = drawn.querySelector(".map-scan-panel"); if (kept) patch(kept, [...panel.childNodes]); // A kept box the person ticked says the skeleton's tick again, as an edit that did not apply leaves it. - for (const box of drawn.querySelectorAll(".map-scan-check input")) box.checked = box.hasAttribute("checked"); + // A picker the person changed shows the skeleton's choice again, as a change that did not apply leaves it. + for (const pick of drawn.querySelectorAll(".map-scan-pick")) pick.value = "-"; } else { - const screen = text("div", "", "map-scan"); + const screen = text("div", "", "map-scan scan-card"); screen.dataset.key = key; screen.append(canvas ?? drawCanvas(doc, scan, acts), panel); body.replaceChildren(screen); } canvasOf.set(body.firstElementChild as HTMLElement, scan); - // An Ignore or Unignore that did not apply leaves its button where it was, focused. + // A press that did not apply leaves its control where it was, focused. if (acts.note) panelFocus = null; if (canvas && panelFocus !== null) { const want = panelFocus; panelFocus = null; - const buttons = [...body.querySelectorAll(".map-scan-panel button[data-folder]")]; - buttons.find((button) => button.dataset.act === want.act && button.dataset.folder?.startsWith(want.folder))?.focus({ preventScroll: true }); + const open = body.querySelector(".map-scan-drawer:popover-open"); + const target = open?.querySelector(`[data-focus="${CSS.escape(want)}"]`) ?? open?.querySelector(".map-scan-close"); + target?.focus({ preventScroll: true }); } if (canvas && focusAfter !== null) { const want = focusAfter; diff --git a/ui/style.css b/ui/style.css index 86ee7e33..742f9cca 100644 --- a/ui/style.css +++ b/ui/style.css @@ -721,12 +721,9 @@ body.panel-open .map-empty { inset-inline-start: calc(var(--inset) + var(--panel .map-scan-panel { display: flex; flex-direction: column; gap: var(--sp-4); min-height: 0; padding: var(--sp-6) var(--map-gutter) var(--sp-6) var(--sp-4); overflow-y: auto; overscroll-behavior: contain; } .map-scan-panel .map-empty-title, .map-scan-panel .empty, .map-scan-languages, .map-scan-time, .map-scan-why { margin: 0; } .map-scan-languages, .map-scan-time, .map-scan-why { font-size: var(--size-small); color: var(--muted); } -.map-scan-draft { display: flex; flex-direction: column; align-items: start; gap: var(--sp-2); } -/* With the edits' fold open, Draft the map stays at the panel's foot. */ -.map-scan-panel:has(.map-scan-fold[open]) { scroll-padding-block-end: 7rem; } -.map-scan-fold[open] ~ .map-scan-draft { position: sticky; inset-block-end: calc(-1 * var(--sp-6)); z-index: 1; padding-block: var(--sp-3) var(--sp-6); - background: var(--bg); border-block-start: var(--hair) solid var(--line); } -.map-scan-draft .primary { background: var(--selected); } +.map-scan-draft { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); } +.map-scan-draft .primary, .map-scan-own { font-size: var(--size); padding: var(--sp-3) var(--sp-6); background: var(--fg); color: var(--bg); } +.map-scan-draft .primary[aria-disabled="true"] { background: var(--selected); color: var(--muted); } .map-scan-prompt { display: flex; flex-direction: column; gap: var(--sp-2); min-height: 0; } .map-scan .map-draft-row { min-width: 0; } .map-scan .map-draft { min-width: 0; max-block-size: 40vh; overflow: auto; } @@ -737,35 +734,44 @@ body.panel-open .map-empty { inset-inline-start: calc(var(--inset) + var(--panel .plate.draft .btn.plate-open { cursor: pointer; } .plate.draft:has(.plate-open:hover) { background: var(--plate); } .map-scan[aria-busy="true"] { cursor: progress; } -/* The skeleton's optional edits (#761): the folders to ignore and the loose files and tests to give a part, quiet beside the plates. */ .map-scan-note { margin: 0; font-size: var(--size-small); color: var(--muted); } -.map-scan-set { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; margin: 0; padding: 0; border: 0; } -.map-scan-set legend { padding: 0; margin-block-end: var(--sp-1); font-weight: 600; } -.map-scan-check { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; cursor: pointer; } -.map-scan-check input { margin: 0; cursor: pointer; } -.map-scan-check code, .map-scan-where code, .map-scan-ignored code { font-family: var(--mono); font-size: var(--size-small); white-space: normal; overflow-wrap: anywhere; } -/* The panel's folds: the optional edits and the copy-prompt, closed until pressed, so Draft the map stays in view. */ -.map-scan-fold { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; } -.map-scan-fold > summary { display: flex; align-items: center; gap: var(--sp-2); list-style: none; cursor: pointer; color: var(--muted); - font-size: var(--size-small); border-radius: var(--radius-small); } -.map-scan-fold > summary::-webkit-details-marker { display: none; } -.map-scan-fold > summary::before { content: "▸"; display: inline-block; rotate: 0deg; } -.map-scan-fold[open] > summary::before { rotate: 90deg; } -.map-scan-fold > summary:hover { color: var(--fg); } -.map-scan-fold[open] > summary { color: var(--fg); margin-block-end: var(--sp-3); } -.map-scan-fold > :not(summary) + :not(summary) { margin-block-start: var(--sp-4); } -@media (prefers-reduced-motion: no-preference) { .map-scan-fold > summary::before { transition: rotate 0.15s; } } -.map-scan-loose { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--sp-1) var(--sp-2); } -.map-scan-loose { margin-inline-start: calc(var(--depth, 0) * var(--sp-5)); } -.map-scan-parent { grid-template-columns: minmax(0, 1fr) auto; } -.map-scan-parent .map-scan-where { grid-column: auto; } -.map-scan-ignored { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-2); } -.map-scan-ignored code { justify-self: start; } -.map-scan-where { grid-column: 1 / -1; margin: 0; min-width: 0; overflow-wrap: anywhere; } -.map-scan-names { color: var(--muted); font-size: var(--size-small); } -.map-scan-label { font-size: var(--size-small); color: var(--muted); } .map-scan-pick { min-width: 0; font: inherit; font-size: var(--size-small); color: var(--fg); background: var(--raised); border: var(--hair) solid var(--field-edge); border-radius: var(--radius-small); padding: var(--sp-1) var(--sp-2); } +/* The card over the plates (#753): centred on the canvas, its button the one strong thing on the screen. */ +.map-scan.scan-card { grid-template-columns: minmax(0, 1fr); } +.map-scan-card { position: absolute; inset-block-start: 50%; inset-inline-start: 50%; translate: -50% -50%; width: min(26rem, calc(100% - 2 * var(--sp-5))); + align-items: center; gap: var(--sp-3); padding: var(--sp-6); overflow: visible; text-align: center; border-radius: var(--radius); + background: var(--surface); border: var(--hair) solid var(--line); box-shadow: var(--shadow); } +.map-scan-card .map-empty-title { font-size: 1.3em; text-wrap: balance; } +.map-scan-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2) var(--sp-4); } +.map-scan-link { background: none; border: 0; color: var(--muted); font-size: var(--size-small); text-decoration: underline; } +.map-scan-link:hover { color: var(--fg); background: none; } +/* The two drawers at the right edge, over everything, light-dismissed. */ +.map-scan-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(28rem, 100vw); height: 100dvh; max-height: none; padding: var(--sp-6); + display: none; flex-direction: column; gap: var(--sp-5); overflow-y: auto; overscroll-behavior: contain; text-align: start; + color: var(--fg); background: var(--surface); border: 0; border-inline-start: var(--hair) solid var(--line); box-shadow: var(--shadow-start); } +.map-scan-drawer:popover-open { display: flex; } +.map-scan-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); } +.map-scan-drawer-title { margin: 0; font-size: 1.2em; } +.map-scan-close { background: none; border: 0; color: var(--muted); } +.map-scan-close:hover { color: var(--fg); background: var(--hover); } +.map-scan-sub { margin: 0; font-size: var(--size-small); color: var(--muted); } +.map-scan-sec { display: flex; flex-direction: column; gap: var(--sp-3); padding-block-start: var(--sp-4); border-block-start: var(--hair) solid var(--line); } +.map-scan-h { margin: 0; font-size: var(--size-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); } +.map-scan-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); } +.map-scan-chip { display: inline-flex; align-items: center; gap: var(--sp-1); max-width: 100%; padding-inline-start: var(--sp-3); border-radius: var(--radius-pane); + background: var(--raised); border: var(--hair) solid var(--line); } +.map-scan-chip code { background: none; padding: 0; white-space: normal; overflow: visible; overflow-wrap: anywhere; } +.map-scan-chip.out { opacity: 0.8; } +.map-scan-chip-x { background: none; border: 0; border-radius: var(--radius-pane); color: var(--muted); font-size: var(--size-small); padding: var(--sp-1) var(--sp-2); } +.map-scan-chip-x:hover { color: var(--fg); background: var(--hover); } +.map-scan-count { color: var(--muted); font-size: var(--size-small); font-variant-numeric: tabular-nums; white-space: nowrap; } +.map-scan-all { align-self: start; } +.map-scan-row { display: grid; grid-template-columns: minmax(0, 1fr) 10rem; align-items: center; gap: var(--sp-3); } +.map-scan-what { display: flex; flex-direction: column; min-width: 0; } +.map-scan-name { background: none; padding: 0; white-space: normal; overflow: visible; overflow-wrap: anywhere; } +.map-scan-foot { display: flex; flex-direction: column; gap: var(--sp-1); margin-block-start: auto; } + /* A plate's actions, placed by `map-scan.ts` beside its plate. */ .menu.map-scan-actions { width: max-content; max-width: min(var(--popover), calc(100vw - 2 * var(--sp-5))); } .map-scan-actions-title { margin: 0; font-weight: 600; overflow-wrap: anywhere; } diff --git a/ui/tests/map.test.mjs b/ui/tests/map.test.mjs index 6ecc1b34..bd7a86ba 100644 --- a/ui/tests/map.test.mjs +++ b/ui/tests/map.test.mjs @@ -2,7 +2,7 @@ import { test } from "node:test"; import assert from "node:assert/strict"; import fs from "node:fs"; -import { actorSize, autoPlace, draftPrompt, draftProgress, draftTime, partStage, languagesLine, looseGroups, ignoredFolders, scanPrompt, dragMove, dragStart, dragThreshold, effectiveTier, escapeMap, layerOrder, parseMap, plateSize, plateTitle, rimPoint, scrubTickets, sheetOf, sheetMarks, narrowBelow, withPanel, withSheet, pressRow, panelSession, switchProject, talksTo, linkLines, readingOrder, markPoints, placement, lineTag, tagWord } from "../../dist/map-model.js"; +import { actorSize, autoPlace, draftPrompt, draftProgress, draftTime, partStage, languagesLine, looseAreas, ignoredFolders, scanPrompt, dragMove, dragStart, dragThreshold, effectiveTier, escapeMap, layerOrder, parseMap, plateSize, plateTitle, rimPoint, scrubTickets, sheetOf, sheetMarks, narrowBelow, withPanel, withSheet, pressRow, panelSession, switchProject, talksTo, linkLines, readingOrder, markPoints, placement, lineTag, tagWord } from "../../dist/map-model.js"; import { cameraRig, revealPan } from "../../dist/map-camera.js"; /** @returns {import("../../dist/map-model.js").Part} */ @@ -427,45 +427,22 @@ test("a Map draft's part stands where its latest group does, and the progress li } }); -test("the loose files are offered by folder, each folder with the names of its files and Ignore muted where it would take a part's files", () => { - // (files, parts, rows as [folder, words, why Ignore is muted]): the root's own files say so, and a long folder names three and counts the rest. - const root = "Ignoring the root would leave out the whole repository"; +test("the loose files are offered by top-level folder, a folder with no code suggested to leave out, and leaving out muted where it would take a part's files", () => { const parts = [{ name: "App", paths: ["src/app/"] }, { name: "Lib", paths: ["src/lib/"] }, { name: "Docs", paths: ["docs/guide.md"] }]; - /** @type {[string[], {name: string, paths: string[]}[], [string, string, string | null][]][]} */ + const root = "Leaving out the root would leave out the whole repository"; + /** @type {[string[], { name: string, paths: string[] }[], [string, number, string | null, boolean][]][]} */ const cases = [ - [[], [], []], - [["src/index.ts"], [], [["src/", "index.ts", null]]], - [["src/index.ts", "main.go", "src/cli.ts", "example/demo/run.ts"], [], [["The root", "main.go", root], ["example/demo/", "run.ts", null], ["src/", "cli.ts and index.ts", null]]], - [["t/a.ts", "t/b.ts", "t/c.ts", "t/d.ts", "t/e.ts"], [], [["t/", "a.ts, b.ts, c.ts and 2 more", null]]], - // Files that are not code, hidden ones too, are rows like any other (#753: the check asks a home for every tracked file). - [["README.md", ".claude/settings.json", "docs/guide.md"], [], [["The root", "README.md", root], [".claude/", "settings.json", null], ["docs/", "guide.md", null]]], - // Ignore would leave out the files of a part with a path inside the folder, a folder's or a file's: the server refuses it too. - [["src/index.ts", "docs/api.md", "wiki/a.md"], parts, [["docs/", "api.md", "Ignoring docs/ would leave out the files of Docs"], ["src/", "index.ts", "Ignoring src/ would leave out the files of App and Lib"], ["wiki/", "a.md", null]]], - // A folder holding two or more loose rows and no files of its own is a parent row above them, at every level; one child row gets none. - [[...["a", "b"].map((n) => `.claude/skills/${n}/s.md`), ".claude/agents/x/a.md", ".claude/agents/y/a.md"], [], [ - [".claude/", "2 folders", null], [".claude/agents/", "2 folders", null], [".claude/agents/x/", "a.md", null], [".claude/agents/y/", "a.md", null], - [".claude/skills/", "2 folders", null], [".claude/skills/a/", "s.md", null], [".claude/skills/b/", "s.md", null], - ]], - [["a/b/f.md"], [], [["a/b/", "f.md", null]]], - // A folder with files of its own keeps its row, and its subfolders' rows follow it; a part's files in a parent mute its Ignore only. - [["d/x.md", "d/e/y.md", "d/f/z.md", "k/p/1.md", "k/q/2.md"], [{ name: "Kit", paths: ["k/q/other.md"] }], [ - ["d/", "x.md", null], ["d/e/", "y.md", null], ["d/f/", "z.md", null], - ["k/", "2 folders", "Ignoring k/ would leave out the files of Kit"], ["k/p/", "1.md", null], ["k/q/", "2.md", "Ignoring k/q/ would leave out the files of Kit"], - ]], + // One row a top-level folder, however deep its files sit; the root's own files are one row too. + [["src/index.ts", "src/x/deep/y.ts", "README.md"], [], [["Root files", 0, root, false], ["src", 2, null, false]]], + // A folder with no code is suggested to leave out, hidden ones too; one code file keeps a folder among the code. + [[".claude/settings.json", ".claude/skills/a/s.md", "assets/icon.png", "tool/run.sh", "tool/notes.md"], [], [[".claude", 0, null, true], ["assets", 0, null, true], ["tool", 1, null, false]]], + // Leaving out a folder that holds a part's path is muted, and never suggested; the server refuses it too. + [["src/index.ts", "docs/api.md", "wiki/a.md"], parts, [["docs", 0, "Leaving out docs/ would leave out the files of Docs", false], ["src", 1, "Leaving out src/ would leave out the files of App and Lib", false], ["wiki", 0, null, true]]], ]; for (const [files, held, rows] of cases) { - const groups = looseGroups(files, held); - assert.deepEqual(groups.map((g) => [g.label, g.names, g.muted]), rows, JSON.stringify(files)); - assert.deepEqual(groups.flatMap((g) => g.files).sort(), [...files].sort(), "every file is in one row"); - assert.ok(groups.every((g) => !g.parent || !g.files.length), "a parent row holds no files to give"); - } - // A row's depth is how many parent rows it sits under: the example's .claude/skills/a/ sits under .claude/skills/ and .claude/. - { - const deep = looseGroups([".claude/skills/a/s.md", ".claude/skills/b/s.md", ".claude/agents/x/a.md", ".claude/agents/y/a.md"]); - assert.deepEqual(deep.map((g) => [g.folder, g.parent, g.depth]), [ - [".claude/", true, 0], [".claude/agents/", true, 1], [".claude/agents/x/", false, 2], [".claude/agents/y/", false, 2], - [".claude/skills/", true, 1], [".claude/skills/a/", false, 2], [".claude/skills/b/", false, 2], - ]); + const areas = looseAreas(files, held); + assert.deepEqual(areas.map((a) => [a.label, a.code, a.muted, a.leave]), rows, JSON.stringify(files)); + assert.deepEqual(areas.flatMap((a) => a.files).sort(), [...files].sort(), "every file is in one row"); } // The folders Ignore left out are the skeleton's ignored ones that are not the copies the scan asks about, which keep their checkboxes. const scan = { map: JSON.stringify({ ignored: ["vendor/", "wiki/", ".claude/"] }), ignore_candidates: [{ path: "vendor/", ticked: true }, { path: "copy/", ticked: false }] };