From f7fe32bfde392e8a43b916f84836c55d2e27988e Mon Sep 17 00:00:00 2001
From: Teknium <127238744+teknium1@users.noreply.github.com>
Date: Tue, 8 Sep 2026 03:21:09 -0700
Subject: [PATCH] feat: add compact Ink agent dock and Enter live tail
---
ui-tui/src/__tests__/agentsCompact.test.tsx | 70 +++++++++++++++++++++
ui-tui/src/app/agentRoster.ts | 3 +
ui-tui/src/app/useInputHandlers.ts | 9 ++-
ui-tui/src/components/agentsOverlay.tsx | 20 +++---
ui-tui/src/components/agentsPanel.tsx | 22 ++++---
ui-tui/src/components/textInput.tsx | 2 +-
ui-tui/src/content/hotkeys.ts | 1 +
ui-tui/src/types/hermes-ink.d.ts | 2 +-
8 files changed, 104 insertions(+), 25 deletions(-)
create mode 100644 ui-tui/src/__tests__/agentsCompact.test.tsx
diff --git a/ui-tui/src/__tests__/agentsCompact.test.tsx b/ui-tui/src/__tests__/agentsCompact.test.tsx
new file mode 100644
index 0000000000..f4cb1350fe
--- /dev/null
+++ b/ui-tui/src/__tests__/agentsCompact.test.tsx
@@ -0,0 +1,70 @@
+import { PassThrough } from 'node:stream'
+
+import { Box, renderSync } from '@hermes/ink'
+import React from 'react'
+import stripAnsi from 'strip-ansi'
+import { expect, it, vi } from 'vitest'
+
+import { renderToScreen } from '../../packages/hermes-ink/src/ink/render-to-screen.js'
+import { cellAtIndex } from '../../packages/hermes-ink/src/ink/screen.js'
+import { applyAgentSnapshot } from '../app/agentRoster.js'
+import { patchUiState, resetUiState } from '../app/uiStore.js'
+import { AgentsOverlay } from '../components/agentsOverlay.js'
+import { AgentsPanelView } from '../components/agentsPanel.js'
+import type { GatewayClient } from '../gatewayClient.js'
+import { buildAgentRows } from '../lib/agentRows.js'
+import { DEFAULT_THEME } from '../theme.js'
+
+it('keeps collapsed live chrome to one row without losing count or restore controls', () => {
+ const rows = buildAgentRows([], [{ delegation_id: 'work', status: 'running', goal: 'Review the boundary' }], 1000)
+
+ for (const cols of [78, 98]) {
+ const view = renderToScreen(, cols)
+ expect(view.height).toBe(1)
+ const text = Array.from({ length: cols }, (_, i) => cellAtIndex(view.screen, i).char).join('')
+ expect(text).toContain(`${rows.running} live agents`)
+ expect(text).toContain('Ctrl+T expand')
+ expect(text).toContain('F7 restore')
+ expect(renderToScreen(, cols).height).toBeGreaterThan(view.height)
+ }
+})
+
+it('opens the selected live transcript on Enter while details remain independently accessible', async () => {
+ patchUiState({ sid: 'owner' })
+ applyAgentSnapshot('owner', { subagents: [{ subagent_id: 'child', goal: 'Inspect ownership', status: 'running' }], delegations: [] })
+
+ const request = vi.fn(async (method: string) => method === 'subagent.tail'
+ ? { available: true, text: 'CHILD_TOOL_OUTPUT', truncated: false }
+ : {})
+
+ const stdout = Object.assign(new PassThrough(), { columns: 80, rows: 20, isTTY: false })
+ const stdin = Object.assign(new PassThrough(), { isTTY: true, setRawMode: () => {}, ref: () => {}, unref: () => {} })
+ let output = ''
+ stdout.on('data', chunk => { output += stripAnsi(chunk.toString()) })
+
+ const view = renderSync( {}} t={DEFAULT_THEME} />, {
+ stdout: stdout as unknown as NodeJS.WriteStream,
+ stdin: stdin as unknown as NodeJS.ReadStream,
+ stderr: new PassThrough() as unknown as NodeJS.WriteStream,
+ patchConsole: false
+ })
+
+ try {
+ await vi.waitFor(() => expect(output).toContain('Inspect ownership'))
+ stdin.write('\r')
+ await vi.waitFor(() => expect(request).toHaveBeenCalledWith('subagent.tail', { session_id: 'owner', subagent_id: 'child' }))
+ await vi.waitFor(() => expect(output).toContain('CHILD_TOOL_OUTPUT'))
+ output = ''
+ stdin.write('d')
+ await vi.waitFor(() => expect(output).toContain('Inspect ownership'))
+ expect(output).not.toContain('CHILD_TOOL_OUTPUT')
+ output = ''
+ stdin.write('t')
+ await vi.waitFor(() => expect(output).toContain('CHILD_TOOL_OUTPUT'))
+ } finally {
+ view.unmount()
+ view.cleanup()
+ applyAgentSnapshot(null)
+ resetUiState()
+ }
+})
diff --git a/ui-tui/src/app/agentRoster.ts b/ui-tui/src/app/agentRoster.ts
index 43715d0bed..3668f4eb86 100644
--- a/ui-tui/src/app/agentRoster.ts
+++ b/ui-tui/src/app/agentRoster.ts
@@ -8,6 +8,9 @@ import type { SubagentProgress } from '../types.js'
import { useTurnSelector } from './turnStore.js'
import { $uiState } from './uiStore.js'
+// Session-local presentation only; never persisted to config.
+export const $agentDockCollapsed = atom(false)
+
const EMPTY: SubagentListResponse = { subagents: [], delegations: [] }
export const $agentSnapshot = atom<{ sid: string | null; data: SubagentListResponse }>({ sid: null, data: EMPTY })
diff --git a/ui-tui/src/app/useInputHandlers.ts b/ui-tui/src/app/useInputHandlers.ts
index 0239befdb6..a5f258c182 100644
--- a/ui-tui/src/app/useInputHandlers.ts
+++ b/ui-tui/src/app/useInputHandlers.ts
@@ -17,6 +17,7 @@ import { computePrecisionWheelStep, initPrecisionWheel } from '../lib/precisionW
import { computeWheelStep, initWheelAccelForHost } from '../lib/wheelAccel.js'
import { closeWidget, dispatchWidgetInput } from '../sdk/host.js'
+import { $agentDockCollapsed } from './agentRoster.js'
import { getInputSelection } from './inputSelectionStore.js'
import {
type GatewayRpc,
@@ -366,7 +367,7 @@ export function useInputHandlers(ctx: InputHandlerContext): InputHandlerResult {
// still the dedicated discard (pushes the draft to history so Up recalls it).
const lastEscRef = useRef(0)
- useInput((ch, key) => {
+ useInput((ch, key, event) => {
const live = getUiState()
if (key.escape) {
@@ -631,6 +632,12 @@ export function useInputHandlers(ctx: InputHandlerContext): InputHandlerResult {
// typed to run the command. Works mid-stream: picking a model writes the
// session model (config.set), which the next turn reads while the in-flight
// turn keeps streaming.
+ if (event.keypress.name === 'f7' && !key.ctrl && !key.meta && !key.shift && !key.super) {
+ $agentDockCollapsed.set(!$agentDockCollapsed.get())
+
+ return
+ }
+
if (isCtrl(key, ch, 't')) {
return patchOverlayState({ agents: true, agentsInitialHistoryIndex: 0 })
}
diff --git a/ui-tui/src/components/agentsOverlay.tsx b/ui-tui/src/components/agentsOverlay.tsx
index 5940979fae..e61c32f758 100644
--- a/ui-tui/src/components/agentsOverlay.tsx
+++ b/ui-tui/src/components/agentsOverlay.tsx
@@ -772,9 +772,9 @@ export function AgentsOverlay({ gw, initialHistoryIndex = 0, onClose, t }: Agent
return setMode('steer')
}
- if (ch === 't' && selected) {
- return setMode('tail')
- }
+ if (ch === 't' && !key.ctrl && selected) {return setMode('tail')}
+
+ if (ch === 'd' && !key.ctrl && selected) {return setMode('detail')}
if (ch === 'q') {
return closeWithCleanup()
@@ -847,7 +847,7 @@ export function AgentsOverlay({ gw, initialHistoryIndex = 0, onClose, t }: Agent
// List mode.
if ((key.return || key.rightArrow || ch === 'l') && selected) {
- return setMode('detail')
+ return setMode(key.return && !replayMode ? 'tail' : 'detail')
}
if (key.upArrow || ch === 'k' || key.wheelUp) {
@@ -980,18 +980,12 @@ export function AgentsOverlay({ gw, initialHistoryIndex = 0, onClose, t }: Agent
)}
-
- Enter detail · e steer · t tail · x stop · Esc back
-
- {flash ? (
-
- {flash}
-
- ) : null}
+ {replayMode ? 'Enter/d detail' : 'Enter/t tail · d detail'} · e steer · x stop · Esc back
+ {flash ? {flash} : null}
{mode === 'list' ? (
- ↑↓/jk move · g/G top/bottom · Enter/→ open detail{controlsHint} · s sort:{SORT_LABEL[sort]} · f filter:
+ ↑↓/jk move · g/G top/bottom · {replayMode ? 'Enter/→ detail' : 'Enter tail · d/→ detail'}{controlsHint} · s sort:{SORT_LABEL[sort]} · f filter:
{FILTER_LABEL[filter]}
{history.length > 0 ? ` · [ / ] history ${historyIndex}/${history.length}` : ''}
{' · q close'}
diff --git a/ui-tui/src/components/agentsPanel.tsx b/ui-tui/src/components/agentsPanel.tsx
index 3c16f16e28..7bf5fa6b3c 100644
--- a/ui-tui/src/components/agentsPanel.tsx
+++ b/ui-tui/src/components/agentsPanel.tsx
@@ -1,8 +1,8 @@
-import { Box, Text, useStdout } from '@hermes/ink'
+import { Box, stringWidth, Text, useStdout } from '@hermes/ink'
import { useStore } from '@nanostores/react'
import { useEffect, useState } from 'react'
-import { useAgentRoster } from '../app/agentRoster.js'
+import { $agentDockCollapsed, useAgentRoster } from '../app/agentRoster.js'
import { $uiState } from '../app/uiStore.js'
import { type AgentRows, buildAgentRows, dockRowLimit } from '../lib/agentRows.js'
import { mix } from '../lib/color.js'
@@ -11,10 +11,13 @@ import { fmtDuration } from '../lib/subagentTree.js'
import { compactPreview } from '../lib/text.js'
import type { Theme } from '../theme.js'
-export function AgentsPanelView({ cols, hidden, rows, running, t }: AgentRows & { cols: number; t: Theme }) {
- if (!running) {
- return null
- }
+export function AgentsPanelView({ collapsed = false, cols, hidden, rows, running, t }: AgentRows & { collapsed?: boolean; cols: number; t: Theme }) {
+ if (!running) {return null}
+
+ const summary = `▸ ${running} live agents`
+ const hints = ' · Ctrl+T expand · F7 restore'
+ const activityWidth = cols - stringWidth(summary + hints) - 3
+ const activity = rows[0]?.detail && activityWidth >= 12 ? ` · ${compactPreview(rows[0].detail, activityWidth)}` : ''
return (
- {`▾ ${running} live agents${hidden ? ` · +${hidden} more` : ''} · Ctrl+T expand`}
+ {collapsed ? summary + activity + hints : `▾ ${running} live agents${hidden ? ` · +${hidden} more` : ''} · Ctrl+T expand · F7 collapse`}
- {rows.map(row => (
+ {!collapsed && rows.map(row => (
{statusGlyph(row.status, t).glyph}
@@ -42,6 +45,7 @@ export function AgentsPanelView({ cols, hidden, rows, running, t }: AgentRows &
export function LiveAgentsPanel({ cols }: { cols: number }) {
const { theme } = useStore($uiState)
+ const collapsed = useStore($agentDockCollapsed)
const { stdout } = useStdout()
const subagents = useAgentRoster()
const live = subagents.some(s => s.status === 'running' || s.status === 'queued')
@@ -57,6 +61,6 @@ export function LiveAgentsPanel({ cols }: { cols: number }) {
}, [live])
return (
-
+
)
}
diff --git a/ui-tui/src/components/textInput.tsx b/ui-tui/src/components/textInput.tsx
index 65b9a45c8d..176b4fa506 100644
--- a/ui-tui/src/components/textInput.tsx
+++ b/ui-tui/src/components/textInput.tsx
@@ -1350,7 +1350,7 @@ export function TextInput({
// actually get voice toggled instead of a paste (Copilot round-7
// follow-up on #19835). The pass-through predicate is a no-op for
// ordinary typing and plain paste when voice is unbound to 'v'.
- if (shouldPassThroughToGlobalHandler(inp, k, voiceRecordKey)) {
+ if (event.keypress.name === 'f7' || shouldPassThroughToGlobalHandler(inp, k, voiceRecordKey)) {
flushKeyBurst()
return
diff --git a/ui-tui/src/content/hotkeys.ts b/ui-tui/src/content/hotkeys.ts
index 13cc2628f1..0fda3cd002 100644
--- a/ui-tui/src/content/hotkeys.ts
+++ b/ui-tui/src/content/hotkeys.ts
@@ -26,6 +26,7 @@ export const HOTKEYS: [string, string][] = [
['↑/↓', 'completions / queue edit / history'],
['Ctrl+X', 'open live session switcher (deletes queued message while editing)'],
['Ctrl+T', 'expand live agents (keeps your draft)'],
+ ['F7', 'collapse / restore live agent preview'],
['Ctrl+O', 'open model picker (keeps your draft; applies to next turn mid-stream)'],
[action + '+A/E', 'home / end of line'],
[action + '+Z / ' + action + '+Y', 'undo / redo input edits'],
diff --git a/ui-tui/src/types/hermes-ink.d.ts b/ui-tui/src/types/hermes-ink.d.ts
index 10a1054405..7e7d9b5437 100644
--- a/ui-tui/src/types/hermes-ink.d.ts
+++ b/ui-tui/src/types/hermes-ink.d.ts
@@ -28,7 +28,7 @@ declare module '@hermes/ink' {
export type InputEvent = {
readonly input: string
readonly key: Key
- readonly keypress: { readonly isPasted?: boolean; readonly raw?: string }
+ readonly keypress: { readonly isPasted?: boolean; readonly name?: string; readonly raw?: string }
}
export type InputHandler = (input: string, key: Key, event: InputEvent) => void