fix(sessions): start --stream answers with the daemon's stream, not the record's
`start`'s reply was `Session.public()`, which reports what was *stored* -- and a
`url` is never stored, because naming one is the daemon's (CONTRACT-sessions.md
§3.5) and a URL on disk is a URL that lies the first time the listener moves.
So a successful `start --stream` handed back a stream with a phrase and no URL,
which no caller could tell from a stream that failed to open: the CLI printed
WARNING: the session is running but its stream was not enabled: the
broker reported no stream
over a stream the daemon had attached a second earlier, and the MCP tool's
summary said `stream: NOT enabled` for the same reason. `stream enable` was
always right, because it answers with `_stream_public` -- only the one-call path
was wrong.
Found by checks/vm-stream.nix's last subtest, which is the only place
`start --stream` runs against a real daemon. The unit test added beside it pins
the seam rather than the symptom: the reply carries a `url`, the record does
not, so anything answering from the record alone has to merge.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011ZeH65zd6pFTgBSu52W9PE
This commit is contained in:
1 parent
b4abd085cc
commit
9d33639c04
2 files changed
+40
-1
No files matched your search
@@ -1018,6 +1018,9 @@ class SessionManager:
|
||||
if session.live:
|
||||
await self._read_back(session, app_id)
|
||||
stream_error: str | None = None
|
||||
#: The daemon's view of the stream, which is the only place a `url`
|
||||
#: exists. Locals and not attributes, for the reason below.
|
||||
stream_public: dict[str, Any] | None = None
|
||||
if stream and session.live:
|
||||
# After the read-back, because that is what settles the container's
|
||||
# output, and a stream has to have one to publish
|
||||
@@ -1032,9 +1035,10 @@ class SessionManager:
|
||||
# be the wrong trade; the refusal is reported on the session's
|
||||
# `stream_error` and the caller can retry `stream.enable`.
|
||||
try:
|
||||
await self.stream_enable(
|
||||
enabled = await self.stream_enable(
|
||||
session.id, phrase=stream_phrase, fps=stream_fps
|
||||
)
|
||||
stream_public = enabled.get("stream")
|
||||
except ManagerError as exc:
|
||||
log.warning("could not enable %s's stream: %s", session.id, exc.reason)
|
||||
session.last_error = session.last_error or exc.reason
|
||||
@@ -1049,6 +1053,19 @@ class SessionManager:
|
||||
# a key that appears only on failure is a key every caller has to
|
||||
# remember to look for.
|
||||
record["stream_error"] = stream_error
|
||||
if stream_public is not None:
|
||||
# The daemon's view, not the record's. `Session.public()`
|
||||
# reports what was stored, and a `url` is never stored --
|
||||
# naming one is the daemon's (§3.5), and a URL on disk is a URL
|
||||
# that lies after the listener moves. So a successful
|
||||
# `start --stream` that answered with `session.public()` alone
|
||||
# handed back a stream with no URL, which a caller cannot tell
|
||||
# from one that failed to open.
|
||||
#
|
||||
# MEASURED in checks/vm-stream.nix: the daemon attached, the
|
||||
# broker recorded it, and the CLI printed "the session is
|
||||
# running but its stream was not enabled".
|
||||
record["stream"] = stream_public
|
||||
if session.state == State.EXITED:
|
||||
# The app exited during the settle: surface it rather than handing
|
||||
# back a healthy-looking id (DESIGN.md §7 #3).
|
||||
|
||||
Reference in new issue
Block a user