fix(webui): stabilize live thread rendering and navigation

This commit is contained in:
Xubin Ren
2026-05-13 16:39:07 +00:00
parent 6a4ed255de
commit 5d7f3f2751
14 changed files with 876 additions and 77 deletions
+30
View File
@@ -0,0 +1,30 @@
export function formatToolCallTrace(call: unknown): string | null {
if (!call || typeof call !== "object") return null;
const item = call as {
name?: unknown;
arguments?: unknown;
function?: { name?: unknown; arguments?: unknown };
};
const name =
typeof item.function?.name === "string"
? item.function.name
: typeof item.name === "string"
? item.name
: "";
if (!name) return null;
const args = item.function?.arguments ?? item.arguments;
if (typeof args === "string" && args.trim()) return `${name}(${args})`;
if (args && typeof args === "object") return `${name}(${JSON.stringify(args)})`;
return `${name}()`;
}
export function toolTraceLinesFromEvents(events: unknown): string[] {
if (!Array.isArray(events)) return [];
return events
.filter((event) => {
if (!event || typeof event !== "object") return false;
return (event as { phase?: unknown }).phase === "start";
})
.map(formatToolCallTrace)
.filter((trace): trace is string => !!trace);
}
+13
View File
@@ -53,6 +53,18 @@ export interface UIMessage {
reasoningStreaming?: boolean;
}
export interface ToolProgressEvent {
version?: number;
phase?: "start" | "end" | "error" | string;
call_id?: string;
name?: string;
arguments?: unknown;
result?: unknown;
error?: unknown;
files?: unknown[];
embeds?: unknown[];
}
export interface ChatSummary {
/** Server-side session key, e.g. ``websocket:abcd-...``. */
key: string;
@@ -146,6 +158,7 @@ export type InboundEvent =
reply_to?: string;
media?: string[];
media_urls?: Array<{ url: string; name?: string }>;
tool_events?: ToolProgressEvent[];
/** Present when the frame is an agent breadcrumb (e.g. tool hint,
* generic progress line) rather than a conversational reply. */
kind?: "tool_hint" | "progress" | "reasoning";