Elffuss BraidHub

kikocis/continue public

feat: adapt duplicate toolCallId (#7733)

Changeset7b12c3a0cd8649375d882613166608a5174baba7952c26abdf1b18bf010affe5
Authorxiaohuanxiong3 <39520495+xiaohuanxiong3@users.noreply.github.com> · 2025-09-23 05:31 +08:00
CommitterGitHub <noreply@github.com> · 2025-09-22 14:31 -07:00
Parentsaca660a1e721

Browse the files at this changeset

3 files changed

modified gui/src/redux/selectors/selectToolCalls.ts +3 −1
@@ -50,7 +50,9 @@
5050 (_store: RootState, toolCallId: string) => toolCallId,
5151 ],
5252 (applyStates, toolCallId) => {
53- return applyStates.states.find((state) => state.toolCallId === toolCallId);
53+ return applyStates.states.findLast(
54+ (state) => state.toolCallId === toolCallId,
55+ );
5456 },
5557 );
5658
modified gui/src/redux/thunks/streamResponseAfterToolCall.ts +1 −1
@@ -69,7 +69,7 @@
6969
7070 // Check if we should continue streaming based on tool call completion
7171 const history = getState().session.history;
72- const assistantMessage = history.find(
72+ const assistantMessage = history.findLast(
7373 (item) =>
7474 item.message.role === "assistant" &&
7575 item.toolCallStates?.some((tc) => tc.toolCallId === toolCallId),
modified gui/src/redux/util/index.ts +3 −2
@@ -66,7 +66,8 @@
6666 chatHistory: RootState["session"]["history"],
6767 toolCallId: string,
6868 ): ToolCallState | undefined {
69- for (const item of chatHistory) {
69+ for (let i = chatHistory.length - 1; i >= 0; i--) {
70+ const item = chatHistory[i];
7071 if (item.toolCallStates) {
7172 const toolCallState = item.toolCallStates.find(
7273 (state) => state.toolCallId === toolCallId,
@@ -84,7 +85,7 @@
8485 chatHistory: RootState["session"]["history"],
8586 toolCallId: string,
8687 ): ChatHistoryItemWithMessageId | undefined {
87- return chatHistory.find(
88+ return chatHistory.findLast(
8889 (item) =>
8990 item.message.role === "tool" && item.message.toolCallId === toolCallId,
9091 );