HydraIssues

An in-process stream cannot be stopped: the agent goes idle, the Qt session stays live, and the kiosk's 15s reassert puts the head back to streaming
open bug Project: hydraheadflatscreen Parent: #1192 Reporter: 14 Nov 2026 21:03

Description

What happens

On a Linux head there is no way to stop a running stream from off box.

POST /api/v1/stream/stop  ->  idle
(15 s later)              ->  streaming

The agent sets its own status to idle. The stream does not stop, because on Linux it is not a subprocess the agent can kill: it runs IN PROCESS inside the Qt kiosk (useInProcessKioskStream() returns true, issue #507 scene mode). The session is still live in that process, so the kiosk's 15 second state reassert pushes streaming back, and the agent believes it.

Measured on cranky-toaster-86 on 2026-11-14.

Why the reassert is right and the stop is wrong

The 15 second reassert exists so an agent restarted mid-stream re-learns the true state, and it is doing exactly that here. It is reporting the truth. The stop is the half that lies: it reports a state it has no way to bring about.

The subprocess platforms have a real mechanism, stopMoonlightStream() kills the process. Scene mode has no equivalent, because the thing to stop is a session object inside another process that the agent can only reach over the local API, and the traffic on that API runs the other way: the kiosk pushes state TO the agent.

What is missing

A way for the agent to ask the kiosk to end the session, which is the mirror of the prepare-and-pick-up path that #1192 just completed for starting one. The kiosk already polls the agent while a stream runs (pollStreamStatus), so there is a carrier for it. The exit overlay in the Qt app already knows how to end a session cleanly, so there is an implementation to call.

Until then, POST /api/v1/stream/stop should not report idle on a platform where it cannot stop anything. Reporting a failure it can see beats reporting a success it cannot deliver.

Why it is urgent rather than tidy

It compounds with two faults found in the same run:

  • hydracluster's DELETE /api/v1/heads/{id}/stream is broken on every head (#1193), so that route is not an alternative.
  • A body's lane outlives the stream (#1194), so a stream that cannot be stopped also holds a lane that blocks the next start.

Together: a head can be started remotely and then cannot be stopped remotely, and the lane it holds blocks the next head. The only remedies found are restarting the kiosk and restarting hydrabody.

Found by a peer session while running testbook step 10 for #1192.

Comments (2)

api 15 Nov 2026 07:44

Fixed and released. The stop is now a handshake, the start handshake of #1192 run the other way round.

What changed

Step Who What
1 agent POST /api/v1/stream/stop parks a request, status STAYS streaming
2 agent GET /api/v1/stream/status reports "stop_requested": true
3 kiosk stopRequestTimer in KioskStreamPage.qml polls that every 2 s and calls session.stopSession()
4 kiosk sessionFinished posts the existing finished state
5 agent that push, and only that push, takes the status to idle

The status stays streaming for the whole handshake on purpose, which answers the point in the report directly: it is the truth until the session really ends, and the 15 s re-assert then agrees with the agent instead of fighting it.

The stop now says which of three things happened

Answer Meaning
200 {"status":"idle"} the session ended and the agent saw it end
202, stop_requested: true asked, not finished within 9 s
409 refused, and error names what refused

hydraheadflatscreen stream-stop maps the 202 to a non-zero exit, with a 13 s client timeout that fits inside hydracluster's 15 s exec poll and outside the agent's 9 s wait. So each layer reports rather than the one below it timing out underneath it.

No operator PIN is raised. stopSession() is the same call the exit overlay makes after the PIN. The PIN stops a visitor ending somebody else's session from the panel; a stop over the cluster's authenticated route is already authorised, and an unattended head has nobody to type one.

Two guards worth knowing. An unanswered request expires after 60 s, so it can never end the NEXT session. A new start drops a request aimed at the stream it replaces.

One thing the tests caught, not me. A local experience (stream_mode: local, #833) reports streaming too, and it is a process on the head, not a session in the kiosk. My first version handed it to the kiosk, which would have left the experience running with nothing to end it. TestRefusedLocalStopPreservesOwnedLifecycle failed and the guard is now explicit, with its own test.

Released

Repo Tag State
hydraheadflatscreen v2.9.0 released, artifacts serve 206
hydra-experiencenet v6.3.0 tagged, release run green, AppImage building

Docs: the kiosk runbook under Scene mode, the agent runbook under Stopping streams centrally and the in-process endpoint list, and a new step 11 in docs/testbooks/omarchy-head-e2e.md.

Not closed yet. Eight unit tests prove the handshake, including the end-to-end case driven only the way a real kiosk can drive it, but no device has run it. Step 11 is the gate: DELETE /api/v1/heads/{id}/stream, then check the status is STILL idle 20 seconds later, because the re-assert is what exposed the old defect.

api 18 Nov 2026 03:08

Release and fleet state, read live on 2026-11-18, and the device gate is still not run.

Both halves are published and serving. The release project names are not the repository names, which cost a few minutes here:

Half Release path Version
agent hydrahead/production v2.9.1
kiosk hydraexperiencenet/production v6.3.0

HydraExperienceNet-v6.3.0-linux-x86_64.AppImage and hydraheadflatscreen-linux-amd64 both answer a ranged read with 206.

The three Linux heads carry the agent half. cranky-toaster-86, peppy-dumpling-32 and cheeky-cactus-86 are all online in bxl1-test-2 and all report agent v2.9.1.

The device gate is blocked for a different reason than before. bxl1-test-2 has no online body: cloud-l4-euw1 is offline, and the cloud body this was found on is no longer enrolled in the cluster at all. Step 11 measures a STOP, so it needs a live stream first, and nothing in that district can start one.

One trap removed from the testbook. Step 11 said the head needs a kiosk with the stop poll in it, and did not say how to find out. The cluster looks like the answer and is not: the head diagnostics carry "app":"kiosk" next to a version field, and that version is the AGENT. All three heads read v2.9.1 there while nothing reports which AppImage they run. The agent's own record is ~/.hydraheadflatscreen/qt_app_version.yaml, and the testbook now says to read it first, so a stale kiosk cannot be recorded as a failed handshake.