Carry the spec into the app's New Session and name it beside the meter

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-09 22:09:03 -08:00
1 parent 7856618a4c
commit 7891c06642
14 files changed
+320 -6

No files matched your search

+39
View File
@@ -145,6 +145,9 @@
<button type="button" class="linky" id="meter-help">What is this?</button>
</div>
</span>
<!-- The spec this session works on (the dashboard picker's pick on the
dashboard), quiet beside the meter. Hidden when there is none. -->
<span class="spec-tag" id="spec-tag" hidden></span>
</div>
<div class="progress-block">
<div class="progress-label">
@@ -436,6 +439,13 @@
<path d="M10 3v14.5a2 2 0 0 0 4 0V3" />
<path d="M10 12h4" />
</symbol>
<!-- Clear out dead code: a skull. -->
<symbol id="ci-dead-code" viewBox="0 0 24 24" fill="none">
<path d="M12 3a7 7 0 0 0-7 7c0 2.4 1.2 4.1 3 5.2V18a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-2.8c1.8-1.1 3-2.8 3-5.2a7 7 0 0 0-7-7z" />
<circle cx="9.5" cy="11" r="1.5" />
<circle cx="14.5" cy="11" r="1.5" />
<path d="M10 19v2M12 19v2M14 19v2" />
</symbol>
<!-- Changelog: a version tag. -->
<symbol id="ci-changelog" viewBox="0 0 24 24" fill="none">
<path d="M3 4a1 1 0 0 1 1-1h7.6a2 2 0 0 1 1.4.6l7.4 7.4a2 2 0 0 1 0 2.8l-5.6 5.6a2 2 0 0 1-2.8 0L4.6 12a2 2 0 0 1-.6-1.4z" />
@@ -901,6 +911,35 @@
</g>
</g>
</svg>
<!-- Dead code: clearing out code nothing uses. He holds up a small
skull whose jaw chatters, his star glancing over at it, before it
settles and the chatter starts again. -->
<svg class="pose pose-dead-code" data-pose="dead-code" viewBox="0 4 240 216" aria-hidden="true" focusable="false">
<ellipse class="shadow" cx="126" cy="198" rx="44" ry="5" />
<g class="bob">
<g class="dd-skull">
<g class="dd-jaw">
<rect class="dd-bone" x="176" y="112" width="22" height="16" rx="5" />
<line class="lt" x1="183" y1="120" x2="183" y2="127" />
<line class="lt" x1="191" y1="120" x2="191" y2="127" />
</g>
<path class="dd-bone" d="M187 88 A17 17 0 0 0 170 105 C170 112 173 116 178 119 L196 119 C201 116 204 112 204 105 A17 17 0 0 0 187 88 Z" />
<circle class="fl" cx="180" cy="105" r="4.5" />
<circle class="fl" cx="194" cy="105" r="4.5" />
<path class="fl" d="M187 110 L184.5 115 L189.5 115 Z" />
</g>
<g transform="translate(-14 0)">
<rect class="fl foot f1" x="94" y="179" width="20" height="10" rx="5" />
<rect class="fl foot f2" x="126" y="179" width="20" height="10" rx="5" />
<rect class="sh" x="80" y="72" width="80" height="108" rx="16" />
<path class="ln" d="M80 126 L66 150" /><circle class="fl" cx="66" cy="150" r="5.5" />
<g class="dd-look"><path class="ey blink" d="M126 86 L129.64 94.98 L139.31 95.67 L131.9 101.92 L134.23 111.33 L126 106.2 L117.77 111.33 L120.1 101.92 L112.69 95.67 L122.36 94.98 Z" /></g>
<path class="es" d="M110 120 Q122 129 134 120" />
<line class="ln" x1="160" y1="126" x2="196" y2="136" />
<circle class="fl" cx="200" cy="136" r="5.5" />
</g>
</g>
</svg>
<!-- Agent setup: waving hello at a terminal window, its prompt waiting
for the command line that brings an agent. -->
<svg class="pose pose-setup" data-pose="setup" viewBox="0 4 240 216" aria-hidden="true" focusable="false">
+16 -2
View File
@@ -54,8 +54,8 @@ import { helperRows, showTab } from "../subagents.js";
import { FOOTER_TIERS, footerLabel } from "../workspace.js";
import {
activity, agentAdrift, agentWorking, askBusy, loopDriving, loopWaiting, loopWaitingKey, asked, awaitingReply, byId, dashboardLive, docs, doingNow,
AGENTS_VIEW, agentsTabShown, finish, gitAwaiting, isDashboard, isGitBoard, isOpen, isSpecFileView, items, loadAgentsDoc, loadOverview, myTurn, openItems,
finishKey, patience, pressStranded, reviewPending, scan, selSpec, sendCollected, specFileTabs, stagedCount, stranded,
AGENTS_VIEW, agentsTabShown, finish, gitAwaiting, isDashboard, isGitBoard, isOpen, isSpecFileView, items, loadAgentsDoc, loadOverview, loadSpecCarry, myTurn, openItems,
finishKey, overviewSpec, patience, pressStranded, reviewPending, scan, selSpec, sendCollected, specFileTabs, stagedCount, stranded,
topics, workingMs, WORKING_GRACE_MS,
workspaceFolders,
} from "../selectors.js";
@@ -550,6 +550,8 @@ export function adopt(body) {
// A spec file tab's file changes under a build, so a tab you are watching
// refetches on every new frame too, not only on the click that opened it.
if (firstLoad || page.S.specDir !== prevSpecDir || page.S.workflow !== prevWorkflow || isSpecFileView(page.view)) loadOverview();
// A New Session in the app leaves the spec it was in; the fresh dashboard picks it up once its scan is here.
loadSpecCarry();
// The Dashboard's AGENTS.md tab: found on arrival, re-read while it is open.
if (firstLoad || page.S.workflow !== prevWorkflow || page.view === AGENTS_VIEW) loadAgentsDoc();
if (announce) showArrival(announce);
@@ -1131,8 +1133,20 @@ function renderMeter() {
);
}
// The spec in hand, quiet beside the meter: the picker's pick on the
// dashboard, the session's own spec everywhere else (overviewSpec()).
function renderSpecTag() {
const tag = $("spec-tag");
const dir = isAgentless(page.S.workflow) ? "" : overviewSpec();
const name = dir ? (isDashboard() && selSpec()?.name) || dir.replace(/^specs\//, "") : "";
tag.hidden = !name;
tag.textContent = name;
tag.title = name ? "Spec: " + dir : "";
}
function renderChrome() {
renderMeter();
renderSpecTag();
$("title").textContent = page.S.title || "Session";
$("badge").textContent = workflowLabel(page.S.workflow);
renderTabTitle();
+21 -1
View File
@@ -3,7 +3,7 @@
// Plain functions over `page` (state.js) that more than one screen asks the
// same question of, kept here so no screen has to import another to ask it.
import { page, redraw } from "./state.js";
import { page, redraw, saveNow } from "./state.js";
import { boardAwaiting } from "./git-board.js";
import { defaultSpec, reviewOffer, dashboardOffer, submittedAwaiting, quietLimitMs } from "./answers.js";
import { isAgentless } from "./skills.js";
@@ -338,6 +338,26 @@ export async function loadOverview() {
if (changed) redraw();
}
// A New Session in the desktop app leaves the spec it was in for the fresh
// dashboard (spec-carry.mjs). Asked once per page, before the picker is
// touched; used only if the picker lists that spec, else the default stands.
let specCarryAsked = false;
export async function loadSpecCarry() {
if (specCarryAsked || !isDashboard() || !scan() || page.local.specSel !== undefined) return;
specCarryAsked = true;
try {
const res = await fetch("/spec-carry", { method: "POST", cache: "no-store" });
const { spec } = res.status === 200 ? await res.json() : {};
if (!spec || page.local.specSel !== undefined || !specList().some((s) => s.dir === spec)) return;
page.local.specSel = spec;
saveNow();
redraw();
loadOverview();
} catch {
/* no hint: the picker keeps its default */
}
}
// The Dashboard's AGENTS.md tab: its view id, and whether it is on now (the
// dashboard, with an AGENTS.md the last read found).
export const AGENTS_VIEW = "agents-md";
+8
View File
@@ -151,6 +151,14 @@
.meter-fresh-row .handoff-code { flex-basis: 180px; font-size: 12px; padding: 6px 10px; }
.meter-item-points { flex: none; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
/* The spec in hand: small and muted so it never competes with the title. */
.spec-tag {
flex: 0 1 auto; min-width: 0; max-width: 220px; align-self: center;
font-size: 11.5px; color: var(--ink-3);
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.spec-tag[hidden] { display: none; }
.badge {
font-size: 11px;
font-weight: 700;
+8
View File
@@ -35,6 +35,7 @@ import { SHOTS_DIR_NAME, SHOT_NAME, shotType, isOpen } from "./patches.mjs";
import { appendChat, currentConversation, pendingChatCount, typedCount } from "./inbox.mjs";
import { specKey } from "./workspace.mjs";
import { readLoopSetup, saveLoopSetup } from "./loop-setup.mjs";
import { takeSpecCarry } from "./spec-carry.mjs";
import { resolveStrengths } from "./strengths.mjs";
import { MARKERS, phaseChecklist } from "./spec-files.mjs";
import {
@@ -128,6 +129,7 @@ const ROUTES = [
{ path: "/workspace/browse", method: "POST", origin: true, run: workspaceBrowse },
{ path: "/loop-setup", method: "GET", run: loopSetupGet },
{ path: "/loop-setup", method: "POST", origin: true, run: loopSetupPost },
{ path: "/spec-carry", method: "POST", origin: true, run: specCarry },
{ path: "/cancel", method: "POST", origin: true, run: cancel },
{ path: "/ping", method: "POST", run: ping },
{ path: "/bye", origin: true, run: bye },
@@ -1723,6 +1725,12 @@ function loopSetupPost(req, res, ctx) {
});
}
// The spec the app's New Session carried over (spec-carry.mjs), taken once by
// the fresh dashboard's page, which keeps it only if its picker lists that spec.
function specCarry(req, res, ctx) {
return json(res, 200, { spec: takeSpecCarry(loopProject(ctx)) });
}
/* --------------------------------------------------------- the workspace */
// The Workspace: the original folder plus any the person adds as context.
+1
View File
@@ -306,6 +306,7 @@ export const PROTECTED_CONSOLE_FILES = new Set([
"workspaces.json",
"loop-setup.json",
"loop-reports.json",
"spec-carry.json",
"subagents.json",
"pr-hosts.json",
"console-dir",
+44
View File
@@ -0,0 +1,44 @@
// Plan2Code Web Console - the spec a desktop app's New Session carries over to its fresh dashboard.
import fs from "node:fs";
import path from "node:path";
import { HOME_DIR } from "./files.mjs";
import { foldKey } from "./workspace.mjs";
// One short-lived file, written by the app just before the fresh agent starts
// and read once by the new dashboard's page:
//
// { "project": "<worktree>", "spec": "specs/<name>", "at": <epoch ms> }
//
// Beside looks.json, never under specs/. It is only a hint: the page uses it
// when that spec is on the new dashboard's picker, and ignores it otherwise.
export const SPEC_CARRY_FILE = path.join(HOME_DIR, "spec-carry.json");
// An old hint must not preselect a spec in a session the person opens much later.
export const SPEC_CARRY_MAX_AGE_MS = 10 * 60 * 1000;
const SPEC_KEY = /^specs\/[^/\\.][^/\\]*$/;
/**
* The spec dir the app left for `project`, or null. The file is removed on any
* read that finds it, so one New Session hints one dashboard: a stale or
* other-folder hint is dropped too, never kept for a later session.
*/
export function takeSpecCarry(project, now = Date.now(), file = SPEC_CARRY_FILE) {
let entry;
try {
entry = JSON.parse(fs.readFileSync(file, "utf8"));
} catch {
return null;
}
if (!entry || typeof entry !== "object") return null;
const mine = typeof entry.project === "string" && project && foldKey(entry.project) === foldKey(project);
// Another window's hint stays for that window's dashboard.
if (!mine) {
return Number.isFinite(entry.at) && now - entry.at <= SPEC_CARRY_MAX_AGE_MS ? null : (fs.rmSync(file, { force: true }), null);
}
fs.rmSync(file, { force: true });
const fresh = Number.isFinite(entry.at) && now - entry.at <= SPEC_CARRY_MAX_AGE_MS;
return fresh && typeof entry.spec === "string" && SPEC_KEY.test(entry.spec) ? entry.spec : null;
}