Skip to content

The agent that grows with you

feat(cli): live dock shows the standing /goal and queued prompts

teknium143455f567023
diff --git a/hermes_cli/cli_info_mixin.py b/hermes_cli/cli_info_mixin.py
index 37d313669b2..774604c7639 100644
--- a/hermes_cli/cli_info_mixin.py
+++ b/hermes_cli/cli_info_mixin.py
@@ -455,8 +455,10 @@ class CLIInfoMixin:
return False
def _should_handle_steer_command_inline(self, text: str, has_images: bool = False) -> bool:
- """Return True when /steer should be dispatched immediately while the agent is running."""
- return self._busy_inline_command(text, has_images, ("steer",))
+ """Return True when /steer or /queue should be dispatched immediately while the agent is
+ running. Queued raw, ``/queue <prompt>`` only re-enqueued itself after the turn and
+ ``/queue list|rm|edit`` could not inspect the queue until it had already drained."""
+ return self._busy_inline_command(text, has_images, ("steer", "queue"))
def _should_handle_background_command_inline(
self, text: str, has_images: bool = False) -> bool:
diff --git a/hermes_cli/cli_session_dock.py b/hermes_cli/cli_session_dock.py
new file mode 100644
index 00000000000..da30559f8c5
--- /dev/null
+++ b/hermes_cli/cli_session_dock.py
@@ -0,0 +1,40 @@
+"""Goal + queued-prompt rows for the classic CLI live-work dock.
+
+Sibling of ``cli_process_dock``: the dock paints an active ``/goal`` and the prompts waiting in
+``/queue`` under the subagent and process blocks, so both are visible while the agent works
+instead of only through ``/goal status`` and ``/queue list``.
+"""
+from __future__ import annotations
+
+# Queued prompts drain one per turn; past this many the dock shows a ``+N more`` line.
+QUEUE_ROWS = 3
+
+
+def goal_line(cli) -> str:
+ """``GoalManager.status_line()`` for an active or paused goal, else ``''``.
+
+ Reads only the manager the CLI already holds for its current session: the dock refreshes on
+ the spinner thread every second and must never be the thing that opens state.db.
+ """
+ mgr = getattr(cli, "_goal_manager", None)
+ if mgr is None or mgr.session_id != getattr(cli, "session_id", None) or not mgr.has_goal():
+ return ""
+ return mgr.status_line()
+
+
+def _prompt_text(item) -> str:
+ if isinstance(item, tuple): # (text, images) from an image-attached submit
+ item = item[0]
+ # TimelineNotification carries a compact title; voice/seeded sentinels wrap their text.
+ text = getattr(item, "display_text", None) or getattr(item, "text", None) or str(item)
+ return " ".join(str(text).split())
+
+
+def queued_prompts(cli) -> list[str]:
+ """One-line previews of the turns waiting in ``_pending_input``, oldest first."""
+ pending = getattr(cli, "_pending_input", None)
+ if pending is None:
+ return []
+ with pending.mutex:
+ items = list(pending.queue)
+ return [text for text in map(_prompt_text, items) if text]
diff --git a/hermes_cli/cli_subagent_monitor.py b/hermes_cli/cli_subagent_monitor.py
index 1aef81e56e5..d41f92d5798 100644
--- a/hermes_cli/cli_subagent_monitor.py
+++ b/hermes_cli/cli_subagent_monitor.py
@@ -1,5 +1,6 @@
-"""Classic CLI live-work dock (subagents + background processes) and scoped controls; no
-agent-loop state is changed. Process rows come from ``cli_process_dock``."""
+"""Classic CLI live-work dock (subagents, background processes, active goal, queued prompts) and
+scoped controls; no agent-loop state is changed. Process rows come from ``cli_process_dock``,
+goal/queue rows from ``cli_session_dock``."""
from __future__ import annotations
import json
@@ -8,6 +9,7 @@ import time
from prompt_toolkit.utils import get_cwidth
from hermes_cli import cli_process_dock as procs
+from hermes_cli import cli_session_dock as session_rows
def _clip(value, width):
@@ -28,6 +30,8 @@ class SubagentMonitor:
self.cli = cli
self.entries = []
self.processes = []
+ self.goal = ''
+ self.queued = []
self.selected_id = None
self._signature = None
self._last_poll = 0
@@ -35,6 +39,10 @@ class SubagentMonitor:
self.opening = False
self.collapsed = False
+ @property
+ def has_rows(self):
+ return bool(self.entries or self.processes or self.goal or self.queued)
+
@property
def roster(self):
"""Agents first, then processes — the order the dock and the full-height monitor paint."""
@@ -68,11 +76,15 @@ class SubagentMonitor:
row['key'] = row['subagent_id']
row.pop('running_seconds', None)
processes = procs.process_rows(now)
- signature = json.dumps([entries, processes], sort_keys=True, default=str)
+ goal = session_rows.goal_line(self.cli)
+ queued = session_rows.queued_prompts(self.cli)
+ signature = json.dumps([entries, processes, goal, queued], sort_keys=True, default=str)
changed = signature != self._signature
self._signature = signature
self.entries = entries
self.processes = processes
+ self.goal = goal
+ self.queued = queued
if self.selected is None:
roster = self.roster
self.selected_id = self._key(roster[0]) if roster else None
@@ -113,14 +125,20 @@ class SubagentMonitor:
from tools.delegate_tool_registry import _handle_control_action
return json.loads(_handle_control_action(action, target, message, getattr(self.cli, 'agent', None)))
- def _counts(self):
- """Collapsed-heading count fragment: ``2 live``, ``1 proc``, or ``2 live · 3 procs``."""
+ def _counts(self, *, session=True):
+ """Count fragment: ``2 live``, ``1 proc``, ``2 live · 3 procs``; the collapsed heading
+ (``session=True``) adds ``goal active|paused|parked`` and ``N queued``."""
parts = []
if self.entries:
parts.append(f'{len(self.entries)} live')
if self.processes:
running = sum(r['status'] == 'running' for r in self.processes)
parts.append(f"{running} proc{'s' if running != 1 else ''}" if running else f'{len(self.processes)} done')
+ if session and self.goal:
+ parts.append('goal ' + ('parked' if self.goal.startswith('⏳') else
+ 'paused' if self.goal.startswith('⏸') else 'active'))
+ if session and self.queued:
+ parts.append(f'{len(self.queued)} queued')
return ' · '.join(parts)
def _title(self):
@@ -132,32 +150,40 @@ class SubagentMonitor:
if self.entries:
row = self.entries[0]
return f"last: {row['last_tool']}" if row.get('last_tool') else row.get('status') or 'starting'
- return procs.process_activity(self.processes[0])
+ if self.processes:
+ return procs.process_activity(self.processes[0])
+ return self.goal or f'next: {self.queued[0]}'
def dock_text(self, *, columns, rows):
- if not self.entries and not self.processes:
+ if not self.has_rows:
return ''
if self.collapsed:
count = self._counts()
- # Keep both controls before spending scarce cells on activity.
- headings = (
- f'{self._title()} · {count} · Ctrl+T expand · F7 restore',
- f'{count} · Ctrl+T expand · F7 restore',
- f'{count} · Ctrl+T · F7',
- count,
- )
+ # Keep both controls before spending scarce cells on activity. Ctrl+T opens the
+ # subagent/process monitor, so a goal/queue-only dock offers just F7.
+ if self.entries or self.processes:
+ headings = (
+ f'{self._title()} · {count} · Ctrl+T expand · F7 restore',
+ f'{count} · Ctrl+T expand · F7 restore',
+ f'{count} · Ctrl+T · F7',
+ count,
+ )
+ else:
+ headings = (f'{count} · F7 restore', f'{count} · F7', count)
width = max(0, columns - 1)
heading = next((text for text in headings if get_cwidth(text) <= width), count)
activity = self._collapsed_activity()
- if get_cwidth(heading + ' · ' + activity) <= width:
- heading += ' · ' + activity
+ # A goal/queue preview is long prose: clip it into the room left instead of dropping it.
+ room = width - get_cwidth(heading + ' · ')
+ if get_cwidth(activity) <= room or (room >= 12 and not (self.entries or self.processes)):
+ heading += ' · ' + _clip(activity, room)
return _clip(' ' + heading, max(0, columns))
columns = max(0, columns - 2)
+ lines = [_clip(f' {self.goal}', columns)] if self.goal else []
budget = max(1, min(4, (rows - 10) // 3))
# Both blocks present: split the row budget so neither hides the other entirely.
agent_budget = budget if not self.processes else max(1, budget - max(1, budget // 2))
agent_count = min(len(self.entries), agent_budget)
- lines = []
if self.entries:
hidden = len(self.entries) - agent_count
lines.append(_clip(f' Subagents · {len(self.entries)} live · Ctrl+T expand · F7 collapse', columns))
@@ -181,6 +207,15 @@ class SubagentMonitor:
lines.append(_clip(f" {procs.process_glyph(row)} {_clip(row['command'], command_width)} · {activity}", columns))
if len(self.processes) > proc_count:
lines.append(_clip(f' +{len(self.processes) - proc_count} more · Ctrl+T all processes', columns))
+ if self.queued:
+ # Last, so the next prompt to run sits right above the input it came from.
+ shown = min(len(self.queued), session_rows.QUEUE_ROWS if rows >= 24 else 1)
+ controls = '' if self.entries or self.processes else ' · F7 collapse'
+ lines.append(_clip(f' Queue · {len(self.queued)} queued · /queue list{controls}', columns))
+ for index, text in enumerate(self.queued[:shown], 1):
+ lines.append(_clip(f' {index}. {text}', columns))
+ if len(self.queued) > shown:
+ lines.append(_clip(f' +{len(self.queued) - shown} more', columns))
return '\n'.join(' ' + line for line in lines)
@@ -258,7 +293,7 @@ def build_monitor_application(monitor, **kwargs):
def header():
row = monitor.selected
- title = f"{monitor._title()} · {monitor._counts()}"
+ title = f"{monitor._title()} · {monitor._counts(session=False)}"
if state['detail'] and row:
title += f" · {monitor._key(row)} · {row.get('goal') or row.get('command') or ''}"
return [('class:subagent-dock.heading', _clip(title, app.output.get_size().columns))]
@@ -416,5 +451,5 @@ def install_dock(cli):
cli._subagent_dock_widget = ConditionalContainer(
Window(FormattedTextControl(text), wrap_lines=False, dont_extend_height=True,
style='class:subagent-dock'),
- filter=Condition(lambda: bool(monitor.entries or monitor.processes) and not modal_prompt_active(cli)),
+ filter=Condition(lambda: monitor.has_rows and not modal_prompt_active(cli)),
)
diff --git a/tests/hermes_cli/test_cli_steer_busy_path.py b/tests/hermes_cli/test_cli_steer_busy_path.py
index 96e8ba6cd6f..64eba34a4b8 100644
--- a/tests/hermes_cli/test_cli_steer_busy_path.py
+++ b/tests/hermes_cli/test_cli_steer_busy_path.py
@@ -75,7 +75,9 @@ class TestSteerInlineDetector:
cli = _make_cli()
cli._agent_running = True
assert cli._should_handle_steer_command_inline("/steer focus on error handling") is True
-
+ # /queue edits the next-turn queue mid-run instead of being queued as a raw command itself.
+ assert cli._should_handle_steer_command_inline("/queue list") is True
+ assert cli._should_handle_steer_command_inline("/q follow up later") is True
diff --git a/tests/hermes_cli/test_session_dock.py b/tests/hermes_cli/test_session_dock.py
new file mode 100644
index 00000000000..8429748351e
--- /dev/null
+++ b/tests/hermes_cli/test_session_dock.py
@@ -0,0 +1,72 @@
+"""Active /goal and queued /queue prompts share the classic CLI live-work dock."""
+import queue
+from types import SimpleNamespace
+
+import pytest
+from prompt_toolkit.utils import get_cwidth
+
+
+def hermes_home(tmp_path, monkeypatch):
+ from pathlib import Path
+
+ from hermes_cli import goals
+
+ home = tmp_path / ".hermes"
+ home.mkdir()
+ monkeypatch.setattr(Path, "home", lambda: tmp_path)
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ goals._DB_CACHE.clear()
+ yield home
+ goals._DB_CACHE.clear()
+
+
+def test_dock_paints_goal_on_top_and_queue_last_and_follows_their_lifecycle(hermes_home):
+ from cli import _VoiceInputMessage
+ from hermes_cli.cli_subagent_monitor import SubagentMonitor
+ from hermes_cli.goals import GoalManager
+ from tools.process_registry_notifications import TimelineNotification
+
+ mgr = GoalManager(session_id="sid-a", default_max_turns=20)
+ mgr.set("ship the dock feature")
+ pending = queue.Queue()
+ for item in ("first follow-up\nwith a newline", ("look at this", ["shot.png"]),
+ _VoiceInputMessage("spoken ask"),
+ TimelineNotification("raw wall", "Process abc exited 0", "notice")):
+ pending.put(item)
+ cli = SimpleNamespace(agent=None, session_id="sid-a", _goal_manager=mgr, _pending_input=pending)
+ dock = SubagentMonitor(cli)
+
+ assert dock.refresh() and dock.has_rows
+ lines = dock.dock_text(columns=80, rows=40).splitlines()
+ assert "⊙ Goal (active, 0/20 turns): ship the dock feature" in lines[0]
+ queue_at = next(i for i, line in enumerate(lines) if "Queue · 4 queued" in line)
+ assert [line.strip() for line in lines[queue_at + 1:]] == [
+ "1. first follow-up with a newline", "2. look at this", "3. spoken ask", "+1 more"]
+ assert all(get_cwidth(line) <= 80 for line in lines)
+ dock.collapsed = True
+ collapsed = dock.dock_text(columns=80, rows=40)
+ assert "\n" not in collapsed and "goal active · 4 queued · F7 restore · ⊙ Goal" in collapsed
+ assert "Ctrl+T" not in collapsed # the monitor only lists subagents/processes
+ assert get_cwidth(collapsed) <= 80
+
+ # A paused goal stays visible; draining the queue and clearing the goal empties the dock.
+ dock.collapsed = False
+ mgr.pause("user-paused")
+ pending.queue.clear()
+ assert dock.refresh() and dock.dock_text(columns=80, rows=40).startswith(" ⏸ Goal (paused")
+ mgr.clear()
+ assert dock.refresh() and not dock.has_rows and dock.dock_text(columns=80, rows=40) == ""
+
+
+def test_dock_ignores_a_goal_manager_left_over_from_another_session(hermes_home):
+ """After /new the cached manager still names the old session until it is rebuilt; the dock
+ must not paint the previous session's goal (and never opens state.db itself)."""
+ from hermes_cli.cli_session_dock import goal_line
+ from hermes_cli.goals import GoalManager
+
+ mgr = GoalManager(session_id="old-sid")
+ mgr.set("previous session objective")
+ assert goal_line(SimpleNamespace(session_id="old-sid", _goal_manager=mgr)).startswith("⊙ Goal")
+ assert goal_line(SimpleNamespace(session_id="new-sid", _goal_manager=mgr)) == ""
+ assert goal_line(SimpleNamespace(session_id="new-sid")) == ""
diff --git a/website/docs/user-guide/cli.md b/website/docs/user-guide/cli.md
index af55963e9ca..cec56deba3a 100644
--- a/website/docs/user-guide/cli.md
+++ b/website/docs/user-guide/cli.md
@@ -201,7 +201,7 @@ When resuming a previous session (`hermes -c` or `hermes --resume <id>`), a "Pre
| `Ctrl+S` | **Stash the prompt.** Parks the current draft and clears the composer so you can send something else first. Press `Ctrl+S` again on an empty composer to bring the draft back (cursor at the end, attached images restored). Repeated presses build a stack rather than overwriting, so an earlier draft is never silently lost — with two or more stashed, `Ctrl+S` opens a browse panel (`↑`/`↓` to navigate, `Enter` to restore, `D` to discard, `Esc` or `Ctrl+S` to close). A `📌 N` badge in the status bar shows how many drafts are parked. Multi-line drafts round-trip exactly, including blank lines. The stash lives in memory for the session only — nothing is written to disk, since drafts often contain secrets. |
| `Ctrl+C` | Interrupt agent (double-press within 2s to force exit) |
| `Ctrl+T` / `F6` | Open the full-screen live work monitor (subagents and background processes) without losing the composer draft. The live dock appears automatically above the status bar; arrows select a worker or process, `Enter` shows its recent log, `s` steers a worker, and `x` requests stop with confirmation. See [Monitoring subagents](./features/delegation.md#monitoring-running-subagents-agents). |
-| `F7` | Toggle the live work dock (subagents + background processes) between its multi-row preview and a single summary line without moving composer focus. |
+| `F7` | Toggle the live work dock between its multi-row preview and a single summary line without moving composer focus. Besides subagents and background processes, the dock shows a standing `/goal` (active, parked or paused, with turns used) on its top row and the prompts waiting in `/queue` on its bottom rows. |
| `Ctrl+D` | Exit |
| `Ctrl+Z` | Suspend Hermes to background (Unix only). Run `fg` in the shell to resume. |
| `Tab` | Accept auto-suggestion (ghost text) or autocomplete slash commands |
@@ -413,6 +413,8 @@ display:
`"steer"` has two automatic fallbacks: if the agent hasn't started yet, or if images are attached, the message falls back to `"queue"` behavior so nothing is lost.
+Whatever the mode, `/queue <prompt>` queues a follow-up turn explicitly, and `/queue list`, `/queue rm N`, `/queue edit N …` and `/queue move A B` act on the pending queue immediately, even mid-run. The live work dock lists what is waiting.
+
You can also change it inside the CLI:
```text