fix(webui): keep reasoning scoped to the current user turn
The post-hoc reasoning fix allowed late reasoning frames to attach back to the nearest assistant message, but the scan crossed a newer user message. That made the next turn's Thinking bubble render above the previous assistant reply. Treat the latest user message as a hard boundary: reasoning after it must start a new assistant placeholder and can no longer attach to earlier assistant turns. Add a regression covering previous assistant -> new user -> reasoning_delta. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -30,6 +30,9 @@ interface StreamBuffer {
|
||||
function attachReasoningChunk(prev: UIMessage[], chunk: string): UIMessage[] {
|
||||
for (let i = prev.length - 1; i >= 0; i -= 1) {
|
||||
const candidate = prev[i];
|
||||
// A user turn is a hard boundary: reasoning after it belongs to the new
|
||||
// assistant turn, never to an earlier assistant reply.
|
||||
if (candidate.role === "user") break;
|
||||
if (candidate.role !== "assistant" || candidate.kind === "trace") continue;
|
||||
const hasAnswer = candidate.content.length > 0;
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user