aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-23 09:28:33 +0200
committerDanilo M. <danix@danix.xyz>2026-10-23 09:28:33 +0200
commit10bee0184488ffe18b5621578811092ccfb6a405 (patch)
treec6f3eee1c6d8bfbab7b6c801f4855a8f6f9ab7ac /desktop/modules
parent5b80aa009289bd004fbca0658863f284c84384a3 (diff)
downloadquickshell-10bee0184488ffe18b5621578811092ccfb6a405.tar.gz
quickshell-10bee0184488ffe18b5621578811092ccfb6a405.zip
ai: Restart for the desktop assistant and local chat
A Restart button sits before Stop on a running app that has a restart control. The assistant uses assistant.sh restart. llamachat has none, and its --quit answers before the app has exited, so a --daemon sent straight after finds an instance still running and does nothing: the restart quits, waits for --ping to fail (5s at most), then starts it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules')
-rw-r--r--desktop/modules/ai/AiModule.qml18
-rw-r--r--desktop/modules/ai/AiPage.qml2
-rw-r--r--desktop/modules/ai/AiRow.qml18
-rw-r--r--desktop/modules/ai/README.md16
4 files changed, 42 insertions, 12 deletions
diff --git a/desktop/modules/ai/AiModule.qml b/desktop/modules/ai/AiModule.qml
index a96f484..6df3d6b 100644
--- a/desktop/modules/ai/AiModule.qml
+++ b/desktop/modules/ai/AiModule.qml
@@ -49,10 +49,16 @@ Module {
Quickshell.env("HOME") + "/Programming/GIT/desktop-assistant/assistant.sh"
// Each project's own control. Fanfictioner has no start, a run needs a
- // story file, and its stop needs the pid, see stop().
+ // story file, and its stop needs the pid, see stop(). llamachat has no
+ // restart, and --quit answers before the app is gone, so a --daemon
+ // straight after would find it still running and do nothing: wait for
+ // --ping to fail first, up to 5s.
readonly property var controls: ({
- assistant: { start: [assistantSh, "start"], stop: [assistantSh, "stop"] },
- chat: { start: ["llamachat", "--daemon"], stop: ["llamachat", "--quit"] },
+ assistant: { start: [assistantSh, "start"], stop: [assistantSh, "stop"],
+ restart: [assistantSh, "restart"] },
+ chat: { start: ["llamachat", "--daemon"], stop: ["llamachat", "--quit"],
+ restart: ["sh", "-c", "llamachat --quit; for _ in $(seq 50); do "
+ + "llamachat --ping || break; sleep 0.1; done; exec llamachat --daemon"] },
imggen: { start: ["imggen", "start"], stop: ["imggen", "stop"] },
})
@@ -62,6 +68,12 @@ Module {
if (canStart(app)) exec(controls[app.name].start);
}
+ function canRestart(app) { return controls[app.name]?.restart !== undefined; }
+
+ function restart(app) {
+ if (canRestart(app)) exec(controls[app.name].restart);
+ }
+
function stop(app) {
if (app.name !== "fanfic") {
exec(controls[app.name].stop);
diff --git a/desktop/modules/ai/AiPage.qml b/desktop/modules/ai/AiPage.qml
index c8e39e9..e89132a 100644
--- a/desktop/modules/ai/AiPage.qml
+++ b/desktop/modules/ai/AiPage.qml
@@ -69,6 +69,8 @@ Column {
}
action: modelData.running ? "Stop" : page.ai.canStart(modelData) ? "Start" : ""
danger: modelData.running
+ restartable: modelData.running && page.ai.canRestart(modelData)
+ onRestart: page.ai.restart(modelData)
onTriggered: modelData.running ? page.ai.stop(modelData) : page.ai.start(modelData)
}
}
diff --git a/desktop/modules/ai/AiRow.qml b/desktop/modules/ai/AiRow.qml
index ac4a180..2950759 100644
--- a/desktop/modules/ai/AiRow.qml
+++ b/desktop/modules/ai/AiRow.qml
@@ -12,8 +12,9 @@
import QtQuick
import "../.."
-// One engine or app: a state dot, a name, a detail line, and at most one
-// button. An empty action means no button, which is every engine row.
+// One engine or app: a state dot, a name, a detail line, at most one
+// button, and a Restart before it when restartable. An empty action means no
+// button, which is every engine row.
Rectangle {
id: row
@@ -23,7 +24,9 @@ Rectangle {
property bool busy: false
property string action: ""
property bool danger: false
+ property bool restartable: false
signal triggered
+ signal restart
implicitHeight: Math.max(texts.implicitHeight, btn.visible ? btn.implicitHeight : 0) + 16
radius: 8
@@ -40,7 +43,8 @@ Rectangle {
id: texts
anchors {
left: dot.right; leftMargin: 10
- right: btn.visible ? btn.left : parent.right; rightMargin: 10
+ right: restartBtn.visible ? restartBtn.left : btn.visible ? btn.left : parent.right
+ rightMargin: 10
verticalCenter: parent.verticalCenter
}
spacing: 2
@@ -63,6 +67,14 @@ Rectangle {
}
Button {
+ id: restartBtn
+ anchors { right: btn.left; rightMargin: 6; verticalCenter: parent.verticalCenter }
+ visible: row.restartable
+ text: "Restart"
+ onClicked: row.restart()
+ }
+
+ Button {
id: btn
anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter }
visible: row.action !== ""
diff --git a/desktop/modules/ai/README.md b/desktop/modules/ai/README.md
index 5e204ca..5aec615 100644
--- a/desktop/modules/ai/README.md
+++ b/desktop/modules/ai/README.md
@@ -27,12 +27,16 @@ written in the last 5s. A step slower than that reads idle.
## Apps
-| App | Status | Start | Stop |
-| --- | --- | --- | --- |
-| desktop-assistant | `assistant.sh status` | `assistant.sh start` | `assistant.sh stop` |
-| local chat | `llamachat --ping` | `llamachat --daemon` | `llamachat --quit` |
-| imggen | `imggen status` | `imggen start` (default model) | `imggen stop` |
-| fanfictioner | `pgrep` on `python3 .../fanfictioner` | none | TERM its children, then it, by pid |
+| App | Status | Start | Stop | Restart |
+| --- | --- | --- | --- | --- |
+| desktop-assistant | `assistant.sh status` | `assistant.sh start` | `assistant.sh stop` | `assistant.sh restart` |
+| local chat | `llamachat --ping` | `llamachat --daemon` | `llamachat --quit` | quit, wait for `--ping` to fail (5s at most), `--daemon` |
+| imggen | `imggen status` | `imggen start` (default model) | `imggen stop` | none |
+| fanfictioner | `pgrep` on `python3 .../fanfictioner` | none | TERM its children, then it, by pid | none |
+
+Restart shows only while an app is running. llamachat's `--quit` answers
+before the app has exited, so a `--daemon` sent straight after finds it still
+running and does nothing; hence the wait.
Each runs detached, so no exit code comes back; the next poll shows whether it
worked. `assistant.sh status` fails when the daemon is down.