fix(assistant): show progress and route natural install requests
Some checks are pending
ci / test (push) Waiting to run

This commit is contained in:
Phoebus 2026-10-03 06:09:53 -07:00
parent 6db4a8784c
commit a05eae850d
5 changed files with 152 additions and 28 deletions

View file

@ -5,6 +5,17 @@ this file is the curated, human-readable summary.
## Unreleased — Fast defaults with user-controlled source builds ## 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 - **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 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 clear of the screen edge. The text, border, and shortcut keycaps use the

View file

@ -3,6 +3,28 @@
Rolling note between work sessions. **Update this file before you finish**, then 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. 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 - **Greeter reference spacing (2026-10-03):** The current VM screenshot shows
`ESC` touching the left edge and yellow keycaps. The upstream Usage image `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 places the status bar roughly two text rows inside the terminal and uses the

View file

@ -48,6 +48,21 @@ disposable VM; `serial-driver.py recovery` now automates the same check.
## Matrix ## 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 External overlay discovery (2026-10-02): local Portage search now labels its
scope as configured repositories. `sys search <term> --legacy --overlays` scope as configured repositories. `sys search <term> --legacy --overlays`
adds a bounded, opt-in read-only lookup of GPO and labels its results as 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 | | 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 | | 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 | | 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 | | 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 | | 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 | | Deterministic `--legacy` administration (fail-closed source choice) | yes | yes | yes (acceptance matrix) | n/a |

View file

@ -240,29 +240,53 @@ const NON_APP_TOKENS: &[&str] = &[
"ebuild", "ebuild",
]; ];
/// Parse an explicit `install <app>` or `install <app> using/via/with <source>` /// Parse an explicit install request, including natural prefixes and multi-word
/// request. Returns `None` for a vague reference such as "install the flatpak /// application names. Vague references such as "install the flatpak one" remain
/// one", which is a conversational follow-up rather than a new application. /// conversational follow-ups rather than new applications.
pub fn parse_explicit_install(query: &str) -> Option<(String, Option<Backend>)> { pub fn parse_explicit_install(query: &str) -> Option<(String, Option<Backend>)> {
let lower = query.trim().to_ascii_lowercase(); let lower = query.trim().to_ascii_lowercase();
let lower = lower.strip_prefix("please ").unwrap_or(&lower).trim(); let lower = lower.strip_prefix("please ").unwrap_or(&lower).trim();
let rest = lower let rest = lower
.strip_prefix("install ") .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 tokens: Vec<&str> = rest.split_whitespace().collect();
let app = tokens let first = tokens.first()?.trim_matches(['"', '\'']);
.first() if NON_APP_TOKENS.contains(&first) || first.starts_with('-') {
.copied() return None;
.filter(|t| !NON_APP_TOKENS.contains(t) && !t.starts_with('-'))?; }
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; let mut backend = None;
for token in &tokens[1..] { if let Some(start) = source_start {
if let Some(b) = backend_from_word(token) { for token in &tokens[start + 1..] {
backend = Some(b); if let Some(b) = backend_from_word(token) {
} else if !NON_APP_TOKENS.contains(token) { backend = Some(b);
// A trailing word that is not a source or a filler makes this an } else if !NON_APP_TOKENS.contains(token) {
// ambiguous instruction; let the model investigate it instead. return None;
return None; }
} }
backend?;
} }
Some((app.to_string(), backend)) Some((app.to_string(), backend))
} }
@ -499,9 +523,29 @@ mod tests {
parse_explicit_install("install firefox"), parse_explicit_install("install firefox"),
Some(("firefox".into(), None)) 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. // Vague references are not explicit applications.
assert_eq!(parse_explicit_install("install the flatpak one"), None); 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("install the nix one"), None);
assert_eq!(
parse_explicit_install("i want to install the flatpak one"),
None
);
let temp = tempdir().unwrap(); let temp = tempdir().unwrap();
let path = temp.path().join("conversation.json"); let path = temp.path().join("conversation.json");

View file

@ -14,6 +14,8 @@ ShellRoot {
property string currentTab: Quickshell.env("PHOEBUS_ASSISTANT_START_TAB") === "updates" ? "updates" : "assistant" property string currentTab: Quickshell.env("PHOEBUS_ASSISTANT_START_TAB") === "updates" ? "updates" : "assistant"
property var conversation: [] property var conversation: []
property bool busy: false property bool busy: false
property bool assistantPending: false
property int assistantElapsedSeconds: 0
property string statusText: "Ready" property string statusText: "Ready"
property var activeAlerts: [] property var activeAlerts: []
property var updateOverview: null property var updateOverview: null
@ -32,6 +34,13 @@ ShellRoot {
onThemeModeChanged: Theme.themeMode = shell.themeMode onThemeModeChanged: Theme.themeMode = shell.themeMode
Timer {
interval: 1000
repeat: true
running: shell.assistantPending
onTriggered: shell.assistantElapsedSeconds += 1
}
Component.onCompleted: { Component.onCompleted: {
Theme.themeMode = shell.themeMode; Theme.themeMode = shell.themeMode;
AssistantBridge.start(); AssistantBridge.start();
@ -94,8 +103,10 @@ ShellRoot {
shell.busy = true; shell.busy = true;
shell.statusText = "Checking for updates across package sources..."; shell.statusText = "Checking for updates across package sources...";
AssistantBridge.getUpdates(reply => { AssistantBridge.getUpdates(reply => {
shell.busy = false; if (!shell.assistantPending) {
shell.statusText = "Ready"; shell.busy = false;
shell.statusText = "Ready";
}
if (reply.ok && reply.result) { if (reply.ok && reply.result) {
shell.updateOverview = reply.result; shell.updateOverview = reply.result;
shell.updateError = ""; shell.updateError = "";
@ -131,21 +142,39 @@ ShellRoot {
shell.conversation = list; 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) { function submitPrompt(query) {
if (!query || query.trim().length === 0) if (shell.assistantPending || !query || query.trim().length === 0)
return; return;
const q = query.trim(); const q = query.trim();
addMessage("user", q, null); 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.busy = true;
shell.statusText = "Investigating request..."; shell.statusText = "Investigating request...";
AssistantBridge.ask(q, null, reply => { AssistantBridge.ask(q, null, reply => {
shell.assistantPending = false;
shell.busy = false; shell.busy = false;
if (!reply.ok) { if (!reply.ok) {
shell.statusText = "Error: " + reply.error; const detail = reply.error || "The assistant did not return a result.";
addMessage("assistant", "Could not complete request: " + reply.error, { 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", kind: "error",
state: "failed" state: "error"
}); });
return; return;
} }
@ -158,7 +187,7 @@ ShellRoot {
} else { } else {
shell.statusText = "Ready"; shell.statusText = "Ready";
} }
addMessage("assistant", text, res); finishMessage(pendingIndex, text, res);
}); });
} }
@ -506,6 +535,7 @@ ShellRoot {
: d.kind === "confirm" ? "Confirmation required" : d.kind === "confirm" ? "Confirmation required"
: d.kind === "plan" ? "Administration plan" : d.kind === "plan" ? "Administration plan"
: d.kind === "info" ? "Information" : d.kind === "info" ? "Information"
: d.kind === "progress" ? "Working"
: d.kind === "error" ? "Error" : "Result"; : d.kind === "error" ? "Error" : "Result";
const stateName = d.state === "prepared" ? "— awaiting your approval" const stateName = d.state === "prepared" ? "— awaiting your approval"
: d.state === "executing" ? "— executing" : d.state === "executing" ? "— executing"
@ -520,7 +550,7 @@ ShellRoot {
// Approval and cancellation for every plan type. // Approval and cancellation for every plan type.
RowLayout { RowLayout {
Layout.fillWidth: true 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 spacing: 8
PhoebusButton { PhoebusButton {
@ -669,7 +699,7 @@ ShellRoot {
border.width: 1 border.width: 1
} }
onAccepted: { onAccepted: {
if (text.length > 0) { if (!shell.busy && !shell.assistantPending && text.trim().length > 0) {
shell.submitPrompt(text); shell.submitPrompt(text);
text = ""; text = "";
} }
@ -679,7 +709,7 @@ ShellRoot {
PhoebusButton { PhoebusButton {
label: "Send" label: "Send"
primary: true primary: true
actionEnabled: !shell.busy && promptField.text.trim().length > 0 actionEnabled: !shell.busy && !shell.assistantPending && promptField.text.trim().length > 0
onClicked: { onClicked: {
shell.submitPrompt(promptField.text); shell.submitPrompt(promptField.text);
promptField.text = ""; promptField.text = "";
@ -688,7 +718,7 @@ ShellRoot {
PhoebusButton { PhoebusButton {
label: "Clear History" label: "Clear History"
actionEnabled: !shell.busy actionEnabled: !shell.busy && !shell.assistantPending
onClicked: shell.clearConversation() onClicked: shell.clearConversation()
} }
} }
@ -1082,7 +1112,9 @@ ShellRoot {
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Label { Label {
text: shell.statusText text: shell.assistantPending
? "Investigating request (" + shell.assistantElapsedSeconds + "s)..."
: shell.statusText
color: Theme.muted color: Theme.muted
font.pixelSize: 12 font.pixelSize: 12
} }