From a05eae850d7e9ada752d85de9991f09b8d191bf2 Mon Sep 17 00:00:00 2001 From: Phoebus Date: Sat, 3 Oct 2026 06:09:53 -0700 Subject: [PATCH] fix(assistant): show progress and route natural install requests --- docs/CHANGELOG.md | 11 +++ docs/HANDOFF.md | 22 ++++++ docs/STATUS.md | 17 ++++- .../phoebus-installer/src/conversation.rs | 74 +++++++++++++++---- .../live/desktop/phoebus-assistant/shell.qml | 56 +++++++++++--- 5 files changed, 152 insertions(+), 28 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d7ad84d..ae0e190 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,6 +5,17 @@ this file is the curated, human-readable summary. ## Unreleased — Fast defaults with user-controlled source builds +- **Assistant request feedback (2026-10-03).** The installed assistant now + displays a working card and elapsed time immediately after a request, then + replaces that card with the result or error. An update check can no longer + make an outstanding assistant request appear "Ready". Natural requests such + as "I want to install ChatGPT desktop" and multi-word application names + enter the reviewed install planner; vague follow-ups still use conversation + context. The running VM shows the working card and timer for the exact + request, with no approval buttons while work is pending. An invalid model + response now appears as a clear failure instead of "unknown error". No + package is installed until a plan is approved. + - **Greeter spacing and colors (2026-10-03).** The installed greeter now uses two rows of terminal padding so `ESC` and the rest of the status bar sit clear of the screen edge. The text, border, and shortcut keycaps use the diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index b851756..1b47766 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -3,6 +3,28 @@ Rolling note between work sessions. **Update this file before you finish**, then commit it. It should be short and current; use `git log` for detail. +- **Assistant request delay (2026-10-03):** In the running encrypted VM, the + assistant accepted "i want to install chatgpt desktop" at 12:34 and did not + show a response until about 12:41. The old phrase parser sent it to general + investigation; the GUI showed no pending card and its footer said "Ready". + The eventual result was a reviewed administration plan; no package was + installed. The parser now recognizes natural install wording and multi-word + names, and QML shows a pending card plus elapsed time until the bridge + replies. Rust format, clippy, workspace tests, release, static builds and + `make test` pass. The running VM's user QML override was updated and the + final static binary was installed as `~/.local/bin/sys` (SHA-256 + `3a0363e1…7cbbfb3`); + its user `AssistantBridge.qml` points at that binary because the root-owned + `/usr/local/bin/sys` is older. The guest displays the immediate working card, + elapsed timer and no approval buttons while a new exact-wording request is + pending; screenshot: `/var/tmp/phoebus-vm/assistant-exact-pending.png`. That + request reached the install planner and failed because OpenCode returned + invalid proposal JSON; the UI showed the failure around 1:01, with no + package change (`assistant-followup-status.png`). The error card now explains + that model failure in user terms. Update the root-installed binary/assets at + a fresh build; no package was approved. The final user-local QML and static + bridge restarted to a connected assistant in the same VM. + - **Greeter reference spacing (2026-10-03):** The current VM screenshot shows `ESC` touching the left edge and yellow keycaps. The upstream Usage image places the status bar roughly two text rows inside the terminal and uses the diff --git a/docs/STATUS.md b/docs/STATUS.md index 33a0c37..eb3503e 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -48,6 +48,21 @@ disposable VM; `serial-driver.py recovery` now automates the same check. ## Matrix +Assistant request feedback (2026-10-03): a connected assistant in the +disposable VM accepted "i want to install chatgpt desktop" at 12:34 and +returned a reviewed plan at about 12:41, without installing. During the wait +the old GUI displayed no working card and showed "Ready". Source now routes +natural, multi-word install requests to the reviewed install planner and +renders a pending card with elapsed time until a result or error arrives. +The parser regression and full Rust gates pass. The running VM now uses the +new QML and a user-local static `sys` bridge; an exact-wording request shows +the working card and timer immediately, with no approval buttons (screenshot: +`/var/tmp/phoebus-vm/assistant-exact-pending.png`). The install path later +returned an invalid-model-JSON error without preparing or executing a plan; +the root-owned system binary remains older until a fresh install. The final +user-local QML and static bridge restarted to a connected assistant. Host +format, clippy, Rust tests, release/static builds and `make test` pass. + External overlay discovery (2026-10-02): local Portage search now labels its scope as configured repositories. `sys search --legacy --overlays` adds a bounded, opt-in read-only lookup of GPO and labels its results as @@ -334,7 +349,7 @@ A fresh install with these defaults is not yet verified. | NVIDIA live GPU decision + real nouveau fallback | yes | yes (fixtures + CLI) | no | no | | Live GUI broker scoped sudoers (no `NOPASSWD: ALL`) | yes | yes (`visudo`) | no | n/a | | Rollback acceptance harness mode | yes | yes (bash -n/unit + vacuous-pass guards) | yes (destructive gate `serial-rollback-20260926T030237Z-912f6386` PASS=11 FAIL=0; root-marker creation is mandatory and asserted present before undo, absent after the detached reboot) | no | -| Desktop assistant GUI (`phoebus-assistant`) | yes | yes (asset/sizing checks) | partial (2026-10-01 disposable installed VM: final QML window loaded and showed `Connected (opencode)` after bridge handshake; prompt execution not exercised; earlier live VM layout) | no | +| Desktop assistant GUI (`phoebus-assistant`) | yes | yes (asset/sizing and parser checks) | partial (2026-10-03 installed VM: connected bridge, request submission, immediate working card and timer, old general-plan response, new install-path invalid-model-JSON error; no execution) | no | | Desktop assistant JSON-RPC bridge (`sys --assistant-bridge`) | yes | yes | yes (acceptance matrix) | n/a | | AI-first administration contract (`sys install`, `please`, `ask`) | yes | yes | yes (acceptance matrix) | no | | Deterministic `--legacy` administration (fail-closed source choice) | yes | yes | yes (acceptance matrix) | n/a | diff --git a/installer-rs/crates/phoebus-installer/src/conversation.rs b/installer-rs/crates/phoebus-installer/src/conversation.rs index b3f408e..4e572d5 100644 --- a/installer-rs/crates/phoebus-installer/src/conversation.rs +++ b/installer-rs/crates/phoebus-installer/src/conversation.rs @@ -240,29 +240,53 @@ const NON_APP_TOKENS: &[&str] = &[ "ebuild", ]; -/// Parse an explicit `install ` or `install using/via/with ` -/// request. Returns `None` for a vague reference such as "install the flatpak -/// one", which is a conversational follow-up rather than a new application. +/// Parse an explicit install request, including natural prefixes and multi-word +/// application names. Vague references such as "install the flatpak one" remain +/// conversational follow-ups rather than new applications. pub fn parse_explicit_install(query: &str) -> Option<(String, Option)> { let lower = query.trim().to_ascii_lowercase(); let lower = lower.strip_prefix("please ").unwrap_or(&lower).trim(); let rest = lower .strip_prefix("install ") - .or_else(|| lower.strip_prefix("add "))?; + .or_else(|| lower.strip_prefix("add ")) + .or_else(|| lower.strip_prefix("i want to install ")) + .or_else(|| lower.strip_prefix("i'd like to install "))?; let tokens: Vec<&str> = rest.split_whitespace().collect(); - let app = tokens - .first() - .copied() - .filter(|t| !NON_APP_TOKENS.contains(t) && !t.starts_with('-'))?; + let first = tokens.first()?.trim_matches(['"', '\'']); + if NON_APP_TOKENS.contains(&first) || first.starts_with('-') { + return None; + } + let source_start = tokens + .iter() + .position(|token| matches!(*token, "using" | "via" | "with" | "through")); + let mut app_end = source_start.unwrap_or(tokens.len()); + if app_end > 0 && tokens[app_end - 1] == "please" { + app_end -= 1; + } + let app_tokens = &tokens[..app_end]; + if app_tokens.is_empty() + || app_tokens.len() > 6 + || app_tokens + .iter() + .any(|token| NON_APP_TOKENS.contains(token) || token.starts_with('-')) + { + return None; + } + let app = app_tokens.join(" "); + let app = app.trim_matches(['"', '\'']).trim(); + if app.is_empty() || app.chars().any(char::is_control) { + return None; + } let mut backend = None; - for token in &tokens[1..] { - if let Some(b) = backend_from_word(token) { - backend = Some(b); - } else if !NON_APP_TOKENS.contains(token) { - // A trailing word that is not a source or a filler makes this an - // ambiguous instruction; let the model investigate it instead. - return None; + if let Some(start) = source_start { + for token in &tokens[start + 1..] { + if let Some(b) = backend_from_word(token) { + backend = Some(b); + } else if !NON_APP_TOKENS.contains(token) { + return None; + } } + backend?; } Some((app.to_string(), backend)) } @@ -499,9 +523,29 @@ mod tests { parse_explicit_install("install firefox"), Some(("firefox".into(), None)) ); + assert_eq!( + parse_explicit_install("i want to install chatgpt desktop"), + Some(("chatgpt desktop".into(), None)) + ); + assert_eq!( + parse_explicit_install("please install 'visual studio code' via flatpak"), + Some(("visual studio code".into(), Some(Backend::Flatpak))) + ); + assert_eq!( + parse_explicit_install("install chatgpt desktop through nix"), + Some(("chatgpt desktop".into(), Some(Backend::Nix))) + ); + assert_eq!( + parse_explicit_install("install firefox please"), + Some(("firefox".into(), None)) + ); // Vague references are not explicit applications. assert_eq!(parse_explicit_install("install the flatpak one"), None); assert_eq!(parse_explicit_install("install the nix one"), None); + assert_eq!( + parse_explicit_install("i want to install the flatpak one"), + None + ); let temp = tempdir().unwrap(); let path = temp.path().join("conversation.json"); diff --git a/installer/live/desktop/phoebus-assistant/shell.qml b/installer/live/desktop/phoebus-assistant/shell.qml index 73d29f7..1e74918 100644 --- a/installer/live/desktop/phoebus-assistant/shell.qml +++ b/installer/live/desktop/phoebus-assistant/shell.qml @@ -14,6 +14,8 @@ ShellRoot { property string currentTab: Quickshell.env("PHOEBUS_ASSISTANT_START_TAB") === "updates" ? "updates" : "assistant" property var conversation: [] property bool busy: false + property bool assistantPending: false + property int assistantElapsedSeconds: 0 property string statusText: "Ready" property var activeAlerts: [] property var updateOverview: null @@ -32,6 +34,13 @@ ShellRoot { onThemeModeChanged: Theme.themeMode = shell.themeMode + Timer { + interval: 1000 + repeat: true + running: shell.assistantPending + onTriggered: shell.assistantElapsedSeconds += 1 + } + Component.onCompleted: { Theme.themeMode = shell.themeMode; AssistantBridge.start(); @@ -94,8 +103,10 @@ ShellRoot { shell.busy = true; shell.statusText = "Checking for updates across package sources..."; AssistantBridge.getUpdates(reply => { - shell.busy = false; - shell.statusText = "Ready"; + if (!shell.assistantPending) { + shell.busy = false; + shell.statusText = "Ready"; + } if (reply.ok && reply.result) { shell.updateOverview = reply.result; shell.updateError = ""; @@ -131,21 +142,39 @@ ShellRoot { shell.conversation = list; } + function finishMessage(index, text, data) { + const list = shell.conversation.slice(); + if (index < 0 || index >= list.length) + return; + list[index] = Object.assign({}, list[index], { text: text, data: data }); + shell.conversation = list; + } + function submitPrompt(query) { - if (!query || query.trim().length === 0) + if (shell.assistantPending || !query || query.trim().length === 0) return; const q = query.trim(); addMessage("user", q, null); + const pendingIndex = addMessage("assistant", + "Investigating your request. Checking available options can take several minutes.", + { kind: "progress", state: "running" }); + shell.assistantElapsedSeconds = 0; + shell.assistantPending = true; shell.busy = true; shell.statusText = "Investigating request..."; AssistantBridge.ask(q, null, reply => { + shell.assistantPending = false; shell.busy = false; if (!reply.ok) { - shell.statusText = "Error: " + reply.error; - addMessage("assistant", "Could not complete request: " + reply.error, { + const detail = reply.error || "The assistant did not return a result."; + const message = detail.includes("proposal JSON is invalid") + ? "The connected model returned an invalid install plan. Nothing was installed. Try again, or use Legacy to choose an exact package and source." + : "Could not complete request: " + detail; + shell.statusText = "Request failed"; + finishMessage(pendingIndex, message, { kind: "error", - state: "failed" + state: "error" }); return; } @@ -158,7 +187,7 @@ ShellRoot { } else { shell.statusText = "Ready"; } - addMessage("assistant", text, res); + finishMessage(pendingIndex, text, res); }); } @@ -506,6 +535,7 @@ ShellRoot { : d.kind === "confirm" ? "Confirmation required" : d.kind === "plan" ? "Administration plan" : d.kind === "info" ? "Information" + : d.kind === "progress" ? "Working" : d.kind === "error" ? "Error" : "Result"; const stateName = d.state === "prepared" ? "— awaiting your approval" : d.state === "executing" ? "— executing" @@ -520,7 +550,7 @@ ShellRoot { // Approval and cancellation for every plan type. RowLayout { Layout.fillWidth: true - visible: modelData.data && modelData.data.prepared && modelData.data.state === "prepared" + visible: !!(modelData.data && modelData.data.prepared && modelData.data.state === "prepared") spacing: 8 PhoebusButton { @@ -669,7 +699,7 @@ ShellRoot { border.width: 1 } onAccepted: { - if (text.length > 0) { + if (!shell.busy && !shell.assistantPending && text.trim().length > 0) { shell.submitPrompt(text); text = ""; } @@ -679,7 +709,7 @@ ShellRoot { PhoebusButton { label: "Send" primary: true - actionEnabled: !shell.busy && promptField.text.trim().length > 0 + actionEnabled: !shell.busy && !shell.assistantPending && promptField.text.trim().length > 0 onClicked: { shell.submitPrompt(promptField.text); promptField.text = ""; @@ -688,7 +718,7 @@ ShellRoot { PhoebusButton { label: "Clear History" - actionEnabled: !shell.busy + actionEnabled: !shell.busy && !shell.assistantPending onClicked: shell.clearConversation() } } @@ -1082,7 +1112,9 @@ ShellRoot { RowLayout { Layout.fillWidth: true Label { - text: shell.statusText + text: shell.assistantPending + ? "Investigating request (" + shell.assistantElapsedSeconds + "s)..." + : shell.statusText color: Theme.muted font.pixelSize: 12 }