Merge pull request #96 from langchain-ai/brace/fix-interrupt-no-msgs

fix: Rendering interrupts when there are no ai/tool messages
This commit is contained in:
Brace Sproul
2025-04-08 12:27:51 -07:00
committed by GitHub
2 changed files with 35 additions and 15 deletions

View File

@@ -200,6 +200,9 @@ export function Thread() {
};
const chatStarted = !!threadId || !!messages.length;
const hasNoAIOrToolMessages = !messages.find(
(m) => m.type === "ai" || m.type === "tool",
);
return (
<div className="flex w-full h-screen overflow-hidden">
@@ -350,6 +353,16 @@ export function Thread() {
/>
),
)}
{/* Special rendering case where there are no AI/tool messages, but there is an interrupt.
We need to render it outside of the messages list, since there are no messages to render */}
{hasNoAIOrToolMessages && !!stream.interrupt && (
<AssistantMessage
key="interrupt-msg"
message={undefined}
isLoading={isLoading}
handleRegenerate={handleRegenerate}
/>
)}
{isLoading && !firstTokenReceived && (
<AssistantMessageLoading />
)}