diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6f6a1f3..5306ae6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,6 +5,18 @@ this file is the curated, human-readable summary. ## Unreleased — Fast defaults with user-controlled source builds +- **Steady assistant display and missing-package result (2026-10-03).** + Progress events now update a small activity list inside the current message + instead of recreating the whole conversation and scrolling it on every + event. Mango keeps the Assistant window opaque and skips its focus animation; + existing user visual rules are preserved. The install advisor can return a + typed `unavailable` result after read-only discovery. The GUI also turns a + bounded investigation with no validated plan into an information card with + AppImage catalog guidance and no approval control. Malformed model replies + remain bounded, and no candidate is invented. In the running VM, the exact + Balena Etcher request completed as a read-only result after package lane + checks, with an `Etcher` catalog lead and no install button or package change. + - **Visible assistant activity (2026-10-03).** The `sys` assistant bridge now streams redacted phase events with the request ID. The QML conversation card shows each phase as running, completed, or failed during investigation and diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index aeab3c3..27fa54c 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -3,6 +3,25 @@ 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 flicker and Etcher follow-up (2026-10-03):** Progress used to + replace the entire QML conversation model and scroll the full view on every + event. It now updates a fixed-height activity list inside the message card. + Mango previously faded the Assistant on focus changes; a per-window + `unfocused_opacity:1,isnoanimation:1` rule keeps it steady, with a one-time + migration that preserves user visual rules. The running VM showed the + Assistant opaque while Kitty held focus + (`/var/tmp/phoebus-vm/no-fade-terminal-after.png`). The installation model + can now report `unavailable` after typed candidate discovery; the bridge + presents a read-only information result with AppImage catalog guidance if + no validated plan emerges. The exact natural Etcher request completed in + the VM as a read-only information card after package lane checks, with an + `Etcher` catalog lead and no install button or package change + (`/var/tmp/phoebus-vm/etcher-new-progress.png`). The user-local static `sys` + SHA-256 is + `f29def8d9d4169f3ffd36c71c3c26781091f6bf0ef2ae518f9881585dd921139`. + Host format, strict clippy, workspace tests, dynamic and static release + builds pass. A fresh ISO remains gated by disk space. + - **Visible assistant activity (2026-10-03):** The assistant bridge now sends redacted `sys` phase events keyed by request ID before the final reply; QML displays and retains each phase in the conversation card. System-fact reads, diff --git a/docs/STATUS.md b/docs/STATUS.md index e5cfbe5..0b1e6dd 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -48,6 +48,25 @@ disposable VM; `serial-driver.py recovery` now automates the same check. ## Matrix +Assistant display and unavailable plan (2026-10-03): QML progress updates +modify only the current card's fixed-height activity list; the conversation +model is not replaced for every phase. The Mango Assistant window stays opaque +and does not animate when focus changes. The running VM showed the Assistant +opaque with Kitty focused (`/var/tmp/phoebus-vm/no-fade-terminal-after.png`) +and retained two completed activity phases in a read-only AppImage reply +(`/var/tmp/phoebus-vm/activity-fixed-test.png`). A typed `unavailable` model +step is accepted only after read-only candidate discovery; no proposal or +execution follows it. Bounded investigation exhaustion becomes a read-only +information result with catalog guidance. Unit tests cover the typed result, +bridge response without approval controls, and preserving a user's existing +Mango visual rule. Rust format, strict clippy, workspace tests, and dynamic +and static release builds pass. The exact Etcher VM request returned read-only +AppImage catalog guidance after lane checks, with no approval control or +package change (`/var/tmp/phoebus-vm/etcher-new-progress.png`). The VM +user-local `sys` binary is SHA-256 +`f29def8d9d4169f3ffd36c71c3c26781091f6bf0ef2ae518f9881585dd921139`; +the root-owned installed binary remains older until a fresh install. + Assistant activity stream (2026-10-03): `sys --assistant-bridge` emits redacted progress JSON lines before its final response, keyed by the same ID. The GUI keeps those lines visible on the corresponding conversation or approval card. diff --git a/docs/SYS.md b/docs/SYS.md index 5acb9d0..d969fd5 100644 --- a/docs/SYS.md +++ b/docs/SYS.md @@ -473,7 +473,11 @@ or approved plan and retains it after completion. Callers must wait for a final response rather than treating a progress event as the reply. Malformed model JSON or typed investigation steps receive up to two bounded correction requests. A third malformed reply returns an error; no action is -executed from that reply. +executed from that reply. Installation investigation also accepts a typed +`unavailable` result after read-only candidate discovery. If it cannot build a +validated plan, the desktop shows a read-only information card with AppImage +catalog guidance and no approval control. A catalog lead is never treated as +an installable candidate without a reviewed artifact URL and SHA-256. - `handshake`: validates client identity and checks active AI model connectivity. - `ask`: submits a conversational request (`install firefox`, `why is audio broken?`) diff --git a/installer-rs/crates/phoebus-ai/src/install.rs b/installer-rs/crates/phoebus-ai/src/install.rs index c002f83..3ac5c79 100644 --- a/installer-rs/crates/phoebus-ai/src/install.rs +++ b/installer-rs/crates/phoebus-ai/src/install.rs @@ -115,6 +115,9 @@ pub enum InstallStep { summary: String, proposal: InstallProposal, }, + Unavailable { + reason: String, + }, } /// The closed set of read-only actions the model may request as evidence. @@ -192,6 +195,11 @@ the application must access local development tools or a specific file. \"backend\":\"...\",\"candidate\":\"...\",\"version\":\"...\",\"reason\":\"...\",\ \"tradeoffs\":[\"...\"],\"evidence\":[\"...\"]}}. +4. No verified candidate after checking the relevant sources: \ +{\"version\":2,\"kind\":\"unavailable\",\"reason\":\"...\"}. Use this when the \ +evidence contains no real installable candidate; do not keep investigating \ +irrelevant names or claim that a catalog link is installable. + Backends: portage-source, portage-binary, portage-vendor, nix, flatpak, snap, appimage, \ custom-ebuild. @@ -264,6 +272,7 @@ pub fn parse_step(text: &str) -> Result { "ask" => &["version", "kind", "question"], "investigate" => &["version", "kind", "requests"], "propose" => &["version", "kind", "proposal"], + "unavailable" => &["version", "kind", "reason"], other => return Err(AiError::Rejected(format!("unknown kind `{other}`"))), }; for key in obj.keys() { @@ -307,6 +316,13 @@ pub fn parse_step(text: &str) -> Result { proposal, }) } + "unavailable" => { + let reason: String = serde_json::from_value(get("reason")?)?; + if reason.trim().is_empty() || reason.len() > 1024 { + return Err(AiError::Rejected("invalid unavailable reason".into())); + } + Ok(InstallStep::Unavailable { reason }) + } _ => unreachable!(), } } @@ -359,6 +375,7 @@ pub fn investigate_install( let mut repeated: std::collections::BTreeMap = std::collections::BTreeMap::new(); let mut turns = 0usize; let mut malformed_replies = 0usize; + let mut discovered_candidates = false; while turns < limits.max_turns { turns += 1; @@ -371,11 +388,15 @@ pub fn investigate_install( if malformed_replies < 2 && turns < limits.max_turns => { malformed_replies += 1; + chat.messages.push(ChatMessage { + role: "assistant".into(), + content: content.clone(), + }); chat.messages.push(ChatMessage { role: "user".into(), content: format!( "Your last reply was invalid ({error}). Return exactly one JSON object \ - with version 2 and kind investigate, ask, or propose. Investigation \ + with version 2 and kind investigate, ask, propose, or unavailable. Investigation \ requests must be typed action objects, for example \ {{\"action\":\"discover_candidates\",\"query\":\"etcher\"}}. \ A proposal application must be a canonical name without spaces, \ @@ -462,6 +483,9 @@ pub fn investigate_install( continue; } let evidence = session.investigate(&requests); + discovered_candidates |= requests + .iter() + .any(|request| matches!(request, SystemAction::DiscoverCandidates { .. })); let mut payload = String::new(); for item in &evidence { payload.push_str(&format!( @@ -501,6 +525,14 @@ pub fn investigate_install( } } } + InstallStep::Unavailable { reason } => { + if !discovered_candidates { + return Err(AiError::Rejected( + "unavailable requires read-only candidate evidence".into(), + )); + } + return Err(AiError::NoVerifiedCandidate(reason)); + } } } @@ -550,7 +582,7 @@ mod tests { } #[test] - fn parse_accepts_the_three_step_kinds() { + fn parse_accepts_the_four_step_kinds() { let ask = parse_step(r#"{"version":2,"kind":"ask","question":"Do you need dev tools?"}"#) .unwrap(); assert!(matches!(ask, InstallStep::Ask { .. })); @@ -561,6 +593,10 @@ mod tests { assert!(matches!(inv, InstallStep::Investigate { .. })); let prop = parse_step(ok_proposal()).unwrap(); assert!(matches!(prop, InstallStep::Propose { .. })); + let unavailable = + parse_step(r#"{"version":2,"kind":"unavailable","reason":"no verified package"}"#) + .unwrap(); + assert!(matches!(unavailable, InstallStep::Unavailable { .. })); } #[test] @@ -581,6 +617,7 @@ mod tests { // Bad candidate for the backend. let bad = r#"{"version":2,"kind":"propose","proposal":{"application":"firefox","backend":"flatpak","candidate":"bad id","reason":"x"}}"#; assert!(parse_step(bad).unwrap_err().to_string().contains("invalid")); + assert!(parse_step(r#"{"version":2,"kind":"unavailable","reason":""}"#).is_err()); } #[test] @@ -623,6 +660,51 @@ mod tests { assert!(requests[1].contains("org.mozilla.firefox")); } + #[test] + fn unavailable_requires_candidate_discovery_and_stops_without_a_proposal() { + let unavailable = + r#"{"version":2,"kind":"unavailable","reason":"no candidate in the checked sources"}"#; + let session = Sessions { + evidence: std::cell::RefCell::new(Vec::new()), + answer: None, + }; + let early = crate::provider::ScriptedTransport::new(vec![chat_response(unavailable)]); + let early_error = investigate_install( + ProviderKind::Local, + "http://127.0.0.1:11434/v1/chat/completions", + "m", + &facts(), + "install etcher", + &early, + &session, + &|_| panic!("no proposal may be validated"), + &Limits::default(), + ) + .unwrap_err(); + assert!(early_error.to_string().contains("requires read-only")); + + let investigated = crate::provider::ScriptedTransport::new(vec![ + chat_response( + r#"{"version":2,"kind":"investigate","requests":[{"action":"discover_candidates","query":"etcher"}]}"#, + ), + chat_response(unavailable), + ]); + let error = investigate_install( + ProviderKind::Local, + "http://127.0.0.1:11434/v1/chat/completions", + "m", + &facts(), + "install etcher", + &investigated, + &session, + &|_| panic!("no proposal may be validated"), + &Limits::default(), + ) + .unwrap_err(); + assert!(matches!(error, AiError::NoVerifiedCandidate(_))); + assert_eq!(session.evidence.borrow().len(), 1); + } + #[test] fn a_rejected_proposal_is_revised_with_findings() { let transport = crate::provider::ScriptedTransport::new(vec![ diff --git a/installer-rs/crates/phoebus-ai/src/lib.rs b/installer-rs/crates/phoebus-ai/src/lib.rs index 4f78274..5ef8a7c 100644 --- a/installer-rs/crates/phoebus-ai/src/lib.rs +++ b/installer-rs/crates/phoebus-ai/src/lib.rs @@ -25,6 +25,8 @@ pub enum AiError { UnsupportedVersion(u32), #[error("change rejected: {0}")] Rejected(String), + #[error("no verified installation candidate: {0}")] + NoVerifiedCandidate(String), #[error("AI provider unavailable: {0}")] ProviderUnavailable(String), #[error("AI provider error: {0}")] diff --git a/installer-rs/crates/phoebus-core/src/system.rs b/installer-rs/crates/phoebus-core/src/system.rs index ad0979a..e87379f 100644 --- a/installer-rs/crates/phoebus-core/src/system.rs +++ b/installer-rs/crates/phoebus-core/src/system.rs @@ -1481,6 +1481,17 @@ if [ ! -e "$updates_window_marker" ] && [ -w "$mango_conf" ]; then : > "$updates_window_marker" fi fi +# Keep the assistant readable when focus moves to a terminal or a system +# dialog. Preserve an existing per-window visual choice if the user made one. +assistant_visual_marker="$HOME/.config/mango/dms/.phoebus-assistant-steady-v1" +if [ ! -e "$assistant_visual_marker" ] && [ -w "$mango_conf" ]; then + if grep -E '^[[:space:]]*windowrule=.*title:\^Phoebus Assistant\$' "$mango_conf" \ + | grep -Eq 'unfocused_opacity|isnoanimation'; then + : > "$assistant_visual_marker" + elif printf '\n# Keep the Assistant opaque and still through focus changes.\nwindowrule=unfocused_opacity:1,isnoanimation:1,title:^Phoebus Assistant$\n' >> "$mango_conf"; then + : > "$assistant_visual_marker" + fi +fi # DMS manages these fragments; they must exist before Mango sources them. for f in colors layout outputs cursor; do [ -e "$HOME/.config/mango/dms/$f.conf" ] || : > "$HOME/.config/mango/dms/$f.conf" @@ -1779,7 +1790,7 @@ windowrule=isfloating:1,appid:^com.danklinux.dms$ # Mango ignores client maximize requests by default; DMS Settings has an expand button. # Size Settings to the current output; DMS switches to compact navigation below 700 px. windowrule=width:0.65,height:0.8,ignore_maximize:0,appid:^com.danklinux.dms$,title:^Settings$ -windowrule=isfloating:1,width:900,height:650,title:^Phoebus Assistant$ +windowrule=isfloating:1,width:900,height:650,unfocused_opacity:1,isnoanimation:1,title:^Phoebus Assistant$ windowrule=isfloating:1,width:900,height:650,title:^Phoebus Updates$ windowrule=isfloating:1,width:720,height:600,title:^Welcome to Phoebus OS$ windowrule=isfullscreen:1,title:^Install Phoebus OS$ diff --git a/installer-rs/crates/phoebus-executor/src/install.rs b/installer-rs/crates/phoebus-executor/src/install.rs index 4accf05..1b3c378 100644 --- a/installer-rs/crates/phoebus-executor/src/install.rs +++ b/installer-rs/crates/phoebus-executor/src/install.rs @@ -16,6 +16,7 @@ use std::path::Path; use phoebus_ai::install::{Evidence, InstallProposal, InstallSession}; use phoebus_ai::provider::{ModelTransport, ProviderKind, SystemFacts}; +use phoebus_ai::AiError; use phoebus_core::action::SystemAction; use phoebus_core::effects::{EffectKind, EffectSource, PackageEffect, ResolvedPlan}; use phoebus_core::selection::{Backend, Candidate, Need, PackageKind, Rejected}; @@ -678,7 +679,18 @@ pub struct AiInstall<'a> { /// an explicit, useful result for a requested AppImage lane instead of asking /// the model to produce an install plan that cannot pass deterministic review. pub fn appimage_discovery_guidance(exec: &Exec, root: &Path, application: &str) -> String { - let report = query::search(exec, root, application, Some(Backend::AppImage)); + let mut report = query::search(exec, root, application, Some(Backend::AppImage)); + if report + .sources + .first() + .is_some_and(|source| source.ok && source.entries.is_empty()) + { + if let Some(last_word) = application.split_whitespace().last() { + if last_word != application { + report = query::search(exec, root, last_word, Some(Backend::AppImage)); + } + } + } let source = &report.sources[0]; let mut answer = format!("AppImage search for {application}: "); if !source.ok { @@ -756,7 +768,23 @@ pub fn resolve_with_ai( &validator, &ai.limits, ) - .map_err(|e| ExecError::operation("install", "AI investigation", e.to_string()))?; + .map_err(|error| match error { + AiError::NoVerifiedCandidate(_) => ExecError::operation( + "install", + "plan unavailable", + "the connected model found no verified install candidate in its evidence", + ), + AiError::Rejected(message) + if message.starts_with("the investigation did not reach a valid proposal within") => + { + ExecError::operation( + "install", + "plan unavailable", + "the connected model did not produce a validated install plan within the investigation limit", + ) + } + other => ExecError::operation("install", "AI investigation", other.to_string()), + })?; let _ = outcome; validated.into_inner().ok_or_else(|| { ExecError::operation( diff --git a/installer-rs/crates/phoebus-executor/tests/session_script.rs b/installer-rs/crates/phoebus-executor/tests/session_script.rs index 6dbdc68..af1c2e9 100644 --- a/installer-rs/crates/phoebus-executor/tests/session_script.rs +++ b/installer-rs/crates/phoebus-executor/tests/session_script.rs @@ -161,6 +161,12 @@ fn existing_mango_profiles_gain_updates_shortcut_once_and_keep_custom_bindings() let content = std::fs::read_to_string(&config).unwrap(); assert_eq!(content.matches("bind=SUPER,u,").count(), 1); assert_eq!(content.matches("title:^Phoebus Updates$").count(), 1); + assert_eq!( + content + .matches("unfocused_opacity:1,isnoanimation:1,title:^Phoebus Assistant$") + .count(), + 1 + ); let custom = Fixture::new(MANGO_FAIL); let custom_config = custom.dir.path().join(".config/mango/config.conf"); @@ -178,6 +184,22 @@ fn existing_mango_profiles_gain_updates_shortcut_once_and_keep_custom_bindings() assert_eq!(custom_content.matches("title:^Phoebus Updates$").count(), 1); } +#[test] +fn existing_assistant_visual_rule_is_preserved() { + let fixture = Fixture::new(MANGO_FAIL); + let config = fixture.dir.path().join(".config/mango/config.conf"); + std::fs::create_dir_all(config.parent().unwrap()).unwrap(); + std::fs::write( + &config, + "windowrule=unfocused_opacity:0.7,title:^Phoebus Assistant$\n", + ) + .unwrap(); + let _ = fixture.run(); + let content = std::fs::read_to_string(&config).unwrap(); + assert!(content.contains("windowrule=unfocused_opacity:0.7,title:^Phoebus Assistant$")); + assert_eq!(content.matches("title:^Phoebus Assistant$").count(), 1); +} + #[test] fn first_login_seeds_wallpaper_folder_and_letter_avatar_without_replacing_choices() { let fixture = Fixture::new(MANGO_OK); diff --git a/installer-rs/crates/phoebus-installer/src/assistant_bridge.rs b/installer-rs/crates/phoebus-installer/src/assistant_bridge.rs index 3370184..1c3ce4d 100644 --- a/installer-rs/crates/phoebus-installer/src/assistant_bridge.rs +++ b/installer-rs/crates/phoebus-installer/src/assistant_bridge.rs @@ -624,11 +624,34 @@ fn plan_and_respond_install( ); plan_response(id, "install", &plan) } + Ok(Err(phoebus_executor::ExecError::Operation { + stage, operation, .. + })) if stage == "install" && operation == "plan unavailable" => { + unavailable_install_response(exec, root, id, app) + } Ok(Err(e)) => BridgeResponse::err(id, e.to_string()), Err(e) => BridgeResponse::err(id, e), } } +fn unavailable_install_response(exec: &Exec, root: &Path, id: u64, app: &str) -> BridgeResponse { + let phase = exec.progress_phase("Checking AppImage catalog for an alternative"); + let appimage = phoebus_executor::install::appimage_discovery_guidance(exec, root, app); + phase.complete(); + BridgeResponse::ok( + id, + json!({ + "kind": "info", + "state": "info", + "application": app, + "recommendation": format!( + "Phoebus could not prepare a verified install plan for {app}. No package was installed. \ + Try an exact package name and source in Legacy Admin if you have one.\n\n{appimage}" + ), + }), + ) +} + #[allow(clippy::too_many_arguments)] fn plan_and_respond_removal( plans: &PlanStore, @@ -1104,6 +1127,21 @@ mod tests { .contains("no verified artifact hash")); } + #[test] + fn unavailable_install_is_information_without_approval_controls() { + let root = tempdir().unwrap(); + let exec = make_test_exec(root.path()); + let response = unavailable_install_response(&exec, root.path(), 9, "etcher"); + assert!(response.ok); + let result = response.result.unwrap(); + assert_eq!(result["kind"], "info"); + assert!(result.get("plan_id").is_none()); + assert!(result["recommendation"] + .as_str() + .unwrap() + .contains("No package was installed")); + } + #[test] fn natural_appimage_install_phrase_reaches_catalog_information() { let root = tempdir().unwrap(); diff --git a/installer/live/desktop/phoebus-assistant/shell.qml b/installer/live/desktop/phoebus-assistant/shell.qml index 79182a4..cddabc3 100644 --- a/installer/live/desktop/phoebus-assistant/shell.qml +++ b/installer/live/desktop/phoebus-assistant/shell.qml @@ -13,6 +13,7 @@ ShellRoot { property string currentTab: Quickshell.env("PHOEBUS_ASSISTANT_START_TAB") === "updates" ? "updates" : "assistant" property var conversation: [] + signal activityEvent(int messageIndex, int position, var entry) property bool busy: false property bool assistantPending: false property int assistantElapsedSeconds: 0 @@ -173,9 +174,8 @@ ShellRoot { activity[position] = entry; else activity.push(entry); - shell.updateMessage(index, { activity: activity.slice(-30) }); - if (index === shell.conversation.length - 1) - Qt.callLater(() => chatList.positionViewAtEnd()); + item.data.activity = activity.slice(-30); + shell.activityEvent(index, position, entry); if (state === "started") shell.statusText = progress.label; } @@ -512,6 +512,7 @@ ShellRoot { model: shell.conversation delegate: Rectangle { + id: messageCard width: chatList.width height: msgCol.height + 16 radius: 8 @@ -585,7 +586,8 @@ ShellRoot { ColumnLayout { Layout.fillWidth: true - visible: !!(modelData.data && modelData.data.activity && modelData.data.activity.length) + visible: !!(modelData.data && + (modelData.data.kind === "progress" || activityList.count > 0)) spacing: 3 Label { @@ -595,15 +597,42 @@ ShellRoot { font.pixelSize: 12 } - Repeater { - model: modelData.data && modelData.data.activity ? modelData.data.activity : [] + ListView { + id: activityList + Layout.fillWidth: true + Layout.preferredHeight: 150 + clip: true + spacing: 3 + model: ListModel { id: activityModel } delegate: Label { - Layout.fillWidth: true - text: "[" + (modelData.state === "completed" ? "done" : modelData.state === "failed" ? "failed" : "running") + "] " + modelData.label - color: modelData.state === "failed" ? Theme.warning : modelData.state === "started" ? Theme.accent : Theme.muted + width: activityList.width + text: "[" + (model.state === "completed" ? "done" : model.state === "failed" ? "failed" : "running") + "] " + model.label + color: model.state === "failed" ? Theme.warning : model.state === "started" ? Theme.accent : Theme.muted font.pixelSize: 12 wrapMode: Text.Wrap } + + Component.onCompleted: { + const activity = modelData.data && modelData.data.activity ? modelData.data.activity : []; + for (let i = 0; i < activity.length; i++) + activityModel.append(activity[i]); + positionViewAtEnd(); + } + } + + Connections { + target: shell + function onActivityEvent(messageIndex, position, entry) { + if (messageIndex !== index) + return; + if (position >= 0 && position < activityModel.count) + activityModel.set(position, entry); + else + activityModel.append(entry); + if (activityModel.count > 30) + activityModel.remove(0); + activityList.positionViewAtEnd(); + } } }