Skip to content

The agent that grows with you

feat(tui): goal row above the live-work dock

teknium1175365345082
diff --git a/ui-tui/src/__tests__/goalBar.test.tsx b/ui-tui/src/__tests__/goalBar.test.tsx
new file mode 100644
index 00000000000..259278e4663
--- /dev/null
+++ b/ui-tui/src/__tests__/goalBar.test.tsx
@@ -0,0 +1,55 @@
+import { PassThrough } from 'node:stream'
+
+import { renderSync } from '@hermes/ink'
+import type { GoalSnapshot } from '@hermes/shared/gateway-events'
+import React from 'react'
+import stripAnsi from 'strip-ansi'
+import { expect, it } from 'vitest'
+
+import { goalLine } from '../app/goalStatus.js'
+import { GoalBarView } from '../components/goalBar.js'
+import { DEFAULT_THEME } from '../theme.js'
+
+const goal = (patch: Partial<GoalSnapshot> = {}): GoalSnapshot => ({
+ contract: {},
+ gates: [],
+ max_turns: 20,
+ status: 'active',
+ subgoals: [],
+ title: 'ship the goal bar',
+ turns_used: 3,
+ ...patch
+})
+
+const paint = (element: React.ReactElement): string => {
+ const stdout = Object.assign(new PassThrough(), { columns: 60, rows: 10 })
+ const frames: string[] = []
+ stdout.on('data', chunk => frames.push(chunk.toString()))
+
+ const view = renderSync(element, {
+ stdout: stdout as unknown as NodeJS.WriteStream,
+ stdin: new PassThrough() as unknown as NodeJS.ReadStream
+ })
+
+ view.unmount()
+ view.cleanup()
+
+ return stripAnsi(frames.join(''))
+}
+
+it('shows a standing goal (active, parked, paused) and hides it once done or cleared', () => {
+ expect(goalLine(goal())).toMatchObject({ detail: '3/20 turns', glyph: '⊙', label: 'goal' })
+ expect(
+ goalLine(goal({ wait_barrier: { reason: 'build running', target: 'proc_1', type: 'session' } }))
+ ).toMatchObject({ detail: 'on session proc_1 · build running · 3/20 turns', glyph: '⏳', label: 'goal parked' })
+ expect(goalLine(goal({ paused_reason: 'budget', status: 'paused' }))).toMatchObject({
+ detail: 'budget · 3/20 turns',
+ label: 'goal paused'
+ })
+ expect(goalLine(goal({ status: 'done' }))).toBeNull()
+ expect(goalLine(null)).toBeNull()
+
+ const painted = paint(<GoalBarView cols={58} line={goalLine(goal())} t={DEFAULT_THEME} />)
+ expect(painted).toContain('⊙ goal · 3/20 turns · ship the goal bar')
+ expect(paint(<GoalBarView cols={58} line={null} t={DEFAULT_THEME} />).trim()).toBe('')
+})
diff --git a/ui-tui/src/app/createGatewayEventHandler.ts b/ui-tui/src/app/createGatewayEventHandler.ts
index ced683d85ad..348168989ea 100644
--- a/ui-tui/src/app/createGatewayEventHandler.ts
+++ b/ui-tui/src/app/createGatewayEventHandler.ts
@@ -29,6 +29,7 @@ import type { Msg, SessionInfo, SubagentProgress } from '../types.js'
import { applyConnectionRequest, applyConnectionUpdate } from './connectionOperationStore.js'
import { applyDelegationStatus, getDelegationState } from './delegationStore.js'
+import { applyGoalSnapshot } from './goalStatus.js'
import type { GatewayEventHandlerContext, NoticeLevel } from './interfaces.js'
import { getOverlayState, patchOverlayState } from './overlayStore.js'
import { flashGoodVibes, flashPet } from './petFlashStore.js'
@@ -893,6 +894,11 @@ export function createGatewayEventHandler(ctx: GatewayEventHandlerContext): (ev:
return
}
+ case 'session.control.update':
+ applyGoalSnapshot(sid, ev.payload?.control.goal ?? null)
+
+ return
+
case 'message.start':
resetAgentsNudgeTurnState()
turnController.startMessage()
diff --git a/ui-tui/src/app/goalStatus.ts b/ui-tui/src/app/goalStatus.ts
new file mode 100644
index 00000000000..cb284152760
--- /dev/null
+++ b/ui-tui/src/app/goalStatus.ts
@@ -0,0 +1,61 @@
+import type { GoalSnapshot } from '@hermes/shared/gateway-events'
+import { useStore } from '@nanostores/react'
+import { atom } from 'nanostores'
+
+import { $uiState } from './uiStore.js'
+
+// The session's standing /goal, as `session.control.read` / `session.control.update` report it.
+// Session-local presentation only; `/goal` itself stays the control surface.
+
+export const $goalSnapshot = atom<{ goal: GoalSnapshot | null; sid: string | null }>({ goal: null, sid: null })
+
+export function applyGoalSnapshot(sid: string | null, goal: GoalSnapshot | null = null) {
+ const previous = $goalSnapshot.get()
+
+ if (previous.sid !== sid || JSON.stringify(previous.goal) !== JSON.stringify(goal)) {
+ $goalSnapshot.set({ goal, sid })
+ }
+}
+
+export interface GoalLine {
+ detail: string
+ glyph: string
+ label: string
+ title: string
+}
+
+const clock = (epochSeconds: number) =>
+ new Date(epochSeconds * 1000).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
+
+/** `⊙ goal · 3/20 turns · <title>` for an active goal, `⏳ goal parked` / `⏸ goal paused` with the
+ * reason while held, `null` once it is done or cleared (the transcript carries the verdict). */
+export function goalLine(goal: GoalSnapshot | null): GoalLine | null {
+ if (!goal || (goal.status !== 'active' && goal.status !== 'paused')) {
+ return null
+ }
+
+ const turns = `${goal.turns_used}/${goal.max_turns} turns`
+ const barrier = goal.status === 'active' ? goal.wait_barrier : null
+
+ if (barrier) {
+ const until = barrier.type === 'until' ? `until ${clock(barrier.until_at)}` : `on ${barrier.type} ${barrier.target}`
+ const reason = barrier.reason ? ` · ${barrier.reason}` : ''
+
+ return { detail: `${until}${reason} · ${turns}`, glyph: '⏳', label: 'goal parked', title: goal.title }
+ }
+
+ if (goal.status === 'paused') {
+ const reason = goal.paused_reason ? `${goal.paused_reason} · ` : ''
+
+ return { detail: `${reason}${turns}`, glyph: '⏸', label: 'goal paused', title: goal.title }
+ }
+
+ return { detail: turns, glyph: '⊙', label: 'goal', title: goal.title }
+}
+
+export function useGoalLine(): GoalLine | null {
+ const snapshot = useStore($goalSnapshot)
+ const { sid } = useStore($uiState)
+
+ return snapshot.sid === sid ? goalLine(snapshot.goal) : null
+}
diff --git a/ui-tui/src/app/useMainApp.ts b/ui-tui/src/app/useMainApp.ts
index 248a659d4c4..a1bfc10ac22 100644
--- a/ui-tui/src/app/useMainApp.ts
+++ b/ui-tui/src/app/useMainApp.ts
@@ -8,6 +8,7 @@ import {
useStdout,
useTerminalTitle
} from '@hermes/ink'
+import type { SessionControlSnapshot } from '@hermes/shared/gateway-events'
import { JSON_RPC_METHOD_NOT_FOUND, type ServerRequest } from '@hermes/shared/json-rpc-channel'
import { useStore } from '@nanostores/react'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
@@ -53,6 +54,7 @@ import { createGatewayEventHandler } from './createGatewayEventHandler.js'
import { createServerRequestHandler } from './createServerRequestHandler.js'
import { createSlashHandler } from './createSlashHandler.js'
import { planGatewayRecovery } from './gatewayRecovery.js'
+import { applyGoalSnapshot } from './goalStatus.js'
import { getInputSelection } from './inputSelectionStore.js'
import { type GatewayRpc, type StateSetter, type TranscriptRow } from './interfaces.js'
import { $overlayState, patchOverlayState } from './overlayStore.js'
@@ -610,6 +612,18 @@ export function useMainApp(gw: GatewayClient) {
let stopped = false
applyAgentSnapshot(ui.sid)
applyProcessSnapshot(ui.sid)
+ applyGoalSnapshot(ui.sid)
+ // Goal state changes only on /goal and after a judged turn, both of which push
+ // `session.control.update`; read it once per session instead of polling state.db.
+ gw.request<{ control: SessionControlSnapshot }>('session.control.read', { session_id: ui.sid })
+ .then(raw => {
+ const result = asRpcResult<{ control: SessionControlSnapshot }>(raw)
+
+ if (!stopped && result && getUiState().sid === ui.sid) {
+ applyGoalSnapshot(ui.sid, result.control?.goal ?? null)
+ }
+ })
+ .catch(() => {})
const refresh = () => {
const sid = ui.sid
diff --git a/ui-tui/src/components/appLayout.tsx b/ui-tui/src/components/appLayout.tsx
index 276c794965d..de0f1dd172c 100644
--- a/ui-tui/src/components/appLayout.tsx
+++ b/ui-tui/src/components/appLayout.tsx
@@ -30,6 +30,7 @@ import { GoodVibesHeart, StatusRule, StickyPromptTracker, TranscriptScrollbar }
import { FloatingOverlays, PromptZone } from './appOverlays.js'
import { Banner, Panel, SessionPanel } from './branding.js'
import { FpsOverlay } from './fpsOverlay.js'
+import { GoalBar } from './goalBar.js'
import { HelpHint } from './helpHint.js'
import { Journey } from './journey.js'
import { MessageLine } from './messageLine.js'
@@ -367,6 +368,7 @@ const ComposerPane = memo(function ComposerPane({
<Box height={1} onMouseDown={captureInputDrag} onMouseDrag={dragFromSpacer} onMouseUp={endInputDrag} />
)}
+ <GoalBar cols={Math.max(1, composer.cols - 2)} />
<LiveAgentsPanel cols={Math.max(1, composer.cols - 2)} />
<StatusRulePane at="top" composer={composer} status={status} />
<AmbientDock placement="dock-top" />
diff --git a/ui-tui/src/components/goalBar.tsx b/ui-tui/src/components/goalBar.tsx
new file mode 100644
index 00000000000..d13fabe0be7
--- /dev/null
+++ b/ui-tui/src/components/goalBar.tsx
@@ -0,0 +1,30 @@
+import { stringWidth, Text } from '@hermes/ink'
+import { useStore } from '@nanostores/react'
+
+import { type GoalLine, useGoalLine } from '../app/goalStatus.js'
+import { $uiState } from '../app/uiStore.js'
+import { compactPreview } from '../lib/text.js'
+import type { Theme } from '../theme.js'
+
+/** One `⊙ goal · 3/20 turns · <title>` row above the live-work dock while a /goal is standing. */
+export function GoalBarView({ cols, line, t }: { cols: number; line: GoalLine | null; t: Theme }) {
+ if (!line) {
+ return null
+ }
+
+ const head = `${line.glyph} ${line.label} · ${line.detail} · `
+
+ return (
+ <Text wrap="truncate-end">
+ <Text color={line.glyph === '⊙' ? t.color.accent : t.color.warn}>{`${line.glyph} ${line.label}`}</Text>
+ <Text color={t.color.muted}>{` · ${line.detail} · `}</Text>
+ <Text color={t.color.text}>{compactPreview(line.title, Math.max(8, cols - stringWidth(head)))}</Text>
+ </Text>
+ )
+}
+
+export function GoalBar({ cols }: { cols: number }) {
+ const { theme } = useStore($uiState)
+
+ return <GoalBarView cols={cols} line={useGoalLine()} t={theme} />
+}
diff --git a/website/docs/user-guide/tui.md b/website/docs/user-guide/tui.md
index fa8e3a8ae10..20deb9c95d6 100644
--- a/website/docs/user-guide/tui.md
+++ b/website/docs/user-guide/tui.md
@@ -103,6 +103,7 @@ The directory must contain `dist/entry.js`.
Keybindings match the [Classic CLI](cli.md#keybindings) exactly. The only behavioral differences:
- **`Ctrl+T`** expands the automatic live-work dock (subagents, plus a **Processes** block for `terminal(background=true)` spawns) into the full-height `/agents` roster. Select a worker and press **Enter** (or **`t`**) for its live transcript, **`d`** for rich details, **`e`** to steer, or **`x`** to stop it. The dock fits its row count to terminal height and preserves your composer draft. See [Monitoring subagents](./features/delegation.md#monitoring-running-subagents-agents).
+- A standing **`/goal`** gets its own row above the live dock (`⊙ goal · 3/20 turns · …`, or `⏳ goal parked` / `⏸ goal paused` with the reason); it leaves once the goal is done or cleared. Queued follow-ups are listed above it.
- **`F7`** toggles the live dock between its default preview and one summary line. This does not open the monitor or move composer focus; the choice lasts for this TUI process without changing config.
- **Mouse drag** highlights text with a uniform selection background.
- **`Cmd+V` / `Ctrl+V`** first tries normal text paste, then falls back to OSC52/native clipboard reads, and finally image attach when the clipboard or pasted payload resolves to an image.