From 0454bdd19a606521eb284aea174635575f3e5379 Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Tue, 3 Nov 2026 11:15:15 -0800 Subject: [PATCH] Show a landed git result as its own zone beside the leftover work AI Assisted --- scripts/test-web-console-git-board.mjs | 37 ++++++++++++++++ src/plan2code-git.md | 6 +-- src/web-console/notes/git.md | 4 +- src/web-console/public/git-board-view.js | 48 ++++++++++++++++++++- src/web-console/public/styles/dashboard.css | 3 ++ src/web-console/public/styles/git.css | 12 ++++++ 6 files changed, 104 insertions(+), 6 deletions(-) diff --git a/scripts/test-web-console-git-board.mjs b/scripts/test-web-console-git-board.mjs index 6e00611..8e1c533 100644 --- a/scripts/test-web-console-git-board.mjs +++ b/scripts/test-web-console-git-board.mjs @@ -549,3 +549,40 @@ test("git board docs: the agent prose, Help topic and readme describe the tabbed for (const old of ["one board", "one page"]) assert.ok(!help.includes(old), `Help's git topic no longer says "${old}"`); assert.ok(!read("../.readme/web-console.md").includes("commits on one page"), "the readme no longer says commits on one page"); }); + +test("git board view: a landed result splits the step strip into Just landed and Still on the tree", () => { + const landed = (id, notice) => { + const s = STATES[id]; + const git = s.git; + const step = nextStep(git, { now: NOW }); + const badges = tabBadges(git, { now: NOW, stepTab: step.tab }); + const board = { tab: null, panel: null, create: null, ticks: null, ignore: new Set(), sweep: null, query: "", showAll: false, remoteOpen: null, base: null }; + const h = fakeH(); + const on = fakeOn(); + const { node } = drawGitBoard({ git, board, now: NOW, mode: "idle", step, badges, notice, activity: null, hasCard: false, h, on }); + return { node, on, step }; + }; + const notice = { id: "git-result", kind: "notice", op: "commit", title: "Committed 1eef797", body: "Mark the last-used model in the launcher menu (3 files, +845/-71)." }; + + const r = landed("cp-dirty", notice); + const duo = walk(r.node).find((n) => n.classes.has("git-duo")); + assert.ok(duo, "a landed notice draws the two zones"); + const left = walk(duo).find((n) => n.classes.has("git-landed")); + const rest = walk(duo).find((n) => n.classes.has("git-left")); + assert.ok(left, "the landed zone is there"); + assert.ok(rest, "the still-on-the-tree zone is there"); + assert.ok(left.textContent.includes("Committed 1eef797"), "the landed zone carries the notice"); + assert.ok(rest.textContent.includes("Commit other changes"), "the leftover commit is relabeled"); + assert.ok(!walk(r.node).some((n) => n.classes.has("git-result")), "no thin result line beside the zones"); + const commit = controls(rest).find((c) => c.textContent === "Commit other changes"); + click(commit); + assert.deepEqual(r.on.calls[0], ["openPanel", "commit"], "the leftover offer runs the same op the primary would"); + + const plain = landed("cp-dirty", { id: "git-result", kind: "notice", title: "Committed 1eef797", body: "no op marker" }); + assert.ok(walk(plain.node).some((n) => n.classes.has("git-result")), "a notice with no op keeps the thin line"); + assert.ok(!walk(plain.node).some((n) => n.classes.has("git-duo")), "and no zones"); + + const clean = landed("nb-unpublished", notice); + const duoClean = walk(clean.node).find((n) => n.classes.has("git-duo")); + assert.ok(duoClean, "zones still draw when nothing is left to commit"); +}); diff --git a/src/plan2code-git.md b/src/plan2code-git.md index df0d4c3..524afa4 100644 --- a/src/plan2code-git.md +++ b/src/plan2code-git.md @@ -61,9 +61,9 @@ On the console the page draws the board itself from `state.git`; you never post 2. Run `git.mjs plan ` with the action's fields as flags. 3. With `ask: true`: a `confirm` becomes a `confirm` card, posted verbatim (`danger` and `consequences` as given; `files` as a `[{ path, state }]` table where the plan names files). A `card` of kind `switch`, `dirty` or `remote` becomes a `choice` card with exactly its `options`, labeled **Switch and bring them** (`bring`), **Commit first** (`commit-first`) and **Cancel** (`cancel`), or for `remote` one option per remote with `preset` recommended; put git's `reason` in `body` when given. Then wait for the answer. A `remote` pick plans `publish --remote ` again and asks its `confirm`. 4. Run the command(s). -5. In ONE post: `{ "reread": true }`, the `git-result` notice (one line: what happened, with short hashes, and after a push or publish the link from `pr-url`), `board: { describe }` when changes remain (a short kebab-case description of them, for the Create prompt), posted with `--wait`. +5. In ONE post: `{ "reread": true }`, the `git-result` notice (one line: what happened, with short hashes, and after a push or publish the link from `pr-url`, plus `op` naming the action that succeeded so the board shows it as the landed zone), `board: { describe }` when changes remain (a short kebab-case description of them, for the Create prompt), posted with `--wait`. -On a non-zero exit, save git's stderr to the session folder, run `classify-error --file `, quote git's error verbatim in the `git-result` notice with `next`, and post `reread` the same way. A Refresh failure posts `reread: { refreshFailed: true }`. An `auth` kind gets a card saying this tool never handles logins, with `next`. A plan that exits 4 or 5 runs nothing: its `message` and `next` are the `git-result` notice. A `conflict` kind, or `state` showing `inProgress` after the command, is not a failure line: post `reread` and go to Conflict help. +On a non-zero exit, save git's stderr to the session folder, run `classify-error --file `, quote git's error verbatim in the `git-result` notice with `next` and no `op`, and post `reread` the same way. A Refresh failure posts `reread: { refreshFailed: true }`. An `auth` kind gets a card saying this tool never handles logins, with `next`. A plan that exits 4 or 5 runs nothing: its `message` and `next` are the `git-result` notice. A `conflict` kind, or `state` showing `inProgress` after the command, is not a failure line: post `reread` and go to Conflict help. ## Actions @@ -97,7 +97,7 @@ In the terminal the same stops are asked in prose, with the diff printed. 3. **Branch.** On the board, skip this: the page's **You're on main** line already offered it, and its answer arrives as `create` with `then: "commit"`. In the terminal, when `onDefault` (or `detached`) and `hasCommits`, offer one drafted branch name `/` (types: feature, fix, chore, docs, refactor, test; `feature/export-csv`). Run any name the person types through `branch-check`, then `plan create`. Skipping is always fine (on a detached HEAD, warn that commits there are easy to lose). When `defaultBranch` is null say why there is no offer. 4. **Read the changes.** `git diff`, `git diff --cached` and the untracked files (an `untracked` path ending in `/` is a folder: list its files with `git ls-files -o --exclude-standard -- ` and stage them by name). If the person staged some files, work from that staged set and leave the rest alone (say what was left). On the board, only the paths the action named, or every changed file on a hand-off. Decide whether the work is one concern or several. 5. **Message.** One concern: draft a subject, or use the argument and skip approval; ask **Yes** / **Edit** / **No**. Several: always suggest whole-file groups, each with a subject, naming any file that mixes concerns and which group took it; ask **Approve** / **Change it** / **One commit instead** (asked even when the subject came as the argument). Name the `sensitive` and `large` files you are leaving out. -6. **Commit.** For each group in order: with more than one group, run `git reset -q` first so only that group is staged; then run `commit-msg.mjs --subject "" --files --files ` (`--files` once per path) and its `command` (or `add`, then `commit`). Finish with `git log --oneline -`. On the console post `run: { "event": "git-commits", "id": "", "commits": }` with the `reread` and a `git-result` line naming the hashes, so the board lights Push. +6. **Commit.** For each group in order: with more than one group, run `git reset -q` first so only that group is staged; then run `commit-msg.mjs --subject "" --files --files ` (`--files` once per path) and its `command` (or `add`, then `commit`). Finish with `git log --oneline -`. On the console post `run: { "event": "git-commits", "id": "", "commits": }` with the `reread` and a `git-result` line naming the hashes with `op: "commit"`, so the board lights Push. 7. **Push.** In the terminal, stop after committing with a one-line push hint and no push prompt. `commit and push` (or a push the person asks for) runs `plan push` / `plan publish` and asks its `confirm`. A rejected push: report it, suggest Pull, run nothing more. ## Terminal diff --git a/src/web-console/notes/git.md b/src/web-console/notes/git.md index 2c7416b..d18d951 100644 --- a/src/web-console/notes/git.md +++ b/src/web-console/notes/git.md @@ -21,11 +21,11 @@ A click arrives as one session action per send, and the board locks until your n **After an action**, ONE post with `--wait`: ```jsonc -{"reread":true,"items":[{"id":"git-result","kind":"notice","title":"Pushed 2 commits to origin/feature/x","body":"a1b2c3d, e4f5a6b. [Open pull request](https://github.com/...)"}],"board":{"describe":"export-csv-button"}} +{"reread":true,"items":[{"id":"git-result","kind":"notice","op":"push","title":"Pushed 2 commits to origin/feature/x","body":"a1b2c3d, e4f5a6b. [Open pull request](https://github.com/...)"}],"board":{"describe":"export-csv-button"}} ``` - `reread` is `true`, or `{"refreshFailed":true}` after a failed Refresh. Only with the `git` workflow, else exit 3. -- `git-result` is one `notice` replaced every action: what happened, short hashes, the `pr-url` link after a push or publish. A failure quotes git's stderr verbatim with `classify-error`'s `next`. +- `git-result` is one `notice` replaced every action: what happened, short hashes, the `pr-url` link after a push or publish, and `op` naming the action that succeeded (`"commit"`, `"push"`, `"pull"`, `"switch"`, `"create"`, `"cleanup"`, `"refresh"`, `"init"`, `"publish"`): the board shows it as the landed zone beside the leftover work. A failure quotes git's stderr verbatim with `classify-error`'s `next` and carries no `op`. - `board.describe`: short kebab-case description of the changes still on the tree (prefills Create); leave out when none remain. **Cards per `plan`** (`git.mjs plan `): diff --git a/src/web-console/public/git-board-view.js b/src/web-console/public/git-board-view.js index 3f0fd3e..a676473 100644 --- a/src/web-console/public/git-board-view.js +++ b/src/web-console/public/git-board-view.js @@ -130,7 +130,8 @@ export function drawGitBoard(ctx) { } const tab = activeTab(ctx); node.appendChild(header(ctx)); - if (ctx.notice) node.appendChild(resultLine(ctx, ctx.notice)); + // A landed result (`op` set) lives in the step strip's two zones instead. + if (ctx.notice && !ctx.notice.op) node.appendChild(resultLine(ctx, ctx.notice)); node.appendChild(tabStrip(ctx, tab)); node.appendChild(cardSlot); node.appendChild(tabPanel(ctx, tab)); @@ -280,6 +281,51 @@ function stepStrip(ctx, id) { } // Mid-operation, Sync's own block is the step (syncBody). if (id === "sync" && git.inProgress) return null; + // A landed result: the notice (it carries `op`) becomes the left zone and + // the leftover step the right, muted, so the board reads "done, and this + // much is not yours" rather than one loud suggestion to commit it all. + if (ctx.notice && ctx.notice.op) { + const duo = h.el("div", "git-duo"); + const landed = h.el("div", "git-landed"); + landed.setAttribute("role", "status"); + landed.appendChild(h.el("div", "git-step-kicker", "Just landed")); + landed.appendChild(h.el("h3", "git-step-title", ctx.notice.title || "")); + if (ctx.notice.body) landed.appendChild(h.md(ctx.notice.body, "md git-result-body")); + if (ctx.mode === "running") landed.appendChild(activityLine(ctx, "p", ctx.activity || "Plan2Code is working on it.")); + // The landed zone's one action is the follow-through on their work, which + // only exists beside a leftover-commit primary (Push 5 there). Every other + // shape leaves the exit to the right zone, which always names the board's + // real next step, muted. + const theirs = p && p.op === "commit" ? p : null; + if (theirs && step.secondary[0]) { + const acts = h.el("div", "git-step-actions"); + acts.appendChild(stepButton(ctx, step.secondary[0], "btn primary")); + landed.appendChild(acts); + } + duo.appendChild(landed); + const left = h.el("div", "git-left"); + left.appendChild(h.el("div", "git-step-kicker", theirs ? "Still on the tree" : p ? "Still to do" : "All caught up")); + if (theirs) left.appendChild(h.el("h3", "git-step-title", theirs.label)); + else left.appendChild(h.el("h3", "git-step-title", p ? p.label : step.line)); + if (p && p.why) left.appendChild(h.el("p", "git-step-why", p.why)); + if (step.stale) left.appendChild(staleLine(ctx, step.stale)); + if (step.held) { + const held = h.el("div", "git-held"); + held.appendChild(h.md(step.held, "md git-held-body")); + left.appendChild(held); + } + const acts = h.el("div", "git-step-actions"); + if (theirs) { + acts.appendChild(stepButton(ctx, { ...theirs, label: "Commit other changes" }, "btn primary")); + for (const s of step.secondary.slice(1)) acts.appendChild(stepButton(ctx, s, "btn small")); + } else { + if (p) acts.appendChild(stepButton(ctx, p, "btn primary")); + for (const s of step.secondary) acts.appendChild(stepButton(ctx, s, "btn small")); + } + if (acts.children.length) left.appendChild(acts); + duo.appendChild(left); + return duo; + } const box = h.el("div", "git-step" + (git.inProgress ? " is-warn" : "") + (p ? "" : " is-calm")); box.appendChild(h.el("div", "git-step-kicker", p ? "Next step" : "Nothing to do")); box.appendChild(h.el("h3", "git-step-title", p ? p.label : step.line)); diff --git a/src/web-console/public/styles/dashboard.css b/src/web-console/public/styles/dashboard.css index 0b6f944..9e26ef3 100644 --- a/src/web-console/public/styles/dashboard.css +++ b/src/web-console/public/styles/dashboard.css @@ -472,6 +472,9 @@ /* The bar's gap sets the rhythm; the row's own margin is for loop-setup, which has no tail. */ .confirm-tail .confirm-actions { margin-top: 0; } +/* The Notebook box frames itself, so the rule line is one separation too + many when it is on the pane; the shadow still marks the bar in a scroll. */ +.dash-confirm:has(.confirm-note-box) .confirm-tail { border-top: 0; } /* "Start with a note from your Notebook": the switch, then the tabs beside a preview of the picked one, its pictures each with a tick. */ diff --git a/src/web-console/public/styles/git.css b/src/web-console/public/styles/git.css index fa99d98..0f16b81 100644 --- a/src/web-console/public/styles/git.css +++ b/src/web-console/public/styles/git.css @@ -128,6 +128,17 @@ .git-wait { margin: 0; font-size: 13.5px; color: var(--stage); } .git-fresh { margin: 0; font-size: 13px; color: var(--ink-3); } .git-fresh.is-stale { color: var(--stage); } +/* A landed result fills the step strip's place with two zones: the result + itself (green, "Just landed") beside the leftover step (muted). The big + headline belongs to what happened, not to the work that is not yours. */ +.git-duo { display: grid; grid-template-columns: 3fr 2fr; gap: 10px; align-items: start; } +.git-landed, .git-left { display: grid; gap: 6px; padding: 14px 18px; border-radius: var(--radius); } +.git-landed { background: var(--ok-soft); border: 1px solid var(--ok); border-left-width: 4px; } +.git-landed .git-step-kicker { color: var(--ok); } +.git-landed .git-result-body { font-size: 14px; color: var(--ink-2); } +.git-landed .git-result-body .md-p { margin: 0; } +.git-left { background: var(--panel-2); border: 1px solid var(--rule-2); } +.git-left .git-step-title { font-size: 16px; } .git-panel-tab { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; } .git-changes, .git-sync { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; } .git-sweep-offer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--ink-2); } @@ -248,6 +259,7 @@ /* Last on purpose: the narrow layout overrides the board rules above it. */ @container git-board (max-width: 720px) { + .git-duo { grid-template-columns: 1fr; } .git-tab-bar { flex-wrap: wrap; } .git-tabs { flex-wrap: wrap; } .git-done { margin: 0 0 6px; }