Skip to content

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

Composer: a retried send keeps the choice to steer, queue or restart

Kanishak todwale40306e525a4
diff --git a/src/components/Composer.tsx b/src/components/Composer.tsx
index e5a2cb2051..06e9021fa6 100644
--- a/src/components/Composer.tsx
+++ b/src/components/Composer.tsx
@@ -556,13 +556,14 @@ export function Composer({
replyToId: failed.replyToId,
threadId: failed.threadId,
channelMode: failed.channelMode,
+ followUp: failed.followUp,
});
},
};
if (group) {
dispatch({ type: "sendGroup", groupId: group.id, mode: failedMode, ...retry });
} else if (bot) {
- dispatch({ type: "send", botId: bot.id, mode: failedMode, ...retry });
+ dispatch({ type: "send", botId: bot.id, mode: failedMode, followUp: failed.followUp, ...retry });
}
};
const send = (followUp: FollowUp | undefined = followUpFor(false)) => {
@@ -590,6 +591,7 @@ export function Composer({
replyToId: replyTo?.id,
threadId,
channelMode: effectiveChannelMode,
+ followUp,
};
if (group) {
dispatch({
diff --git a/src/components/send-key.test.ts b/src/components/send-key.test.ts
index 0780861881..06e7ff6d9b 100644
--- a/src/components/send-key.test.ts
+++ b/src/components/send-key.test.ts
@@ -284,6 +284,26 @@ describe("a message sent while a one-to-one bot works", () => {
expect(sends().slice(-2).map((action) => [action.text, action.followUp])).toEqual([["clicked", "steer"], ["ctrl-clicked", "queue"]]);
});
+ it("keeps the person's choice when a failed send is retried, and again when the retry fails", () => {
+ fixture.instances = [steers];
+ render(createElement(Composer, { bot: working }));
+ const retry = () => [...host.querySelectorAll("button")].find((button) => button.textContent === "Retry")!;
+ type(textarea(), "a new task for later");
+ press(textarea(), { ctrlKey: true });
+ const failed = sends().at(-1);
+ expect(failed.followUp).toBe("queue");
+ type(textarea(), "a newer draft");
+ flushSync(() => failed.onError());
+
+ flushSync(() => retry().click());
+ const retried = sends().at(-1);
+ expect(retried).toMatchObject({ type: "send", sendId: failed.sendId, text: "a new task for later", followUp: "queue" });
+
+ flushSync(() => retried.onError());
+ flushSync(() => retry().click());
+ expect(sends().at(-1)).toMatchObject({ sendId: failed.sendId, followUp: "queue" });
+ });
+
it("follows the setting: Enter queues and Ctrl/⌘ steers once the person picks queue", () => {
fixture.instances = [steers];
setFollowUpDefault("queue");
diff --git a/src/lib/drafts.test.ts b/src/lib/drafts.test.ts
index 094879ac69..d1e0749ce8 100644
--- a/src/lib/drafts.test.ts
+++ b/src/lib/drafts.test.ts
@@ -107,6 +107,14 @@ describe("channel draft delivery mode", () => {
expect(failedComposerSends(draftId)[0]?.requestText).toBe(requestText);
});
+ it("keeps a failed outbox send's choice of how it meets the running turn", () => {
+ const draftId = "bot:follow-up-outbox:task";
+ const revision = draftRevision(draftId);
+ markDraftEdited(draftId);
+ expect(recoverFailedComposerSend({ draftId, revision, sendId: "follow-up-outbox-send", threadId: "task", text: "later", requestText: "later", attachments: [], followUp: "queue" })).toBe("outbox");
+ expect(failedComposerSends(draftId)[0]?.followUp).toBe("queue");
+ });
+
it("restores goal intent on remount and from persisted storage after restart", () => {
const store = memoryStorage();
Object.defineProperty(globalThis, "localStorage", { configurable: true, value: store });
diff --git a/src/lib/drafts.ts b/src/lib/drafts.ts
index 8c0a37376d..b3898a7c0e 100644
--- a/src/lib/drafts.ts
+++ b/src/lib/drafts.ts
@@ -1,4 +1,5 @@
import { useCallback, useEffect, useState, useSyncExternalStore, type SetStateAction } from "react";
+import type { FollowUp } from "../../shared/follow-up.js";
import { isAttachment, type Attachment } from "./composer-attachments.js";
const KEY = "omb-drafts";
@@ -23,6 +24,7 @@ export interface FailedComposerSend {
replyToId?: string;
threadId: string;
channelMode?: "chat" | "goal";
+ followUp?: FollowUp;
}
type FailedComposerSendInput = Omit<FailedComposerSend, "id">;
export interface ComposerSendSnapshot extends FailedComposerSendInput {
@@ -425,6 +427,7 @@ export function recoverFailedComposerSend(sent: ComposerSendSnapshot): "restored
replyToId: sent.replyToId,
threadId: sent.threadId,
channelMode: sent.channelMode,
+ followUp: sent.followUp,
});
return "outbox";
}