AI Clear Button (#1274)

Adds a button and Cmd:l keybinding to clear the ai message history in
the current block
This commit is contained in:
Sylvie Crowe 2024-11-13 18:00:33 -05:00 committed by GitHub
parent 4d57b5842b
commit 31d0aa114d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -252,6 +252,14 @@ export class WaveAiModel implements ViewModel {
});
return viewTextChildren;
});
this.endIconButtons = atom((get) => {
let clearButton: IconButtonDecl = {
elemtype: "iconbutton",
icon: "delete-left",
click: this.clearMessages.bind(this),
};
return [clearButton];
});
}
dispose() {
@ -387,6 +395,19 @@ export class WaveAiModel implements ViewModel {
sendMessage: this.sendMessage.bind(this),
};
}
async clearMessages() {
await BlockService.SaveWaveAiData(this.blockId, []);
globalStore.set(this.messagesAtom, []);
}
keyDownHandler(waveEvent: WaveKeyboardEvent): boolean {
if (checkKeyPressed(waveEvent, "Cmd:l")) {
this.clearMessages();
return true;
}
return false;
}
}
function makeWaveAiViewModel(blockId): WaveAiModel {