Skip to content

The agent that grows with you

fix(tui): serve Ink /reload-mcp and /config from the shared gateway

Tekniumb8c5fa9cd27f
diff --git a/ui-tui/src/__tests__/canonicalSlashCommands.test.ts b/ui-tui/src/__tests__/canonicalSlashCommands.test.ts
index 5c685477405..a5ffd67f33d 100644
--- a/ui-tui/src/__tests__/canonicalSlashCommands.test.ts
+++ b/ui-tui/src/__tests__/canonicalSlashCommands.test.ts
@@ -67,12 +67,26 @@ function harness() {
}
}
+ if (method === 'reload.mcp') {
+ return params.confirm
+ ? { status: 'reloaded', message: 'MCP servers reconciled (no server changes)' }
+ : { status: 'confirm_required', message: 'Reloading MCP refreshes every chat of this profile.' }
+ }
+
+ if (method === 'process.stop') {
+ return { killed: 0 }
+ }
+
if (method === 'slash.exec' && /^voice( |$)/.test(params.command)) {
voiceMode = params.command === 'voice on' ? 'voice_only' : params.command === 'voice off' ? 'off' : voiceMode
return { type: 'exec', output: `voice: ${voiceMode}` }
}
+ if (method === 'config.get' && params.key === 'full') {
+ return { config: { display: { skin: 'ares', streaming: true }, voice: { record_key: 'ctrl+b' } } }
+ }
+
if (method === 'config.get' && params.key === 'voice') {
return { value: voiceMode }
}
@@ -258,29 +272,27 @@ it('/status reads through the gateway', async () => {
expect(request.mock.calls.map(([method]) => method)).not.toContain('session.status')
})
-it('/stop is session-scoped; process-global /reload-mcp refuses on the shared gateway', async () => {
+it('/stop is session-scoped; /reload-mcp runs the owner\'s session-scoped reload.mcp (T10)', async () => {
const { request, slash, sys } = harness()
- for (const cmd of ['/stop', '/reload-mcp now']) {
+ for (const cmd of ['/stop', '/reload-mcp', '/reload-mcp now', '/reload-mcp always']) {
slash(cmd)
+ await flush()
}
- await flush()
-
// dokterdok N2: a sessionless process.stop was the owner-wide kill_all.
expect(request).toHaveBeenCalledWith('process.stop', { session_id: 'owner' })
-
- const methods = request.mock.calls.map(([method]) => method)
-
- for (const method of ['reload.mcp']) {
- expect(methods).not.toContain(method)
- }
+ // The owner's reload reconciles only this profile's servers; `always` has no owner-side
+ // opt-out (the owner always asks), so it confirms once like `now`.
+ expect(request).toHaveBeenCalledWith('reload.mcp', { session_id: 'owner' })
+ expect(request.mock.calls.filter(([m, p]) => m === 'reload.mcp' && p.confirm === true)).toHaveLength(2)
+ expect(request.mock.calls.every(([m, p]) => m !== 'reload.mcp' || !('always' in p))).toBe(true)
const notices = sys.mock.calls.map(([text]) => String(text))
- for (const name of ['reload-mcp']) {
- expect(notices).toContain(`/${name} is not available on the shared gateway yet`)
- }
+ expect(notices.some(line => /not available/.test(line))).toBe(false)
+ expect(notices).toContain('Reloading MCP refreshes every chat of this profile.')
+ expect(notices).toContain('MCP servers reconciled (no server changes)')
})
it('/reasoning --global is the owner\'s /reasoning handler behind config.set; /skin reads still work', async () => {
@@ -391,3 +403,19 @@ it('session /reasoning <level> is the owner\'s fenced reasoning mutation (B14);
expect(notices.some(line => /not available/.test(line))).toBe(false)
expect(getUiState().showReasoning).toBe(true)
})
+
+it('/config pages the owner\'s presentation config (config.get full), never slash.exec (T10)', async () => {
+ const { page, request, slash, sys } = harness()
+
+ slash('/config')
+ await flush()
+
+ expect(request).toHaveBeenCalledWith('config.get', { key: 'full', session_id: 'owner' })
+ expect(request.mock.calls.some(([method]) => method === 'slash.exec')).toBe(false)
+ expect(sys.mock.calls.map(([text]) => String(text)).some(line => /not available|unsupported/.test(line))).toBe(false)
+ const [text, title] = page.mock.calls[0]!
+ expect(title).toBe('Config')
+ expect(text).toContain('display:')
+ expect(text).toContain(' skin: ares')
+ expect(text).toContain(' record_key: ctrl+b')
+})
diff --git a/ui-tui/src/__tests__/canonicalUnsupportedCommand.test.ts b/ui-tui/src/__tests__/canonicalUnsupportedCommand.test.ts
index ad244f40d75..b421311c002 100644
--- a/ui-tui/src/__tests__/canonicalUnsupportedCommand.test.ts
+++ b/ui-tui/src/__tests__/canonicalUnsupportedCommand.test.ts
@@ -16,7 +16,7 @@ beforeEach(() => {
})
it.each([
- ['/config', 'config'],
+ ['/snapshot', 'snapshot'],
['/plugins enable foo', 'plugins'],
['/pet toggle', 'pet']
])('%s refused by the shared gateway names the command', async (cmd, name) => {
diff --git a/ui-tui/src/app/slash/commands/core.ts b/ui-tui/src/app/slash/commands/core.ts
index 29350cf4e22..48e1ea66d87 100644
--- a/ui-tui/src/app/slash/commands/core.ts
+++ b/ui-tui/src/app/slash/commands/core.ts
@@ -5,6 +5,7 @@ import { dailyFortune, randomFortune } from '../../../content/fortunes.js'
import { hotkeys } from '../../../content/hotkeys.js'
import { isSectionName, nextDetailsMode, parseDetailsMode, SECTION_NAMES } from '../../../domain/details.js'
import type {
+ ConfigFullResponse,
ConfigGetValueResponse,
ConfigSetResponse,
SessionSaveResponse,
@@ -39,6 +40,14 @@ const saveDisplayPref = (ctx: SlashRunCtx, key: string, value: string) => {
ctx.gateway.rpc<ConfigSetResponse>('config.set', { key, value, ...session }).catch(() => {})
}
+/** `/config`: the projection as indented `key: value` lines (YAML-shaped, like the classic CLI). */
+const configLines = (value: Record<string, unknown>, indent: string): string[] =>
+ Object.entries(value).flatMap(([key, v]) =>
+ v && typeof v === 'object' && !Array.isArray(v)
+ ? [`${indent}${key}:`, ...configLines(v as Record<string, unknown>, `${indent} `)]
+ : [`${indent}${key}: ${Array.isArray(v) ? JSON.stringify(v) : String(v)}`]
+ )
+
const flagFromArg = (arg: string, current: boolean): boolean | null => {
if (!arg) {
return !current
@@ -326,6 +335,34 @@ export const coreCommands: SlashCommand[] = [
}
},
+ {
+ help: 'show the presentation settings the gateway serves for this profile',
+ name: 'config',
+ run: (_arg, ctx, cmd) => {
+ // Main's sidecar ran the classic CLI's /config in its slash worker; keep that there.
+ if (!ctx.gateway.gw?.isCanonical) {
+ return void ctx.gateway.gw
+ .request<SlashExecResponse>('slash.exec', { command: cmd.slice(1), session_id: ctx.sid })
+ .then(r => !ctx.stale() && ctx.transcript.page(r?.output || '{}', 'Config'))
+ .catch(ctx.guardedErr)
+ }
+
+ // T10: the owner's config.get `full` is the redacted presentation projection (display,
+ // approvals, voice keybinding) — never provider/MCP/terminal config, which can hold secrets.
+ // The client renders it; the classic CLI's full dump stays `hermes config`.
+ ctx.gateway
+ .rpc<ConfigFullResponse>('config.get', { key: 'full', ...(ctx.sid ? { session_id: ctx.sid } : {}) })
+ .then(
+ ctx.guarded<ConfigFullResponse>(r => {
+ const lines = configLines(r.config ?? {}, '')
+
+ ctx.transcript.page(lines.length ? lines.join('\n') : '{}', 'Config')
+ })
+ )
+ .catch(ctx.guardedErr)
+ }
+ },
+
{
aliases: ['detail'],
help: 'control agent detail visibility (global or per-section)',
diff --git a/ui-tui/src/app/slash/commands/ops.ts b/ui-tui/src/app/slash/commands/ops.ts
index 61dc60e312d..462f5237d1a 100644
--- a/ui-tui/src/app/slash/commands/ops.ts
+++ b/ui-tui/src/app/slash/commands/ops.ts
@@ -102,16 +102,31 @@ export const opsCommands: SlashCommand[] = [
help: 'reload MCP servers in the live session (warns about prompt cache invalidation)',
name: 'reload-mcp',
run: (arg, ctx) => {
- // A canonical session's MCP servers are frozen with its launch policy; the shared owner's
- // pool is every chat's, so there is no per-session reload verb yet.
+ const a = (arg || '').trim().toLowerCase()
+
+ // The shared owner serves a session-scoped reload.mcp: it reconciles only this profile's
+ // servers and moves this session to a new policy generation when idle (session_ancillary.py).
+ // It has no persistent opt-out (`always`), so `always` confirms this once like `now`.
if (ctx.gateway.gw?.isCanonical) {
- return ctx.transcript.sys(t('canonical.controls.notAvailable', 'reload-mcp'))
+ const confirm = ['always', 'approve', 'now', 'once', 'yes'].includes(a)
+
+ return void ctx.gateway
+ .rpc<ReloadMcpResponse>('reload.mcp', { session_id: ctx.sid, ...(confirm ? { confirm: true } : {}) })
+ .then(
+ ctx.guarded<ReloadMcpResponse>(r =>
+ ctx.transcript.sys(
+ r.message ||
+ (r.status === 'confirm_required'
+ ? t('slashCmd.ops.reloadMcp.confirmRequired')
+ : t('slashCmd.ops.reloadMcp.reloaded'))
+ )
+ )
+ )
+ .catch(ctx.guardedErr)
}
// Parse arg: `now` / `always` skip the confirmation gate.
// `always` additionally persists approvals.mcp_reload_confirm=false.
- const a = (arg || '').trim().toLowerCase()
-
const params: { session_id: string | null; confirm?: boolean; always?: boolean } = {
session_id: ctx.sid
}
diff --git a/website/docs/developer-guide/gateway-command-parity.md b/website/docs/developer-guide/gateway-command-parity.md
index 91713eb1ccc..bf395ed3bd8 100644
--- a/website/docs/developer-guide/gateway-command-parity.md
+++ b/website/docs/developer-guide/gateway-command-parity.md
@@ -46,7 +46,7 @@ handler does; `client-local (cli_only)` commands are terminal/UI features of a c
| `/codex-runtime` (/codex_runtime) | control | HermesCLI._handle_codex_runtime | slash.exec | slash.exec | slash.exec | per-session setting (gateway handler) |
| `/commands` | read | messaging-only: unknown command | slash.exec | action: help | slash.exec | messaging-only |
| `/compress` (/compact) | refused | HermesCLI._manual_compress | canonical route | action: compress | session.mutate compress | |
-| `/config` | refused | HermesCLI.show_config | slash.exec: refused | unavailable: terminal | slash.exec: refused | client-local (cli_only) |
+| `/config` | refused | HermesCLI.show_config | canonical route | unavailable: terminal | slash.exec: refused | client-local (cli_only) |
| `/context` (/ctx) | read | HermesCLI._show_context_breakdown | slash.exec | slash.exec | slash.exec | TUI session: main's live /context with the category table |
| `/copy` | refused | HermesCLI._handle_copy_command | local | unavailable: terminal | slash.exec: refused | client-local (cli_only) |
| `/cron` | refused | HermesCLI._handle_cron_command | slash.exec | unavailable: terminal | slash.exec: refused | TUI session: bare `/cron` and `/cron list [--all]` read the profile's jobs; client-local (cli_only) |
@@ -96,7 +96,7 @@ handler does; `client-local (cli_only)` commands are terminal/UI features of a c
| `/redraw` | refused | HermesCLI._cmd_redraw | local | unavailable: terminal | slash.exec: refused | client-local (cli_only) |
| `/refine` | control | HermesCLI._handle_refine_command | slash.exec | slash.exec | slash.exec | |
| `/reload` | refused | HermesCLI._cmd_reload | canonical route | unavailable: terminal | slash.exec: refused | client-local (cli_only) |
-| `/reload-mcp` (/reload_mcp) | refused | HermesCLI._confirm_and_reload_mcp | refused: not available yet | unavailable: advanced | slash.exec: refused | |
+| `/reload-mcp` (/reload_mcp) | refused | HermesCLI._confirm_and_reload_mcp | canonical route | unavailable: advanced | slash.exec: refused | |
| `/reload-skills` (/reload_skills) | refused | HermesCLI._cmd_reload_skills | commands.catalog, skills.reload | unavailable: advanced | slash.exec: refused | |
| `/restart` | refused | messaging-only: unknown command | slash.exec: refused | unavailable: terminal | slash.exec: refused | messaging-only |
| `/resume` | refused | HermesCLI._handle_resume_command | local | picker: session | slash.exec: refused | switches the messaging chat's session; local clients resume by id |