Skip to content

Commit 5a55fd4

Browse files
author
Hylke Sijbesma
committed
fix: render interrupt after tool result
Fix GenericInterruptView not rendering after tool result followed by interrupt Previously, the GenericInterruptView failed to render when an interrupt occurred immediately after a tool result message.
1 parent 89e58cf commit 5a55fd4

File tree

1 file changed

+67
-54
lines changed
  • src/components/thread/messages

1 file changed

+67
-54
lines changed

src/components/thread/messages/ai.tsx

Lines changed: 67 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -114,64 +114,77 @@ export function AssistantMessage({
114114

115115
return (
116116
<div className="group mr-auto flex items-start gap-2">
117-
{isToolResult ? (
118-
<ToolResult message={message} />
119-
) : (
120-
<div className="flex flex-col gap-2">
121-
{contentString.length > 0 && (
122-
<div className="py-1">
123-
<MarkdownText>{contentString}</MarkdownText>
124-
</div>
125-
)}
117+
<div className="flex flex-col gap-2">
118+
{isToolResult ? (
119+
<>
120+
<ToolResult message={message} />
121+
{isAgentInboxInterruptSchema(threadInterrupt?.value) &&
122+
(isLastMessage || hasNoAIOrToolMessages) && (
123+
<ThreadView interrupt={threadInterrupt.value} />
124+
)}
125+
{threadInterrupt?.value &&
126+
!isAgentInboxInterruptSchema(threadInterrupt.value) &&
127+
isLastMessage ? (
128+
<GenericInterruptView interrupt={threadInterrupt.value} />
129+
) : null}
130+
</>
131+
) : (
132+
<>
133+
{contentString.length > 0 && (
134+
<div className="py-1">
135+
<MarkdownText>{contentString}</MarkdownText>
136+
</div>
137+
)}
126138

127-
{!hideToolCalls && (
128-
<>
129-
{(hasToolCalls && toolCallsHaveContents && (
130-
<ToolCalls toolCalls={message.tool_calls} />
131-
)) ||
132-
(hasAnthropicToolCalls && (
133-
<ToolCalls toolCalls={anthropicStreamedToolCalls} />
139+
{!hideToolCalls && (
140+
<>
141+
{(hasToolCalls && toolCallsHaveContents && (
142+
<ToolCalls toolCalls={message.tool_calls} />
134143
)) ||
135-
(hasToolCalls && <ToolCalls toolCalls={message.tool_calls} />)}
136-
</>
137-
)}
138-
139-
{message && (
140-
<CustomComponent
141-
message={message}
142-
thread={thread}
143-
/>
144-
)}
145-
{isAgentInboxInterruptSchema(threadInterrupt?.value) &&
146-
(isLastMessage || hasNoAIOrToolMessages) && (
147-
<ThreadView interrupt={threadInterrupt.value} />
144+
(hasAnthropicToolCalls && (
145+
<ToolCalls toolCalls={anthropicStreamedToolCalls} />
146+
)) ||
147+
(hasToolCalls && <ToolCalls toolCalls={message.tool_calls} />)}
148+
</>
148149
)}
149-
{threadInterrupt?.value &&
150-
!isAgentInboxInterruptSchema(threadInterrupt.value) &&
151-
isLastMessage ? (
152-
<GenericInterruptView interrupt={threadInterrupt.value} />
153-
) : null}
154-
<div
155-
className={cn(
156-
"mr-auto flex items-center gap-2 transition-opacity",
157-
"opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",
150+
151+
{message && (
152+
<CustomComponent
153+
message={message}
154+
thread={thread}
155+
/>
158156
)}
159-
>
160-
<BranchSwitcher
161-
branch={meta?.branch}
162-
branchOptions={meta?.branchOptions}
163-
onSelect={(branch) => thread.setBranch(branch)}
164-
isLoading={isLoading}
165-
/>
166-
<CommandBar
167-
content={contentString}
168-
isLoading={isLoading}
169-
isAiMessage={true}
170-
handleRegenerate={() => handleRegenerate(parentCheckpoint)}
171-
/>
172-
</div>
173-
</div>
174-
)}
157+
{isAgentInboxInterruptSchema(threadInterrupt?.value) &&
158+
(isLastMessage || hasNoAIOrToolMessages) && (
159+
<ThreadView interrupt={threadInterrupt.value} />
160+
)}
161+
{threadInterrupt?.value &&
162+
!isAgentInboxInterruptSchema(threadInterrupt.value) &&
163+
isLastMessage ? (
164+
<GenericInterruptView interrupt={threadInterrupt.value} />
165+
) : null}
166+
<div
167+
className={cn(
168+
"mr-auto flex items-center gap-2 transition-opacity",
169+
"opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",
170+
)}
171+
>
172+
<BranchSwitcher
173+
branch={meta?.branch}
174+
branchOptions={meta?.branchOptions}
175+
onSelect={(branch) => thread.setBranch(branch)}
176+
isLoading={isLoading}
177+
/>
178+
<CommandBar
179+
content={contentString}
180+
isLoading={isLoading}
181+
isAiMessage={true}
182+
handleRegenerate={() => handleRegenerate(parentCheckpoint)}
183+
/>
184+
</div>
185+
</>
186+
)}
187+
</div>
175188
</div>
176189
);
177190
}

0 commit comments

Comments
 (0)