fix(tui): align slash command parsing and handlers

This commit is contained in:
William Valentin
2026-02-16 12:22:40 -08:00
parent fd7ad7bfb0
commit 1d16cd54e6
4 changed files with 176 additions and 0 deletions
+13
View File
@@ -13,6 +13,7 @@ export type Command =
| { type: 'transfer'; target: string }
| { type: 'pair'; action?: 'generate' | 'list' | 'revoke'; args?: string }
| { type: 'queue'; action?: 'show' | 'set' | 'reset'; args?: string }
| { type: 'elevate'; args?: string }
| { type: 'message'; content: string };
export function parseCommand(input: string): Command | null {
@@ -130,6 +131,15 @@ export function parseCommand(input: string): Command | null {
return { type: 'queue', action: 'set', args };
}
// Elevate
if (trimmed === '/elevate') {
return { type: 'elevate' };
}
if (trimmed.startsWith('/elevate ')) {
const args = trimmed.slice('/elevate '.length).trim();
return { type: 'elevate', args };
}
// Regular message
return { type: 'message', content: trimmed };
}
@@ -148,6 +158,7 @@ Commands:
/queue Show queue policy for this session
/queue set <k> <v> Set queue override (mode/cap/overflow/debounce_ms/summarize_overflow)
/queue reset Clear queue overrides for this session
/elevate [args] Show or manage elevated mode
/reset, /clear, /new Clear conversation history
/compact Compact conversation history
/usage Show token usage and estimated cost
@@ -180,6 +191,7 @@ export const SLASH_COMMANDS = [
'/login',
'/pair',
'/queue',
'/elevate',
'/transfer',
'/quit',
'/exit',
@@ -202,6 +214,7 @@ export const COMMAND_TOOLTIPS: Record<string, string> = {
'/login': 'Authenticate with GitHub/OpenAI/Anthropic (OAuth/token or API key) or Z.AI (API key store)',
'/pair': 'Generate/list/revoke DM pairing codes',
'/queue': 'Show or update per-session queue policy',
'/elevate': 'Show or manage elevated mode',
'/transfer': 'Transfer session to another frontend',
'/quit': 'Exit TUI',
'/exit': 'Exit TUI',