2026-04-16 01:04:35 -05:00
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
|
|
|
|
|
|
import { asCommandDispatch } from '../lib/rpc.js'
|
|
|
|
|
|
|
|
|
|
describe('asCommandDispatch', () => {
|
fix(tui): slash.exec _pending_input commands, tool ANSI, terminal title
Additional TUI fixes discovered in the same audit:
1. /plan slash command was silently lost — process_command() queues the
plan skill invocation onto _pending_input which nobody reads in the
slash worker subprocess. Now intercepted in slash.exec and routed
through command.dispatch with a new 'send' dispatch type.
Same interception added for /retry, /queue, /steer as safety nets
(these already have correct TUI-local handlers in core.ts, but the
server-side guard prevents regressions if the local handler is
bypassed).
2. Tool results were stripping ANSI escape codes — the messageLine
component used stripAnsi() + plain <Text> for tool role messages,
losing all color/styling from terminal, search_files, etc. Now
uses <Ansi> component (already imported) when ANSI is detected.
3. Terminal tab title now shows model + busy status via useTerminalTitle
hook from @hermes/ink (was never used). Users can identify Hermes
tabs and see at a glance whether the agent is busy or ready.
4. Added 'send' variant to CommandDispatchResponse type + asCommandDispatch
parser + createSlashHandler handler for commands that need to inject
a message into the conversation (plan, queue fallback, steer fallback).
2026-04-18 17:52:19 +05:30
|
|
|
it('parses exec, alias, skill, and send', () => {
|
2026-04-16 01:04:35 -05:00
|
|
|
expect(asCommandDispatch({ type: 'exec', output: 'hi' })).toEqual({ type: 'exec', output: 'hi' })
|
|
|
|
|
expect(asCommandDispatch({ type: 'alias', target: 'help' })).toEqual({ type: 'alias', target: 'help' })
|
|
|
|
|
expect(asCommandDispatch({ type: 'skill', name: 'x', message: 'do' })).toEqual({
|
|
|
|
|
type: 'skill',
|
|
|
|
|
name: 'x',
|
|
|
|
|
message: 'do'
|
|
|
|
|
})
|
fix(tui): slash.exec _pending_input commands, tool ANSI, terminal title
Additional TUI fixes discovered in the same audit:
1. /plan slash command was silently lost — process_command() queues the
plan skill invocation onto _pending_input which nobody reads in the
slash worker subprocess. Now intercepted in slash.exec and routed
through command.dispatch with a new 'send' dispatch type.
Same interception added for /retry, /queue, /steer as safety nets
(these already have correct TUI-local handlers in core.ts, but the
server-side guard prevents regressions if the local handler is
bypassed).
2. Tool results were stripping ANSI escape codes — the messageLine
component used stripAnsi() + plain <Text> for tool role messages,
losing all color/styling from terminal, search_files, etc. Now
uses <Ansi> component (already imported) when ANSI is detected.
3. Terminal tab title now shows model + busy status via useTerminalTitle
hook from @hermes/ink (was never used). Users can identify Hermes
tabs and see at a glance whether the agent is busy or ready.
4. Added 'send' variant to CommandDispatchResponse type + asCommandDispatch
parser + createSlashHandler handler for commands that need to inject
a message into the conversation (plan, queue fallback, steer fallback).
2026-04-18 17:52:19 +05:30
|
|
|
expect(asCommandDispatch({ type: 'send', message: 'hello world' })).toEqual({
|
|
|
|
|
type: 'send',
|
|
|
|
|
message: 'hello world'
|
|
|
|
|
})
|
2026-04-16 01:04:35 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('rejects malformed payloads', () => {
|
|
|
|
|
expect(asCommandDispatch(null)).toBeNull()
|
|
|
|
|
expect(asCommandDispatch({ type: 'alias' })).toBeNull()
|
|
|
|
|
expect(asCommandDispatch({ type: 'skill', name: 1 })).toBeNull()
|
fix(tui): slash.exec _pending_input commands, tool ANSI, terminal title
Additional TUI fixes discovered in the same audit:
1. /plan slash command was silently lost — process_command() queues the
plan skill invocation onto _pending_input which nobody reads in the
slash worker subprocess. Now intercepted in slash.exec and routed
through command.dispatch with a new 'send' dispatch type.
Same interception added for /retry, /queue, /steer as safety nets
(these already have correct TUI-local handlers in core.ts, but the
server-side guard prevents regressions if the local handler is
bypassed).
2. Tool results were stripping ANSI escape codes — the messageLine
component used stripAnsi() + plain <Text> for tool role messages,
losing all color/styling from terminal, search_files, etc. Now
uses <Ansi> component (already imported) when ANSI is detected.
3. Terminal tab title now shows model + busy status via useTerminalTitle
hook from @hermes/ink (was never used). Users can identify Hermes
tabs and see at a glance whether the agent is busy or ready.
4. Added 'send' variant to CommandDispatchResponse type + asCommandDispatch
parser + createSlashHandler handler for commands that need to inject
a message into the conversation (plan, queue fallback, steer fallback).
2026-04-18 17:52:19 +05:30
|
|
|
expect(asCommandDispatch({ type: 'send' })).toBeNull()
|
|
|
|
|
expect(asCommandDispatch({ type: 'send', message: 42 })).toBeNull()
|
2026-04-16 01:04:35 -05:00
|
|
|
})
|
|
|
|
|
})
|