From 9226b82c37d32f05dfd453bb5e1d64c0cae7787e Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Fri, 6 Nov 2026 11:01:08 -0800 Subject: [PATCH] Tell desktop app users when a newer release is out, and release 3.0.2 The app now asks GitHub for the newest vX.Y.Z tag when it starts and, when it is ahead, the top bar says so with a button that copies `plan2code update`. Before, the app only compared its own version with the installed skills, so it never knew a release existed. Version 3.0.2 everywhere (version.json, package.json, the app's package.json, package-lock.json, Cargo.toml, Cargo.lock, tauri.conf.json, README, CHANGELOG). --- CHANGELOG.md | 10 +++ README.md | 2 +- package.json | 2 +- plan2code-app/Cargo.lock | 4 +- plan2code-app/fake-agent/Cargo.toml | 2 +- plan2code-app/package-lock.json | 4 +- plan2code-app/package.json | 2 +- plan2code-app/src-tauri/Cargo.toml | 2 +- plan2code-app/src-tauri/src/main.rs | 12 +++ plan2code-app/src-tauri/src/versions.rs | 106 ++++++++++++++++++++++++ plan2code-app/src-tauri/tauri.conf.json | 2 +- plan2code-app/ui/app.js | 36 +++++++- plan2code-app/ui/meter.js | 19 ++++- scripts/test-app-meter.mjs | 32 ++++++- version.json | 2 +- 15 files changed, 220 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a85451d..a937024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to Plan2Code will be documented in this file. +## v3.0.2 + +### โœจ Added + +- **desktop app**: the app now checks GitHub for a newer release when it starts, and its top bar says `Update available: vX.Y.Z` with a button that copies `plan2code update`, the command that brings the app, skills and launcher up together. The web console already showed this in the browser; the app only compared its own version with the installed skills, so it never knew a release was out. + +### ๐Ÿ”ง Changed + +- **releases**: the release workflow now builds all four systems first and creates the release, with its `vX.Y.Z` tag, last, so nobody is offered an upgrade before its downloads exist. CI runs the root `npm test` suite only by hand, and the app job on Ubuntu only for pushes. + ## v3.0.1 ### ๐Ÿ› Fixed diff --git a/README.md b/README.md index cb66bca..dd7a46e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ the next engineer all start from the same specs. One command opens it, every step is a card, and the terminal is always there if you prefer it. -Version 3.0.1 ยท MIT ยท ๐Ÿ“– [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com) +Version 3.0.2 ยท MIT ยท ๐Ÿ“– [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com) --- diff --git a/package.json b/package.json index d390c93..2f8030a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plan2code", - "version": "3.0.1", + "version": "3.0.2", "private": true, "bin": { "plan2code-install": "./install.js" diff --git a/plan2code-app/Cargo.lock b/plan2code-app/Cargo.lock index 1c5cbe3..780098c 100644 --- a/plan2code-app/Cargo.lock +++ b/plan2code-app/Cargo.lock @@ -757,7 +757,7 @@ dependencies = [ [[package]] name = "fake-agent" -version = "3.0.1" +version = "3.0.2" dependencies = [ "serde_json", "terminal_size", @@ -2371,7 +2371,7 @@ checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" [[package]] name = "plan2code-app" -version = "3.0.1" +version = "3.0.2" dependencies = [ "chrono", "libc", diff --git a/plan2code-app/fake-agent/Cargo.toml b/plan2code-app/fake-agent/Cargo.toml index 1b8f8be..968dc68 100644 --- a/plan2code-app/fake-agent/Cargo.toml +++ b/plan2code-app/fake-agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fake-agent" -version = "3.0.1" +version = "3.0.2" description = "A stand-in agent program for the Plan2Code app's tests" edition = "2021" publish = false diff --git a/plan2code-app/package-lock.json b/plan2code-app/package-lock.json index e971cdb..44293f4 100644 --- a/plan2code-app/package-lock.json +++ b/plan2code-app/package-lock.json @@ -1,12 +1,12 @@ { "name": "plan2code-app", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "plan2code-app", - "version": "3.0.1", + "version": "3.0.2", "dependencies": { "@tauri-apps/api": "2.12.4", "@xterm/addon-fit": "0.11.0", diff --git a/plan2code-app/package.json b/plan2code-app/package.json index eaccae1..168898c 100644 --- a/plan2code-app/package.json +++ b/plan2code-app/package.json @@ -1,6 +1,6 @@ { "name": "plan2code-app", - "version": "3.0.1", + "version": "3.0.2", "private": true, "description": "Plan2Code desktop app (Tauri). Separate from the repo root so the root and the web console stay dependency-free.", "scripts": { diff --git a/plan2code-app/src-tauri/Cargo.toml b/plan2code-app/src-tauri/Cargo.toml index 5052d40..a5e5cb2 100644 --- a/plan2code-app/src-tauri/Cargo.toml +++ b/plan2code-app/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plan2code-app" -version = "3.0.1" +version = "3.0.2" description = "Plan2Code desktop app" edition = "2021" publish = false diff --git a/plan2code-app/src-tauri/src/main.rs b/plan2code-app/src-tauri/src/main.rs index 97fa0b8..288496e 100644 --- a/plan2code-app/src-tauri/src/main.rs +++ b/plan2code-app/src-tauri/src/main.rs @@ -765,6 +765,17 @@ fn version_status(app: tauri::AppHandle) -> versions::VersionStatus { ) } +/// The newest GitHub release's version when it is newer than this app, else none (also none on +/// any failure to ask). The page asks once at start and never waits on it. +#[tauri::command] +async fn check_new_release(app: tauri::AppHandle) -> Option { + let version = app.package_info().version.to_string(); + tauri::async_runtime::spawn_blocking(move || versions::check_new_release(&version)) + .await + .ok() + .flatten() +} + /// What `update_skills` resolves with: the installer's last line, and the version status /// re-read afterwards, so the bar can say plainly whether the mismatch is actually gone. #[derive(serde::Serialize)] @@ -1319,6 +1330,7 @@ fn main() { save_term_panel, save_first_run_done, version_status, + check_new_release, update_skills, pick_project_folder, change_project, diff --git a/plan2code-app/src-tauri/src/versions.rs b/plan2code-app/src-tauri/src/versions.rs index e660552..c78ad9e 100644 --- a/plan2code-app/src-tauri/src/versions.rs +++ b/plan2code-app/src-tauri/src/versions.rs @@ -73,6 +73,84 @@ pub fn status(app: &str, skills: Option) -> VersionStatus { } } +/// The repo's tags, asked of GitHub the way the web console's own check does it +/// (src/web-console/update-check.mjs): `git ls-remote --tags` needs no token and rides on the +/// person's own git and proxy setup. +const REPO_URL: &str = "https://github.com/jparkerweb/plan2code.git"; +/// How long the tag lookup may take before it is given up on (nothing waits on it). +const RELEASE_CHECK_TIMEOUT: Duration = Duration::from_secs(10); + +/// The highest plain `vX.Y.Z` tag in `git ls-remote --tags` output, without the `v`. Peeled +/// lines (`^{}`) and pre-release or other tag names never match. +pub fn latest_tag(text: &str) -> Option { + let mut best: Option<((u64, u64, u64), String)> = None; + for line in text.lines() { + let Some(version) = line.trim().rsplit_once("refs/tags/v").map(|(_, v)| v) else { + continue; + }; + let Some(triple) = parse(version) else { + continue; + }; + if best.as_ref().is_none_or(|(top, _)| triple > *top) { + best = Some((triple, version.to_string())); + } + } + best.map(|(_, version)| version) +} + +/// The newest release's version when it is newer than `app`; none when the app is current, +/// ahead, or either version is not a plain `X.Y.Z`. +pub fn newer_release(app: &str, ls_remote: &str) -> Option { + let latest = latest_tag(ls_remote)?; + (parse(&latest)? > parse(app)?).then_some(latest) +} + +/// Ask GitHub for the newest release and return its version when it is newer than `app`. +/// None on any failure (no git, no network, a login prompt, the timeout): a missing answer +/// is never a reason to nag. No prompt and no console window. +pub fn check_new_release(app: &str) -> Option { + let mut command = Command::new("git"); + command + .env("PATH", crate::node_check::resolved_path()) + .env("GIT_TERMINAL_PROMPT", "0") + .env("GCM_INTERACTIVE", "never") + .args(["ls-remote", "--tags", REPO_URL]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::null()); + if std::env::var_os("GIT_SSH_COMMAND").is_none() { + command.env("GIT_SSH_COMMAND", "ssh -o BatchMode=yes"); + } + #[cfg(windows)] + { + use std::os::windows::process::CommandExt; + command.creation_flags(0x08000000); // CREATE_NO_WINDOW, as the console calls are + } + let mut child = command.spawn().ok()?; + let mut stdout = child.stdout.take()?; + let (tx, rx) = mpsc::channel::(); + std::thread::spawn(move || { + let mut text = String::new(); + let _ = std::io::Read::read_to_string(&mut stdout, &mut text); + let _ = tx.send(text); + }); + match rx.recv_timeout(RELEASE_CHECK_TIMEOUT) { + Ok(text) => { + let ok = child.wait().is_ok_and(|status| status.success()); + if ok { + newer_release(app, &text) + } else { + None + } + } + Err(_) => { + let _ = child.kill(); + let _ = child.wait(); + None + } + } +} + /// Run the existing installer's update (`plan2code update`, through the launcher's own copy), /// which brings the skills, the launcher and the app level. Pinned to the release tag `app_version` /// names, not `main`, so Update skills never pulls in work the app does not know about yet. Blocks @@ -215,6 +293,34 @@ mod tests { assert!(!status("3.0.0", Some("".into())).mismatch); } + const TAGS: &str = "aaa\trefs/tags/v2.11.0\n\ + bbb\trefs/tags/v3.0.0\n\ + ccc\trefs/tags/v3.0.0^{}\n\ + ddd\trefs/tags/v3.0.1\n\ + eee\trefs/tags/v3.10.0\n\ + fff\trefs/tags/v3.11.0-beta\n\ + ggg\trefs/tags/not-a-version\n"; + + #[test] + fn the_latest_tag_is_the_highest_plain_version_compared_by_number() { + assert_eq!(latest_tag(TAGS).as_deref(), Some("3.10.0")); + assert_eq!( + latest_tag("aaa\trefs/tags/v3.0.1\r\nbbb\trefs/tags/v3.0.9\r\n").as_deref(), + Some("3.0.9") + ); + assert_eq!(latest_tag(""), None); + assert_eq!(latest_tag("aaa\trefs/tags/v3.0.0-beta\n"), None); + } + + #[test] + fn a_newer_release_is_reported_only_when_it_is_ahead_of_the_app() { + assert_eq!(newer_release("3.0.0", TAGS).as_deref(), Some("3.10.0")); + assert_eq!(newer_release("3.10.0", TAGS), None); + assert_eq!(newer_release("3.11.0", TAGS), None); + assert_eq!(newer_release("3.0.0-beta", TAGS), None); + assert_eq!(newer_release("3.0.0", ""), None); + } + #[test] fn reads_the_version_field_of_a_version_file() { let file = temp_file("ok", r#"{ "name": "Plan2Code", "version": "2.11.0" }"#); diff --git a/plan2code-app/src-tauri/tauri.conf.json b/plan2code-app/src-tauri/tauri.conf.json index 14c4a52..352c01b 100644 --- a/plan2code-app/src-tauri/tauri.conf.json +++ b/plan2code-app/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Plan2Code", - "version": "3.0.1", + "version": "3.0.2", "identifier": "com.plan2code.desktop", "build": { "frontendDist": "../ui", diff --git a/plan2code-app/ui/app.js b/plan2code-app/ui/app.js index aacc26c..9f1488c 100644 --- a/plan2code-app/ui/app.js +++ b/plan2code-app/ui/app.js @@ -2,7 +2,7 @@ // agent's terminal panel docked at the bottom with a drag handle. import { mountTerminal } from './terminal.js'; -import { attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, lastAgentNotice, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopLocks, loopStopLabels, loopWindowTitle } from './meter.js'; +import { NEW_RELEASE_COMMAND, attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, lastAgentNotice, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopLocks, loopStopLabels, loopWindowTitle } from './meter.js'; const { invoke, Channel } = window.__TAURI__.core; @@ -1012,6 +1012,29 @@ async function checkVersions() { } } +// Once, at start, and never waited on: is a newer Plan2Code release out on GitHub? The Rust +// side asks (the same tag lookup the web console uses) and answers with the newer version, or +// nothing when the app is current or the lookup failed. +async function checkNewRelease() { + try { + const latest = await invoke('check_new_release'); + if (latest) setNewRelease({ latest, copied: false }); + } catch { + // No answer is no reason to nag. + } +} + +async function copyUpdateCommand() { + if (!newRelease) return; + try { + await navigator.clipboard.writeText(NEW_RELEASE_COMMAND); + setNewRelease({ ...newRelease, copied: true }); + } catch { + // The webview refused the clipboard: the bar spells the command out instead. + setNewRelease({ ...newRelease, manual: true }); + } +} + async function updateSkills() { setVersionState({ kind: 'updating', line: 'Updating Plan2Code...' }); const progress = new Channel(); @@ -1225,11 +1248,12 @@ loopStopNowBtn.onclick = () => // barNextSteps decides which, and its button), with the rest as "+N more". let consoleDead = false; let versionState = null; -const NEXT_STEP_ACTIONS = { reconnect: reconnectConsole, 'restart-console': restartConsole, update: updateSkills }; +let newRelease = null; +const NEXT_STEP_ACTIONS = { reconnect: reconnectConsole, 'restart-console': restartConsole, update: updateSkills, 'copy-update': copyUpdateCommand }; let nextStepAction = null; function renderNextStep() { - const steps = barNextSteps({ consoleDead, version: versionState }); + const steps = barNextSteps({ consoleDead, version: versionState, newRelease }); nextStepEl.hidden = steps.length === 0; const [first, ...rest] = steps; nextStepTextEl.textContent = first ? first.text : ''; @@ -1249,6 +1273,11 @@ function setVersionState(next) { renderNextStep(); } +function setNewRelease(next) { + newRelease = next; + renderNextStep(); +} + function markConsoleAlive() { consoleDead = false; renderNextStep(); @@ -1425,6 +1454,7 @@ async function main() { applyDefaultAgent(state.lastAgent); setInterval(updateBadge, BADGE_POLL_MS); checkVersions(); + checkNewRelease(); let reattach = null; try { diff --git a/plan2code-app/ui/meter.js b/plan2code-app/ui/meter.js index 022681c..1a48a69 100644 --- a/plan2code-app/ui/meter.js +++ b/plan2code-app/ui/meter.js @@ -9,8 +9,14 @@ export const NEXT_STEP_LABELS = { reconnect: 'Reconnect the console', 'restart-console': 'Reconnect the console', update: 'Update skills', + 'copy-update': 'Copy update command', }; +// What a person runs in a terminal to move to the newest release: the same line the web +// console's banner gives. The app cannot replace itself, and Update skills is pinned to the +// app's own version, so only this brings the app, the skills and the launcher up together. +export const NEW_RELEASE_COMMAND = 'plan2code update'; + /** * What the console page's **continue** button types into the agent's * terminal, one write each: the word, then Enter. Claude Code holds typed @@ -76,7 +82,7 @@ export function lastAgentNotice(list, remembered) { * update, its Reconnect (which stops the old console first, so the new skills * are really picked up) covers a console that has also stopped. */ -export function barNextSteps({ consoleDead = false, version = null } = {}) { +export function barNextSteps({ consoleDead = false, version = null, newRelease = null } = {}) { const v = version || {}; const steps = []; if (v.kind === 'updated') { @@ -108,6 +114,17 @@ export function barNextSteps({ consoleDead = false, version = null } = {}) { default: break; } + // Last: the pending fix for a mismatch or a stopped console comes before a release that is + // merely out. `newRelease` is `{ latest, copied, manual }`. + if (newRelease && newRelease.latest) { + steps.push( + newRelease.manual + ? { id: 'new-release', text: `Run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app`, title: `Plan2Code v${newRelease.latest} is out. Run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app.`, tone: 'warn', action: null } + : newRelease.copied + ? { id: 'new-release', text: `Copied: run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app`, title: `Plan2Code v${newRelease.latest} is out. Run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app.`, tone: 'ok', action: null } + : { id: 'new-release', text: `Update available: v${newRelease.latest}`, title: `Plan2Code v${newRelease.latest} is out. Copy the command, run it in a terminal, then reopen the app.`, tone: 'warn', action: 'copy-update' } + ); + } return steps.map((step) => ({ ...step, label: step.action ? NEXT_STEP_LABELS[step.action] : null })); } diff --git a/scripts/test-app-meter.mjs b/scripts/test-app-meter.mjs index 0099167..30ad978 100644 --- a/scripts/test-app-meter.mjs +++ b/scripts/test-app-meter.mjs @@ -11,7 +11,7 @@ import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; -import { attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopRunText, loopLocks, loopStopLabels, loopWindowTitle, CONSOLE_ASIDE_BREAKPOINT_PX, NEXT_STEP_LABELS } from "../plan2code-app/ui/meter.js"; +import { attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopRunText, loopLocks, loopStopLabels, loopWindowTitle, CONSOLE_ASIDE_BREAKPOINT_PX, NEXT_STEP_LABELS, NEW_RELEASE_COMMAND } from "../plan2code-app/ui/meter.js"; import { findBrowser, launchBrowser } from "./browser.mjs"; const HERE = path.dirname(fileURLToPath(import.meta.url)); @@ -38,6 +38,34 @@ test("only one control for reconnecting the console is ever offered: after an up assert.deepEqual(steps.map((step) => step.action), ["restart-console"], "the plain reconnect steps aside for the one that stops the old console first"); }); +test("a newer GitHub release is offered last, with the command to copy; a mismatch or a stopped console comes first", () => { + const newRelease = { latest: "3.0.1" }; + const ids = (input) => barNextSteps(input).map((step) => step.id); + assert.deepEqual(ids({ newRelease }), ["new-release"]); + assert.deepEqual(ids({ consoleDead: true, version: { kind: "mismatch", skills: "3.0.0", app: "3.1.0" }, newRelease }), ["console-dead", "mismatch", "new-release"]); + const [step] = barNextSteps({ newRelease }); + assert.equal(step.text, "Update available: v3.0.1"); + assert.equal(step.label, "Copy update command"); + assert.equal(step.action, "copy-update"); + assert.equal(NEW_RELEASE_COMMAND, "plan2code update"); + assert.deepEqual(barNextSteps({ newRelease: null }), [], "nothing newer, nothing shown"); +}); + +test("after the copy the bar says what to do next; if the clipboard was refused it spells the command out", () => { + const [copied] = barNextSteps({ newRelease: { latest: "3.0.1", copied: true } }); + assert.match(copied.text, /^Copied: run `plan2code update` in a terminal/); + assert.equal(copied.action, null); + const [manual] = barNextSteps({ newRelease: { latest: "3.0.1", manual: true } }); + assert.match(manual.text, /^Run `plan2code update` in a terminal/); + assert.equal(manual.action, null); +}); + +test("the app asks once at start for a newer release, and the bar is wired to the copy action", () => { + assert.match(APP_JS, /invoke\('check_new_release'\)/); + assert.match(APP_JS, /'copy-update': copyUpdateCommand/); + assert.match(APP_JS, /barNextSteps\(\{ consoleDead, version: versionState, newRelease \}\)/); +}); + test("each version state reads and acts as the old version bar did", () => { const [mismatch] = barNextSteps({ version: { kind: "mismatch", skills: "3.0.0", app: "3.1.0" } }); assert.equal(mismatch.text, "Skills v3.0.0, app v3.1.0"); @@ -63,7 +91,7 @@ test("every control that reconnects the console carries the same label, never 'R }); test("app.js draws the bar's right end through barNextSteps, not a hand-rolled copy of its order", () => { - assert.match(APP_JS, /const steps = barNextSteps\(\{ consoleDead, version: versionState \}\);/); + assert.match(APP_JS, /const steps = barNextSteps\(\{ consoleDead, version: versionState, newRelease \}\);/); for (const gone of ["console-again", "version-update", "permissions-note", "console-status", "project-dir"]) { assert.ok(!INDEX_HTML.includes(`id="${gone}"`), `index.html still has #${gone}`); } diff --git a/version.json b/version.json index 4cd82c0..af74032 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "name": "Plan2Code", - "version": "3.0.1", + "version": "3.0.2", "description": "A structured 4-step workflow methodology for AI-assisted software development", "keywords": [ "ai",