Skip to content

The agent that grows with you

fix(gateway): offer queued-row Steer/Edit on Desktop chats migrated from main

unsupportedpastels2d665f9f4bc2
diff --git a/gateway/session_authority.py b/gateway/session_authority.py
index a0014767836..a3b7011b029 100644
--- a/gateway/session_authority.py
+++ b/gateway/session_authority.py
@@ -104,6 +104,7 @@ class SessionAuthority:
# session -> (generation, {admission_id: delivered}): queued admissions prompt.steer_queued handed
# to that running claim (gateway/session_queued_controls.py); its settlement decides each one.
self.steer_transfers = {}
+ self.launch_sources = {} # session -> its frozen launch source (session_queued_controls)
# session -> generation of the last Stop delivered to a live agent. A repeated
# Stop can land on the session's reusable cached agent after that turn's finalizer
# cleared it; the next generation's adopt_agent drops it instead of starting interrupted.
diff --git a/gateway/session_queued_controls.py b/gateway/session_queued_controls.py
index bd4d88cfac0..20d55169f15 100644
--- a/gateway/session_queued_controls.py
+++ b/gateway/session_queued_controls.py
@@ -8,7 +8,7 @@ A steer is a TRANSFER to the running claim, not an outcome: the row goes queued
completes with the text delivered, ``interrupted`` otherwise; queued again in its own FIFO place when
the text never reached the claim's agent). The fence is ``authority.steer_transfers``, changed only
under the session's ``event_stream.lock`` (the lock the drain clears ``executing`` under): no storage
-wait ever happens under that lock, which loop-side receipts, attaches and publication take.
+write ever waits under that lock, which loop-side receipts, attaches and publication take.
"""
import asyncio
from dataclasses import asdict
@@ -24,9 +24,10 @@ from hermes_state_runtime import (
_TEXT_ONLY = frozenset({'text', 'surface_v1', 'display_v1', 'local_operator_v1'})
# Sessions launched from an interactive local surface (classic CLI, TUI, Desktop, ACP editor): their
# plain-text rows are prompt.submit input, whose observers settle a ``steered``/``cancelled`` row.
+# ``desktop`` is the label a Desktop chat migrated from main keeps (hermes_state_local_migration).
# cron, kanban, a2a and hosted-room (bot_room) producers read a saved result for every outcome they
# do not name, so a transfer or replacement would strand them: never offered, refused by name.
-_INTERACTIVE_SOURCES = frozenset({'cli', 'tui', 'gui', 'acp'})
+_INTERACTIVE_SOURCES = frozenset({'cli', 'tui', 'gui', 'desktop', 'acp'})
def handlers(connection):
@@ -36,8 +37,9 @@ def handlers(connection):
def _interactive(authority, session_id):
"""The session's frozen launch source (a local session's row records it) names a local surface.
- Callers hold the stream lock: a plain read (``get_session`` flushes token counts, a write)."""
- sources = authority.__dict__.setdefault('_launch_sources', {})
+ Callers hold the stream lock: one plain read per session, cached (``get_session`` flushes token
+ counts, a write). Under WAL it takes the lock-free reader pool, as ``_pending_rows`` does there."""
+ sources = authority.launch_sources
if session_id not in sources:
with authority.db._read_ctx() as conn:
found = conn.execute('SELECT source FROM sessions WHERE id=?', (session_id,)).fetchone()
diff --git a/tests/gateway/test_prompt_queued_transfer.py b/tests/gateway/test_prompt_queued_transfer.py
index 24c75573069..79cc49ff9ca 100644
--- a/tests/gateway/test_prompt_queued_transfer.py
+++ b/tests/gateway/test_prompt_queued_transfer.py
@@ -404,9 +404,10 @@ def test_only_interactive_local_sessions_are_offered_queued_controls(tmp_path, m
row = {'status': 'queued', 'target_session_id': 's', 'payload': {'text': 'hello'}}
with db:
assert session_queued_controls.queued_controls(authority, row) == [], 'no launch policy: not interactive'
- for source, offered in (('gui', True), ('tui', True), ('cli', True), ('acp', True), ('cron', False),
- ('kanban', False), ('a2a', False), ('bot_room', False)):
- authority._launch_sources = {}
+ # ``desktop``: a Desktop chat migrated from main keeps main's source label.
+ for source, offered in (('gui', True), ('desktop', True), ('tui', True), ('cli', True), ('acp', True),
+ ('cron', False), ('kanban', False), ('a2a', False), ('bot_room', False)):
+ authority.launch_sources = {}
interactive(db, source=source)
controls = session_queued_controls.queued_controls(authority, row)
assert controls == (['steer', 'replace'] if offered else []), (source, controls)
diff --git a/tests/hermes_cli/test_gateway_chat_pending_preview.py b/tests/hermes_cli/test_gateway_chat_pending_preview.py
index f72054a263b..4665fff971b 100644
--- a/tests/hermes_cli/test_gateway_chat_pending_preview.py
+++ b/tests/hermes_cli/test_gateway_chat_pending_preview.py
@@ -8,7 +8,7 @@ def test_resume_lists_pending_admission_text_capped_and_terminal_safe(capsys):
authority = object.__new__(SessionAuthority)
authority.profile_id, authority.epoch = "profile", 3
- authority._launch_sources = {"stored": "cli"} # the resumed classic CLI's launch source
+ authority.launch_sources = {"stored": "cli"} # the resumed classic CLI's launch source
row = {"target_session_id": "stored", "outcome": None, "owner_epoch": 3}
hostile = "\x1b]0;pwned\x07\x1b[2Jdeploy\rhidden\x08\u202e\x9b31m now " + "x" * 200
rows = [