Skip to content

Commit 47d7d49

Browse files
committed
fix
1 parent a72d491 commit 47d7d49

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/xl-ai/src/components/BlockNoteAIContext.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,14 @@ export function BlockNoteAIContextProvider(
9999
}
100100
ret = await llm.markdown.call(editor, { model, ...options });
101101
}
102-
// if the menu has been closed already, don't set it to done
103-
if (aiMenuBlockID !== undefined) {
104-
setAIResponseStatus("done");
105-
}
102+
setAIResponseStatus((old) => {
103+
// if the menu has been closed already, it's probably set to "initial" and not "generating" anymore,
104+
// in that case, don't set it to "done"
105+
if (old === "generating") {
106+
return "done";
107+
}
108+
return old;
109+
});
106110
return ret;
107111
} catch (e) {
108112
setAIResponseStatus("initial");
@@ -111,7 +115,7 @@ export function BlockNoteAIContextProvider(
111115
console.error(e);
112116
}
113117
},
114-
[model, dataFormat, stream, editor, aiMenuBlockID]
118+
[model, dataFormat, stream, editor]
115119
);
116120

117121
// TODO: Revisit - this pattern might be a bit iffy

0 commit comments

Comments
 (0)