From fd23aa4890eec0d7bd092e167bfc5a43188b6339 Mon Sep 17 00:00:00 2001 From: Phoebus Date: Thu, 1 Oct 2026 09:08:49 -0700 Subject: [PATCH] fix(desktop): launch assistant and ready Snap on desktops --- docs/CHANGELOG.md | 14 +++ docs/HANDOFF.md | 18 ++++ docs/STATUS.md | 4 +- docs/SYS.md | 11 +-- docs/adr/0006-package-lanes.md | 2 +- .../crates/phoebus-core/src/system.rs | 3 + .../crates/phoebus-executor/src/desktop.rs | 5 + .../crates/phoebus-executor/src/snap.rs | 8 +- .../phoebus-installer/tests/live_iso.rs | 17 ++-- .../live/desktop/phoebus-assistant/shell.qml | 91 ++++++++++--------- 10 files changed, 104 insertions(+), 69 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e7c9663..457e232 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,6 +5,20 @@ this file is the curated, human-readable summary. ## Unreleased — Fast defaults with user-controlled source builds +- **Assistant startup and Snap availability (2026-10-01).** Fixed the installed + assistant's Quickshell window: `FloatingWindow` rejected `palette` and + `minimumHeight`, so the configuration never loaded. The palette now belongs + to a Controls ancestor, window size uses implicit dimensions, and model + status follows the bridge's asynchronous handshake and shows a connecting + message while it is pending. New Mango desktops install `snapd` and enable + its socket so `sys find` can query the Snap Store + after boot. Existing desktops can use the reviewed first-use commands in + `docs/SYS.md`. The final assistant QML opened in the disposable graphical + VM and reached `Connected (opencode)` after its handshake. In that older VM, + reviewed `sys` actions installed `snapd` 2.63 and activated `snapd.socket`; + `snap find` and `sys find glances` returned Store results with the Snap lane + ready. The new desktop default awaits a fresh installed VM check. + - **Readable `sys` progress (2026-10-01).** The terminal now names the active planning, evidence, effect-checking, execution and verification steps, shows a slow command's operation, and repeats the current step every ten seconds. diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index ccf5d35..933ce22 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -3,6 +3,24 @@ 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 launch and Snap desktop default (2026-10-01):** The visible + playground exposed a Quickshell configuration error at `shell.qml:223`: + `FloatingWindow` has no `palette`; after removing that error, it rejected + `minimumHeight`. The corrected QML loaded and showed the assistant window + in the disposable VM. A second issue was a startup race: the shell asked + the bridge before its process started and retained a false offline state. + The shell now applies the completed handshake and loads user state then; + the final QML opened in the disposable VM and showed `Connected (opencode)`. + New Mango installs include `app-containers/snapd` and enable + `snapd.socket`. The existing playground predates this; reviewed `sys` + actions installed `snapd` 2.63 and enabled/started its socket there. + `snap find glances` returned Store results, and `sys find glances` completed + with a Snap match and all three package lanes ready. Rust format, Clippy, + tests, release build and `make test` pass. The playground was restarted + from its validated disposable overlay. A fresh ISO/install remains required + for release evidence; host free space was 11 GiB versus the 20 GiB VM + threshold in `make doctor`. + - **`sys` terminal presentation (2026-10-01, overlay VM VERIFIED):** Human CLI runs now show the current planning, evidence, effects, execution and verification phase; slow commands identify their operation and long diff --git a/docs/STATUS.md b/docs/STATUS.md index efd0093..c1d6c8e 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -134,7 +134,7 @@ disposable VM; `serial-driver.py recovery` now automates the same check. | Transaction log (outcomes, protective snapshots) | yes | yes | read-only in installed VM; write path needs root | no | | Flatpak/Nix bounded typed actions | yes | yes | no | no | | Shared hardware-aware source selection (all lanes) | yes | yes | no | no | -| Snap lane (detect/install/list/remove/refresh/connections) | yes (reviewed first-use setup) | yes (incl. exact revisions and confinement) | partial (VM: Portage snapd, active socket, `hello-world` install/list/refresh/remove; partial confinement; refresh had no newer revision; connections not exercised. **Re-checked 2026-09-26 against the live Store**: `hello-world` still 6.4 rev 29 on every channel, refresh reports no updates; guest has no `aa-status`, confinement still `partial`. A revision-changing refresh and strict confinement stay blocked on a Store revision + AppArmor-ready guest) | no | +| Snap lane (detect/install/list/remove/refresh/connections) | yes (snapd and socket enabled by default on new Mango desktops; reviewed first-use setup for older/minimal installs) | yes (incl. exact revisions and confinement; default package/service assertions) | partial (VM: Portage snapd, active socket, `hello-world` install/list/refresh/remove; partial confinement; refresh had no newer revision; connections not exercised. **Re-checked 2026-09-26 against the live Store**: `hello-world` still 6.4 rev 29 on every channel, refresh reports no updates; guest has no `aa-status`, confinement still `partial`. **2026-10-01 existing playground overlay:** reviewed `sys` actions installed `snapd` 2.63 and activated its socket; `snap find glances` and `sys find glances` returned Store results. The new default has no fresh-install VM run yet. A revision-changing refresh and strict confinement stay blocked on a Store revision + AppArmor-ready guest) | no | | AppImage lane (import/acquire/integrity/desktop/remove) | yes | yes | yes (VM: acquire with pinned SHA, list, launch fixture, remove; tampered SHA refused) | no | | Custom ebuild overlay (stage/approve/build/remove) | yes | yes | yes (VM: stage → build/install → VDB+file present → remove) | no | | `sys` installed into the target + verified in chroot | yes | yes (unit) | yes (detached boot verified) | no | @@ -187,7 +187,7 @@ disposable VM; `serial-driver.py recovery` now automates the same check. | 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 | yes (live VM layout) | 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 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/docs/SYS.md b/docs/SYS.md index 7ca1b30..2390bb8 100644 --- a/docs/SYS.md +++ b/docs/SYS.md @@ -205,7 +205,7 @@ installs anything and never fabricates a candidate. | --- | --- | --- | | `nix prepare nodejs python312` | `nix_prepare` | mutate | -### Snap (opt-in; `app-containers/snapd` through Portage) +### Snap (`app-containers/snapd` through Portage) | Phrase | Typed action | Kind | | --- | --- | --- | @@ -217,11 +217,10 @@ installs anything and never fabricates a candidate. | `snap refresh [name]` | `snap_refresh` | mutate | | `snap connections thunderbird` | `snap_connections` | read | -Snap requires a ready `snapd` daemon. A Snap install does not silently install -the Portage dependency; that dependency receives its own review and approval. -The normal `sys install --legacy --snap` workflow must confirm the app -against the Snap Store before approval, so its first use requires a separate, -reviewed setup step: +New Phoebus desktop installs include `snapd` and enable `snapd.socket`; systemd +starts the socket on boot. Snap application installs still receive their own +review and approval. Systems installed before this change, and minimal +installations, need a separate reviewed setup step: ```sh sys install app-containers/snapd --legacy --portage diff --git a/docs/adr/0006-package-lanes.md b/docs/adr/0006-package-lanes.md index fd3fd19..677942e 100644 --- a/docs/adr/0006-package-lanes.md +++ b/docs/adr/0006-package-lanes.md @@ -63,7 +63,7 @@ used by both the deterministic `sys` front-end and the assistant. | **Portage vendor (`-bin`/`-launcher`)** | vendor blobs (`google-chrome`, `steam-launcher`, `discord-bin`, …) | vendor ebuild present | | **Flatpak** | sandboxed graphical applications; multi-distro binaries | always (default desktop) | | **Nix** | developer tools, alternate versions, reproducible per-project environments | always, user-level use | -| **Snap** | applications distributed as snaps, when the user wants the Snap Store and its channel/refresh model | opt-in; `app-containers/snapd` through Portage | +| **Snap** | applications distributed as snaps, when the user wants the Snap Store and its channel/refresh model | ready on the default desktop; `app-containers/snapd` through Portage, with socket activation | | **AppImage** | a single-file application with no maintained package, adopted with pinned integrity | opt-in, managed inventory | | **Custom ebuild** | a maintained package that is unsuitable or absent and cannot be met otherwise | Phoebus overlay, approval-gated | diff --git a/installer-rs/crates/phoebus-core/src/system.rs b/installer-rs/crates/phoebus-core/src/system.rs index 4904b46..ab4da86 100644 --- a/installer-rs/crates/phoebus-core/src/system.rs +++ b/installer-rs/crates/phoebus-core/src/system.rs @@ -60,6 +60,8 @@ pub fn mango_desktop_packages() -> Vec<&'static str> { "gui-apps/dankmaterialshell", "gui-apps/danksearch", "gui-apps/quickshell", + // Keep the Snap application lane ready on installed desktops. + "app-containers/snapd", "dev-vcs/git", "sys-apps/accountsservice", "sys-power/upower", @@ -2608,6 +2610,7 @@ mod tests { #[test] fn desktop_includes_portals_for_flatpak_and_wayland() { let pkgs = desktop_packages(DesktopProfile::Mango); + assert!(pkgs.contains(&"app-containers/snapd")); assert!(pkgs.contains(&"sys-apps/xdg-desktop-portal")); assert!(pkgs.contains(&"sys-apps/xdg-desktop-portal-gtk")); assert!(pkgs.contains(&"gui-libs/xdg-desktop-portal-wlr")); diff --git a/installer-rs/crates/phoebus-executor/src/desktop.rs b/installer-rs/crates/phoebus-executor/src/desktop.rs index e74a258..05b44fa 100644 --- a/installer-rs/crates/phoebus-executor/src/desktop.rs +++ b/installer-rs/crates/phoebus-executor/src/desktop.rs @@ -210,6 +210,10 @@ pub fn configure_login(exec: &Exec, config: &InstallConfig) -> Result<()> { ) })?; } + // snapd is part of the desktop package set. Socket activation keeps the + // daemon idle until needed while making `sys find` and installs available. + portage::chroot(exec, root, "systemctl", &["enable", "snapd.socket"]) + .map_err(|e| ExecError::operation("desktop", "enable snapd socket", e.to_string()))?; // Gentoo ships these user units disabled. A graphical login must start // PipeWire and WirePlumber without requiring a per-user manual setup. for unit in [ @@ -621,6 +625,7 @@ mod tests { // greetd is enabled and the greeter account is created. let commands: Vec = runner.recorded().iter().map(|s| s.args.join(" ")).collect(); assert!(commands.iter().any(|a| a.contains("enable greetd"))); + assert!(commands.iter().any(|a| a.contains("enable snapd.socket"))); assert!(commands.iter().any(|a| a.contains("useradd"))); for unit in [ "pipewire.socket", diff --git a/installer-rs/crates/phoebus-executor/src/snap.rs b/installer-rs/crates/phoebus-executor/src/snap.rs index 4897ad9..dad636a 100644 --- a/installer-rs/crates/phoebus-executor/src/snap.rs +++ b/installer-rs/crates/phoebus-executor/src/snap.rs @@ -1,8 +1,8 @@ -//! Snap as an optional sandboxed application lane. +//! Snap as a sandboxed application lane on installed desktops. //! -//! Snap is not part of a default Phoebus install. The user first reviews and -//! installs `app-containers/snapd` through Portage, then enables and starts -//! `snapd.socket`. Snaps are managed through the `snap` client. +//! New desktop installs include `app-containers/snapd` and enable its socket. +//! Existing installs can add it through a reviewed Portage action, then enable +//! and start `snapd.socket`. Snaps are managed through the `snap` client. //! //! The lane is honest about its capabilities: the daemon must actually be ready, //! application confinement is detected rather than assumed, and the classic diff --git a/installer-rs/crates/phoebus-installer/tests/live_iso.rs b/installer-rs/crates/phoebus-installer/tests/live_iso.rs index d75009c..650e429 100644 --- a/installer-rs/crates/phoebus-installer/tests/live_iso.rs +++ b/installer-rs/crates/phoebus-installer/tests/live_iso.rs @@ -344,17 +344,12 @@ fn assistant_theme_tokens_never_drift() { #[test] fn assistant_layout_fits_small_vm_windows() { let shell = read("installer/live/desktop/phoebus-assistant/shell.qml"); - // No fixed 820x640-only behavior: a minimum size plus a scrollable tab - // row so Send/Cancel/Details stay visible at 1024x768, 1280x720 and - // increased UI scale. - assert!( - shell.contains("minimumWidth"), - "assistant has no minimumWidth" - ); - assert!( - shell.contains("minimumHeight"), - "assistant has no minimumHeight" - ); + // Quickshell FloatingWindow accepts implicit sizing, not minimumWidth or + // minimumHeight. The content and tab row scroll at smaller sizes. + assert!(shell.contains("implicitWidth: 820")); + assert!(shell.contains("implicitHeight: 640")); + assert!(!shell.contains("minimumWidth:")); + assert!(!shell.contains("minimumHeight:")); assert!( shell.contains("Flickable") || shell.contains("Flow") || shell.contains("ScrollView"), "tab row never wraps or scrolls" diff --git a/installer/live/desktop/phoebus-assistant/shell.qml b/installer/live/desktop/phoebus-assistant/shell.qml index 37613a8..da93f71 100644 --- a/installer/live/desktop/phoebus-assistant/shell.qml +++ b/installer/live/desktop/phoebus-assistant/shell.qml @@ -21,6 +21,7 @@ ShellRoot { property string aiBackend: "direct" property string aiError: "" readonly property bool assistantConnected: AssistantBridge.ready && shell.aiConfigured + readonly property bool bridgeConnecting: AssistantBridge.handshake === null && !AssistantBridge.crashed // Theme: dark by default (charcoal/warm-white/amber), light available, // selection persists through preferences when the backend keeps it. property string themeMode: "dark" @@ -30,14 +31,30 @@ ShellRoot { Component.onCompleted: { Theme.themeMode = shell.themeMode; AssistantBridge.start(); - refreshStatus(); - // Apply a persisted theme selection when the backend kept it. - AssistantBridge.getPreferences(reply => { - if (reply.ok && reply.result && reply.result.theme) { - shell.themeMode = reply.result.theme === "light" ? "light" : "dark"; - Theme.themeMode = shell.themeMode; - } - }); + } + + // The process starts asynchronously. Apply its handshake only when it + // arrives, then load the user's state; startup calls otherwise report a + // false offline error and leave the assistant disabled for the session. + Connections { + target: AssistantBridge + function onHandshakeReady() { + const result = AssistantBridge.handshake || {}; + shell.aiConfigured = !!result.ai_configured; + shell.aiBackend = result.ai_backend || "direct"; + shell.aiError = ""; + AssistantBridge.getProactiveAlerts(reply => { + if (reply.ok && reply.result) + shell.activeAlerts = reply.result.alerts || []; + }); + AssistantBridge.getPreferences(reply => { + if (reply.ok && reply.result) { + shell.preferences = reply.result; + if (reply.result.theme) + shell.themeMode = reply.result.theme === "light" ? "light" : "dark"; + } + }); + } } onCurrentTabChanged: { @@ -48,29 +65,11 @@ ShellRoot { function refreshStatus() { AssistantBridge.refreshHandshake(reply => { - if (reply.ok && reply.result) { - shell.aiConfigured = !!reply.result.ai_configured; - shell.aiBackend = reply.result.ai_backend || "direct"; - shell.aiError = ""; - } else { + if (!reply.ok) { shell.aiConfigured = false; shell.aiError = reply.error || "The assistant broker did not answer."; } }); - AssistantBridge.getProactiveAlerts(reply => { - if (reply.ok && reply.result) { - shell.activeAlerts = reply.result.alerts || []; - } - }); - AssistantBridge.getPreferences(reply => { - if (reply.ok && reply.result) { - shell.preferences = reply.result; - if (reply.result.theme) { - shell.themeMode = reply.result.theme === "light" ? "light" : "dark"; - Theme.themeMode = shell.themeMode; - } - } - }); } function toggleTheme() { @@ -212,22 +211,23 @@ ShellRoot { id: window title: "Phoebus Assistant" color: "transparent" - // Responsive: a sensible default that fits 1024x768 and 1280x720, - // resizable down to a usable minimum at increased UI scale. The - // content areas scroll, so nothing essential clips. - width: 820 - height: 640 - minimumWidth: 600 - minimumHeight: 450 - // Qt Quick Controls follow the Phoebus palette (dark default). - palette.window: Theme.background - palette.windowText: Theme.text - palette.base: Theme.card - palette.text: Theme.text - palette.button: Theme.card - palette.buttonText: Theme.text - palette.highlight: Theme.primary - palette.highlightedText: Theme.background + // Default fits 1024x768 and 1280x720. Content areas scroll at + // smaller window sizes and increased UI scale. + implicitWidth: 820 + implicitHeight: 640 + // FloatingWindow has no palette property. A Control provides an + // inherited palette for the Qt Quick Controls inside this window. + Control { + anchors.fill: parent + padding: 0 + palette.window: Theme.background + palette.windowText: Theme.text + palette.base: Theme.card + palette.text: Theme.text + palette.button: Theme.card + palette.buttonText: Theme.text + palette.highlight: Theme.primary + palette.highlightedText: Theme.background Rectangle { anchors.fill: parent @@ -261,7 +261,7 @@ ShellRoot { } Label { - text: shell.assistantConnected ? "Connected (" + shell.aiBackend + ")" : (AssistantBridge.ready ? "Setup required" : "Offline") + text: shell.assistantConnected ? "Connected (" + shell.aiBackend + ")" : (shell.bridgeConnecting ? "Connecting…" : (AssistantBridge.ready ? "Setup required" : "Offline")) color: Theme.muted font.pixelSize: 12 } @@ -353,7 +353,7 @@ ShellRoot { Label { Layout.fillWidth: true wrapMode: Text.Wrap - text: AssistantBridge.ready ? ("No AI model is connected" + (shell.aiError ? ": " + shell.aiError : ". Connect a provider or use Legacy Admin.") ) : "The assistant broker is not running." + text: shell.bridgeConnecting ? "Connecting to the assistant broker…" : (AssistantBridge.ready ? ("No AI model is connected" + (shell.aiError ? ": " + shell.aiError : ". Connect a provider or use Legacy Admin.")) : "The assistant broker is not running.") color: Theme.text font.pixelSize: 12 } @@ -1025,5 +1025,6 @@ ShellRoot { } } } + } } }