diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-17 10:53:17 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-17 10:53:17 +0200 |
| commit | ca3c66d882e60874b1cf4a1c5f9ea4232a593255 (patch) | |
| tree | 8ce9c36025ec1deea947866849060f5583533c7c | |
| parent | 885d65a2bbcde0e8e5094ae4589647875ee5838d (diff) | |
| download | quickshell-ca3c66d882e60874b1cf4a1c5f9ea4232a593255.tar.gz quickshell-ca3c66d882e60874b1cf4a1c5f9ea4232a593255.zip | |
assistant: opening the canvas loads the preferred model
A preferred model that only took effect from the settings page did
nothing the next time another client had swapped it out. On this
desktop one model and one client run at a time, so opening the canvas
is when the assistant's model should come back: if the preferred one is
neither loaded nor loading, it is loaded, and the canvas header says so
until the router reports it in. The daemon still never asks for a model;
with no preference set nothing changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | desktop/assistant/Assistant.qml | 3 | ||||
| -rw-r--r-- | desktop/assistant/Card.qml | 1 | ||||
| -rw-r--r-- | desktop/modules/assistant/AssistantModule.qml | 13 | ||||
| -rw-r--r-- | desktop/modules/assistant/README.md | 7 | ||||
| -rw-r--r-- | desktop/shell.qml | 11 |
5 files changed, 33 insertions, 2 deletions
diff --git a/desktop/assistant/Assistant.qml b/desktop/assistant/Assistant.qml index f76c38d..6692648 100644 --- a/desktop/assistant/Assistant.qml +++ b/desktop/assistant/Assistant.qml @@ -63,6 +63,9 @@ Scope { readonly property bool connected: link.item?.connected ?? false property string state: "idle" property string model: "" + // The preferred model being loaded on open, shown in the header until + // the router reports it loaded. Set from shell.qml. + property string swapping: "" property int ctxUsed: 0 property int ctxMax: 0 property var convId: null diff --git a/desktop/assistant/Card.qml b/desktop/assistant/Card.qml index 150e483..4c76e64 100644 --- a/desktop/assistant/Card.qml +++ b/desktop/assistant/Card.qml @@ -83,6 +83,7 @@ Rectangle { Text { anchors { left: parent.left; verticalCenter: parent.verticalCenter } text: !card.canvas.connected ? "assistant not running" + : card.canvas.swapping ? `loading ${card.canvas.swapping}…` : card.canvas.model || "assistant" color: card.canvas.connected ? Theme.text : Theme.red font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 } diff --git a/desktop/modules/assistant/AssistantModule.qml b/desktop/modules/assistant/AssistantModule.qml index a85b2b3..b53a33f 100644 --- a/desktop/modules/assistant/AssistantModule.qml +++ b/desktop/modules/assistant/AssistantModule.qml @@ -198,6 +198,19 @@ Module { else { poll.left = 300; poll.start(); } }); } + // Called when the assistant canvas opens: the preferred model, if one is + // set, still listed, and neither loaded nor loading, is loaded. One model + // and one client at a time is how this desktop runs, so opening the + // assistant is the moment to bring its model back. + function ensurePreferred() { + const id = Prefs.assistantModel; + if (id === "" || am.loading !== "") return; + am.listModels(() => { + const m = am.models.find(x => x.id === id); + if (m && m.status !== "loaded" && m.status !== "loading") am.loadModel(id); + }); + } + property Timer poll: Timer { property int left: 0 interval: 1000 diff --git a/desktop/modules/assistant/README.md b/desktop/modules/assistant/README.md index 07cc7ad..93b8507 100644 --- a/desktop/modules/assistant/README.md +++ b/desktop/modules/assistant/README.md @@ -19,6 +19,13 @@ deliberate swap: it saves that model as the preferred one (in `Prefs`) and asks the router to load it now, polling `/v1/models` until it reports `loaded`. Prefer marks the already-loaded model as preferred. +Opening the assistant canvas (SUPER+Home) loads the preferred model when +another one is resident, and the canvas header reads "loading <model>…" +until it is in. This desktop runs one model and one client at a time, so +opening the assistant is when its model should come back; the daemon still +never asks for a model itself. With no preferred model set, nothing is +swapped. + The daemon reads all of this only at startup, so after a change the page says so and offers Restart, which runs `assistant.sh restart`; a daemon that does not come back shows the script's status, whose log tail says why. diff --git a/desktop/shell.qml b/desktop/shell.qml index ec58936..ea2ce67 100644 --- a/desktop/shell.qml +++ b/desktop/shell.qml @@ -81,7 +81,7 @@ ShellRoot { SunsetModule {}, IdleModule {}, AutostartModule {}, - AssistantModule {}, + AssistantModule { id: asstSettings }, PresetsModule {}, GitModule {}, ] @@ -109,7 +109,14 @@ ShellRoot { // The assistant canvas on SUPER+Home, a view over desktop-assistant's // socket. See assistant/README.md. - Assistant { id: assistant } + Assistant { id: assistant; swapping: asstSettings.loading } + + // Opening the assistant loads its preferred model if another one is in + // VRAM. See modules/assistant/README.md. + Connections { + target: assistant + function onOpenChanged() { if (assistant.open) asstSettings.ensurePreferred(); } + } // The waybar launcher and the deep-link keybinds all reach this: // qs -p <this dir> ipc call drawer toggle -> the grid |
