fix(webui): tighten turn completion handling
Keep the new turn-end signal scoped to WebSocket clients, preserve pending tool-call state across trailing tool result rows, and drop the accidental npm lockfile from the Bun-based WebUI. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
Xubin Ren
co-authored by
Cursor
parent
be83525f99
commit
96da6d8190
@@ -84,7 +84,7 @@ export function useSessionHistory(key: string | null): {
|
||||
messages: UIMessage[];
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
/** ``true`` when the last persisted message has ``tool_calls`` but no
|
||||
/** ``true`` when the last persisted assistant turn has ``tool_calls`` but no
|
||||
* final text yet — the model was still processing when the page loaded. */
|
||||
hasPendingToolCalls: boolean;
|
||||
} {
|
||||
@@ -153,9 +153,11 @@ export function useSessionHistory(key: string | null): {
|
||||
},
|
||||
];
|
||||
});
|
||||
// Check if the last persisted message has tool_calls but no final
|
||||
// text yet — the model was still processing when the page loaded.
|
||||
const lastRaw = body.messages[body.messages.length - 1];
|
||||
// Tool result rows can trail the assistant tool-call row while the turn
|
||||
// is still running, so check the last conversational row.
|
||||
const lastRaw = [...body.messages]
|
||||
.reverse()
|
||||
.find((m) => m.role === "user" || m.role === "assistant");
|
||||
const hasPending =
|
||||
lastRaw?.role === "assistant" &&
|
||||
Array.isArray(lastRaw.tool_calls) &&
|
||||
|
||||
Reference in New Issue
Block a user