mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-17 04:45:33 -08:00
Add Stop with a handoff, handoff chips on the dashboard, and a one-step delete for fixed bugs
AI Assisted
This commit is contained in:
1 parent
33a0dbd34a
commit
36843e4bc9
34 files changed
+1926
-267
No files matched your search
@@ -371,6 +371,16 @@ export function handoffShape(fin) {
|
||||
// sentence: nothing Pathfinder would read as asking for a brief.
|
||||
export const STOP_REPLY = "Stop here and save my place, so I can pick this up later.";
|
||||
|
||||
// The same request, with a handoff note written first. Same plain voice: the
|
||||
// reply is read by the agent, and a word like "brief" would send Pathfinder
|
||||
// off to write one.
|
||||
export const STOP_HANDOFF_REPLY = "Stop here, save my place and write a handoff, so the dashboard can pick this up later.";
|
||||
|
||||
/** The `__stop` action; `handoff: true` only when the handoff choice was pressed. */
|
||||
export function stopAction({ handoff } = {}) {
|
||||
return handoff ? { i: "__stop", type: "stop", handoff: true } : { i: "__stop", type: "stop" };
|
||||
}
|
||||
|
||||
/**
|
||||
* Why a session-level button (Stop session, Back to the dashboard) cannot be
|
||||
* pressed right now, or null when it can. Both wait for the person's turn:
|
||||
@@ -813,7 +823,7 @@ const ON = { on: true };
|
||||
export const GIT_INIT_NOTE = "Not a git repository yet: it offers to start one";
|
||||
export const pendingNote = (n) => `${n} file${n === 1 ? "" : "s"} to commit`;
|
||||
const off = (reason) => ({ on: false, reason });
|
||||
const FIXED_REASON = "This bug is fixed. Delete it with ✕, or move it to specs--completed/.";
|
||||
export const FIXED_REASON = "This bug is fixed. Delete it with the Delete button on its chip, or move it to specs--completed/.";
|
||||
|
||||
/**
|
||||
* The spec the picker opens on: the most recently touched one that is still
|
||||
@@ -955,12 +965,50 @@ export function deleteReply(spec) {
|
||||
|
||||
// What the delete dialog says about the spec, from the scan alone. `touched`
|
||||
// stays a number: the page formats it in the person's own locale.
|
||||
// A handoff on the dashboard (scan.handoffs). The page sends only the id; the
|
||||
// CLI reads the rest from the stored metadata. Plain wording, no em dashes:
|
||||
// these lines are read by the agent.
|
||||
export function pickupAction(h) {
|
||||
return { i: "__pickup", type: "pickup", handoff: h.id };
|
||||
}
|
||||
export function pickupReply(h) {
|
||||
return `Pick up the handoff "${h.title}" right here in this session.`;
|
||||
}
|
||||
export function deleteHandoffAction(h) {
|
||||
return { i: "__delete", type: "delete", handoff: h.id };
|
||||
}
|
||||
export function deleteHandoffReply(h) {
|
||||
return `Delete the handoff "${h.title}" for good, right here in this session.`;
|
||||
}
|
||||
export function handoffCopyText(file) {
|
||||
return `Read the handoff at ${file} and carry on with its Next task.`;
|
||||
}
|
||||
/** "just now", "12 min ago", "6 h ago", "3 days ago" for an ISO time. */
|
||||
export function handoffAge(written, now = Date.now()) {
|
||||
const t = Date.parse(written);
|
||||
if (!Number.isFinite(t)) return "";
|
||||
const mins = Math.max(0, Math.floor((now - t) / 60000));
|
||||
if (mins < 1) return "just now";
|
||||
if (mins < 60) return `${mins} min ago`;
|
||||
const hours = Math.floor(mins / 60);
|
||||
if (hours < 24) return `${hours} h ago`;
|
||||
const days = Math.floor(hours / 24);
|
||||
return `${days} day${days === 1 ? "" : "s"} ago`;
|
||||
}
|
||||
|
||||
// The line under a spec's name on its chip. A fixed bug's label already says
|
||||
// "Bug fixed", so the scan's "bug fixed" detail would only repeat it.
|
||||
export function chipDetail(spec) {
|
||||
return spec.state === "fixed" ? "" : spec.detail || "";
|
||||
}
|
||||
|
||||
export function deleteSummary(spec) {
|
||||
const label = SPEC_STATE_LABELS[spec.state] || spec.state || "";
|
||||
const detail = chipDetail(spec);
|
||||
const n = spec.files;
|
||||
return {
|
||||
folder: `${spec.dir}/`,
|
||||
stage: spec.detail ? `${label}: ${spec.detail}` : label,
|
||||
stage: detail ? `${label}: ${detail}` : label,
|
||||
files: Number.isInteger(n) ? `${n} file${n === 1 ? "" : "s"}` : "",
|
||||
touched: Number.isFinite(spec.touched) && spec.touched > 0 ? spec.touched : null,
|
||||
};
|
||||
|
||||
@@ -1761,6 +1761,9 @@ input[type="text"].invalid { border-color: var(--warn); }
|
||||
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
|
||||
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
|
||||
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
|
||||
/* A review card's approve verdict, before it is picked: the accent outline
|
||||
marks it as the main way forward. */
|
||||
.btn.is-approve { border-color: var(--accent); }
|
||||
/* Send glows and breathes while there is something to send: the steady
|
||||
--glow, plus a soft accent ring that spreads and fades. The ring is off
|
||||
under reduced motion, below; the glow stays. */
|
||||
@@ -2773,6 +2776,47 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
|
||||
.modal-why { margin: 14px 0 0; font-size: 13px; color: var(--warn); min-height: 1px; }
|
||||
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
|
||||
|
||||
/* The Stop dialog's two ways out, stacked: the handoff first (the suggested
|
||||
one), the plain stop second, "Keep going" alone below. */
|
||||
.stop-choices { display: grid; gap: 10px; margin-top: 16px; }
|
||||
.stop-choice {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
text-align: left;
|
||||
font: inherit;
|
||||
color: var(--ink);
|
||||
background: var(--panel-2);
|
||||
border: 1px solid var(--rule-2);
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
}
|
||||
.stop-choice:hover, .stop-choice.suggested { border-color: var(--accent); }
|
||||
.stop-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
.stop-choice:disabled { opacity: 0.6; cursor: default; }
|
||||
.stop-choice[hidden] { display: none; }
|
||||
.stop-choice-icon {
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid var(--rule-2);
|
||||
font-size: 13px;
|
||||
color: var(--accent);
|
||||
}
|
||||
.stop-choice-text { display: grid; gap: 2px; min-width: 0; }
|
||||
.stop-choice-title { font-weight: 600; font-size: 14px; }
|
||||
.stop-choice-detail { font-size: 12.5px; color: var(--ink-2); }
|
||||
.modal-actions:has(#stop-cancel) { justify-content: center; margin-top: 14px; }
|
||||
@media (max-width: 560px) {
|
||||
.modal-actions:has(#stop-cancel) .btn { width: 100%; }
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------- doc tools */
|
||||
|
||||
.doc-tools { display: flex; gap: 8px; margin-left: auto; flex: none; align-items: center; }
|
||||
@@ -3056,6 +3100,38 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
|
||||
}
|
||||
.spec-chip:not(.is-sel) .spec-chip-state { color: var(--ink-3); }
|
||||
.spec-chip-detail { font-size: 11.5px; color: var(--ink-3); }
|
||||
/* A handoff in the picker: the same lozenge, dashed, in the stage colour. */
|
||||
.spec-chip.is-handoff { border-style: dashed; }
|
||||
.spec-chip.is-handoff .spec-chip-state, .spec-chip.is-handoff:not(.is-sel) .spec-chip-state { color: var(--stage); }
|
||||
.spec-chip.is-handoff.is-sel { border-style: solid; border-color: var(--stage); }
|
||||
.spec-chip.is-handoff.is-deleting { opacity: 0.5; }
|
||||
|
||||
/* What a picked handoff shows under the picker. */
|
||||
.handoff-preview {
|
||||
margin: 0 0 30px;
|
||||
padding: 18px 20px;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--stage);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
.handoff-preview-title { font: 600 20px/1.25 var(--serif); margin: 0 0 4px; }
|
||||
.handoff-preview-meta { margin: 0 0 14px; font-size: 12.5px; color: var(--ink-3); }
|
||||
.handoff-preview-label {
|
||||
margin: 0 0 3px;
|
||||
font-size: 10.5px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--stage);
|
||||
}
|
||||
.handoff-preview-next { margin: 0 0 16px; font-size: 14px; color: var(--ink); }
|
||||
.handoff-preview-actions { display: flex; flex-wrap: wrap; gap: 10px; }
|
||||
.handoff-preview-actions .btn.danger { margin-left: auto; }
|
||||
.modal.handoff-read { max-width: 720px; }
|
||||
.modal.handoff-read[open] { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
|
||||
.handoff-body { flex: 1; min-height: 0; overflow-y: auto; margin-top: 8px; }
|
||||
.modal.handoff-read .modal-actions { flex: none; }
|
||||
|
||||
/* A spec's Delete button sits beside its chip, not inside it: a button cannot
|
||||
hold a button. Quiet until the chip is hovered or focused. */
|
||||
.spec-chip-wrap { position: relative; display: flex; }
|
||||
@@ -3085,6 +3161,28 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
|
||||
.spec-chip-del:hover { color: var(--warn); border-color: var(--warn); opacity: 1; }
|
||||
.spec-chip-del:focus-visible { outline: 2px solid var(--warn); outline-offset: 1px; }
|
||||
.spec-chip-del:disabled { cursor: default; opacity: 0.3; }
|
||||
/* A fixed bug's Delete is always shown, as a pill at the chip's bottom right;
|
||||
the chip makes room below its lines so the pill never covers the name. The
|
||||
chip's is-fixed dimming targets .spec-chip, so the pill keeps full strength. */
|
||||
.spec-chip-wrap.is-fixed .spec-chip { padding-right: 14px; padding-bottom: 36px; }
|
||||
.spec-chip-del-label {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
bottom: 8px;
|
||||
padding: 2px 10px;
|
||||
border: 1px solid var(--warn);
|
||||
border-radius: 999px;
|
||||
background: var(--panel);
|
||||
color: var(--warn);
|
||||
font: inherit;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
cursor: pointer;
|
||||
}
|
||||
.spec-chip-del-label:hover:not(:disabled) { background: var(--warn-soft); }
|
||||
.spec-chip-del-label:focus-visible { outline: 2px solid var(--warn); outline-offset: 1px; }
|
||||
.spec-chip-del-label:disabled { cursor: default; opacity: 0.4; }
|
||||
.spec-chip-wrap.is-deleting .spec-chip { opacity: 0.5; }
|
||||
.delete-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0 0; font-size: 13.5px; }
|
||||
.delete-facts dt { color: var(--ink-3); }
|
||||
|
||||
+300
-32
@@ -9,7 +9,7 @@
|
||||
// that is local and reversible. For someone who has never used a tool like
|
||||
// this, that reversibility is the whole point.
|
||||
|
||||
import { md, el, copyButton, selectContents } from "./render.js";
|
||||
import { md, mdInto, el, copyButton, selectContents } from "./render.js";
|
||||
import { ACCENTS, DEFAULT_ACCENT, DEFAULT_CARD_WIDTH, SOUND_EVENTS, cardWidth, soundKey, soundPrefs } from "./palette.js";
|
||||
import { activityLabel, workingLine } from "./labels.js";
|
||||
import { playWake } from "./boot.js";
|
||||
@@ -46,6 +46,13 @@ import {
|
||||
launchTarget,
|
||||
deleteAction,
|
||||
deleteReply,
|
||||
pickupAction,
|
||||
pickupReply,
|
||||
deleteHandoffAction,
|
||||
deleteHandoffReply,
|
||||
handoffCopyText,
|
||||
handoffAge,
|
||||
chipDetail,
|
||||
deleteSummary,
|
||||
isDeletableSpecDir,
|
||||
MAX_ATTACHMENTS,
|
||||
@@ -71,6 +78,8 @@ import {
|
||||
STALE_MS,
|
||||
startPose,
|
||||
STOP_REPLY,
|
||||
STOP_HANDOFF_REPLY,
|
||||
stopAction,
|
||||
sentAnswer,
|
||||
agentRepliedAfterSend,
|
||||
indentReply,
|
||||
@@ -831,6 +840,22 @@ const selSpec = () => {
|
||||
return specs.find((s) => s.dir === local.specSel) || null;
|
||||
};
|
||||
|
||||
// This checkout's unused handoffs (scan.handoffs, newest first). A handoff is
|
||||
// picked in the same chip row as a spec, stored as `specSel = "handoff:<id>"`;
|
||||
// selSpec() then reads as "no spec", and selHandoff() is the handoff itself,
|
||||
// or null once it is gone from the scan (which also drops the stale pick).
|
||||
const handoffList = () => {
|
||||
const sc = scan();
|
||||
return sc && Array.isArray(sc.handoffs) ? sc.handoffs : [];
|
||||
};
|
||||
const selHandoff = () => {
|
||||
if (typeof local.specSel !== "string" || !local.specSel.startsWith("handoff:")) return null;
|
||||
const id = local.specSel.slice("handoff:".length);
|
||||
const h = handoffList().find((x) => x.id === id) || null;
|
||||
if (!h) delete local.specSel;
|
||||
return h;
|
||||
};
|
||||
|
||||
// The review a finished build offers, and where it has got to:
|
||||
// "open" on offer, and a press would reach the agent
|
||||
// "asked" pressed, and the agent has not taken it up yet
|
||||
@@ -3098,6 +3123,10 @@ function openUpdateModal() {
|
||||
|
||||
function renderDashboard(main) {
|
||||
maybeWake();
|
||||
// First, so nothing below reads a pick whose handoff has left the scan, and
|
||||
// a delete the agent's rescan has finished stops holding the buttons.
|
||||
selHandoff();
|
||||
settleDeleting();
|
||||
const menu = (S && S.menu) || {};
|
||||
const wrap = el("div", "dash");
|
||||
if (needsRoleNudge(looks)) wrap.appendChild(roleNudge());
|
||||
@@ -3159,7 +3188,17 @@ function renderDashboard(main) {
|
||||
}
|
||||
|
||||
const specs = specList();
|
||||
if (specs.length) wrap.appendChild(renderSpecPicker(specs));
|
||||
if (specs.length || handoffList().length) wrap.appendChild(renderSpecPicker(specs));
|
||||
const handoff = selHandoff();
|
||||
if (handoff) {
|
||||
// A handoff is picked up, not launched: its skill and spec come from its
|
||||
// own record, so the skill cards and their toggle have nothing to say.
|
||||
if (!local.launching && !launchScoping && scopeMine !== "") syncWorkspaceScope();
|
||||
wrap.appendChild(renderHandoffPreview(handoff));
|
||||
main.appendChild(wrap);
|
||||
queueMicrotask(maybeWelcome);
|
||||
return;
|
||||
}
|
||||
wrap.appendChild(hideUnavailableToggle());
|
||||
// Only when this tab's own pick moved: another tab changing the scope
|
||||
// sends a frame here too, and re-asserting this tab's pick on every render
|
||||
@@ -3678,13 +3717,18 @@ function hideUnavailableToggle() {
|
||||
no send — so it costs nothing to change your mind. */
|
||||
function renderSpecPicker(specs) {
|
||||
const sel = selSpec();
|
||||
const handoffs = handoffList();
|
||||
const pickedHandoff = selHandoff();
|
||||
const box = el("section", "spec-pick");
|
||||
box.appendChild(el("h3", "dash-group-title", "Pick up a spec, or start fresh"));
|
||||
box.appendChild(
|
||||
el("h3", "dash-group-title", handoffs.length ? "Pick up a spec or a handoff, or start fresh" : "Pick up a spec, or start fresh")
|
||||
);
|
||||
const row = el("div", "spec-row");
|
||||
|
||||
const scratch = el("button", "spec-chip" + (sel ? "" : " is-sel"));
|
||||
const scratchOn = !sel && !pickedHandoff;
|
||||
const scratch = el("button", "spec-chip" + (scratchOn ? " is-sel" : ""));
|
||||
scratch.type = "button";
|
||||
scratch.setAttribute("aria-current", String(!sel));
|
||||
scratch.setAttribute("aria-current", String(scratchOn));
|
||||
scratch.appendChild(el("span", "spec-chip-name", "Start from scratch"));
|
||||
scratch.appendChild(el("span", "spec-chip-state", "a new idea"));
|
||||
scratch.addEventListener("click", () => {
|
||||
@@ -3695,13 +3739,6 @@ function renderSpecPicker(specs) {
|
||||
});
|
||||
row.appendChild(scratch);
|
||||
|
||||
// A delete in flight ends when the agent's rescan lands (a new scan), gone
|
||||
// or refused: either way the picker below is the truth again.
|
||||
const sc = scan();
|
||||
if (local.deleting && sc && sc.at !== local.deleting.scanAt) {
|
||||
local.deleting = null;
|
||||
save();
|
||||
}
|
||||
for (const spec of specs) {
|
||||
const on = sel && sel.dir === spec.dir;
|
||||
// A fixed bug is finished: hidden while unavailable workflows are, dimmed
|
||||
@@ -3715,7 +3752,8 @@ function renderSpecPicker(specs) {
|
||||
b.setAttribute("aria-current", String(Boolean(on)));
|
||||
b.appendChild(el("span", "spec-chip-name", spec.name));
|
||||
b.appendChild(el("span", "spec-chip-state", deleting ? "Deleting…" : SPEC_STATE_LABELS[spec.state] || spec.state));
|
||||
if (spec.detail) b.appendChild(el("span", "spec-chip-detail", spec.detail));
|
||||
const detail = chipDetail(spec);
|
||||
if (detail) b.appendChild(el("span", "spec-chip-detail", detail));
|
||||
b.addEventListener("click", () => {
|
||||
local.specSel = spec.dir;
|
||||
save();
|
||||
@@ -3724,7 +3762,9 @@ function renderSpecPicker(specs) {
|
||||
});
|
||||
wrap.appendChild(b);
|
||||
if (isDeletableSpecDir(spec.dir)) {
|
||||
const del = el("button", "spec-chip-del", "✕");
|
||||
// A fixed bug is done with, so its Delete is a visible button rather
|
||||
// than the hover ✕ every other spec has.
|
||||
const del = fixed ? el("button", "spec-chip-del-label", "Delete") : el("button", "spec-chip-del", "✕");
|
||||
del.type = "button";
|
||||
del.title = `Delete ${spec.dir}/`;
|
||||
del.setAttribute("aria-label", `Delete the spec ${spec.name}`);
|
||||
@@ -3734,10 +3774,139 @@ function renderSpecPicker(specs) {
|
||||
}
|
||||
row.appendChild(wrap);
|
||||
}
|
||||
// Handoffs follow the specs: dashed chips, the state word is "Handoff".
|
||||
for (const h of handoffs) {
|
||||
const on = Boolean(pickedHandoff && pickedHandoff.id === h.id);
|
||||
const deleting = Boolean(local.deleting && local.deleting.dir === "handoff:" + h.id);
|
||||
const b = el("button", "spec-chip is-handoff" + (on ? " is-sel" : "") + (deleting ? " is-deleting" : ""));
|
||||
b.type = "button";
|
||||
b.setAttribute("aria-current", String(on));
|
||||
b.appendChild(el("span", "spec-chip-name", h.title || "Handoff"));
|
||||
b.appendChild(el("span", "spec-chip-state", deleting ? "Deleting…" : "Handoff"));
|
||||
b.appendChild(el("span", "spec-chip-detail", handoffAge(h.written)));
|
||||
b.addEventListener("click", () => {
|
||||
local.specSel = "handoff:" + h.id;
|
||||
save();
|
||||
render();
|
||||
});
|
||||
row.appendChild(b);
|
||||
}
|
||||
box.appendChild(row);
|
||||
return box;
|
||||
}
|
||||
|
||||
// A delete in flight ends when the agent's rescan lands (a new scan), gone
|
||||
// or refused: either way the picker is the truth again.
|
||||
function settleDeleting() {
|
||||
const sc = scan();
|
||||
if (local.deleting && sc && sc.at !== local.deleting.scanAt) {
|
||||
local.deleting = null;
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
// What a picked handoff shows: where it came from and its Next task, with the
|
||||
// four things to do with it.
|
||||
function renderHandoffPreview(h) {
|
||||
const box = el("section", "handoff-preview");
|
||||
box.appendChild(el("h3", "handoff-preview-title", h.title || "Handoff"));
|
||||
const entry = SKILL_CATALOG.find((e) => e.skill === h.skill);
|
||||
const meta = [
|
||||
"Written " + (h.written ? new Date(h.written).toLocaleString() : "at an unknown time"),
|
||||
h.spec ? "spec " + h.spec.replace(/^specs\//, "") : "no spec",
|
||||
"from " + (entry ? entry.title : h.skill),
|
||||
];
|
||||
box.appendChild(el("p", "handoff-preview-meta", meta.join(" · ")));
|
||||
if (h.next) {
|
||||
box.appendChild(el("p", "handoff-preview-label", "Next task"));
|
||||
box.appendChild(el("p", "handoff-preview-next", h.next));
|
||||
}
|
||||
const busy = Boolean(local.launching || local.deleting) || gone || pendingResult;
|
||||
const actions = el("div", "handoff-preview-actions");
|
||||
const go = el("button", "btn primary", "Pick it up here");
|
||||
go.type = "button";
|
||||
go.disabled = busy;
|
||||
go.addEventListener("click", () => pickUpHandoff(h));
|
||||
const read = el("button", "btn", "Read it all");
|
||||
read.type = "button";
|
||||
read.addEventListener("click", () => readHandoff(h));
|
||||
const copy = el("button", "btn", "Copy for a new conversation");
|
||||
copy.type = "button";
|
||||
copy.addEventListener("click", () => {
|
||||
const dir = (scan() && scan().handoffsDir) || "";
|
||||
const sep = dir.includes("\\") ? "\\" : "/";
|
||||
const file = dir ? dir.replace(/[\\/]+$/, "") + sep + h.id + ".md" : h.id + ".md";
|
||||
copyHandoffText(handoffCopyText(file), copy);
|
||||
});
|
||||
const del = el("button", "btn danger", "Delete");
|
||||
del.type = "button";
|
||||
del.disabled = busy;
|
||||
del.addEventListener("click", () => openHandoffDelete(h));
|
||||
actions.append(go, read, copy, del);
|
||||
box.appendChild(actions);
|
||||
return box;
|
||||
}
|
||||
|
||||
// The prompt that sends a new conversation to the handoff. A refused
|
||||
// clipboard gets a plain word on the button instead of a silent nothing.
|
||||
async function copyHandoffText(text, button) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
button.textContent = "Copied";
|
||||
} catch {
|
||||
button.textContent = "Copy was refused";
|
||||
}
|
||||
setTimeout(() => (button.textContent = "Copy for a new conversation"), 1500);
|
||||
}
|
||||
|
||||
// Pick it up here: a hop like a card launch. The page sends only the id; the
|
||||
// CLI reads the stored skill and spec, marks the handoff used and falls back
|
||||
// to Quick Task if either is gone.
|
||||
async function pickUpHandoff(h) {
|
||||
if (gone || pendingResult || local.launching || finish()) return;
|
||||
launchScoping = true;
|
||||
await syncWorkspaceScope(h.spec || "");
|
||||
try {
|
||||
const res = await fetch("/submit", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ actions: [pickupAction(h)], reply: pickupReply(h) }),
|
||||
});
|
||||
if (res.status === 409) {
|
||||
launchScoping = false;
|
||||
pendingResult = true;
|
||||
banner("Your last pick is still being picked up. One moment.", "info");
|
||||
return;
|
||||
}
|
||||
if (!res.ok) throw new Error(String(res.status));
|
||||
sound("startSkill");
|
||||
local.launching = { skill: h.skill, title: h.title || "the handoff", at: Date.now() };
|
||||
launchScoping = false;
|
||||
pendingResult = true;
|
||||
save();
|
||||
render();
|
||||
} catch {
|
||||
launchScoping = false;
|
||||
banner("That did not go through. Nothing was lost; try again.", "warn");
|
||||
}
|
||||
}
|
||||
|
||||
// Read it all: the document, in a dialog, from /handoff?id= (served only for
|
||||
// an id the dashboard's own scan listed).
|
||||
async function readHandoff(h) {
|
||||
$("handoff-title").textContent = h.title || "Handoff";
|
||||
const body = $("handoff-body");
|
||||
body.replaceChildren(el("p", "md-p", "Reading…"));
|
||||
$("handoff-modal").showModal();
|
||||
try {
|
||||
const res = await fetch("/handoff?id=" + encodeURIComponent(h.id), { cache: "no-store" });
|
||||
if (res.status !== 200) throw new Error(String(res.status));
|
||||
mdInto(body, await res.text());
|
||||
} catch {
|
||||
body.replaceChildren(el("p", "md-p", "This handoff could not be read."));
|
||||
}
|
||||
}
|
||||
|
||||
function dashCard(entry, menu) {
|
||||
const presentation = cardPresentation(entry, scan(), selSpec(), menu);
|
||||
// The agent's `recommend` and detail describe the initially selected spec.
|
||||
@@ -5248,8 +5417,13 @@ function buildReview(card, item, staged) {
|
||||
for (const v of verdicts) {
|
||||
const on = staged && staged.verdict === v.id;
|
||||
// A picked danger verdict stays red (filled), so choosing "Abort" never
|
||||
// reads like choosing the safe default.
|
||||
const b = el("button", "btn" + (on ? (v.danger ? " danger is-on" : " primary") : v.danger ? " danger" : ""), verdictText(v));
|
||||
// reads like choosing the safe default. An unpicked approve is outlined
|
||||
// in the accent, so the main way forward stands out.
|
||||
const b = el(
|
||||
"button",
|
||||
"btn" + (on ? (v.danger ? " danger is-on" : " primary") : v.danger ? " danger" : v.id === "approve" ? " is-approve" : ""),
|
||||
verdictText(v)
|
||||
);
|
||||
b.type = "button";
|
||||
b.addEventListener("click", () =>
|
||||
stage(item.id, withNote(item, on ? null : { type: "answer", kind: "review", verdict: v.id }))
|
||||
@@ -7550,13 +7724,58 @@ function openHomeConfirm() {
|
||||
|
||||
// The picker's Delete: a dialog in two steps. The first says what goes and
|
||||
// that it is for good; "Delete this spec…" then reveals the second, which
|
||||
// enables the final button only once the spec's name is typed exactly.
|
||||
// enables the final button only once the spec's name is typed exactly. A
|
||||
// fixed bug skips the second step: its first press sends the delete.
|
||||
// Cancel, Escape or a click on Keep it at either step changes nothing.
|
||||
let deleteTarget = null;
|
||||
// The spec warning as index.html writes it, kept so a fixed bug's wording
|
||||
// never sticks for the next spec.
|
||||
let deleteWarnDefault = null;
|
||||
|
||||
// A handoff's Delete reuses the same dialog in one step: no name to type, and
|
||||
// the warning says where the file lives instead of what git does not track.
|
||||
function openHandoffDelete(h) {
|
||||
if (gone || pendingResult || local.launching || local.deleting) return;
|
||||
deleteTarget = { handoff: h };
|
||||
$("delete-title").textContent = "Delete this handoff?";
|
||||
$("delete-blurb").textContent = "This handoff will be deleted from ~/.plan2code/handoffs/.";
|
||||
$("delete-warn").hidden = true;
|
||||
$("delete-warn-handoff").hidden = false;
|
||||
const facts = $("delete-facts");
|
||||
facts.replaceChildren();
|
||||
const fact = (term, value) => {
|
||||
if (!value) return;
|
||||
facts.appendChild(el("dt", "", term));
|
||||
facts.appendChild(el("dd", "", value));
|
||||
};
|
||||
const entry = SKILL_CATALOG.find((e) => e.skill === h.skill);
|
||||
fact("Handoff", h.title || h.id);
|
||||
fact("Written", h.written ? new Date(h.written).toLocaleString() : "");
|
||||
fact("Spec", h.spec ? h.spec.replace(/^specs\//, "") : "");
|
||||
fact("From", entry ? entry.title : h.skill);
|
||||
$("delete-confirm").hidden = true;
|
||||
const go = $("delete-go");
|
||||
go.textContent = "Delete it";
|
||||
go.classList.add("is-on");
|
||||
go.disabled = false;
|
||||
$("delete-modal").showModal();
|
||||
}
|
||||
|
||||
function openDeleteConfirm(spec) {
|
||||
if (!isDeletableSpecDir(spec.dir) || gone || pendingResult || local.launching || local.deleting) return;
|
||||
deleteTarget = spec;
|
||||
// A fixed bug is finished work: one confirm, and a warning that says so.
|
||||
const fixed = spec.state === "fixed";
|
||||
$("delete-title").textContent = "Delete this spec?";
|
||||
const warn = $("delete-warn");
|
||||
if (!deleteWarnDefault) deleteWarnDefault = [...warn.childNodes].map((n) => n.cloneNode(true));
|
||||
warn.replaceChildren(
|
||||
...(fixed
|
||||
? ["The bug is fixed, so this only clears the write-up. ", el("code", "", "specs/"), " is not tracked by git, so it cannot be brought back."]
|
||||
: deleteWarnDefault.map((n) => n.cloneNode(true)))
|
||||
);
|
||||
warn.hidden = false;
|
||||
$("delete-warn-handoff").hidden = true;
|
||||
const sum = deleteSummary(spec);
|
||||
$("delete-blurb").textContent = `Everything in ${sum.folder} will be deleted from this project.`;
|
||||
const facts = $("delete-facts");
|
||||
@@ -7575,8 +7794,8 @@ function openDeleteConfirm(spec) {
|
||||
$("delete-name").value = "";
|
||||
$("delete-confirm").hidden = true;
|
||||
const go = $("delete-go");
|
||||
go.textContent = "Delete this spec…";
|
||||
go.classList.remove("is-on");
|
||||
go.textContent = fixed ? "Delete it" : "Delete this spec…";
|
||||
go.classList.toggle("is-on", fixed);
|
||||
go.disabled = false;
|
||||
$("delete-modal").showModal();
|
||||
}
|
||||
@@ -7584,6 +7803,8 @@ function openDeleteConfirm(spec) {
|
||||
function deleteStep() {
|
||||
const go = $("delete-go");
|
||||
if (!deleteTarget) return;
|
||||
if (deleteTarget.handoff) return sendDeleteHandoff(deleteTarget.handoff);
|
||||
if (deleteTarget.state === "fixed") return sendDelete(deleteTarget);
|
||||
if ($("delete-confirm").hidden) {
|
||||
$("delete-confirm").hidden = false;
|
||||
go.textContent = "Delete for good";
|
||||
@@ -7596,6 +7817,38 @@ function deleteStep() {
|
||||
sendDelete(deleteTarget);
|
||||
}
|
||||
|
||||
async function sendDeleteHandoff(h) {
|
||||
const go = $("delete-go");
|
||||
go.disabled = true;
|
||||
try {
|
||||
const res = await fetch("/submit", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ actions: [deleteHandoffAction(h)], reply: deleteHandoffReply(h) }),
|
||||
});
|
||||
if (res.status === 409) throw Object.assign(new Error("pending"), { pending: true });
|
||||
if (!res.ok) throw new Error(String(res.status));
|
||||
const sc = scan();
|
||||
local.deleting = { dir: "handoff:" + h.id, scanAt: sc ? sc.at : null };
|
||||
if (local.specSel === "handoff:" + h.id) delete local.specSel;
|
||||
pendingResult = true;
|
||||
save();
|
||||
$("delete-modal").close();
|
||||
} catch (err) {
|
||||
$("delete-modal").close();
|
||||
if (err && err.pending) pendingResult = true;
|
||||
banner(
|
||||
err && err.pending
|
||||
? "Your last pick is still being picked up, so that could not go yet. Nothing was deleted; try again in a moment."
|
||||
: "That did not go through. Nothing was deleted; try again.",
|
||||
"warn"
|
||||
);
|
||||
} finally {
|
||||
deleteTarget = null;
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
async function sendDelete(spec) {
|
||||
const go = $("delete-go");
|
||||
go.disabled = true;
|
||||
@@ -7684,29 +7937,42 @@ function openStopConfirm() {
|
||||
}
|
||||
const n = Object.keys(local.staged).length + pendingNotes().length;
|
||||
const warn = stopWarning();
|
||||
const dash = isDashboard();
|
||||
$("stop-blurb").textContent =
|
||||
(n === 1 ? "The answer you have ready goes with it. " : n ? `The ${n} answers you have ready go with it. ` : "") +
|
||||
(isDashboard()
|
||||
? "Nothing has started yet, so there is nothing to save: this just ends the console session."
|
||||
: warn
|
||||
? "Plan2Code stops here."
|
||||
: "Plan2Code will save your place and give you a command to pick this up later, in a new conversation.");
|
||||
(dash ? "Nothing has started yet, so there is nothing to save: this just ends the console session." : "");
|
||||
$("stop-blurb").hidden = !$("stop-blurb").textContent;
|
||||
$("stop-warn").hidden = !warn;
|
||||
$("stop-warn").textContent = warn;
|
||||
$("stop-go").textContent = isDashboard() ? "Stop" : warn ? "Stop anyway" : "Stop and save";
|
||||
// The dashboard has nothing to hand off: one plain Stop. Elsewhere both
|
||||
// choices show, and "Just stop and save" turns into "Stop anyway" where
|
||||
// nothing is saved yet.
|
||||
$("stop-handoff").hidden = dash;
|
||||
const title = $("stop-go").querySelector(".stop-choice-title");
|
||||
const detail = $("stop-go").querySelector(".stop-choice-detail");
|
||||
if (dash) {
|
||||
title.textContent = "Stop";
|
||||
detail.textContent = "Ends the console session.";
|
||||
} else if (warn) {
|
||||
title.textContent = "Stop anyway";
|
||||
detail.textContent = "Ends the session now. What the warning above names is not kept.";
|
||||
} else {
|
||||
title.textContent = "Just stop and save";
|
||||
detail.textContent = "Saves what this step keeps on disk and gives you a command to resume. What we talked about is not kept.";
|
||||
}
|
||||
$("stop-modal").showModal();
|
||||
}
|
||||
|
||||
async function stopSession() {
|
||||
const go = $("stop-go");
|
||||
go.disabled = true;
|
||||
async function stopSession(handoff = false) {
|
||||
const buttons = [$("stop-handoff"), $("stop-go")];
|
||||
for (const b of buttons) b.disabled = true;
|
||||
const payload = stagedPayload();
|
||||
payload.actions.push({ i: "__stop", type: "stop" });
|
||||
payload.actions.push(stopAction({ handoff }));
|
||||
try {
|
||||
const res = await fetch("/submit", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ actions: payload.actions, reply: [...payload.replyLines, STOP_REPLY].join("\n") }),
|
||||
body: JSON.stringify({ actions: payload.actions, reply: [...payload.replyLines, handoff ? STOP_HANDOFF_REPLY : STOP_REPLY].join("\n") }),
|
||||
});
|
||||
if (res.status === 409) throw Object.assign(new Error("pending"), { pending: true });
|
||||
if (!res.ok) throw new Error(String(res.status));
|
||||
@@ -7725,7 +7991,7 @@ async function stopSession() {
|
||||
"warn"
|
||||
);
|
||||
} finally {
|
||||
go.disabled = false;
|
||||
for (const b of buttons) b.disabled = false;
|
||||
render();
|
||||
}
|
||||
}
|
||||
@@ -8299,6 +8565,7 @@ function openHelpOn(id) {
|
||||
$("btn-home").addEventListener("click", openHomeConfirm);
|
||||
$("update-done").addEventListener("click", () => $("update-modal").close());
|
||||
$("delete-cancel").addEventListener("click", () => $("delete-modal").close());
|
||||
$("handoff-close").addEventListener("click", () => $("handoff-modal").close());
|
||||
$("delete-go").addEventListener("click", deleteStep);
|
||||
$("delete-name").addEventListener("input", () => {
|
||||
$("delete-go").disabled = !deleteTarget || $("delete-name").value.trim() !== deleteTarget.name;
|
||||
@@ -8316,7 +8583,8 @@ $("home-cancel").addEventListener("click", () => $("home-modal").close());
|
||||
$("home-go").addEventListener("click", goHome);
|
||||
$("btn-stop").addEventListener("click", openStopConfirm);
|
||||
$("stop-cancel").addEventListener("click", () => $("stop-modal").close());
|
||||
$("stop-go").addEventListener("click", stopSession);
|
||||
$("stop-handoff").addEventListener("click", () => stopSession(true));
|
||||
$("stop-go").addEventListener("click", () => stopSession(false));
|
||||
$("stopping-hide").addEventListener("click", () => {
|
||||
stoppingHidden = true;
|
||||
$("stopping-modal").close();
|
||||
|
||||
@@ -1661,6 +1661,23 @@
|
||||
<strong>Hide unavailable workflows</strong>, under the picker, hides
|
||||
them instead. It is on to begin with, and remembered on this machine.
|
||||
</p>
|
||||
<p>
|
||||
The <strong>✕</strong> on a spec deletes its folder, after two steps:
|
||||
one says what goes, the other wants the spec's name typed. A fixed
|
||||
bug has its own <strong>Delete</strong> button at the bottom of its
|
||||
chip instead, and needs just one confirm, since the work is done.
|
||||
</p>
|
||||
<p>
|
||||
A <strong>Handoff</strong> is a note a step left when you stopped it
|
||||
with a handoff. It shows as a dashed chip after the specs. Pick one
|
||||
and the cards give way to a preview with its Next task and four
|
||||
buttons: <strong>Pick it up here</strong> carries on in the same step
|
||||
and spec, <strong>Read it all</strong> shows the whole note,
|
||||
<strong>Copy for a new conversation</strong> puts a ready prompt on
|
||||
the clipboard, and <strong>Delete</strong> removes it. A picked-up
|
||||
handoff drops off the list, but stays in
|
||||
<code>~/.plan2code/handoffs/</code> until the 30-day sweep.
|
||||
</p>
|
||||
<h4>The Suggested flag</h4>
|
||||
<p>
|
||||
One card may carry a <strong>Suggested</strong> flag: where Plan2Code
|
||||
@@ -2092,8 +2109,16 @@
|
||||
through writing your answers down.
|
||||
</li>
|
||||
<li>
|
||||
It asks first. <strong>Keep going</strong> backs out;
|
||||
<strong>Stop and save</strong> stops.
|
||||
It asks first, and offers two ways to stop.
|
||||
<strong>Stop with a handoff</strong> saves your place and writes a
|
||||
note the dashboard can offer to pick up later;
|
||||
<strong>Just stop and save</strong> saves what the step keeps on
|
||||
disk and gives you a command to resume, without the conversation;
|
||||
<strong>Keep going</strong> backs out.
|
||||
</li>
|
||||
<li>
|
||||
A handoff lands in <code>~/.plan2code/handoffs/</code> and shows on
|
||||
the dashboard, next to your specs, until you use or delete it.
|
||||
</li>
|
||||
<li>
|
||||
At points where nothing is saved yet, such as early in a plan, the
|
||||
@@ -2245,7 +2270,9 @@
|
||||
that folder is usually gitignored and git can't restore it. It
|
||||
shows each one with its size, and <strong>Delete these</strong>
|
||||
removes exactly that list. Your preferences, saved folders, models,
|
||||
the launcher and the session you are in always stay.
|
||||
the launcher and the session you are in always stay, and the
|
||||
<code>handoffs/</code> folder is Plan2Code's own, so it is never
|
||||
offered for removal.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Back to default</strong> puts everything back as it was, and
|
||||
@@ -2296,7 +2323,10 @@
|
||||
this machine who has it can open the session.
|
||||
</p>
|
||||
<h4>What is kept, and where</h4>
|
||||
<p>Everything lives under <code>~/.plan2code/console/</code> in your home folder:</p>
|
||||
<p>
|
||||
Everything lives in your home folder, under
|
||||
<code>~/.plan2code/console/</code> unless noted:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
each session's questions, your drafts and your answers, in
|
||||
@@ -2314,7 +2344,13 @@
|
||||
</li>
|
||||
<li>
|
||||
your Subagents switch for each project and skill, in
|
||||
<code>subagents.json</code>.
|
||||
<code>subagents.json</code>;
|
||||
</li>
|
||||
<li>
|
||||
handoffs you save when you stop or with the Handoff skill, in
|
||||
<code>~/.plan2code/handoffs/</code>, one <code>.md</code> and one
|
||||
<code>.json</code> each, removed after the same
|
||||
<span data-fact="cleanupDays">30</span> days.
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
@@ -2585,20 +2621,37 @@
|
||||
<!-- Only when stopping now would lose answers. A button that says it
|
||||
saves has to be true about the times it cannot. -->
|
||||
<p class="modal-why" id="stop-warn" hidden></p>
|
||||
<div class="stop-choices">
|
||||
<button type="button" class="stop-choice suggested" id="stop-handoff">
|
||||
<span class="stop-choice-icon" aria-hidden="true">✎</span>
|
||||
<span class="stop-choice-text">
|
||||
<span class="stop-choice-title">Stop with a handoff</span>
|
||||
<span class="stop-choice-detail">Saves your place and writes a handoff note. Next time the dashboard offers to pick it up right where this left off.</span>
|
||||
</span>
|
||||
</button>
|
||||
<button type="button" class="stop-choice" id="stop-go">
|
||||
<span class="stop-choice-icon" aria-hidden="true">■</span>
|
||||
<span class="stop-choice-text">
|
||||
<span class="stop-choice-title">Just stop and save</span>
|
||||
<span class="stop-choice-detail">Saves what this step keeps on disk and gives you a command to resume. What we talked about is not kept.</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button type="button" class="btn ghost" id="stop-cancel">Keep going</button>
|
||||
<button type="button" class="btn primary" id="stop-go">Stop and save</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<!-- Deleting a spec from the dashboard's picker. Two deliberate steps: the
|
||||
first says what goes and that it is for good, the second wants the
|
||||
spec's name typed. The page only asks; the agent deletes. -->
|
||||
spec's name typed. A fixed bug takes the first step only. The page
|
||||
only asks; the agent deletes. -->
|
||||
<dialog class="modal" id="delete-modal" aria-labelledby="delete-title">
|
||||
<h2 id="delete-title">Delete this spec?</h2>
|
||||
<p class="modal-blurb" id="delete-blurb"></p>
|
||||
<dl class="delete-facts" id="delete-facts"></dl>
|
||||
<p class="modal-why" id="delete-warn">This is permanent. <code>specs/</code> is not tracked by git, so nothing can bring these files back.</p>
|
||||
<p class="modal-why" id="delete-warn-handoff" hidden>Handoffs are not kept anywhere else.</p>
|
||||
<div class="delete-confirm" id="delete-confirm" hidden>
|
||||
<label for="delete-name">To delete it for good, type <strong id="delete-name-hint"></strong></label>
|
||||
<input type="text" id="delete-name" autocomplete="off" spellcheck="false" />
|
||||
@@ -2609,6 +2662,16 @@
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<!-- A handoff's whole document, from the dashboard's "Read it all". Escape
|
||||
closes it; the body is filled by the page with rendered markdown. -->
|
||||
<dialog class="modal handoff-read" id="handoff-modal" aria-labelledby="handoff-title">
|
||||
<h2 id="handoff-title">Handoff</h2>
|
||||
<div class="handoff-body md" id="handoff-body"></div>
|
||||
<div class="modal-actions">
|
||||
<button type="button" class="btn ghost" id="handoff-close">Close</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<dialog class="modal" id="home-modal" aria-labelledby="home-title">
|
||||
<h2 id="home-title">Leave this workflow?</h2>
|
||||
<p class="modal-blurb" id="home-blurb"></p>
|
||||
|
||||
Reference in new issue
Block a user