fix(cli): open subagent monitor with the TUI Ctrl+T shortcut
This commit is contained in:
@@ -83,9 +83,9 @@ class SubagentMonitor:
|
||||
count = f'{len(self.entries)} live'
|
||||
# Keep both controls before spending scarce cells on activity.
|
||||
headings = (
|
||||
f'Subagents · {count} · F6 expand · F7 restore',
|
||||
f'{count} · F6 expand · F7 restore',
|
||||
f'{count} · F6 · F7',
|
||||
f'Subagents · {count} · Ctrl+T expand · F7 restore',
|
||||
f'{count} · Ctrl+T expand · F7 restore',
|
||||
f'{count} · Ctrl+T · F7',
|
||||
count,
|
||||
)
|
||||
width = max(0, columns - 1)
|
||||
@@ -98,7 +98,7 @@ class SubagentMonitor:
|
||||
columns = max(0, columns - 2)
|
||||
count = min(len(self.entries), max(1, min(4, (rows - 10) // 3)))
|
||||
hidden = len(self.entries) - count
|
||||
heading = f' Subagents · {len(self.entries)} live · F6 expand · F7 collapse'
|
||||
heading = f' Subagents · {len(self.entries)} live · Ctrl+T expand · F7 collapse'
|
||||
lines = [_clip(heading, columns)]
|
||||
for row in self.entries[:count]:
|
||||
activity = f"{row['elapsed']}s · " + (f"last: {row['last_tool']}" if row['last_tool'] else row.get('status') or 'starting')
|
||||
@@ -106,7 +106,7 @@ class SubagentMonitor:
|
||||
goal_width = max(3, columns - get_cwidth(activity) - 5)
|
||||
lines.append(_clip(f" ● {_clip(row.get('goal'), goal_width)} · {activity}", columns))
|
||||
if hidden:
|
||||
lines.append(_clip(f' +{hidden} more · F6 all subagents', columns))
|
||||
lines.append(_clip(f' +{hidden} more · Ctrl+T all subagents', columns))
|
||||
return '\n'.join(' ' + line for line in lines)
|
||||
|
||||
|
||||
@@ -186,9 +186,9 @@ def build_monitor_application(monitor, **kwargs):
|
||||
if state['steering']:
|
||||
return 'Enter send · Esc cancel' if narrow else 'Enter queues guidance · Esc cancels (does not interrupt)'
|
||||
if narrow:
|
||||
return 'PgUp/Dn · s steer x stop · Esc' if state['detail'] else '↑↓ select Enter tail F6 close'
|
||||
return 'PgUp/Dn · s steer x stop · Esc' if state['detail'] else '↑↓ · Enter tail · Ctrl+T close'
|
||||
return ('Esc roster · PgUp/PgDn tail · s steer · x stop' if state['detail'] else
|
||||
'↑/↓ select · Enter tail · s steer · x stop · q/F6 close')
|
||||
'↑/↓ select · Enter tail · s steer · x stop · q/Ctrl+T close')
|
||||
|
||||
kb = KeyBindings()
|
||||
normal = Condition(lambda: not state['steering'] and not state['confirm'])
|
||||
@@ -251,6 +251,7 @@ def build_monitor_application(monitor, **kwargs):
|
||||
|
||||
@kb.add('q', filter=normal)
|
||||
@kb.add('f6', filter=normal)
|
||||
@kb.add('c-t', filter=normal)
|
||||
@kb.add('c-c')
|
||||
def close(event):
|
||||
app.exit()
|
||||
|
||||
@@ -1859,8 +1859,9 @@ class CLITuiMixin:
|
||||
kb.add('c-v')(self._tui_handle_ctrl_v)
|
||||
kb.add('escape', 'v')(self._tui_handle_alt_v)
|
||||
from hermes_cli.cli_subagent_monitor import modal_prompt_active, open_monitor, toggle_dock
|
||||
kb.add('f6', filter=Condition(lambda: not modal_prompt_active(self)))(
|
||||
lambda event: open_monitor(self))
|
||||
for key in ('c-t', 'f6'):
|
||||
kb.add(key, filter=Condition(lambda: not modal_prompt_active(self)))(
|
||||
lambda event: open_monitor(self))
|
||||
kb.add('f7', filter=Condition(lambda: not modal_prompt_active(self)))(
|
||||
lambda event: toggle_dock(self))
|
||||
return kb
|
||||
|
||||
@@ -85,8 +85,8 @@ def test_collapsed_summary_prioritizes_live_count_and_controls_at_small_widths()
|
||||
assert len(text.splitlines()) == 1
|
||||
assert get_cwidth(text) <= width
|
||||
if width >= 24:
|
||||
assert '6 live' in text and 'F6' in text and 'F7' in text
|
||||
assert '6 live' in text and 'Ctrl+T' in text and 'F7' in text
|
||||
if width >= 80:
|
||||
assert 'last: terminal' in text and 'F6 expand' in text and 'F7 restore' in text
|
||||
assert 'last: terminal' in text and 'Ctrl+T expand' in text and 'F7 restore' in text
|
||||
monitor.entries.clear()
|
||||
assert monitor.dock_text(columns=80, rows=20) == ''
|
||||
|
||||
@@ -15,7 +15,7 @@ def test_dock_scopes_children_and_fits_short_narrow_terminal(monkeypatch):
|
||||
assert dock.refresh(now=20)
|
||||
text = dock.dock_text(columns=32, rows=14)
|
||||
from prompt_toolkit.utils import get_cwidth
|
||||
assert '8 live' in text and 'F6' in text and 'read_file' in text
|
||||
assert '8 live' in text and 'Ctrl+T' in text and 'read_file' in text
|
||||
assert 'SECRET' not in text
|
||||
assert len(text.splitlines()) <= 3
|
||||
assert all(get_cwidth(line) <= 32 for line in text.splitlines())
|
||||
|
||||
@@ -27,7 +27,7 @@ def test_monitor_keys_pin_controls_across_roster_changes(monkeypatch):
|
||||
output.get_size = lambda: Size(rows=14, columns=32)
|
||||
app = build_monitor_application(dock, input=pipe, output=output)
|
||||
footer = app.layout.container.children[-1].content.text()
|
||||
assert 'F6' in footer and len(footer) <= 32
|
||||
assert 'Ctrl+T' in footer and len(footer) <= 32
|
||||
rendered = asyncio.Event()
|
||||
app.after_render += lambda app: rendered.set()
|
||||
task = asyncio.create_task(app.run_async())
|
||||
@@ -44,7 +44,7 @@ def test_monitor_keys_pin_controls_across_roster_changes(monkeypatch):
|
||||
dock.refresh()
|
||||
await send('y')
|
||||
await send('\x1b')
|
||||
pipe.send_text('q')
|
||||
pipe.send_text('\x14')
|
||||
await asyncio.wait_for(task, 3)
|
||||
asyncio.run(run())
|
||||
assert dock.selected_id == 'first'
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
"""The shared TUI shortcut routes without editing the classic composer."""
|
||||
import asyncio
|
||||
|
||||
|
||||
def test_monitor_shortcuts_preserve_draft_and_respect_modal_prompts(monkeypatch):
|
||||
from cli import HermesCLI
|
||||
from hermes_cli import cli_subagent_monitor as monitor
|
||||
from prompt_toolkit.application import Application
|
||||
from prompt_toolkit.document import Document
|
||||
from prompt_toolkit.input import create_pipe_input
|
||||
from prompt_toolkit.layout import Layout
|
||||
from prompt_toolkit.output import DummyOutput
|
||||
|
||||
monkeypatch.setenv('HERMES_DEFER_AGENT_STARTUP', '1')
|
||||
cli = HermesCLI(model='fixture', provider='openai-compat', api_key='fixture',
|
||||
base_url='http://127.0.0.1:1/v1')
|
||||
cli._tui_init_run_state()
|
||||
editor = cli._tui_build_input_area()
|
||||
cli._input_area = editor
|
||||
opened = []
|
||||
monkeypatch.setattr(monitor, 'open_monitor', lambda target: opened.append(target))
|
||||
|
||||
async def run():
|
||||
with create_pipe_input() as pipe:
|
||||
app = Application(layout=Layout(editor), key_bindings=cli._tui_build_key_bindings(),
|
||||
input=pipe, output=DummyOutput())
|
||||
painted = asyncio.Event()
|
||||
app.after_render += lambda _: painted.set()
|
||||
task = asyncio.create_task(app.run_async())
|
||||
await asyncio.wait_for(painted.wait(), 3)
|
||||
try:
|
||||
for key in ('\x14', '\x1b[17~'):
|
||||
editor.buffer.document = Document('keep my draft', 5)
|
||||
painted.clear()
|
||||
pipe.send_text(key)
|
||||
await asyncio.wait_for(painted.wait(), 3)
|
||||
assert opened.pop() is cli
|
||||
assert (editor.text, editor.buffer.cursor_position) == ('keep my draft', 5)
|
||||
cli._approval_state = {'options': []}
|
||||
bindings = app.key_bindings
|
||||
for key in ('c-t', 'f6'):
|
||||
assert not any(b.filter() for b in bindings.get_bindings_for_keys((key,)))
|
||||
finally:
|
||||
cli._approval_state = None
|
||||
app.exit()
|
||||
await task
|
||||
asyncio.run(run())
|
||||
@@ -186,7 +186,7 @@ When resuming a previous session (`hermes -c` or `hermes --resume <id>`), a "Pre
|
||||
| `Ctrl+X Ctrl+E` | Emacs-style alternate binding for the external editor (same behavior as `Ctrl+G`). |
|
||||
| `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) |
|
||||
| `F6` | Open the full-screen live subagent monitor without losing the composer draft. The live dock appears automatically above the status bar; arrows select a worker, `Enter` shows its recent log, `s` steers, and `x` requests stop with confirmation. See [Monitoring subagents](/user-guide/features/delegation#monitoring-running-subagents-agents). |
|
||||
| `Ctrl+T` / `F6` | Open the full-screen live subagent monitor without losing the composer draft. The live dock appears automatically above the status bar; arrows select a worker, `Enter` shows its recent log, `s` steers, and `x` requests stop with confirmation. See [Monitoring subagents](/user-guide/features/delegation#monitoring-running-subagents-agents). |
|
||||
| `F7` | Toggle the live subagent dock between its multi-row preview and a single summary line without moving composer focus. |
|
||||
| `Ctrl+D` | Exit |
|
||||
| `Ctrl+Z` | Suspend Hermes to background (Unix only). Run `fg` in the shell to resume. |
|
||||
|
||||
@@ -285,7 +285,7 @@ What happens:
|
||||
|
||||
The canonical flow: your main agent opens a PR, you type `/review`, and a second pair of eyes investigates it while you keep working; the review lands back in the chat addressed to the agent that created the PR.
|
||||
|
||||
Dispatch prints only “Review started. Results will return here.” The live subagent viewer identifies the worker as **Review: your focus** (or **Review recent work** for bare `/review`), with a shortened single-line label; the reviewer still receives your full instructions. In the classic CLI, the dock above the composer shows elapsed time and latest activity; **F6** opens the roster with its model, transcript, steering, and stop controls. The same review label appears in the TUI and Desktop subagent viewers.
|
||||
Dispatch prints only “Review started. Results will return here.” The live subagent viewer identifies the worker as **Review: your focus** (or **Review recent work** for bare `/review`), with a shortened single-line label; the reviewer still receives your full instructions. In the classic CLI, the dock above the composer shows elapsed time and latest activity; **Ctrl+T** (or **F6**) opens the roster with its model, transcript, steering, and stop controls. The same review label appears in the TUI and Desktop subagent viewers.
|
||||
|
||||
### Review model
|
||||
|
||||
@@ -416,7 +416,7 @@ The classic CLI, TUI, and Desktop automatically show live subagents above the co
|
||||
|
||||
| Surface | Expand and inspect | Control a selected worker |
|
||||
|---|---|---|
|
||||
| Classic CLI | **F6** opens the full-screen live roster; arrows select, **Enter** opens the transcript tail, **PgUp/PgDn** scroll | **s** opens a separate steering input; **x**, then **y** requests stop |
|
||||
| Classic CLI | **Ctrl+T** (or **F6**) opens the full-screen live roster; arrows select, **Enter** opens the transcript tail, **PgUp/PgDn** scroll | **s** opens a separate steering input; **x**, then **y** requests stop |
|
||||
| TUI | **Ctrl+T** or `/agents` opens the full-height tree; **Enter/t** opens the live transcript tail; **d** opens rich detail (archived/replay Enter still opens detail) | **e** opens steering; **x** stops the selected worker; **X** stops its subtree |
|
||||
| Desktop | Expand **Subagents** above the composer, then select a worker to inspect its activity and details | **Steer** queues guidance; **Stop** requests interruption for that worker |
|
||||
|
||||
@@ -426,7 +426,7 @@ Press **F7** in the Classic CLI or TUI composer to toggle the dock between its m
|
||||
|
||||
The live transcript tail is a bounded recent excerpt, not an unlimited conversation browser. A child leaving the live registry leaves the dock; completion messages and the TUI/Desktop history views remain the place to review finished work. Latest activity is an observation, not a percentage-complete estimate.
|
||||
|
||||
The classic CLI's `/agents` and `/tasks` commands still print a text summary; **F6** is the immediate interactive monitor, including while the parent is busy. See [TUI — Slash commands](/user-guide/tui#slash-commands).
|
||||
The classic CLI's `/agents` and `/tasks` commands still print a text summary; **Ctrl+T** (or **F6**) is the immediate interactive monitor, including while the parent is busy. See [TUI — Slash commands](/user-guide/tui#slash-commands).
|
||||
|
||||
On the classic CLI and every gateway platform (Telegram, Discord, Slack, ...),
|
||||
`/agents` also lists **background delegations with live per-child activity**,
|
||||
|
||||
Reference in New Issue
Block a user