Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions gui/src/redux/slices/sessionSlice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,45 @@ describe("sessionSlice streamUpdate", () => {
);
expect(newState.history[1].message.id).toBe("mock-uuid-1");
});

it("should not drop later messages in a batch after a <think> block", () => {
const initialState = createInitialState();
// Mirror the production layout: submitEditorAndInitAtIndex appends an
// empty assistant placeholder after the user message, so reasoning is
// attached to that placeholder rather than to the user turn.
initialState.history.push({
message: {
role: "assistant" as const,
content: "",
id: "initial-assistant-message",
},
contextItems: [],
});

const action = {
type: "session/streamUpdate",
payload: [
{
role: "assistant" as const,
content: "<think>Reasoning here.</think>First part.",
},
{
role: "assistant" as const,
content: " Second part.",
},
],
};

const newState = sessionSlice.reducer(initialState, action);

expect(newState.history[1].message.role).toBe("assistant");
expect(newState.history[1].reasoning?.text).toBe("Reasoning here.");

// The second message in the same payload must still be appended.
expect(newState.history[2].message.content).toBe(
"First part. Second part.",
);
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
});

describe("Tool Call With Response", () => {
Expand Down
6 changes: 5 additions & 1 deletion gui/src/redux/slices/sessionSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,11 @@ export const sessionSlice = createSlice({

handleToolCallsInMessage(message, lastItem);

return;
// `continue`, not `return`: this branch has finished handling
// *this* message, but `action.payload` may contain more. A
// `return` here exits the reducer entirely and silently drops
// every remaining message in the batch.
continue;
}
}

Expand Down
Loading