feat(*): Handle initial thinking step alongside tools

This commit is contained in:
Josh Creek
2025-04-22 18:34:31 +01:00
parent 96b212b63c
commit fa69411829
2 changed files with 21 additions and 17 deletions
+8 -2
View File
@@ -37,7 +37,13 @@
submitting = true;
successMsg = '';
errorMsg = '';
toolEvents = [];
const THINKING_EVENT = { tool: 'thinking', time: new Date().toISOString() };
function ensureThinkingStep(events) {
// Remove any existing 'thinking' event
const filtered = events.filter(e => e.tool !== 'thinking');
return [THINKING_EVENT, ...filtered];
}
toolEvents = [THINKING_EVENT];
// Generate a unique roomId for this submission
roomId = crypto.randomUUID();
@@ -47,7 +53,7 @@
ws.onmessage = (event) => {
try {
const data = JSON.parse(event.data);
toolEvents = [...toolEvents, data];
toolEvents = ensureThinkingStep([...toolEvents, data]);
} catch {}
};