Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Composer: recheck busy when a delete is confirmed

erywim990e0749e116
diff --git a/src/components/Composer.slash.test.ts b/src/components/Composer.slash.test.ts
index 52894e2ae2..5a5156ec21 100644
--- a/src/components/Composer.slash.test.ts
+++ b/src/components/Composer.slash.test.ts
@@ -203,6 +203,18 @@ describe("the / menu in the composer", () => {
expect(document.body.querySelector('[role="alertdialog"]')).toBeNull();
});
+ it("rechecks busy when the delete is confirmed", () => {
+ const input = fill("/delete");
+ press(input, "Enter");
+ flushSync(() => root.render(createElement(Composer, { bot: { ...bot, busy: true } })));
+ const dialog = document.body.querySelector('[role="alertdialog"]')!;
+ const confirm = [...dialog.querySelectorAll("button")].find((button) => button.textContent === "Delete thread")!;
+ flushSync(() => confirm.click());
+ expect(dispatch).toHaveBeenCalledWith({ type: "error", message: "Stop this conversation before deleting it." });
+ expect(dispatch.mock.calls.some(([action]) => action.type === "deleteTask")).toBe(false);
+ expect(container.querySelector("textarea")!.value).toBe("/delete");
+ });
+
it("refuses /archive while a turn runs, and keeps the command in place", () => {
flushSync(() => root.render(createElement(Composer, { bot: { ...bot, busy: true } })));
const input = fill("/archive");
diff --git a/src/components/use-composer-thread-command.tsx b/src/components/use-composer-thread-command.tsx
index 90049d54bc..3265cc9877 100644
--- a/src/components/use-composer-thread-command.tsx
+++ b/src/components/use-composer-thread-command.tsx
@@ -55,6 +55,7 @@ export function useComposerThreadCommand({ text, botId, threadId, mainThreadId,
const confirmDelete = () => {
if (!botId) return;
setConfirming(false);
+ if (busy) { dispatch({ type: "error", message: t("composer.command.deleteBusy") }); return; }
onCleared();
nextThread();
dispatch({ type: "deleteTask", botId, threadId });