From 5f9cfcbcf3312270ce7cd35b268ca67fd3806422 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 17 Feb 2026 16:11:34 +0900 Subject: [PATCH] feat(cli-run): show agent/model header and suppress toast output --- src/cli/run/event-handlers.ts | 33 ++++++++++++++++++++++----------- src/cli/run/event-state.ts | 6 ++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/cli/run/event-handlers.ts b/src/cli/run/event-handlers.ts index 13cfdd6d..b39cce30 100644 --- a/src/cli/run/event-handlers.ts +++ b/src/cli/run/event-handlers.ts @@ -141,6 +141,22 @@ export function handleMessageUpdated(ctx: RunContext, payload: EventPayload, sta state.hasReceivedMeaningfulWork = true state.messageCount++ state.lastPartText = "" + + const agent = props?.info?.agent ?? null + const model = props?.info?.modelID ?? null + if (agent !== state.currentAgent || model !== state.currentModel) { + state.currentAgent = agent + state.currentModel = model + printAgentHeader(agent, model) + } +} + +function printAgentHeader(agent: string | null, model: string | null): void { + if (!agent && !model) return + const agentLabel = agent ? pc.bold(pc.magenta(agent)) : "" + const modelLabel = model ? pc.dim(model) : "" + const separator = agent && model ? " " : "" + process.stdout.write(`\n${agentLabel}${separator}${modelLabel}\n`) } export function handleToolExecute(ctx: RunContext, payload: EventPayload, state: EventState): void { @@ -193,19 +209,14 @@ export function handleTuiToast(_ctx: RunContext, payload: EventPayload, state: E if (payload.type !== "tui.toast.show") return const props = payload.properties as TuiToastShowProps | undefined - const title = props?.title ? `${props.title}: ` : "" - const message = props?.message?.trim() const variant = props?.variant ?? "info" - if (!message) return - if (variant === "error") { - state.mainSessionError = true - state.lastError = `${title}${message}` - console.error(pc.red(`\n[tui.toast.error] ${state.lastError}`)) - return + const title = props?.title ? `${props.title}: ` : "" + const message = props?.message?.trim() + if (message) { + state.mainSessionError = true + state.lastError = `${title}${message}` + } } - - const colorize = variant === "warning" ? pc.yellow : pc.dim - console.log(colorize(`[toast:${variant}] ${title}${message}`)) } diff --git a/src/cli/run/event-state.ts b/src/cli/run/event-state.ts index db49f565..b7dde245 100644 --- a/src/cli/run/event-state.ts +++ b/src/cli/run/event-state.ts @@ -9,6 +9,10 @@ export interface EventState { hasReceivedMeaningfulWork: boolean /** Count of assistant messages for the main session */ messageCount: number + /** Current agent name from the latest assistant message */ + currentAgent: string | null + /** Current model ID from the latest assistant message */ + currentModel: string | null } export function createEventState(): EventState { @@ -21,5 +25,7 @@ export function createEventState(): EventState { currentTool: null, hasReceivedMeaningfulWork: false, messageCount: 0, + currentAgent: null, + currentModel: null, } }