fix(terra): surface empty Hermes replies, reconnect the voice widget

- luna-voice treats an empty reply or a stream error frame as a failure,
  so a dead provider key notifies instead of speaking "".
- The Luna widget reads `luna-voice watch` instead of Quickshell's
  Socket, which never retries after one failed connect and left the
  widget OFFLINE after a daemon restart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 02:23:07 +02:00
co-authored by Claude Opus 5.5
parent a9022fa8fc
commit 48aa11eab5
2 changed files with 65 additions and 22 deletions
@@ -23,7 +23,9 @@ QtObject {
property string state: "idle"
// Voice mode itself — the widget is only on screen while this is true.
property bool active: false
property bool connected: socket.connected
// Set by the first line, not by the process starting: the daemon replays
// its state on connect, so only a live connection produces one.
property bool connected: false
// Mic level while listening, her output level while speaking. Drives the
// only genuinely live part of the visuals.
property real rms: 0
@@ -31,35 +33,39 @@ QtObject {
property string lunaText: ""
property string error: ""
readonly property var socket: Socket {
id: socket
path: `${Quickshell.env("XDG_RUNTIME_DIR") ?? "/run/user/1000"}/luna-voiced.sock`
connected: true
// `luna-voice watch`, not Quickshell's Socket: a Socket whose connect
// fails once (daemon mid-restart) keeps the dead QLocalSocket and ignores
// every later `connected = true`, so the widget stuck on OFFLINE.
readonly property var watch: Process {
id: watch
command: ["luna-voice", "watch"]
running: true
onConnectionStateChanged: {
if (!socket.connected) {
// A daemon that went away is not a daemon that is idle: reset
// rather than leave the last frame of a conversation frozen
// on screen.
root.active = false;
root.state = "idle";
root.rms = 0;
stdout: SplitParser {
splitMarker: "\n"
onRead: line => {
root.connected = true;
root.ingest(line);
}
}
parser: SplitParser {
splitMarker: "\n"
onRead: line => root.ingest(line)
onExited: {
// A daemon that went away is not a daemon that is idle: reset
// rather than leave the last frame of a conversation frozen
// on screen.
root.connected = false;
root.active = false;
root.state = "idle";
root.rms = 0;
}
}
// Retry forever, cheaply. Setting `connected` true on an already-open
// socket is a no-op, so this doubles as the initial connect.
// Retry forever, cheaply; each attempt is a fresh connection.
readonly property var reconnect: Timer {
interval: 2000
running: !socket.connected
running: !watch.running
repeat: true
onTriggered: socket.connected = true
onTriggered: watch.running = true
}
function ingest(line: string): void {