mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 10:03:27 +00:00
Hooks can render custom status (#385)
* Add ctx.ui.setStatus(key, text) API for hooks to display status in footer - Add setStatus to HookUIContext interface - Implement in interactive mode (FooterComponent) - Implement in RPC mode (fire-and-forget) - Add no-op implementations for headless contexts - Multiple statuses displayed on single line, sorted by key - Supports ANSI styling (hooks handle their own colors) * Remove setStatus from changelog for now * Fix hook status API to follow TUI rules - Sanitize status text: replace newlines, tabs, carriage returns with spaces - Truncate combined status line to terminal width using truncateToWidth - Update JSDoc to document sanitization and truncation behavior - Remove unused createHookUIContext method - Add missing setStatus to test mock * Add setStatus to changelog * Use dim ellipsis for hook status truncation for consistency with footer style --------- Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
This commit is contained in:
parent
89db7ed024
commit
9b2aa4a683
10 changed files with 90 additions and 3 deletions
|
|
@ -119,6 +119,17 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
|||
} as RpcHookUIRequest);
|
||||
},
|
||||
|
||||
setStatus(key: string, text: string | undefined): void {
|
||||
// Fire and forget - no response needed
|
||||
output({
|
||||
type: "hook_ui_request",
|
||||
id: crypto.randomUUID(),
|
||||
method: "setStatus",
|
||||
statusKey: key,
|
||||
statusText: text,
|
||||
} as RpcHookUIRequest);
|
||||
},
|
||||
|
||||
async custom() {
|
||||
// Custom UI not supported in RPC mode
|
||||
return undefined as never;
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ export type RpcHookUIRequest =
|
|||
message: string;
|
||||
notifyType?: "info" | "warning" | "error";
|
||||
}
|
||||
| { type: "hook_ui_request"; id: string; method: "setStatus"; statusKey: string; statusText: string | undefined }
|
||||
| { type: "hook_ui_request"; id: string; method: "set_editor_text"; text: string };
|
||||
|
||||
// ============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue