The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): /queue list never erases a queued turn the CLI has not painted
Teknium2437fb0842b1
diff --git a/hermes_cli/gateway_queue.py b/hermes_cli/gateway_queue.pyindex 23b67fb81c8..30b916511ec 100644--- a/hermes_cli/gateway_queue.py+++ b/hermes_cli/gateway_queue.py@@ -39,8 +39,8 @@ def submit_queued(cli, store, text: str) -> str:def queued_rows(cli, store) -> list[tuple[str, str]]:"""``[(admission_id, text)]`` still queued in the owner's FIFO, in run order.- This viewer's own admissions are read back with ``prompt.receipt`` (one it finds started or gone- is forgotten); other viewers' queued rows come from the last pending list the owner published.+ This viewer's own admissions are read back with ``prompt.receipt`` (one it finds started or settled+ is left for the idle tick to paint); other viewers' queued rows come from the last pending list the owner published."""state = _state(cli, store)rows: dict[str, tuple[int, str]] = {}@@ -57,9 +57,10 @@ def queued_rows(cli, store) -> list[tuple[str, str]]:if receipt.get("status") == "queued":rows[admission] = (int(receipt.get("sequence") or 0), text)else:+ # Started or settled: no longer queued, but its turn may not be painted yet. The idle tick+ # paints it (``gateway_tools_notify.recover_queued``); listing never erases that.rows.pop(admission, None)- if receipt.get("status") != "started": # a started one is adopted by the idle tick- state.queued_inputs.pop(admission, None)+ state.missed.add(admission)return [(admission, text) for admission, (_, text) in sorted(rows.items(), key=lambda kv: kv[1][0])]diff --git a/tests/hermes_cli/test_cli_queue_gateway_fifo.py b/tests/hermes_cli/test_cli_queue_gateway_fifo.pyindex e8bd3265acf..6f4ee25be50 100644--- a/tests/hermes_cli/test_cli_queue_gateway_fifo.py+++ b/tests/hermes_cli/test_cli_queue_gateway_fifo.py@@ -295,3 +295,28 @@ def test_a_queued_admission_another_client_cancelled_is_forgotten_not_painted():assert cli._pending_input.empty() and state.queued_inputs == {}finally:conn.close()+++def test_queue_list_never_erases_a_finished_queued_turn_this_viewer_has_not_painted():+ """Greptile P1 (gateway_queue.py:62): a fast queued turn settles while this CLI is still busy.+ ``/queue list`` reads its receipt as terminal; that must not drop the tracking the idle tick needs+ to paint the turn whose frames are still buffered."""+ from hermes_cli import gateway_queue+ from tests.hermes_cli.test_gateway_agent import SID, frame+ from tests.hermes_cli.test_gateway_tools_notify import _connected, _idle_cli, _play+ conn, client = _connected()+ try:+ cli = _idle_cli(conn)+ conn.state(SID).queued_inputs["adm-q"] = TEXT+ _play(conn, client, [frame("message.start", {}, admission="adm-q"),+ frame("message.delta", {"text": "fast"}, admission="adm-q"),+ frame("message.complete", {"text": "fast", "status": "complete"}, admission="adm-q")])+ assert gateway_queue.queued_rows(cli, cli._session_db) == [] # receipt: terminal, not queued+ cli._drain_process_notifications("cli-idle")+ result = _run_adopted(cli, conn)+ assert "prompt.submit" not in [m for m, _ in client.calls]+ assert result["final_response"] == "fast"+ assert conn.state(SID).queued_inputs == {}+ finally:+ conn.close()+