fix(webui): hydrate reasoning and tool traces from history

Live reasoning/tool frames were rendering correctly, but refreshing WebUI
replayed only role/content/media from `/api/sessions/:key/messages`.
Assistant `reasoning_content` / `thinking_blocks` and `tool_calls` were
already persisted by the backend and returned by the history endpoint, but
useSessionHistory discarded them.

Hydrate persisted assistant reasoning into `UIMessage.reasoning` and
reconstruct assistant tool calls as `kind: "trace"` rows so the replayed
thread keeps the same Thinking bubble and Used tools block as the live
stream. Tool result rows remain hidden from the conversation view to avoid
replaying raw tool output as chat text.

Adds regression coverage for both persisted reasoning and historical tool
call trace hydration.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Xubin Ren
2026-05-13 07:33:52 +00:00
co-authored by Cursor
parent 0033a8a185
commit 278affc25e
3 changed files with 149 additions and 5 deletions
+2
View File
@@ -89,6 +89,8 @@ export async function fetchSessionMessages(
content: string;
timestamp?: string;
tool_calls?: unknown;
reasoning_content?: string | null;
thinking_blocks?: unknown;
tool_call_id?: string;
name?: string;
/** Present on ``user`` turns that attached images. Paths have already