Skip to content

The agent that grows with you

test: verify busy acknowledgements and document Ink recovery limits

Teknium59a90b4d46ab
diff --git a/ui-tui/CANONICAL_GATEWAY.md b/ui-tui/CANONICAL_GATEWAY.md
index 4779b3421cf..c8b56e03805 100644
--- a/ui-tui/CANONICAL_GATEWAY.md
+++ b/ui-tui/CANONICAL_GATEWAY.md
@@ -30,20 +30,47 @@ legacy readiness event. Shared
approval/clarify responses carry the actual prompt ID and generation; a resumed
snapshot restores its pending prompt cards. Stop includes the active generation.
+## Input recovery and controls
+
+The disconnected view keeps its destination. Enter writes a private fsync/rename
+journal before clearing the composer; reconnect only resumes that destination.
+Discovery keeps retrying without starting a stopped daemon. Confirmed admissions
+are retired from the journal; ambiguous prompt retries preserve their original ID
+and payload. Unknown executions stay paused: select the row with Up and use
+Ctrl+X to discard it through the generation-bound authority resolver. A refused
+Discard remains visible and reports the error.
+
+Model, branch and compression use `session.mutate` with revision/generation
+preconditions and a stable request ID. The session picker reads `session.list`.
+Busy preference reads/writes are session scoped. Steer/redirect target the active
+generation; these controls are not durable prompt admissions. An ambiguous control
+reply is retained for inspection but never automatically or manually replayed;
+check the transcript before submitting a new correction. Unsupported controls do
+not silently become queued turns.
+
+Image paths, startup images and clipboard images are staged on the Ink host.
+Local-owner files go into the captured profile's private `cache/images`; explicit
+remote connections upload bytes and require an owner-readable returned path.
+Identified `prompt.submit` carries `{path,mime}` attachments, including journal
+retries. Clipboard extraction never reads a remote owner's clipboard. Image busy
+corrections are refused and retained: use queue mode for an image-bearing turn.
+
## Current gaps
- Fresh TUI creation requires an authority advertising TUI launch-policy support;
older CLI-only runtimes are rejected. No CLI impersonation is used.
- Runtime descriptions and session metadata are intentionally narrow. Ink renders
an explicit unavailable-inventory message, not fabricated tool/skill lists.
-- Most legacy rich UI RPCs (config, wake, slash execution, uploads, historical
- pickers, metadata editing, and subagents) are not exposed by this authority yet;
- they fail visibly. This is not complete feature parity.
+- Canonical busy controls/config projection and remote image uploads require the
+ corresponding owner handlers. Older owners reject them visibly. The model
+ chooser still requires the owner's `model.options` projection; explicit `/model`
+ uses the canonical mutation path.
+- Rich legacy RPCs outside these controls (wake, general config settings, subagent
+ panels and some slash execution) are not claimed implemented by this change.
- A per-view session switch does not terminate the old shared session. The present
authority removes subscriptions when the socket closes, so old subscriptions
can remain until that detach; the renderer still filters by current session.
-- Secret/sudo and batch clarification are not claimed supported. Cold owner
- restart recovery is outside this scoped migration.
+- Secret/sudo and batch clarification are not claimed supported.
## Native verification
diff --git a/ui-tui/src/__tests__/busyQueueAdmission.test.tsx b/ui-tui/src/__tests__/busyQueueAdmission.test.tsx
index 2ae32b4be70..de7327f1545 100644
--- a/ui-tui/src/__tests__/busyQueueAdmission.test.tsx
+++ b/ui-tui/src/__tests__/busyQueueAdmission.test.tsx
@@ -9,13 +9,13 @@ import React from 'react'
import { expect, it, vi } from 'vitest'
import { createGatewayEventHandler } from '../app/createGatewayEventHandler.js'
+import { captureDestination } from '../app/submissionDestination.js'
import { turnController } from '../app/turnController.js'
import { $uiState, patchUiState, resetUiState } from '../app/uiStore.js'
import { useSubmission } from '../app/useSubmission.js'
import { canonicalEvent, canonicalResult } from '../canonicalGateway.js'
import { useQueue } from '../hooks/useQueue.js'
import { loadPendingInputs } from '../lib/pendingInputs.js'
-import { captureDestination } from '../app/submissionDestination.js'
// Canonical authority rows: `pending` carries the server-issued admission_id,
// the client's input_id and the public text under `ref` destination fields.
@@ -144,6 +144,7 @@ it('deletes a server-queued row through prompt.cancel rather than local removal'
it('retains disconnected input durably on its old destination without dispatching or draining', async () => {
const h = mount()
+
try {
patchUiState({ gatewayConnected: false, busy: false } as any)
const destination = captureDestination()
@@ -157,6 +158,7 @@ it('retains disconnected input durably on its old destination without dispatchin
it('discards unknown execution with its generation, retaining the row on refusal', async () => {
const h = mount()
+
try {
h.request.mockImplementation(async (method, params) => { h.calls.push({method, params}); throw new Error('stale_generation') })
h.fanout([{ ...row('unknown-admission', 'unknown-input', 'interrupted input', 'unknown'), execution_generation: 7 }])
@@ -171,6 +173,7 @@ it('discards unknown execution with its generation, retaining the row on refusal
it('never replays an ambiguous non-idempotent busy correction or falls back to queue', async () => {
const h = mount('steer')
+
try {
h.request.mockImplementation(async (method, params) => { h.calls.push({ method, params }); throw new Error('invalid_params') })
h.submission.dispatchSubmission('correction')
@@ -187,6 +190,24 @@ it('never replays an ambiguous non-idempotent busy correction or falls back to q
} finally { h.cleanup() }
})
+it('retires a generation-matched redirect acknowledgement without resetting the live turn', async () => {
+ const h = mount('interrupt')
+
+ try {
+ h.request.mockImplementation(async (method, params) => {
+ h.calls.push({method, params});
+
+ return { status: 'redirected', execution_generation: params.execution_generation } as any
+ })
+ h.submission.dispatchSubmission('redirect correction')
+ await expect.poll(() => h.calls.length).toBe(1)
+ expect(h.calls[0]).toEqual({ method: 'session.redirect', params: { session_id: 'owner', text: 'redirect correction', execution_generation: 1 } })
+ await expect.poll(() => h.queue.queueRef.current.length).toBe(0)
+ expect(loadPendingInputs(captureDestination())).toEqual([])
+ expect($uiState.get()).toMatchObject({ busy: true, status: 'running…' })
+ } finally { h.cleanup() }
+})
+
it('projects canonical pending rows onto the legacy pending_submissions shape for resume snapshots and fanout', () => {
const pending = [row('adm-3', 'in-3', 'hello')]
diff --git a/ui-tui/src/__tests__/canonicalImages.test.ts b/ui-tui/src/__tests__/canonicalImages.test.ts
index 7942e65a07a..b189537e329 100644
--- a/ui-tui/src/__tests__/canonicalImages.test.ts
+++ b/ui-tui/src/__tests__/canonicalImages.test.ts
@@ -56,7 +56,11 @@ it('extracts clipboard on the client and uploads only captured bytes to a remote
vi.stubEnv('HERMES_TUI_GATEWAY_URL', 'wss://remote.example')
resetUiState(); patchUiState({ sid: 'owner' })
const request = vi.fn(async () => ({ path: '/owner/cache/images/clip.png' }))
- const extract = vi.fn(async (path: string) => { writeFileSync(path, png); return true })
+
+ const extract = vi.fn(async (path: string) => { writeFileSync(path, png);
+
+ return true })
+
try {
const image = await stageClipboardImage({ request } as any, captureDestination(), extract)
expect(image).toMatchObject({ path: '/owner/cache/images/clip.png', mime: 'image/png' })
diff --git a/ui-tui/src/__tests__/gatewayClient.test.ts b/ui-tui/src/__tests__/gatewayClient.test.ts
index d162a647c16..ca741dadb13 100644
--- a/ui-tui/src/__tests__/gatewayClient.test.ts
+++ b/ui-tui/src/__tests__/gatewayClient.test.ts
@@ -174,6 +174,7 @@ describe('GatewayClient websocket attach mode', () => {
const gw = new GatewayClient(bootstrap)
const events: any[] = []
gw.on('event', event => events.push(event))
+
try {
gw.start(); gw.drain()
await vi.advanceTimersByTimeAsync(0)
diff --git a/ui-tui/src/__tests__/useConfigSync.test.ts b/ui-tui/src/__tests__/useConfigSync.test.ts
index 015fd8477bb..53490c732ac 100644
--- a/ui-tui/src/__tests__/useConfigSync.test.ts
+++ b/ui-tui/src/__tests__/useConfigSync.test.ts
@@ -527,9 +527,11 @@ describe('syncMcpReload (revision-aware ack)', () => {
describe('hydrateFullConfig', () => {
it('hydrates the session busy preference instead of profile defaults and preserves it on read failure', async () => {
patchUiState({ sid: 'owner', busyInputMode: 'queue' })
+
const request = vi.fn(async (_method: string, params: any) =>
params.key === 'busy' ? { value: 'steer' } : { config: { display: { busy_input_mode: 'interrupt' } } }
)
+
const gw = { isCanonical: true, request } as any
const scope = { sid: 'owner', isCurrent: () => true }
await hydrateFullConfig(gw, vi.fn(), undefined, undefined, scope)
@@ -537,7 +539,8 @@ describe('hydrateFullConfig', () => {
expect(request).toHaveBeenCalledWith('config.get', { key: 'busy', session_id: 'owner' })
expect($uiState.get().busyInputMode).toBe('steer')
request.mockImplementation(async (_method, params) => {
- if (params.key === 'busy') throw new Error('disconnected')
+ if (params.key === 'busy') {throw new Error('disconnected')}
+
return { config: { display: { busy_input_mode: 'interrupt' } } }
})
await hydrateFullConfig(gw, vi.fn(), undefined, undefined, scope)
@@ -548,15 +551,18 @@ describe('hydrateFullConfig', () => {
patchUiState({ sid: 'old', busyInputMode: 'queue' })
let current = true
const replies: Array<(value: any) => void> = []
+
const gw = {
isCanonical: true,
request: vi.fn(() => new Promise(resolve => replies.push(resolve)))
} as any
+
const setBell = vi.fn()
const pending = hydrateFullConfig(gw, setBell, undefined, undefined, { sid: 'old', isCurrent: () => current })
current = false
patchUiState({ sid: 'new', busyInputMode: 'interrupt' })
- for (const reply of replies) reply({ config: { display: { busy_input_mode: 'steer' } }, value: 'steer' })
+
+ for (const reply of replies) {reply({ config: { display: { busy_input_mode: 'steer' } }, value: 'steer' })}
await pending
expect(setBell).not.toHaveBeenCalled()
expect($uiState.get().busyInputMode).toBe('interrupt')
diff --git a/ui-tui/src/app/createGatewayEventHandler.ts b/ui-tui/src/app/createGatewayEventHandler.ts
index 5cae26f3b43..c778b590f3b 100644
--- a/ui-tui/src/app/createGatewayEventHandler.ts
+++ b/ui-tui/src/app/createGatewayEventHandler.ts
@@ -15,7 +15,7 @@ import type {
} from '../gatewayTypes.js'
import { billingDialogCopy } from '../lib/billingDialog.js'
import { relativeLuminance } from '../lib/color.js'
-import { stageImagePath, type ImageAttachment } from '../lib/imageAttachments.js'
+import { type ImageAttachment, stageImagePath } from '../lib/imageAttachments.js'
import { isTodoDone } from '../lib/liveProgress.js'
import { openExternalUrl } from '../lib/openExternalUrl.js'
import { rpcErrorMessage } from '../lib/rpc.js'
diff --git a/ui-tui/src/app/slash/canonicalSessionControls.ts b/ui-tui/src/app/slash/canonicalSessionControls.ts
index 6d8d38e6499..5479e966bff 100644
--- a/ui-tui/src/app/slash/canonicalSessionControls.ts
+++ b/ui-tui/src/app/slash/canonicalSessionControls.ts
@@ -103,6 +103,7 @@ export async function mutateCanonicalSession(
throw error
}
+
return { result, expectedGeneration: params.expected_generation as number }
}
@@ -125,6 +126,7 @@ export async function runCanonicalSessionControl(
}
const { result, expectedGeneration } = mutation
+
if (ctx.stale()) {
return
}
diff --git a/ui-tui/src/app/slash/commands/session.ts b/ui-tui/src/app/slash/commands/session.ts
index 9a1feefa963..f711f5451da 100644
--- a/ui-tui/src/app/slash/commands/session.ts
+++ b/ui-tui/src/app/slash/commands/session.ts
@@ -247,6 +247,7 @@ export const sessionCommands: SlashCommand[] = [
if (ctx.gateway.gw.isCanonical) {
return runCanonicalSessionControl('compress', arg, ctx)
}
+
ctx.gateway
.rpc<SessionCompressResponse>('session.compress', {
session_id: ctx.sid,
@@ -255,6 +256,7 @@ export const sessionCommands: SlashCommand[] = [
.then(
ctx.guarded<SessionCompressResponse>(r => {
const current = getUiState()
+
const authorityKeys = [
'stored_session_id',
'execution_epoch',
@@ -331,6 +333,7 @@ export const sessionCommands: SlashCommand[] = [
if (ctx.gateway.gw.isCanonical) {
return runCanonicalSessionControl('branch', arg, ctx)
}
+
ctx.gateway.rpc<SessionBranchResponse>('session.branch', { name: arg, session_id: ctx.sid }).then(
ctx.guarded<SessionBranchResponse>(r => {
if (!r.session_id) {
@@ -691,6 +694,7 @@ export const sessionCommands: SlashCommand[] = [
if (next === 'queue' || next === 'steer' || next === 'interrupt') {
patchUiState({ busyInputMode: next })
}
+
ctx.transcript.sys(`busy input mode: ${next}`)
})
)
diff --git a/ui-tui/src/app/submissionCore.ts b/ui-tui/src/app/submissionCore.ts
index 63bfe15bbdb..ae9752a9116 100644
--- a/ui-tui/src/app/submissionCore.ts
+++ b/ui-tui/src/app/submissionCore.ts
@@ -105,6 +105,7 @@ export function submitPrompt(
if (item) {
item.preparedText ??= submitText
+
// Busy controls have no deduplication receipt: never replay after an ambiguous reply.
if (item.controlMethod) { item.legacyAttempted = true }
item.attachments ??= opts.attachments?.map(attachment => ({ ...attachment }))
@@ -117,7 +118,9 @@ export function submitPrompt(
if (item?.controlMethod && item.attachments?.length) {
item.settle?.(false)
+
if (focused()) { deps.sys('busy corrections accept text only — image input retained; submit it with /queue') }
+
return
}
@@ -132,12 +135,17 @@ export function submitPrompt(
.then(r => {
if (item?.controlMethod) {
const control = r as PromptSubmitResponse & { execution_generation?: number }
+
const accepted = control.execution_generation === item.executionGeneration &&
['queued', 'redirected'].includes(control.status ?? '')
+
item.settle?.(accepted)
+
if (focused()) { deps.sys(accepted ? `correction ${control.status}` : 'correction rejected — input retained') }
+
return
}
+
if (item) {
const accepted =
(r?.input_id ?? r?.admission_id) === item.submissionId &&
diff --git a/ui-tui/src/app/useComposerState.ts b/ui-tui/src/app/useComposerState.ts
index 04d55c104fa..05059831ded 100644
--- a/ui-tui/src/app/useComposerState.ts
+++ b/ui-tui/src/app/useComposerState.ts
@@ -279,7 +279,9 @@ export function useComposerState({ gw, submitRef, sys }: UseComposerStateOptions
(gw.isCanonical
? stageClipboardImage(gw, destination).then(image => image ? { ...image, attached: true } : null)
: gw.request<ClipboardPasteResponse & { path?: string; mime?: string }>('clipboard.paste', { session_id: sid }))
- .catch((error: Error) => { if (!quiet) { sys(`clipboard image failed: ${error.message}`) } return null }),
+ .catch((error: Error) => { if (!quiet) { sys(`clipboard image failed: ${error.message}`) }
+
+ return null }),
r => {
if (r?.attached) {
return attachImageToken(r, value, cursor)
diff --git a/ui-tui/src/app/useConfigSync.ts b/ui-tui/src/app/useConfigSync.ts
index e17db659894..e0f7fc32786 100644
--- a/ui-tui/src/app/useConfigSync.ts
+++ b/ui-tui/src/app/useConfigSync.ts
@@ -258,6 +258,7 @@ export async function hydrateFullConfig(
scope?: { sid: string; isCurrent: () => boolean }
): Promise<ConfigFullResponse | null> {
const params = scope ? { session_id: scope.sid } : {}
+
const [cfg, busy] = await Promise.all([
quietRpc<ConfigFullResponse>(gw, 'config.get', { key: 'full', ...params }),
gw.isCanonical && scope ? quietRpc(gw, 'config.get', { key: 'busy', ...params }) : null
@@ -268,6 +269,7 @@ export async function hydrateFullConfig(
}
applyDisplay(cfg, setBell, setVoiceRecordKey, setBellOnPrompt, !gw.isCanonical)
+
if (gw.isCanonical && BUSY_MODES.has(busy?.value)) {
patchUiState({ busyInputMode: busy!.value })
}
@@ -354,7 +356,7 @@ export function useConfigSync({
// check still runs when the user opens /voice.
setVoiceEnabled(process.env.HERMES_VOICE === '1')
quietRpc<ConfigMtimeResponse>(gw, 'config.get', { key: 'mtime', session_id: sid }).then(r => {
- if (!scope.isCurrent()) return
+ if (!scope.isCurrent()) {return}
mtimeRef.current = Number(r?.mtime ?? 0)
// Seed the MCP revision baseline too: after a normal boot mtime is
// already non-zero, so the poller's baseline branch never runs, and an
@@ -363,6 +365,7 @@ export function useConfigSync({
mcpRevRef.current.accepted = String(r?.mcp_rev ?? '')
})
void hydrateFullConfig(gw, setBellOnComplete, setVoiceRecordKey, setBellOnPrompt, scope)
+
return () => {
active = false
}
@@ -375,9 +378,10 @@ export function useConfigSync({
let active = true
const scope = { sid, isCurrent: () => active && getUiState().sid === sid }
+
const id = setInterval(() => {
quietRpc<ConfigMtimeResponse>(gw, 'config.get', { key: 'mtime', session_id: sid }).then(r => {
- if (!scope.isCurrent()) return
+ if (!scope.isCurrent()) {return}
const next = Number(r?.mtime ?? 0)
const nextMcpRev = String(r?.mcp_rev ?? '')
diff --git a/ui-tui/src/app/useSubmission.ts b/ui-tui/src/app/useSubmission.ts
index b0aa9a7cb84..6d883ef17f5 100644
--- a/ui-tui/src/app/useSubmission.ts
+++ b/ui-tui/src/app/useSubmission.ts
@@ -6,8 +6,8 @@ import { completionToApplyOnSubmit, looksLikeSlashCommand, parseSlashCommand } f
import type { GatewayClient } from '../gatewayClient.js'
import type { ShellExecResponse } from '../gatewayTypes.js'
import { queueItem, type QueueItem } from '../hooks/useQueue.js'
-import { asRpcResult } from '../lib/rpc.js'
import { savePendingInput } from '../lib/pendingInputs.js'
+import { asRpcResult } from '../lib/rpc.js'
import { hasInterpolation, INTERPOLATION_RE } from '../protocol/interpolation.js'
import type { Msg } from '../types.js'
@@ -256,10 +256,12 @@ export function useSubmission(opts: UseSubmissionOptions) {
if (gw.isCanonical && mode !== 'queue') {
const staged = item.settle ? item : composerActions.stage?.(item.text, item.display, destination)
+
if (!staged) { return }
staged.controlMethod ??= mode === 'steer' ? 'session.steer' : 'session.redirect'
staged.executionGeneration ??= live.info?.execution_generation
staged.attachments ??= item.attachments
+
return send(item.text, true, item.display, value => value, {
destination, behindTurn: true, queueItem: staged, attachments: item.attachments })
}
@@ -327,6 +329,7 @@ export function useSubmission(opts: UseSubmissionOptions) {
if (queued) {
const retained = composerActions.enqueue(queued.text, queued.display, destination)
+
if (retained) { retained.attachments = submission.attachments; savePendingInput(retained) }
sys(`queued: "${queued.display.slice(0, 50)}${queued.display.length > 50 ? '…' : ''}"`)
} else {
@@ -347,6 +350,7 @@ export function useSubmission(opts: UseSubmissionOptions) {
if (!live.sid || live.gatewayConnected === false) {
composerActions.pushHistory(toHistory)
const retained = composerActions.enqueue(submission.text, submission.display, destination)
+
if (retained) { retained.attachments = submission.attachments; savePendingInput(retained) }
composerActions.clearIn()
diff --git a/ui-tui/src/hooks/useQueue.ts b/ui-tui/src/hooks/useQueue.ts
index 491d8cd7b06..4733f31e2e9 100644
--- a/ui-tui/src/hooks/useQueue.ts
+++ b/ui-tui/src/hooks/useQueue.ts
@@ -371,8 +371,10 @@ export function useQueue(gw?: { request: (method: string, params: Record<string,
if (server) {
if (server.status === 'unknown') {
patchUiState({ status: 'unknown execution — Ctrl+X to discard before retrying' })
+
return undefined
}
+
cancelServerRow(server)
const item = queueItem(editedDisplay ?? server.user)
queue.items.push(item)
diff --git a/ui-tui/src/lib/imageAttachments.ts b/ui-tui/src/lib/imageAttachments.ts
index 50c74724617..97335a4ae11 100644
--- a/ui-tui/src/lib/imageAttachments.ts
+++ b/ui-tui/src/lib/imageAttachments.ts
@@ -1,10 +1,10 @@
-import { randomUUID } from 'node:crypto'
import { execFile } from 'node:child_process'
-import { promisify } from 'node:util'
+import { randomUUID } from 'node:crypto'
import { mkdir, mkdtemp, open, readFile, rm, stat } from 'node:fs/promises'
import { homedir, tmpdir } from 'node:os'
import { basename, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
+import { promisify } from 'node:util'
import type { SubmissionDestination } from '../app/submissionDestination.js'
import type { GatewayClient } from '../gatewayClient.js'
@@ -70,10 +70,13 @@ async function resolveImagePath(raw: string): Promise<{ path: string; remainder:
async function extractClipboardImage(path: string): Promise<boolean> {
const root = process.env.HERMES_PYTHON_SRC_ROOT ?? resolve(import.meta.dirname, '../../..')
+
const python = process.env.HERMES_PYTHON?.trim() || process.env.PYTHON?.trim() ||
(process.platform === 'win32' ? 'python' : 'python3')
+
const { stdout } = await promisify(execFile)(python, [join(root, 'ui-tui/scripts/clipboard_image.py'), path],
{ cwd: root, env: { ...process.env, PYTHONPATH: root }, timeout: 15_000, windowsHide: true })
+
return stdout.trim() === 'true'
}
@@ -83,8 +86,10 @@ export async function stageClipboardImage(
): Promise<StagedImage | null> {
const directory = await mkdtemp(join(tmpdir(), 'hermes-clipboard-'))
const path = join(directory, 'clipboard.png')
+
try {
if (!await extract(path)) { return null }
+
return await stageImagePath(path, gw, destination)
} finally { await rm(directory, { recursive: true, force: true }) }
}