mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-18 13:01:18 -08:00
Guide the git board through Save, Share, Review and Tidy, with the other actions folded away
AI Assisted
This commit is contained in:
1 parent
e6d5075101
commit
326262df5a
11 files changed
+566
-177
No files matched your search
@@ -94,7 +94,7 @@ In the terminal the same stops are asked in prose, with the diff printed.
|
||||
1. **State.** Run `state`. Exit 3 → 1b. `inProgress` or `conflicted` → say what is in progress and go to Conflict help.
|
||||
1b. **Not a repository.** Run `init-check`. `safe: false` → explain (inside another repository, the home folder or a drive root) and stop. `safe` → ask before `git init`, naming the folder and its first branch (`branch`, `main` unless `init.defaultBranch` says otherwise). On yes run `commands` in order (never a bare `git init`, which may start on `master`). If `hasGitignore` is false and `suggestedIgnore` is not empty, propose that `.gitignore` for approval, write it, then continue at 4 (the first commit; no push offer later because there is no remote; say it can be added with `git remote add origin <url>`).
|
||||
2. **Nothing to commit.** If `push` is not null, go to 7. Otherwise say the tree is clean and everything is pushed (or that there is no remote), and stop.
|
||||
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 `<type>/<short-description>` (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.
|
||||
3. **Branch.** On the board, skip this: the Save step's **Start a branch and commit** 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 `<type>/<short-description>` (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 -- <folder>` 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 "<s>" --files <a> --files <b>` (`--files` once per path) and its `command` (or `add`, then `commit`). Finish with `git log --oneline -<n>`. On the console post `run: { "event": "git-commits", "id": "<first short hash>", "commits": <n> }` with the `reread` and a `git-result` line naming the hashes with `op: "commit"`, so the board lights Push.
|
||||
|
||||
@@ -49,7 +49,7 @@ An `auth` failure: a `notice` saying the tool never handles logins, with `next`.
|
||||
| `git init` | `confirm` naming folder and first branch (`init-check`'s `branch`, `danger:false`), `consequences` its `commands`. Run those, not a bare `git init`. |
|
||||
| `.gitignore` | The proposed file, or a `commit`'s `ignore[]` lines, as a doc plus `review`. |
|
||||
|
||||
Risky files (`sensitive`, `large`) go in the card's `body`. There is no branch-offer card: the commit panel's **You're on main** asks, answered as `create` with `then:"commit"`.
|
||||
Risky files (`sensitive`, `large`) go in the card's `body`. There is no branch-offer card: on the default branch the board's Save step offers **Start a branch and commit**, answered as `create` with `then:"commit"`.
|
||||
|
||||
**Conflict help.** A pull, rebase or merge stopped on conflicts: `choice` "Resolve them for me?": **Yes**, **I'll fix it**, **Abort pull**. On yes, each stop is doc `conflict` (replaced per stop: step N of M, the commit replayed, each file with a one-line reason, per-file diff) plus a `review` with a fresh id per stop, `"nothingYet":false`, verdicts `continue`, `change`, `abort` ("Abort pull", `danger`). Only **Continue** runs `plan continue`'s commands; **Abort pull** runs `plan abort`. A file you cannot resolve confidently keeps its markers, as does **I'll fix it**. A `continue` click from the board's banner means the files are fixed: run `plan continue`; on exit 5 (markers left) post a `reread` with its `message` as the `git-result`. End with a `notice` summary (commits replayed, each resolved file with its reason, "N commits ready to push").
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// Plan2Code Web Console - the tabbed git board's drawing.
|
||||
//
|
||||
// drawGitBoard(ctx) builds the whole board -- header, tab strip, card slot,
|
||||
// step strip and the Changes, Branches and Sync bodies -- from what
|
||||
// git-board.js decides and what the host hands it. It decides nothing new:
|
||||
// drawGitBoard(ctx) builds the whole board -- header (with Done with git), the
|
||||
// path (Save, Share, Review, Tidy), the card slot, one task card for where the
|
||||
// person is on it, and the "All branches and tools" fold-out holding the
|
||||
// Changes, Branches and Sync tabs -- from what git-board.js decides and what
|
||||
// the host hands it. It decides nothing new:
|
||||
// a rule belongs in git-board.js, a click goes out through ctx.on.
|
||||
//
|
||||
// No DOM access: every node comes from `ctx.h` (el, md, copyButton); the page
|
||||
@@ -24,8 +26,10 @@ import {
|
||||
NOT_CONNECTED,
|
||||
PR_HOST_LABELS,
|
||||
boardActions,
|
||||
boardPath,
|
||||
boardBranchLink,
|
||||
boardPrLink,
|
||||
cardShowsFiles,
|
||||
cleanupGroups,
|
||||
commitTicks,
|
||||
composeBranchName,
|
||||
@@ -101,8 +105,8 @@ export function activeTab(ctx) {
|
||||
|
||||
/**
|
||||
* The whole board: `{ node, cardSlot }`. `node` is div.git-board holding the
|
||||
* header, the result line, the tab strip, `cardSlot` (empty, for the host's
|
||||
* cards) and the active tab's panel.
|
||||
* header, the result line, the path, `cardSlot` (empty, for the host's
|
||||
* cards), the task card and the tools fold-out (the tabs, while open).
|
||||
*/
|
||||
export function drawGitBoard(ctx) {
|
||||
const { git, h } = ctx;
|
||||
@@ -132,11 +136,12 @@ export function drawGitBoard(ctx) {
|
||||
}
|
||||
const tab = activeTab(ctx);
|
||||
node.appendChild(header(ctx));
|
||||
// A landed result (`op` set) lives in the step strip's two zones instead.
|
||||
// A landed result (`op` set) lives in the task card's two zones instead.
|
||||
if (ctx.notice && !ctx.notice.op) node.appendChild(resultLine(ctx, ctx.notice));
|
||||
node.appendChild(tabStrip(ctx, tab));
|
||||
node.appendChild(pathStrip(ctx));
|
||||
node.appendChild(cardSlot);
|
||||
node.appendChild(tabPanel(ctx, tab));
|
||||
node.appendChild(taskCard(ctx));
|
||||
node.appendChild(toolsBox(ctx, tab));
|
||||
return { node, cardSlot };
|
||||
}
|
||||
|
||||
@@ -170,6 +175,9 @@ function header(ctx) {
|
||||
);
|
||||
if (remotes.length > 1 && cur && cur.upstreamRemote) row.appendChild(h.el("span", "pill is-accent is-caps badge", cur.upstreamRemote));
|
||||
}
|
||||
const done = control(ctx, "button", "btn sm git-done", "Done with git", { role: "done", onClick: () => ctx.on.send("done") });
|
||||
if (ctx.mode === "offline") done.title = ctx.offlineReason === "pending" ? "Your last click is still being picked up." : NOT_CONNECTED;
|
||||
row.appendChild(done);
|
||||
box.appendChild(row);
|
||||
|
||||
const meta = h.el("div", "git-head-meta");
|
||||
@@ -221,18 +229,65 @@ function tabStrip(ctx, active) {
|
||||
b.appendChild(h.el("span", "git-tab-label", t.label));
|
||||
const badge = ctx.badges && ctx.badges[t.id];
|
||||
if (badge) {
|
||||
b.appendChild(h.el("span", `git-tab-badge is-${badge.kind}${badge.next ? " is-next" : ""}`, badge.text));
|
||||
b.appendChild(h.el("span", `git-tab-badge is-${badge.kind}`, badge.text));
|
||||
if (badge.label) b.setAttribute("aria-label", `${t.label}, ${badge.label}`);
|
||||
}
|
||||
strip.appendChild(b);
|
||||
}
|
||||
bar.appendChild(strip);
|
||||
const done = control(ctx, "button", "btn sm git-done", "Done with git", { role: "done", onClick: () => ctx.on.send("done") });
|
||||
if (ctx.mode === "offline") done.title = ctx.offlineReason === "pending" ? "Your last click is still being picked up." : NOT_CONNECTED;
|
||||
bar.appendChild(done);
|
||||
return bar;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- path */
|
||||
|
||||
// The four stops, the current one lit. Plain marks, no controls: the task
|
||||
// card under it is where the click is.
|
||||
function pathStrip(ctx) {
|
||||
const { h } = ctx;
|
||||
const p = boardPath(ctx.git, ctx.step);
|
||||
const ol = h.el("ol", "git-route" + (p.paused ? " is-paused" : ""));
|
||||
ol.setAttribute("aria-label", p.paused ? "Where you are: paused until this is sorted" : "Where you are");
|
||||
p.stops.forEach((s, i) => {
|
||||
const li = h.el("li", `git-stop is-${s.state}`);
|
||||
if (s.state === "now") li.setAttribute("aria-current", "step");
|
||||
const mark = h.el("span", "git-stop-mark", s.state === "done" ? "✓" : String(i + 1));
|
||||
mark.setAttribute("aria-hidden", "true");
|
||||
li.appendChild(mark);
|
||||
const words = h.el("span", "git-stop-words");
|
||||
words.appendChild(h.el("strong", "git-stop-label", s.label));
|
||||
words.appendChild(h.el("span", "git-stop-hint", s.hint));
|
||||
li.appendChild(words);
|
||||
ol.appendChild(li);
|
||||
});
|
||||
return ol;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- tools */
|
||||
|
||||
// Every action the path does not put front and center, folded away until
|
||||
// the person opens it. Opening it is navigation, so it is never locked.
|
||||
function toolsBox(ctx, tab) {
|
||||
const { h } = ctx;
|
||||
const open = Boolean(ctx.board && ctx.board.tools);
|
||||
const box = h.el("section", "git-toolbox" + (open ? " is-open" : ""));
|
||||
const toggle = control(ctx, "button", "git-toolbox-toggle", null, { role: "nav", onClick: () => ctx.on.toggleTools() });
|
||||
toggle.setAttribute("aria-expanded", open ? "true" : "false");
|
||||
toggle.setAttribute("aria-controls", "git-toolbox-body");
|
||||
const chev = h.el("span", "git-toolbox-chev", "›");
|
||||
chev.setAttribute("aria-hidden", "true");
|
||||
toggle.appendChild(chev);
|
||||
toggle.appendChild(h.el("span", "git-toolbox-label", "All branches and tools"));
|
||||
toggle.appendChild(h.el("span", "git-toolbox-sub", "Changes, Branches, Sync"));
|
||||
box.appendChild(toggle);
|
||||
if (!open) return box;
|
||||
const body = h.el("div", "git-toolbox-body");
|
||||
body.id = "git-toolbox-body";
|
||||
body.appendChild(tabStrip(ctx, tab));
|
||||
body.appendChild(tabPanel(ctx, tab));
|
||||
box.appendChild(body);
|
||||
return box;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------- tab panels */
|
||||
|
||||
function tabPanel(ctx, id) {
|
||||
@@ -240,13 +295,11 @@ function tabPanel(ctx, id) {
|
||||
panel.setAttribute("role", "tabpanel");
|
||||
panel.id = `git-panel-${id}`;
|
||||
panel.setAttribute("aria-labelledby", `git-tab-${id}`);
|
||||
const strip = stepStrip(ctx, id);
|
||||
if (strip) panel.appendChild(strip);
|
||||
panel.appendChild(id === "changes" ? changesBody(ctx) : id === "branches" ? branchesBody(ctx) : syncBody(ctx));
|
||||
return panel;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------- step strip */
|
||||
/* ----------------------------------------------------------- task card */
|
||||
|
||||
// One step's click, as the board offers it.
|
||||
function runStep(ctx, s) {
|
||||
@@ -260,7 +313,7 @@ function runStep(ctx, s) {
|
||||
return on.send("commit", picks);
|
||||
}
|
||||
case "create-commit":
|
||||
return on.openPanel("create", { commit: true });
|
||||
return on.openPanel("create", { commit: true, ...tablePicks(ctx) });
|
||||
case "create":
|
||||
return on.openPanel("create");
|
||||
case "cleanup":
|
||||
@@ -282,24 +335,24 @@ function runStep(ctx, s) {
|
||||
}
|
||||
}
|
||||
|
||||
// A commit step works on ticked files or .gitignore picks alone (the held-back
|
||||
// offer leaves only those), so it grays only when both are empty.
|
||||
function stepButton(ctx, s, cls) {
|
||||
if (s.op === "pr") return prLink(ctx, s.url, cls);
|
||||
const disabled = s.op === "commit" && !tablePicks(ctx).files.length;
|
||||
return control(ctx, "button", cls, stepLabel(ctx, s), { disabled, onClick: () => runStep(ctx, s) });
|
||||
const ticking = s.op === "commit" || (s.op === "create-commit" && cardShowsFiles(ctx.git, ctx.step));
|
||||
const picks = tablePicks(ctx);
|
||||
const disabled = ticking && !picks.files.length && !picks.ignore.length;
|
||||
return control(ctx, "button", cls, s.action || stepLabel(ctx, s), { disabled, onClick: () => runStep(ctx, s) });
|
||||
}
|
||||
|
||||
// A step's name. A "Commit N files" count follows the table's ticks, so the
|
||||
// card and its button say what the click will send.
|
||||
// card and its button say what the click will send; with only .gitignore
|
||||
// picks, the commit takes .gitignore alone and says so.
|
||||
function stepLabel(ctx, s) {
|
||||
if (!s || s.op !== "commit" || !/^Commit \d+ files?$/.test(s.label)) return s ? s.label : "";
|
||||
return `Commit ${plural(tablePicks(ctx).files.length, "file", "files")}`;
|
||||
}
|
||||
|
||||
// Whether the step strip over the Changes tab already carries a plain commit
|
||||
// button (the same one the commit table would draw).
|
||||
function stripCommits(ctx) {
|
||||
const p = ctx.step && ctx.step.primary;
|
||||
return Boolean(p && p.op === "commit" && ctx.step.tab === "changes");
|
||||
const { files, ignore } = tablePicks(ctx);
|
||||
if (!files.length && ignore.length) return `Add ${ignore.length} to .gitignore`;
|
||||
return `Commit ${plural(files.length, "file", "files")}`;
|
||||
}
|
||||
|
||||
// The commit table's ticked files and .gitignore picks, checked against the snapshot.
|
||||
@@ -312,19 +365,16 @@ function tablePicks(ctx) {
|
||||
return { files: [...ticks].filter((path) => known.has(path)), ignore: [...ignored].filter((path) => known.has(path)) };
|
||||
}
|
||||
|
||||
function stepStrip(ctx, id) {
|
||||
// The one thing to do now, under the path. On a Save stop that commits it
|
||||
// carries the file table (and, once asked, the new-branch prompt), so the
|
||||
// person ticks and commits in one place.
|
||||
function taskCard(ctx) {
|
||||
const { git, h, step } = ctx;
|
||||
const p = step.primary;
|
||||
if (id !== step.tab) {
|
||||
if (!p) return null;
|
||||
const where = GIT_TABS.find((t) => t.id === step.tab);
|
||||
return control(ctx, "button", "btn sm standby git-hint", `Next step is on ${where ? where.label : step.tab}: ${stepLabel(ctx, p)} →`, {
|
||||
role: "nav",
|
||||
onClick: () => ctx.on.pickTab(step.tab),
|
||||
});
|
||||
}
|
||||
// Mid-operation, Sync's own block is the step (syncBody).
|
||||
if (id === "sync" && git.inProgress) return null;
|
||||
// Mid-operation the card is the operation: its files and its two buttons.
|
||||
if (git.inProgress) return opBlock(ctx);
|
||||
const files = cardShowsFiles(git, step);
|
||||
const creating = Boolean(files && ctx.board.panel === "create" && ctx.board.create && ctx.board.create.commit);
|
||||
// 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.
|
||||
@@ -357,6 +407,12 @@ function stepStrip(ctx, id) {
|
||||
held.appendChild(h.md(step.held, "md git-held-body"));
|
||||
left.appendChild(held);
|
||||
}
|
||||
if (creating) {
|
||||
left.appendChild(createPanel(ctx, false));
|
||||
duo.appendChild(left);
|
||||
return duo;
|
||||
}
|
||||
if (files) left.appendChild(fileTable(ctx, false));
|
||||
const acts = h.el("div", "git-step-actions");
|
||||
if (theirs) {
|
||||
acts.appendChild(stepButton(ctx, { ...theirs, label: "Commit other changes" }, "btn primary"));
|
||||
@@ -369,7 +425,7 @@ function stepStrip(ctx, id) {
|
||||
duo.appendChild(left);
|
||||
return duo;
|
||||
}
|
||||
const box = h.el("div", "git-step" + (git.inProgress ? " is-warn" : "") + (p ? "" : " is-calm"));
|
||||
const box = h.el("div", "git-step" + (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 ? stepLabel(ctx, p) : step.line));
|
||||
if (p && p.why) box.appendChild(h.el("p", "git-step-why", p.why));
|
||||
@@ -379,6 +435,11 @@ function stepStrip(ctx, id) {
|
||||
held.appendChild(h.md(step.held, "md git-held-body"));
|
||||
box.appendChild(held);
|
||||
}
|
||||
if (creating) {
|
||||
box.appendChild(createPanel(ctx, false));
|
||||
return box;
|
||||
}
|
||||
if (files) box.appendChild(fileTable(ctx, false));
|
||||
if (ctx.mode === "running") {
|
||||
box.appendChild(activityLine(ctx, "p", ctx.activity || "Plan2Code is working on it."));
|
||||
return box;
|
||||
@@ -425,6 +486,13 @@ function changesBody(ctx) {
|
||||
const body = h.el("div", "git-changes");
|
||||
const frozen = Boolean(git.inProgress);
|
||||
if (frozen) body.appendChild(waitLine(ctx));
|
||||
// The task card already carries the table: say so rather than draw it twice.
|
||||
if (cardShowsFiles(git, ctx.step)) {
|
||||
const ch0 = git.changes || {};
|
||||
const n = list(ch0.files).length + list(ch0.untrackedDirs).length;
|
||||
body.appendChild(h.el("p", "git-note", `Your ${plural(n, "changed file is", "changed files are")} in the Save step above.`));
|
||||
return body;
|
||||
}
|
||||
if (board.panel === "create" && board.create && board.create.commit) {
|
||||
body.appendChild(createPanel(ctx, frozen));
|
||||
return body;
|
||||
@@ -439,12 +507,12 @@ function changesBody(ctx) {
|
||||
return body;
|
||||
}
|
||||
|
||||
function commitPanel(ctx, frozen) {
|
||||
// The commit table: one row per changed file or untracked folder, each with
|
||||
// its tick and, for held-back files and folders, an Add to .gitignore toggle.
|
||||
// Shared by the task card (on a Save stop) and the Changes tab.
|
||||
function fileTable(ctx, frozen) {
|
||||
const { git, board, h, on } = ctx;
|
||||
const ch = git.changes || {};
|
||||
const first = git.hasCommits === false;
|
||||
const opened = board.panel === "commit";
|
||||
const p = panelFrame(ctx, first ? "Make the first commit" : "Commit", { closable: opened, disabled: frozen });
|
||||
const ticks = board.ticks || (board.ticks = commitTicks(ch));
|
||||
const ignored = board.ignore || (board.ignore = new Set());
|
||||
|
||||
@@ -518,7 +586,15 @@ function commitPanel(ctx, frozen) {
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
table.appendChild(tbody);
|
||||
p.appendChild(table);
|
||||
return table;
|
||||
}
|
||||
|
||||
function commitPanel(ctx, frozen) {
|
||||
const { git, board, h, on } = ctx;
|
||||
const first = git.hasCommits === false;
|
||||
const opened = board.panel === "commit";
|
||||
const p = panelFrame(ctx, first ? "Make the first commit" : "Commit", { closable: opened, disabled: frozen });
|
||||
p.appendChild(fileTable(ctx, frozen));
|
||||
|
||||
const { files, ignore } = tablePicks(ctx);
|
||||
const send = () => on.send("commit", { files, ignore });
|
||||
@@ -545,10 +621,7 @@ function commitPanel(ctx, frozen) {
|
||||
})
|
||||
);
|
||||
actions.appendChild(control(ctx, "button", "btn sm", `Commit on ${head.branch}`, { disabled: frozen || !files.length, onClick: send }));
|
||||
} else if (!stripCommits(ctx)) {
|
||||
// The step above this table already offers this same "Commit N files" (its
|
||||
// count follows the ticks), so a second one here would be a duplicate; the
|
||||
// table keeps its own only when the step is somewhere else.
|
||||
} else {
|
||||
actions.appendChild(
|
||||
control(ctx, "button", "btn sm primary", `Commit ${plural(files.length, "file", "files")}`, { disabled: frozen || !files.length, onClick: send })
|
||||
);
|
||||
@@ -882,7 +955,7 @@ function syncBody(ctx) {
|
||||
const { git, h } = ctx;
|
||||
const body = h.el("div", "git-sync");
|
||||
if (git.inProgress) {
|
||||
body.appendChild(opBlock(ctx));
|
||||
body.appendChild(h.el("p", "git-wait", `The ${opName(git.inProgress)} is in the step above; everything here waits until it is finished or aborted.`));
|
||||
return body;
|
||||
}
|
||||
const pr = prBlock(ctx);
|
||||
@@ -890,12 +963,11 @@ function syncBody(ctx) {
|
||||
|
||||
const acts = boardActions(git, { busy: ctx.mode !== "idle" });
|
||||
const row = h.el("div", "git-sync-actions");
|
||||
const primaryOp = ctx.step.primary && ctx.step.primary.op;
|
||||
for (const key of ["refresh", "pull", "push", "publish"]) {
|
||||
const a = acts[key];
|
||||
if (!a.shown) continue;
|
||||
row.appendChild(
|
||||
control(ctx, "button", "btn sm" + (key === primaryOp ? " primary" : ""), a.label, {
|
||||
control(ctx, "button", "btn sm", a.label, {
|
||||
disabled: ctx.mode === "idle" && !a.enabled,
|
||||
title: a.title,
|
||||
onClick: () => runStep(ctx, { op: key }),
|
||||
|
||||
@@ -507,7 +507,12 @@ function matches(git) {
|
||||
// 4. Uncommitted changes, held-back files left out.
|
||||
if (count > 0) {
|
||||
if (onDefault) {
|
||||
out.push({ op: "create-commit", label: `Start a branch for ${files(count)}`, why: `You're on ${head.branch}. Work usually goes on its own branch.` });
|
||||
out.push({
|
||||
op: "create-commit",
|
||||
label: `Start a branch for ${files(count)}`,
|
||||
action: "Start a branch and commit",
|
||||
why: `You're on ${head.branch}. Work usually goes on its own branch, so ${head.branch} stays clean; your changes come along.`,
|
||||
});
|
||||
out.push({ op: "commit", label: `Commit on ${head.branch}`, why: "Commit straight to the default branch.", forced: true });
|
||||
} else {
|
||||
out.push({ op: "commit", label: `Commit ${files(count)}`, why: `${files(count)} changed on ${head.branch || "this commit"}.` });
|
||||
@@ -589,11 +594,11 @@ export function nextStep(git, { now = Date.now() } = {}) {
|
||||
/**
|
||||
* What each tab has waiting: `{ changes, branches, sync }`, each null or
|
||||
* `{ kind, text, label, next }` (kind "count", "dot" or "warn"; `label` is
|
||||
* for the tab's accessible name). `next` marks the tab owning the next step
|
||||
* when there is a primary; that tab always carries a badge. Mid-operation
|
||||
* only Sync is badged, with a warning.
|
||||
* for the tab's accessible name). `next` is always false: the task card above
|
||||
* the tools carries the next step, so no tab points at it. Mid-operation only
|
||||
* Sync is badged, with a warning.
|
||||
*/
|
||||
export function tabBadges(git, { now = Date.now(), stepTab = null } = {}) {
|
||||
export function tabBadges(git, { now = Date.now() } = {}) {
|
||||
const g = git || {};
|
||||
const head = g.head || {};
|
||||
const out = { changes: null, branches: null, sync: null };
|
||||
@@ -621,15 +626,69 @@ export function tabBadges(git, { now = Date.now(), stepTab = null } = {}) {
|
||||
out.sync = { kind: "count", text: "?", label: "not checked lately", next: false };
|
||||
}
|
||||
}
|
||||
const step = nextStep(g, { now });
|
||||
const owner = TAB_IDS.has(stepTab) ? stepTab : step.tab;
|
||||
if (step.primary && TAB_IDS.has(owner)) {
|
||||
const b = out[owner] || { kind: "dot", text: "·", label: "" };
|
||||
out[owner] = { ...b, next: true, label: b.label ? `${b.label}, next step` : "next step" };
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- path */
|
||||
|
||||
/**
|
||||
* The usual trip through git, as the board walks it: save the work (a branch
|
||||
* first when on the default one), share it, get it reviewed, tidy up after
|
||||
* the merge. A pull belongs to Share; only an operation stopped part-way
|
||||
* (conflicts) pauses the path.
|
||||
*/
|
||||
export const PATH_STOPS = Object.freeze([
|
||||
Object.freeze({ id: "save", label: "Save", hint: "Commit your changes" }),
|
||||
Object.freeze({ id: "share", label: "Share", hint: "Publish or push" }),
|
||||
Object.freeze({ id: "review", label: "Review", hint: "Open a pull request" }),
|
||||
Object.freeze({ id: "tidy", label: "Tidy", hint: "Clean up merged branches" }),
|
||||
]);
|
||||
|
||||
// The stop each suggested step belongs to. Pull sits on Share: it is what
|
||||
// stands between the work and pushing it.
|
||||
const STOP_OF = Object.freeze({
|
||||
commit: "save",
|
||||
"create-commit": "save",
|
||||
create: "save",
|
||||
ignore: "save",
|
||||
pull: "share",
|
||||
push: "share",
|
||||
publish: "share",
|
||||
pr: "review",
|
||||
cleanup: "tidy",
|
||||
});
|
||||
|
||||
/**
|
||||
* Where the board stands on the path: `{ current, paused, stops }`, each stop
|
||||
* a PATH_STOPS entry plus `state` ("done", "now" or "todo"). `current` is the
|
||||
* stop of the step's primary; with no primary every stop is done. An
|
||||
* operation stopped part-way pauses the path: no current stop, all to do.
|
||||
*/
|
||||
export function boardPath(git, step) {
|
||||
const paused = Boolean(git && git.inProgress);
|
||||
const primary = step && step.primary;
|
||||
const current = paused || !primary ? null : STOP_OF[primary.op] || null;
|
||||
const at = PATH_STOPS.findIndex((s) => s.id === current);
|
||||
const stops = PATH_STOPS.map((s, i) => ({
|
||||
...s,
|
||||
state: paused ? "todo" : current === null ? "done" : i < at ? "done" : i === at ? "now" : "todo",
|
||||
}));
|
||||
return { current, paused, stops };
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the task card carries the commit table: its step commits (on this
|
||||
* branch, or on a new one) and there is something on the tree to tick.
|
||||
* Otherwise the table stays on the Changes tab inside the tools.
|
||||
*/
|
||||
export function cardShowsFiles(git, step) {
|
||||
const g = git || {};
|
||||
const p = step && step.primary;
|
||||
if (g.inProgress || !p || (p.op !== "commit" && p.op !== "create-commit")) return false;
|
||||
const ch = g.changes || {};
|
||||
return list(ch.files).length + list(ch.untrackedDirs).length > 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- busy */
|
||||
|
||||
/**
|
||||
|
||||
@@ -2607,9 +2607,12 @@
|
||||
<section class="help-panel" data-tab="git">
|
||||
<h3>The git board</h3>
|
||||
<p class="help-lead">
|
||||
The Git card opens a board for your repository: three tabs — Changes,
|
||||
Branches and Sync — and the next step on top. Every button is a request
|
||||
to Plan2Code, which runs the git commands and says what each one did.
|
||||
The Git card opens a board that walks you through the usual trip:
|
||||
save your work, share it, get it reviewed, tidy up. A path shows where
|
||||
you are, one card holds the thing to do now, and every other action
|
||||
waits in <strong>All branches and tools</strong>. Every button is a
|
||||
request to Plan2Code, which runs the git commands and says what each
|
||||
one did.
|
||||
</p>
|
||||
<h4>The header</h4>
|
||||
<ul>
|
||||
@@ -2626,8 +2629,25 @@
|
||||
<strong>Last refreshed</strong> says when the remotes were last
|
||||
fetched. If a refresh fails, the line says so.
|
||||
</li>
|
||||
<li><strong>Done with git</strong> sits at the right end of the branch line.</li>
|
||||
</ul>
|
||||
<h4>The tabs</h4>
|
||||
<h4>The path</h4>
|
||||
<ul>
|
||||
<li>
|
||||
Four stops: <strong>Save</strong> (commit your changes, on a branch of
|
||||
their own when you are on the default one), <strong>Share</strong>
|
||||
(publish or push), <strong>Review</strong> (open a pull request) and
|
||||
<strong>Tidy</strong> (clean up merged branches).
|
||||
</li>
|
||||
<li>The stop you are on is lit; the ones behind you are checked.</li>
|
||||
<li>A stopped rebase or merge pauses the path (it dims) until it is sorted; a pull is part of Share.</li>
|
||||
</ul>
|
||||
<h4>All branches and tools</h4>
|
||||
<p>
|
||||
Closed until you open it. Inside are three tabs, Changes, Branches and
|
||||
Sync, with everything the board can do. A step that needs one of them,
|
||||
such as clean-up or a new branch, opens it for you.
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<strong>Changes</strong> lists your uncommitted files, ready to
|
||||
@@ -2652,18 +2672,18 @@
|
||||
branch or the one you pick beside it; the first time a host is
|
||||
unknown, it asks which kind it is and remembers the answer.
|
||||
</li>
|
||||
<li>A filled badge marks the tab where the next step is.</li>
|
||||
</ul>
|
||||
<h4>The next step</h4>
|
||||
<h4>The task card</h4>
|
||||
<ul>
|
||||
<li>
|
||||
The tab that holds it opens with one main button and, at most, one
|
||||
quieter one beside it: Commit, Push, Publish, Open pull request, and
|
||||
so on.
|
||||
Under the path: one main button and, at most, one quieter one beside
|
||||
it: Commit, Push, Publish, Open pull request, and so on.
|
||||
</li>
|
||||
<li>
|
||||
On the other tabs, a line reads <strong>Next step is on
|
||||
‹tab›</strong>; click it to go there.
|
||||
On the Save stop it lists your changed files with their ticks, so you
|
||||
pick and commit in one place. On the default branch its button is
|
||||
<strong>Start a branch and commit</strong>, with
|
||||
<strong>Commit on ‹branch›</strong> as the quieter choice.
|
||||
</li>
|
||||
<li>
|
||||
Held-back files never count toward the next step. The board offers
|
||||
@@ -2687,10 +2707,10 @@
|
||||
<h4>Moving between tabs</h4>
|
||||
<ul>
|
||||
<li>
|
||||
Once a click of yours has landed, the board moves to the tab of the
|
||||
Once a click of yours has landed, the tools move to the tab of the
|
||||
next step. Anything else that changes leaves you where you are.
|
||||
</li>
|
||||
<li>Reloading the page keeps the tab you were on.</li>
|
||||
<li>Reloading the page keeps the tools open or closed, and the tab you were on.</li>
|
||||
<li>The arrow keys move between tabs, and Home and End jump to the first and last.</li>
|
||||
</ul>
|
||||
<h4>While something is running</h4>
|
||||
@@ -2699,8 +2719,8 @@
|
||||
Everything grays out except switching tabs, searching and opening
|
||||
folds, so nothing queues up behind the running command.
|
||||
</li>
|
||||
<li>What is running shows where the next step usually sits.</li>
|
||||
<li>Plan2Code's questions appear under the tab strip.</li>
|
||||
<li>What is running shows in the task card.</li>
|
||||
<li>Plan2Code's questions appear under the path.</li>
|
||||
<li>
|
||||
When it is done, a result line says what happened, with the commit
|
||||
hashes, and the board redraws from the repository as it now stands.
|
||||
@@ -2708,11 +2728,11 @@
|
||||
</ul>
|
||||
<h4>Mid-rebase or merge</h4>
|
||||
<p>
|
||||
A rebase or merge that stopped on conflicts shows one block on Sync,
|
||||
with the files still to fix. <strong>Continue</strong> becomes the main
|
||||
A rebase or merge that stopped on conflicts turns the task card into
|
||||
one block, with the files still to fix. <strong>Continue</strong> becomes the main
|
||||
button once no conflict markers are left; a single <strong>Abort</strong>
|
||||
puts everything back as it was. The other tabs wait until it is
|
||||
finished or aborted.
|
||||
puts everything back as it was. The tools wait until it is finished
|
||||
or aborted.
|
||||
</p>
|
||||
<h4>Done with git</h4>
|
||||
<p>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Plan2Code Web Console - hosts the git board: tabs, panels and what each click sends.
|
||||
|
||||
import { hooks, page, saveNow, redraw } from "../state.js";
|
||||
import { GIT_TABS, busyMode, gitReply, pickTab, nextStep, tabBadges, createSources, BRANCH_TYPES, commitTicks, cleanupGroups } from "../git-board.js";
|
||||
import { GIT_TABS, busyMode, cardShowsFiles, gitReply, pickTab, nextStep, tabBadges, createSources, BRANCH_TYPES, commitTicks, cleanupGroups } from "../git-board.js";
|
||||
import { finish, agentWorking, agentAdrift, gitAwaiting, myTurn, byId, activity } from "../selectors.js";
|
||||
import { drawGitBoard, activeTab } from "../git-board-view.js";
|
||||
import { el, md, copyButton } from "../render.js";
|
||||
@@ -25,11 +25,13 @@ const $ = (id) => document.getElementById(id);
|
||||
// sweep the cleanup list's ticked branches
|
||||
// base the pull-request base the picker chose
|
||||
// settled cards the agent settled since the last click on the board
|
||||
// tab the tab on show: "changes", "branches" or "sync", or null before the first draw
|
||||
// tools whether the "All branches and tools" fold-out is open (closed by default)
|
||||
// tab the tab on show inside it: "changes", "branches" or "sync", or null before the first draw
|
||||
// scroll how far the column was scrolled on each tab, put back after each redraw
|
||||
// repickAt when their last board click went out (ms): the first agent post
|
||||
// after it moves the board to the new next step's tab
|
||||
export const board = {
|
||||
tools: false,
|
||||
tab: null,
|
||||
scroll: { changes: 0, branches: 0, sync: 0 },
|
||||
repickAt: null,
|
||||
@@ -50,6 +52,7 @@ export const board = {
|
||||
// are harmless: the next send re-checks every path against the snapshot. The
|
||||
// restore waits for the first draw: load() has not run when this module does.
|
||||
const boardBlank = {
|
||||
tools: false,
|
||||
tab: null,
|
||||
scroll: { changes: 0, branches: 0, sync: 0 },
|
||||
repickAt: null,
|
||||
@@ -80,6 +83,7 @@ const hydrateBoard = () => {
|
||||
if (!g) return;
|
||||
boardReloaded = true;
|
||||
Object.assign(board, boardBlank, {
|
||||
tools: g.tools === true,
|
||||
tab: GIT_TABS.some((t) => t.id === g.tab) ? g.tab : null,
|
||||
scroll: { changes: 0, branches: 0, sync: 0, ...(g.scroll || {}) },
|
||||
repickAt: typeof g.repickAt === "number" ? g.repickAt : null,
|
||||
@@ -97,6 +101,7 @@ const hydrateBoard = () => {
|
||||
|
||||
const persistBoard = () => {
|
||||
page.local.gitBoard = {
|
||||
tools: board.tools,
|
||||
tab: board.tab,
|
||||
scroll: { ...board.scroll },
|
||||
repickAt: board.repickAt,
|
||||
@@ -180,6 +185,12 @@ const gitOn = {
|
||||
redraw: () => redraw(),
|
||||
pickTab: (id) => {
|
||||
board.tab = id;
|
||||
board.tools = true;
|
||||
persistBoard();
|
||||
redraw();
|
||||
},
|
||||
toggleTools: () => {
|
||||
board.tools = !board.tools;
|
||||
persistBoard();
|
||||
redraw();
|
||||
},
|
||||
@@ -222,7 +233,7 @@ export function renderGitBoard(main, card = null, pager = null) {
|
||||
mode: gitMode(),
|
||||
offlineReason: page.gone ? "gone" : page.pendingResult ? "pending" : null,
|
||||
step,
|
||||
badges: tabBadges(git, { stepTab: step.tab }),
|
||||
badges: tabBadges(git),
|
||||
notice: result && result.kind === "notice" ? result : null,
|
||||
activity: activity(),
|
||||
hasCard: Boolean(card),
|
||||
@@ -280,14 +291,19 @@ async function pickPrHost(host, kind) {
|
||||
sendGit("pr-host", { host, kind });
|
||||
}
|
||||
|
||||
// Opening a panel moves to the tab that draws it, so a panel is never open
|
||||
// on a hidden tab. `opts.ticks` / `opts.ignore` set the commit panel's picks
|
||||
// (the held-back .gitignore offer opens it with nothing ticked).
|
||||
// Opening a panel moves to the tab that draws it, and opens the tools when
|
||||
// that tab lives there, so a panel is never open out of sight. The commit
|
||||
// table and its new-branch prompt sit in the task card on a Save stop, so
|
||||
// those leave the tools as they are. `opts.ticks` / `opts.ignore` set the
|
||||
// commit panel's picks (the held-back .gitignore offer opens it with nothing
|
||||
// ticked).
|
||||
function openPanel(name, opts = {}) {
|
||||
if (gitLocked()) return;
|
||||
const git = page.S.git;
|
||||
const inCard = cardShowsFiles(git, nextStep(git));
|
||||
if (name === "commit") {
|
||||
board.tab = "changes";
|
||||
if (!inCard) board.tools = true;
|
||||
if (opts.ticks) board.ticks = new Set(opts.ticks);
|
||||
if (opts.ignore) board.ignore = new Set(opts.ignore);
|
||||
if (board.panel !== "commit") return openCommit(git);
|
||||
@@ -296,12 +312,14 @@ function openPanel(name, opts = {}) {
|
||||
}
|
||||
if (name === "create") {
|
||||
board.tab = opts.commit ? "changes" : "branches";
|
||||
if (!(opts.commit && inCard)) board.tools = true;
|
||||
// A branch for the commit takes what the commit table has ticked, not a fresh default.
|
||||
if (opts.commit && !opts.files) return openCreate(git, { ...opts, ...tablePicks(git) });
|
||||
return openCreate(git, opts);
|
||||
}
|
||||
if (name === "cleanup") {
|
||||
board.tab = "branches";
|
||||
board.tools = true;
|
||||
return openCleanup(git);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@
|
||||
}
|
||||
/* Narrow layout keys off the board's width, not the window's. */
|
||||
.git-board { container-type: inline-size; container-name: git-board; }
|
||||
/* Plan2Code's card, between the tab strip and the tab's content. */
|
||||
/* Plan2Code's card, between the path and the task card. */
|
||||
.git-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
|
||||
.git-cards:empty { display: none; }
|
||||
|
||||
/* The tab strip: three tabs, Done with git on the right. */
|
||||
/* The tab strip inside the tools fold-out: three tabs. */
|
||||
.git-tab-bar {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
@@ -80,11 +80,78 @@
|
||||
}
|
||||
.git-tab-badge.is-dot { min-width: 0; font-weight: 700; }
|
||||
.git-tab-badge.is-warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn); }
|
||||
.git-tab-badge.is-next { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
|
||||
.git-tab-badge.is-warn.is-next { color: var(--accent-ink); background: var(--warn); border-color: var(--warn); }
|
||||
.git-done { margin: 0 0 6px auto; }
|
||||
/* Done with git sits at the right end of the header's branch row. */
|
||||
.git-done { margin-left: auto; align-self: center; }
|
||||
.git-done:not(:disabled) { border-color: var(--accent); }
|
||||
|
||||
/* The path: Save, Share, Review, Tidy. Marks, not buttons; the current stop
|
||||
is lit, finished ones get a check. */
|
||||
.git-route {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: var(--sp-2);
|
||||
}
|
||||
.git-stop {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
min-width: 0;
|
||||
padding: var(--sp-2) var(--sp-3);
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--ink-3);
|
||||
}
|
||||
.git-stop-mark {
|
||||
flex: none;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border: 1.5px solid var(--rule-2);
|
||||
border-radius: 50%;
|
||||
background: var(--panel);
|
||||
font-size: var(--fs-xs);
|
||||
font-weight: 700;
|
||||
}
|
||||
.git-stop-words { display: grid; min-width: 0; }
|
||||
.git-stop-label { font-size: var(--fs-md); font-weight: 600; }
|
||||
.git-stop-hint { font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.git-stop.is-done { color: var(--ink-2); }
|
||||
.git-stop.is-done .git-stop-mark { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
|
||||
.git-stop.is-now { color: var(--ink); background: var(--panel); border-color: var(--accent); box-shadow: var(--shadow-1); }
|
||||
.git-stop.is-now .git-stop-mark { color: var(--accent-ink); border-color: var(--accent); background: var(--accent); }
|
||||
.git-route.is-paused { opacity: 0.55; }
|
||||
|
||||
/* Every other action, folded away until asked for. */
|
||||
.git-toolbox { display: grid; grid-template-columns: minmax(0, 1fr); border: 1px dashed var(--rule-2); border-radius: var(--radius); }
|
||||
.git-toolbox.is-open { border-style: solid; background: var(--panel-2); }
|
||||
.git-toolbox-toggle {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: var(--sp-2);
|
||||
width: 100%;
|
||||
padding: var(--sp-3) var(--sp-4);
|
||||
border: 0;
|
||||
border-radius: var(--radius);
|
||||
background: transparent;
|
||||
color: var(--ink-2);
|
||||
font: inherit;
|
||||
font-size: var(--fs-md);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
.git-toolbox-toggle:hover { color: var(--ink); }
|
||||
.git-toolbox-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: var(--focus-offset); }
|
||||
.git-toolbox-chev { display: inline-block; transition: rotate 0.15s; }
|
||||
.git-toolbox.is-open .git-toolbox-chev { rotate: 90deg; }
|
||||
.git-toolbox-label { font-weight: 600; }
|
||||
.git-toolbox-sub { font-size: var(--fs-sm); color: var(--ink-3); }
|
||||
.git-toolbox-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); padding: 0 var(--sp-4) var(--sp-4); }
|
||||
@media (prefers-reduced-motion: reduce) { .git-toolbox-chev { transition: none; } }
|
||||
|
||||
/* The next step: one primary button, at most one quieter one. */
|
||||
.git-step { display: grid; gap: 6px; padding: 14px 18px; }
|
||||
.git-step:not(.callout) {
|
||||
@@ -101,7 +168,8 @@
|
||||
.git-step-why, .git-step-label { margin: 0; font-size: var(--fs-md); color: var(--ink-2); }
|
||||
.git-step-label { font-weight: 600; color: var(--ink); }
|
||||
.git-step-actions, .git-sync-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||||
.git-hint { justify-self: start; border-style: dashed; font-weight: 400; }
|
||||
/* The file table inside the task card, on a Save stop. */
|
||||
.git-step .git-files, .git-left .git-files { margin: var(--sp-1) 0; }
|
||||
.git-stale { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-md); color: var(--stage); }
|
||||
.git-held { font-size: var(--fs-md); color: var(--ink-2); }
|
||||
.git-held .md-p { margin: 0; }
|
||||
@@ -218,7 +286,7 @@
|
||||
.git-duo { grid-template-columns: 1fr; }
|
||||
.git-tab-bar { flex-wrap: wrap; }
|
||||
.git-tabs { flex-wrap: wrap; }
|
||||
.git-done { margin: 0 0 6px; }
|
||||
.git-route { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.git-head-meta { flex-direction: column; align-items: flex-start; }
|
||||
.git-step-actions, .git-sync-actions, .git-op-actions, .git-panel-actions { flex-wrap: wrap; }
|
||||
.git-step-actions .btn, .git-op-actions .btn { flex: 1 1 auto; }
|
||||
|
||||
Reference in new issue
Block a user