mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Keep the taskbar dot and tab icon lit while a finished screen still offers a button
AI Assisted
This commit is contained in:
1 parent
03f433043e
commit
5950abb0aa
6 files changed
+86
-16
No files matched your search
@@ -299,6 +299,27 @@ test("framed, the page tells the app its state once per change, never on a redra
|
||||
assert.deepEqual((await toApp(s, "attention")).at(-1), { plan2code: "attention", state: "plain" });
|
||||
});
|
||||
|
||||
test("framed, a finished screen with a button still to press is the person's move; one with nothing left is plain", async (t) => {
|
||||
const browser = await pages.browser();
|
||||
const last = async (s) => (await toApp(s, "attention")).at(-1)?.state;
|
||||
// The finished screen that waits on a press once told the app plain, so the
|
||||
// taskbar showed no dot while the person was needed.
|
||||
// Both start busy, so the state read after the finish's line shows is the
|
||||
// finish's own (the line and the message come from the same redraw).
|
||||
const WORKING = { agent: { status: "working", activity: "Task 1 of 2" } };
|
||||
const offered = await openSession(browser, { t, workflow: "quick-task", payload: WORKING, env: { PLAN2CODE_IN_APP: "1" }, init: FAKE_APP_FRAME });
|
||||
await until(async () => (await last(offered)) === "busy", 5000);
|
||||
offered.post({ finish: { headline: "Quick task done", command: "git add -A && git commit -m x -m y", dashboard: true } });
|
||||
await until(async () => (await offered.page.locator("#agent-text").textContent()).includes("Head back to the dashboard"), 5000);
|
||||
assert.equal(await last(offered), "ready", "a finish offering the dashboard is the person's move");
|
||||
|
||||
const paused = await openSession(browser, { t, workflow: "implement", payload: WORKING, env: { PLAN2CODE_IN_APP: "1" }, init: FAKE_APP_FRAME });
|
||||
await until(async () => (await last(paused)) === "busy", 5000);
|
||||
paused.post({ finish: { headline: "Paused at Phase 2", command: "/plan2code-3-implement specs/audit-export/overview.md" } });
|
||||
await until(async () => (await paused.page.locator("#agent-text").textContent()).startsWith("Paused"), 5000);
|
||||
assert.equal(await last(paused), "plain", "a paused finish has nothing left to press");
|
||||
});
|
||||
|
||||
test("the Desktop app group shows only in the app's frame, reflects the app's saved switch and tells the app when it changes", async (t) => {
|
||||
const browser = await pages.browser();
|
||||
const plain = await openSession(browser, { t, workflow: "implement", payload: ASKING });
|
||||
|
||||
@@ -32,15 +32,16 @@ import { joinedCss } from "./css-helpers.mjs";
|
||||
test("favicon: the dot follows the status line -- busy, ready, attention, plain", () => {
|
||||
// Anything with the spinning ring is busy, even a finished screen opening the dashboard.
|
||||
assert.equal(faviconState({ mood: "work", spin: true }), "busy");
|
||||
assert.equal(faviconState({ mood: "work", spin: true, finished: true }), "busy");
|
||||
// Pointing is the person's move, a finished screen with a press on offer too.
|
||||
assert.equal(faviconState({ mood: "point" }), "ready");
|
||||
// A working mood without the ring is the stale line; adrift and gone need a look too.
|
||||
// A working mood without the ring is the stale line; adrift (a finished
|
||||
// screen's stranded press among them) and gone need a look too.
|
||||
assert.equal(faviconState({ mood: "work" }), "attention");
|
||||
assert.equal(faviconState({ mood: "adrift" }), "attention");
|
||||
assert.equal(faviconState({ mood: "gone" }), "attention");
|
||||
assert.equal(faviconState({ mood: "happy" }), "plain");
|
||||
assert.equal(faviconState({ mood: "done", finished: true }), "plain");
|
||||
assert.equal(faviconState({ mood: "point", finished: true }), "plain");
|
||||
// All done or paused, nothing left to press.
|
||||
assert.equal(faviconState({ mood: "done" }), "plain");
|
||||
assert.equal(faviconState(), "plain");
|
||||
});
|
||||
|
||||
@@ -420,3 +421,49 @@ test("getting started: the new help, status and finished-screen strings carry no
|
||||
const fresh = stuck.slice(0, stuck.indexOf("<h4>Not running, or not connected?</h4>"));
|
||||
assert.ok(!fresh.includes(EM), "the callout and rows have no em dash");
|
||||
});
|
||||
|
||||
// Every relative module a file pulls in, as `{ file, dynamic, names }`: static
|
||||
// `import`/`export ... from` lines, and `import("./x")` calls with the names
|
||||
// destructured from them when the call reads `const { a, b } = await import(...)`.
|
||||
function relativeImports(file) {
|
||||
const text = fs.readFileSync(file, "utf8");
|
||||
const found = [];
|
||||
for (const m of text.matchAll(/(?:^|[\s;])(?:import|export)\s+(?:[^"';]*?\sfrom\s+)?["'](\.{1,2}\/[^"']+)["']/g)) {
|
||||
found.push({ file: path.resolve(path.dirname(file), m[1]), dynamic: false, names: null });
|
||||
}
|
||||
for (const m of text.matchAll(/(?:const\s*\{([^}]*)\}\s*=\s*await\s+)?import\(\s*["'](\.{1,2}\/[^"']+)["']\s*\)/g)) {
|
||||
const names = m[1] ? m[1].split(",").map((n) => n.trim().split(/\s*:\s*/)[0]).filter(Boolean) : null;
|
||||
found.push({ file: path.resolve(path.dirname(file), m[2]), dynamic: true, names, from: file });
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
test("no agent CLI module imports notepads.mjs, directly or through a module it imports", () => {
|
||||
const dir = path.join(ROOT, "src", "web-console");
|
||||
const store = path.join(dir, "notepads.mjs");
|
||||
const starts = ["console.mjs", ...fs.readdirSync(dir).filter((n) => /^cmd-.*\.mjs$/.test(n))].map((n) => path.join(dir, n));
|
||||
assert.ok(starts.length > 1, "found the agent CLI's modules");
|
||||
const seen = new Set();
|
||||
const lazy = [];
|
||||
const queue = [...starts];
|
||||
while (queue.length) {
|
||||
const file = queue.shift();
|
||||
if (seen.has(file) || !fs.existsSync(file)) continue;
|
||||
seen.add(file);
|
||||
for (const dep of relativeImports(file)) {
|
||||
if (dep.file === store) {
|
||||
assert.ok(dep.dynamic, `${path.relative(ROOT, file)} imports notepads.mjs at the top`);
|
||||
lazy.push(dep);
|
||||
} else queue.push(dep.file);
|
||||
}
|
||||
}
|
||||
assert.ok(seen.size > 5, "walked the import graph");
|
||||
assert.equal(seen.has(store), false, "the store is never loaded at the top of an agent-side module");
|
||||
// The one way in is Cleanup (User Preferences, reached only through the
|
||||
// page's /cleanup route), which lists stale notepads and removes one whole,
|
||||
// never reading a note's text.
|
||||
for (const dep of lazy) {
|
||||
assert.equal(path.basename(dep.from), "sessions.mjs", "only Cleanup loads the store, lazily");
|
||||
assert.ok(dep.names && dep.names.every((n) => n === "staleNotepads" || n === "removeNotepad"), `Cleanup takes only staleNotepads and removeNotepad, not ${dep.names}`);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user