From 26cb17f04afdb018c5b633d617a7a4a5b8bef9d2 Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Mon, 2 Nov 2026 13:23:13 -0800 Subject: [PATCH] Add Back to the dashboard to the loop's end screen AI Assisted --- CHANGELOG.md | 4 ++++ plan2code-app/src-tauri/src/loop_driver.rs | 4 ++-- plan2code-app/src-tauri/src/main.rs | 25 ++++++++++++++++++++++ plan2code-app/ui/app.js | 12 +++++++++++ scripts/test-web-console-loop.mjs | 4 ++-- scripts/test-web-console-page-loop.mjs | 4 +++- src/web-console/patches.mjs | 2 +- src/web-console/public/app-bridge.js | 2 +- src/web-console/public/screens/core.js | 11 ++++++++++ src/web-console/public/screens/ending.js | 1 + 10 files changed, 62 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ac79c4..16307e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ All notable changes to Plan2Code will be documented in this file. **Stale installs are still cleaned up.** `install.js` keeps a small `removeLegacyLoopShims()` step that removes the old global artifacts (`plan2code-loop`, `plan2code-loop.cmd`, `plan2code-loop.ps1` and `node_modules/plan2code-loop` under the npm prefix) when they are present. `update()` runs it once before reinstalling and quietly skips a stale `"loop"` entry in `~/.plan2code/install.json`; uninstall runs it too. +### 🐛 Fixed + +- **desktop app**: the Implementation Loop's end screen offers **Back to the dashboard** next to its other actions, on a finished loop and a stopped one, and it works with no agent running (it opens a fresh dashboard console session in the frame). The screen's status line also tells the truth now: it reads "Loop finished. Pick what happens next." (or "The loop stopped.") as your move instead of spinning "Starting Building + review…", so the taskbar dot goes green there instead of staying dark while the loop's finished page waits. + ## v3.0.0 ### ✨ Added diff --git a/plan2code-app/src-tauri/src/loop_driver.rs b/plan2code-app/src-tauri/src/loop_driver.rs index af32114..5769f4e 100644 --- a/plan2code-app/src-tauri/src/loop_driver.rs +++ b/plan2code-app/src-tauri/src/loop_driver.rs @@ -2540,7 +2540,7 @@ fn stop_loop(ctx: &Ctx, cause: StopCause, line: String, can: &[&str]) { "evidence": "evidence", "phases": phase_rows(&rec), "uncommitted": uncommitted, - "can": can, + "can": can.iter().copied().chain(["dashboard"]).collect::>(), }, }); post_end(ctx, &rec, &patch); @@ -2609,7 +2609,7 @@ fn finish(ctx: &Ctx) { "line": one_line(&said), "phases": phase_rows(&rec), "uncommitted": [], - "can": ["finalize"], + "can": ["finalize", "dashboard"], }); if let Some(id) = evidence { end["evidence"] = json!(id); diff --git a/plan2code-app/src-tauri/src/main.rs b/plan2code-app/src-tauri/src/main.rs index 817ba94..900979c 100644 --- a/plan2code-app/src-tauri/src/main.rs +++ b/plan2code-app/src-tauri/src/main.rs @@ -1185,6 +1185,30 @@ fn loop_finalize(state: State<'_, AppState>) -> Result<(), String> { ) } +/// The loop end screen's way home: stop the session it ended on and open a +/// fresh dashboard console in its place. Needs no agent: a dashboard session +/// is only `console.mjs open --workflow dashboard`, which the supervisor runs +/// itself. +#[tauri::command] +fn loop_dashboard(state: State<'_, AppState>) -> Result { + let app = state.app.get().cloned().ok_or("no window yet")?; + let origin = window_origin(&app); + let dir = state + .project + .lock() + .ok() + .and_then(|p| p.as_ref().map(|p| p.dir.clone())) + .ok_or("no project yet")?; + let mut guard = state.console.lock().map_err(|e| e.to_string())?; + if let Some(mut sup) = guard.take() { + let _ = sup.stop(); + } + let sup = ConsoleSupervisor::start(dir, origin)?; + let session = serde_json::to_value(sup.session()).map_err(|e| e.to_string())?; + *guard = Some(sup); + Ok(session) +} + fn main() { // Without Node 18+ the console and skills cannot run: say so and stop (FR-13). let status = node_check::check_node(); @@ -1240,6 +1264,7 @@ fn main() { loop_resume, loop_fix, loop_finalize, + loop_dashboard, set_attention, clear_attention_cmd, set_taskbar_signal diff --git a/plan2code-app/ui/app.js b/plan2code-app/ui/app.js index 5faa270..fa5e7fb 100644 --- a/plan2code-app/ui/app.js +++ b/plan2code-app/ui/app.js @@ -729,6 +729,18 @@ window.addEventListener('message', (event) => { invoke(command) .then(() => source.postMessage({ plan2code: `${kind}-result`, ok: true, error: null }, '*')) .catch((error) => source.postMessage({ plan2code: `${kind}-result`, ok: false, error: String(error) }, '*')); + } else if (kind === 'loop-dashboard') { + // The loop end screen's way home: a fresh dashboard session in the frame. + const source = event.source; + invoke('loop_dashboard') + .then((info) => { + source.postMessage({ plan2code: 'loop-dashboard-result', ok: true, error: null }, '*'); + if (info && info.url) { + showState('Opening the dashboard'); + loadFrame(info.url); + } + }) + .catch((error) => source.postMessage({ plan2code: 'loop-dashboard-result', ok: false, error: String(error) }, '*')); } else if (kind === 'loop-notify-test') { // Send a test: no values at all. The app reads the saved setup itself and // asks the person to confirm in its own dialog. diff --git a/scripts/test-web-console-loop.mjs b/scripts/test-web-console-loop.mjs index 9f1cc01..3d52bee 100644 --- a/scripts/test-web-console-loop.mjs +++ b/scripts/test-web-console-loop.mjs @@ -291,7 +291,7 @@ const goodEnd = (extra = {}) => ({ line: "Stopped at phase 2: a Critical finding was skipped", phases: [{ n: 1, name: "Setup", commit: "abc1234", unfixed: 0, retries: 0 }], uncommitted: ["src/x.js"], - can: ["resume", "fix"], + can: ["resume", "fix", "dashboard"], ...extra, }); const EVIDENCE = { id: "evidence", title: "What happened", blocks: [{ id: "b1", md: "The phase stopped on a skipped Critical." }] }; @@ -313,7 +313,7 @@ test("loopEnd: a valid stopped with an evidence doc in the same patch is stored" test("loopEnd: an unknown evidence id, a push in can, and the other bad fields are refused, each named", () => { const cases = [ ["an unknown evidence id", goodEnd({ evidence: "nope" }), /loopEnd\.evidence must be the id of a doc on the page/], - ["a push in can", goodEnd({ can: ["resume", "push"] }), /loopEnd\.can must be an array with entries from resume, fix, finalize/], + ["a push in can", goodEnd({ can: ["resume", "push"] }), /loopEnd\.can must be an array with entries from resume, fix, finalize, dashboard/], ["a bad kind", goodEnd({ kind: "paused" }), /loopEnd\.kind must be "stopped" or "finished"/], ["a two-line line", goodEnd({ line: "one\ntwo" }), /loopEnd\.line must be one line/], ["an absolute uncommitted path", goodEnd({ uncommitted: ["/etc/passwd"] }), /loopEnd\.uncommitted must be an array of relative paths/], diff --git a/scripts/test-web-console-page-loop.mjs b/scripts/test-web-console-page-loop.mjs index f5b3053..a1a38d5 100644 --- a/scripts/test-web-console-page-loop.mjs +++ b/scripts/test-web-console-page-loop.mjs @@ -242,16 +242,18 @@ test("the finish card counts each kind of decision per phase and opens on the fu line: "All 1 phases built", phases: [{ n: 2, name: "API", commit: "abc1234", unfixed: 3, retries: 1, fixed: 4, skipped: 2, left: 1, assumed: 5, decisions: 6 }], uncommitted: [], - can: ["finalize"], + can: ["finalize", "dashboard"], }); return { head: [...card.querySelectorAll("th")].map((c) => c.textContent), row: [...card.querySelectorAll("td")].map((c) => c.textContent), + actions: [...card.querySelectorAll(".loop-end-actions button")].map((b) => b.textContent), }; }); assert.deepEqual(seen.head, ["Phase", "Commit", "Fixed", "Not fixed", "Left open", "Assumed", "Other decisions", "Retries"]); assert.deepEqual(seen.row.slice(0, 1), ["Phase 2: API"]); assert.deepEqual(seen.row.slice(2), ["4", "2", "1", "5", "6", "1"]); + assert.deepEqual(seen.actions, ["Finalize", "Back to the dashboard"], "the way home is offered next to Finalize"); }); // A real loop session: `open --loop` under the app's signal stamps the lock. diff --git a/src/web-console/patches.mjs b/src/web-console/patches.mjs index 19218c4..fefca0c 100644 --- a/src/web-console/patches.mjs +++ b/src/web-console/patches.mjs @@ -1054,7 +1054,7 @@ export function isOpen(item) { const LOOP_LEVELS = ["critical", "warning", "suggestion"]; const LOOP_REASONS = ["tests", "findings", "blocked", "conflict", "other"]; -const LOOP_CAN = ["resume", "fix", "finalize"]; +const LOOP_CAN = ["resume", "fix", "finalize", "dashboard"]; const TASK_ID = /^\d+\.\d+$/; // A one-line path that stays inside the project: not absolute, no `..` step. diff --git a/src/web-console/public/app-bridge.js b/src/web-console/public/app-bridge.js index fa6fe36..c56d125 100644 --- a/src/web-console/public/app-bridge.js +++ b/src/web-console/public/app-bridge.js @@ -62,7 +62,7 @@ export function wireLoopMessages(store, redraw) { store.loopNotifyTest = { waiting: false, ok: data.ok === true, sent: data.sent === true, error: data.ok === true ? null : String(data.error || "The app could not send the test.") }; redraw(); }); - for (const kind of ["loop-resume-result", "loop-fix-result", "loop-finalize-result"]) { + for (const kind of ["loop-resume-result", "loop-fix-result", "loop-finalize-result", "loop-dashboard-result"]) { onAppMessage(kind, (data) => { store.loopAction = { kind, ok: data.ok === true, error: data.ok === true ? null : String(data.error || "The app could not do that.") }; redraw(); diff --git a/src/web-console/public/screens/core.js b/src/web-console/public/screens/core.js index 832dd2f..54f25d9 100644 --- a/src/web-console/public/screens/core.js +++ b/src/web-console/public/screens/core.js @@ -1225,6 +1225,17 @@ export function renderStatus() { return say("done", `All done. You can close this ${closeWord}.`); } if (page.gone) return say("gone", "Not connected. Your answers are saved.", "", false, true); + // The loop's own end screen (the app's `loopEnd`) is no `finish()`: while it + // still has presses on offer the move is theirs; with none, it is done. + if (page.S.loopEnd) { + const end = page.S.loopEnd; + const moves = Array.isArray(end.can) ? end.can.length : 0; + if (!moves) return say("done", "The loop is done."); + return say( + "point", + end.kind === "finished" ? "Loop finished. Pick what happens next." : "The loop stopped. Pick what happens next." + ); + } // On the way home: the request is sent, and the page stays this skill's // until the agent resumes the session as the dashboard. if (page.local.homeward && !isDashboard()) { diff --git a/src/web-console/public/screens/ending.js b/src/web-console/public/screens/ending.js index 520cf1b..3437fd7 100644 --- a/src/web-console/public/screens/ending.js +++ b/src/web-console/public/screens/ending.js @@ -165,6 +165,7 @@ const LOOP_BUTTONS = [ ["resume", "loop-resume", "Resume the loop", "primary"], ["fix", "loop-fix", "Fix it by hand", ""], ["finalize", "loop-finalize", "Finalize", "primary"], + ["dashboard", "loop-dashboard", "Back to the dashboard", ""], ]; function shortHash(h) {