feat(terra): luna v3 voice, channel marker and rail panel

- TTS defaults to eleven_v3_conversational over the Text to Dialogue
  socket: performs audio tags and gets her German right. Flash still
  works via the TTS socket.
- Every spoken message is prefixed with a [voice] marker so luna's
  profile on mars can tell the channel apart.
- LunaIndicator/LunaCall replaced by a LunaPanel in the bar rail, with
  captions; headless test updated to match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 00:52:03 +02:00
co-authored by Claude Opus 5.5
parent 386a46c4fe
commit e4ee637ccd
13 changed files with 675 additions and 467 deletions
@@ -4,7 +4,7 @@ import QtQuick.Layouts
import Quickshell
import Quickshell.Wayland
import qs.HyprChrome.Theme
import qs.HyprChrome.Widgets.Bar.Debug
import qs.HyprChrome.Widgets.Bar.Luna
import qs.HyprChrome.Widgets.Bar.Host
import qs.HyprChrome.Widgets.Bar.Vitals
import qs.HyprChrome.Widgets.Bar.Workspaces
@@ -87,8 +87,8 @@ PanelWindow {
//
// The zone still follows the target height, so tiled windows reflow once
// per toggle, at the start, and slide while the panels animate.
readonly property real expandedContent: Math.max(hostPanel.expandedHeight, workspacesPanel.expandedHeight, vitalsPanel.expandedHeight, testPanel.expandedHeight, trayPanel.expandedHeight) + window.margin * 2
readonly property real contentHeight: Math.max(hostPanel.targetHeight, workspacesPanel.targetHeight, vitalsPanel.targetHeight, testPanel.targetHeight, trayPanel.targetHeight) + window.margin * 2
readonly property real expandedContent: Math.max(hostPanel.expandedHeight, workspacesPanel.expandedHeight, vitalsPanel.expandedHeight, lunaPanel.expandedHeight, trayPanel.expandedHeight) + window.margin * 2
readonly property real contentHeight: Math.max(hostPanel.targetHeight, workspacesPanel.targetHeight, vitalsPanel.targetHeight, lunaPanel.targetHeight, trayPanel.targetHeight) + window.margin * 2
implicitHeight: Math.round(window.expandedContent)
@@ -157,8 +157,8 @@ PanelWindow {
// and a trace at each end.
Item { Layout.fillWidth: true }
TestPanel {
id: testPanel
LunaPanel {
id: lunaPanel
expanded: window.expanded
toggleOnClick: false
@@ -0,0 +1,200 @@
pragma ComponentBehavior: Bound
import QtQuick
import qs.HyprChrome.Theme
import qs.HyprChrome.Widgets.Bar.Panels
// luna's voice loop on the rail (services/desktop/luna-voice.nix).
//
// Always present, unlike the daemon it watches: the panel is where you look
// to find out whether she is listening, so it has to be there when the answer
// is "no" — including when luna-voiced is not running at all. SUPER+V toggles
// LISTENING, not this.
//
// Collapsed it is the state and nothing else, because that is the one fact
// worth a glance; expanded it carries the last exchange, which is the thing
// you actually want during the seconds her reply takes to arrive.
BarPanel {
id: luna
// Overridable so the headless render can stage every state without a
// daemon; in the rail they track the socket below.
property string daemonState: state.state
property bool active: state.active
property bool connected: state.connected
property real rms: state.rms
property string userText: state.userText
property string lunaText: state.lunaText
// Instantiated here rather than in the shell: the panel is the only
// reader, and it is a second reader that would make this shell state.
readonly property var state: LunaState {}
panelId: "LUN"
title: "LUNA"
meta: luna.active ? "VOICE" : "IDLE"
// Sized to content like the tray, and per DENSITY: collapsed it is one
// word, so reserving the expanded body's width would leave the rail
// carrying a mostly empty panel for the state it spends most of its time
// in. It floats between two spacers, so the width change costs no other
// panel anything.
implicitWidth: luna.expanded
? Math.max(luna.headerMinWidth, luna.padding * 2 + body.implicitWidth)
: Math.max(luna.headerMinWidth, luna.briefLeft + brief.implicitWidth + luna.padding)
readonly property color stateColor: {
if (!luna.connected)
return Theme.disabled;
switch (luna.daemonState) {
case "listening":
return Theme.accent;
case "thinking":
return Theme.muted;
case "speaking":
return Theme.accentSoft;
default:
return luna.active ? Theme.text : Theme.raised;
}
}
readonly property string stateLabel: {
if (!luna.connected)
return "OFFLINE";
if (!luna.active)
return "OFF";
switch (luna.daemonState) {
case "listening":
return "LISTENING";
case "thinking":
return "THINKING";
case "speaking":
return "SPEAKING";
default:
return "READY";
}
}
summary: Row {
id: brief
spacing: 6
// Breathes only while the mic is open, so "she is listening to me
// right now" is legible without reading the word next to it.
Rectangle {
width: 7
height: 7
radius: 4
anchors.verticalCenter: parent.verticalCenter
color: luna.stateColor
SequentialAnimation on opacity {
running: luna.daemonState === "listening"
loops: Animation.Infinite
alwaysRunToEnd: true
NumberAnimation { to: 0.25; duration: 700; easing.type: Easing.InOutQuad }
NumberAnimation { to: 1.0; duration: 700; easing.type: Easing.InOutQuad }
}
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: luna.stateLabel
color: luna.stateColor
font.family: Theme.displayFont
font.pixelSize: 13
font.bold: true
}
}
Column {
id: body
spacing: 6
// Level meter: live whenever voice mode is on, not only once a
// trigger has fired, so a mic too quiet to reach the threshold still
// shows movement instead of looking broken.
Row {
id: meter
width: 260
height: 18
spacing: 2
readonly property int count: 28
readonly property bool sweeping: luna.daemonState === "thinking"
property real phase: 0
NumberAnimation on phase {
running: meter.sweeping
loops: Animation.Infinite
from: 0
to: 1
duration: 1200
}
Repeater {
model: meter.count
Rectangle {
required property int index
width: (meter.width - (meter.count - 1) * meter.spacing) / meter.count
height: {
if (meter.sweeping) {
const pos = index / (meter.count - 1);
return 2 + 14 * Math.max(0, 1 - Math.abs(pos - meter.phase) * 6);
}
if (!luna.active && luna.daemonState !== "speaking")
return 2;
// sqrt opens up the quiet end, which on this mic is
// where all of the speech actually sits.
const level = Math.min(1, Math.sqrt(luna.rms) * 6.0);
const centre = 1 - Math.abs(index / (meter.count - 1) - 0.5) * 1.6;
return 2 + 16 * level * Math.max(0.15, centre);
}
anchors.bottom: parent.bottom
color: luna.stateColor
opacity: meter.sweeping ? 0.9 : 0.5 + 0.5 * (height / 18)
Behavior on height {
enabled: !meter.sweeping
NumberAnimation { duration: 70; easing.type: Easing.OutQuad }
}
}
}
}
Text {
width: 260
visible: luna.userText !== ""
text: `> ${luna.userText}`
color: Theme.muted
font.family: Theme.microFont
font.pixelSize: 10
wrapMode: Text.WordWrap
maximumLineCount: 2
elide: Text.ElideRight
}
Text {
width: 260
visible: luna.lunaText !== ""
text: luna.lunaText
color: Theme.text
font.family: Theme.microFont
font.pixelSize: 11
wrapMode: Text.WordWrap
maximumLineCount: 4
elide: Text.ElideRight
}
Text {
visible: luna.userText === "" && luna.lunaText === ""
text: luna.connected ? "SUPER+V TO TALK" : "DAEMON NOT RUNNING"
color: Theme.muted
font.family: Theme.microFont
font.pixelSize: 9
font.letterSpacing: 1.4
}
}
}
@@ -9,7 +9,6 @@ import qs.HyprChrome.Widgets.Polkit
import qs.HyprChrome.Widgets.Launcher
import qs.HyprChrome.Widgets.Askpass
import qs.HyprChrome.Widgets.Notifications
import qs.HyprChrome.Widgets.Luna
// The hyprchrome shell: owns everything the rail's surfaces have to agree on,
// and instantiates them.
@@ -217,25 +216,6 @@ Scope {
screen: shell.targetScreen
}
// luna's voice-mode readout. Beside the notification stack rather than
// among the modals: it never takes the keyboard and raises no scrim, so
// it is deliberately NOT part of `modalOpen`. It does read `targetScreen`,
// which is what makes it belong to the shell at all.
LunaState {
id: lunaState
}
LunaCall {
state: lunaState
targetScreen: shell.targetScreen
// Same source the backdrop uses. The rail's exclusive zone does NOT
// push this surface down on its own — measured: the bar occupies
// y 0..147 and the readout still landed at y=8 — so the offset is
// passed explicitly rather than left to the compositor. That makes
// the bar's height shell state by the usual rule: a second reader.
barHeight: bar.contentHeight
}
// Polkit authentication agent. It registers for this logind session on
// creation, so it replaces hyprpolkitagent rather than coexisting with it —
// only one agent may hold a session (see hosts/terra/home/hyprland.nix).
@@ -1,60 +0,0 @@
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Wayland
import qs.HyprChrome.Widgets.Luna
// Voice-mode surface: top-left, directly under the rail.
//
// Thin by design — the visuals are all in LunaIndicator so they stay
// headless-renderable. Anchoring top+left is enough to sit under the bar:
// the rail sets an exclusiveZone of its collapsed height, so the compositor
// places this below it without either surface knowing the other's metrics.
//
// NOT a modal. She never takes the keyboard — the whole point is that you
// keep working while talking — so this does not join the shell's `modalOpen`
// and raises no scrim.
PanelWindow {
id: window
required property var state
required property var targetScreen
// The rail's settled height, from the shell. Not the compositor's job
// here: the bar's exclusive zone leaves this surface at the top of the
// output, so the gap is opened by hand.
required property real barHeight
screen: window.targetScreen
visible: window.state.active
anchors { top: true; left: true }
margins { left: 8; top: window.barHeight + 8 }
implicitWidth: indicator.implicitWidth
implicitHeight: indicator.implicitHeight
color: "transparent"
// Below the rail's own layer: this is a readout, not a surface that
// should ever cover the bar.
WlrLayershell.layer: WlrLayer.Top
// A readout that stole focus would break typing the moment she answered.
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
// Normal with a zero zone: reserve nothing of our own, but still RESPECT
// the rail's exclusion so the compositor places this under it. Ignore
// would skip other surfaces' zones too, which put it over the bar.
exclusionMode: ExclusionMode.Normal
exclusiveZone: 0
LunaIndicator {
id: indicator
anchors.fill: parent
state: window.state.state
active: window.state.active
connected: window.state.connected
rms: window.state.rms
userText: window.state.userText
lunaText: window.state.lunaText
}
}
@@ -1,229 +0,0 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Shapes
import qs.HyprChrome.Theme
// The voice-mode readout: whether luna is listening, thinking or talking.
//
// Item-rooted with no window of its own so tools/quickshell-preview/render.sh
// can shoot it offscreen — the PanelWindow lives in LunaCall.qml. A standalone
// 3D avatar replaces the meter later; the states and their colours are the
// part that has to read correctly first.
Item {
id: root
// Driven by LunaState; defaulted so the headless render and the
// DebugWindow can stage this without a daemon.
property string state: "idle"
property bool active: true
property bool connected: true
property real rms: 0
property string userText: ""
property string lunaText: ""
// Metrics are per-component in this tree; Theme carries colour and type only.
readonly property int pad: 8
readonly property int chamfer: 10
implicitWidth: 260
implicitHeight: content.implicitHeight + root.pad * 2
// Not readonly: a Behavior cannot attach to a readonly property, and the
// colour crossfade is what keeps state changes from snapping.
property color stateColor: {
if (!root.connected)
return Theme.disabled;
switch (root.state) {
case "listening":
return Theme.accent;
case "thinking":
return Theme.muted;
case "speaking":
return Theme.accentSoft;
default:
return Theme.raised;
}
}
readonly property string stateLabel: {
if (!root.connected)
return "OFFLINE";
switch (root.state) {
case "listening":
return "LISTENING";
case "thinking":
return "THINKING";
case "speaking":
return "SPEAKING";
default:
return "READY";
}
}
Behavior on stateColor {
ColorAnimation { duration: 180 }
}
// The card is ONE chamfered path, not a rectangle with a triangle drawn
// over its corner — that leaves the square border showing underneath and
// reads as an artifact rather than a cut.
Shape {
anchors.fill: parent
preferredRendererType: Shape.CurveRenderer
opacity: 0.96
ShapePath {
strokeWidth: 1
strokeColor: root.stateColor
fillColor: Theme.surface
startX: 0
startY: 0
PathLine { x: root.width - root.chamfer; y: 0 }
PathLine { x: root.width; y: root.chamfer }
PathLine { x: root.width; y: root.height }
PathLine { x: 0; y: root.height }
PathLine { x: 0; y: 0 }
}
}
Column {
id: content
anchors.fill: parent
anchors.margins: root.pad
spacing: root.pad
Row {
spacing: root.pad
// The one element that is alive while nothing else moves: a dot
// that breathes in listening and holds steady otherwise, so "the
// mic is open" is legible from across the room.
Rectangle {
id: dot
width: 8
height: 8
radius: 4
anchors.verticalCenter: parent.verticalCenter
color: root.stateColor
SequentialAnimation on opacity {
running: root.state === "listening"
loops: Animation.Infinite
alwaysRunToEnd: true
NumberAnimation { to: 0.25; duration: 700; easing.type: Easing.InOutQuad }
NumberAnimation { to: 1.0; duration: 700; easing.type: Easing.InOutQuad }
}
// An animation that stops mid-fade would leave the dot dim
// and looking half-dead.
onVisibleChanged: if (root.state !== "listening") opacity = 1
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: "LUNA"
color: Theme.text
font.family: Theme.displayFont
font.pixelSize: 12
font.letterSpacing: 2
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: root.stateLabel
color: root.stateColor
font.family: Theme.microFont
font.pixelSize: 10
font.letterSpacing: 1
}
}
// Level meter. Bars react to rms while listening or speaking; during
// thinking they run a sweep instead, because a dead meter and a
// crashed daemon look identical and her replies take seconds.
Row {
id: meter
width: parent.width
height: 22
spacing: 2
readonly property int count: 24
readonly property bool sweeping: root.state === "thinking"
property real phase: 0
NumberAnimation on phase {
running: meter.sweeping
loops: Animation.Infinite
from: 0
to: 1
duration: 1200
}
Repeater {
model: meter.count
Rectangle {
required property int index
width: (meter.width - (meter.count - 1) * meter.spacing) / meter.count
height: {
if (meter.sweeping) {
// A travelling bump rather than a bar graph.
const pos = index / (meter.count - 1);
const d = Math.abs(pos - meter.phase);
return 3 + 16 * Math.max(0, 1 - d * 6);
}
// Live whenever voice mode is on, not only once a
// trigger has fired: "is it hearing me at all" has to
// be answerable BEFORE anything happens, or a mic
// that is too quiet looks exactly like a broken one.
if (!root.active && root.state !== "speaking")
return 3;
// rms is small and non-linear; sqrt opens up the
// quiet end where speech actually sits.
const level = Math.min(1, Math.sqrt(root.rms) * 3.2);
// Centre bars taller, so it reads as a voice rather
// than a progress bar.
const centre = 1 - Math.abs(index / (meter.count - 1) - 0.5) * 1.6;
return 3 + 19 * level * Math.max(0.15, centre);
}
anchors.bottom: parent.bottom
color: root.stateColor
opacity: meter.sweeping ? 0.9 : 0.55 + 0.45 * (height / 22)
Behavior on height {
enabled: !meter.sweeping
NumberAnimation { duration: 70; easing.type: Easing.OutQuad }
}
}
}
}
// Captions: hers leads the audio (the daemon emits each sentence as
// it goes to the synthesiser), which is what makes a 5s reply feel
// like it has started.
Text {
width: parent.width
visible: root.userText !== ""
text: `> ${root.userText}`
color: Theme.muted
font.family: Theme.microFont
font.pixelSize: 10
wrapMode: Text.WordWrap
maximumLineCount: 2
elide: Text.ElideRight
}
Text {
width: parent.width
visible: root.lunaText !== ""
text: root.lunaText
color: Theme.text
font.family: Theme.microFont
font.pixelSize: 11
wrapMode: Text.WordWrap
maximumLineCount: 3
elide: Text.ElideRight
}
}
}