aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/ai/AiModule.qml
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/ai/AiModule.qml
parent5b80aa009289bd004fbca0658863f284c84384a3 (diff)
downloadquickshell-10bee0184488ffe18b5621578811092ccfb6a405.tar.gz
quickshell-10bee0184488ffe18b5621578811092ccfb6a405.zip
ai: Restart for the desktop assistant and local chatHEADmaster
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/ai/AiModule.qml')
-rw-r--r--desktop/modules/ai/AiModule.qml18
1 files changed, 15 insertions, 3 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);