From a90e747f926f2b18b1e525a34f6b3b74aa2d59b3 Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Thu, 17 Oct 2024 12:53:49 -0400 Subject: [PATCH] Fix runaway name appending on the default AI preset (#1051) Shallow copy the presets when updating `display:name` so that the appending of the model name for the default preset doesn't accumulate every time the tab refreshes. closes #1040 --- frontend/app/view/waveai/waveai.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/frontend/app/view/waveai/waveai.tsx b/frontend/app/view/waveai/waveai.tsx index 0c170d645..db6bb67ef 100644 --- a/frontend/app/view/waveai/waveai.tsx +++ b/frontend/app/view/waveai/waveai.tsx @@ -81,12 +81,12 @@ export class WaveAiModel implements ViewModel { .filter(([k]) => k.startsWith("ai@")) .map(([k, v]) => { const aiPresetKeys = Object.keys(v).filter((k) => k.startsWith("ai:")); - console.log(aiPresetKeys); - v["display:name"] = + const newV = { ...v }; + newV["display:name"] = aiPresetKeys.length == 1 && aiPresetKeys.includes("ai:*") - ? `${v["display:name"] ?? "Default"} (${settings["ai:model"]})` - : v["display:name"]; - return [k, v]; + ? `${newV["display:name"] ?? "Default"} (${settings["ai:model"]})` + : newV["display:name"]; + return [k, newV]; }) ); }); @@ -109,7 +109,7 @@ export class WaveAiModel implements ViewModel { messages.pop(); set(this.messagesAtom, [...messages]); }); - this.simulateAssistantResponseAtom = atom(null, async (get, set, userMessage: ChatMessageType) => { + this.simulateAssistantResponseAtom = atom(null, async (_, set, userMessage: ChatMessageType) => { // unused at the moment. can replace the temp() function in the future const typingMessage: ChatMessageType = { id: crypto.randomUUID(), @@ -213,7 +213,7 @@ export class WaveAiModel implements ViewModel { } async fetchAiData(): Promise> { - const { data, fileInfo } = await fetchWaveFile(this.blockId, "aidata"); + const { data } = await fetchWaveFile(this.blockId, "aidata"); if (!data) { return []; } @@ -318,7 +318,6 @@ export class WaveAiModel implements ViewModel { content: errMsg, }; updatedHist.push(errorPrompt); - console.log(updatedHist); await BlockService.SaveWaveAiData(blockId, updatedHist); } setLocked(false);