We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4139e3e commit bca96b7Copy full SHA for bca96b7
src/components/ai-assistant/AITeachingAssistant.tsx
@@ -154,8 +154,13 @@ export default function AITeachingAssistant({
154
} catch (err) {
155
console.error('Chat error:', err);
156
setError(err instanceof Error ? err.message : 'An error occurred');
157
- // Remove the empty assistant message if there was an error
158
- setMessages((prev) => prev.filter((msg) => msg.content !== ''));
+ // Remove the last assistant message if there was an error
+ setMessages((prev) => {
159
+ if (prev.length > 0 && prev[prev.length - 1].role === 'assistant') {
160
+ return prev.slice(0, -1);
161
+ }
162
+ return prev;
163
+ });
164
} finally {
165
setIsLoading(false);
166
}
0 commit comments