Skip to content

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

fix(titles): wait for turn outcome before using reply

CI fixture373a2ecd9872
diff --git a/server/host/handed-thread-title.test.ts b/server/host/handed-thread-title.test.ts
index c1058e9272..0281918e9f 100644
--- a/server/host/handed-thread-title.test.ts
+++ b/server/host/handed-thread-title.test.ts
@@ -68,9 +68,9 @@ describe("a thread a teammate opened", () => {
p.titles.turnStarted("thread", "turn");
await vi.advanceTimersByTimeAsync(TITLE_REPLY_WAIT_MS);
expect(p.generate).not.toHaveBeenCalled();
- p.titles.replyReceived("thread", "turn", "First reply");
+ expect(p.generate).not.toHaveBeenCalled();
p.titles.turnEnded("thread", "turn", "Last reply");
- expect(p.generate).toHaveBeenCalledExactlyOnceWith({}, expect.stringContaining("First reply"), "follow-up");
+ expect(p.generate).toHaveBeenCalledExactlyOnceWith({}, expect.stringContaining("Last reply"), "follow-up");
} finally {
vi.useRealTimers();
}
diff --git a/server/host/thread-titles.ts b/server/host/thread-titles.ts
index 227527edf4..9dec7283e0 100644
--- a/server/host/thread-titles.ts
+++ b/server/host/thread-titles.ts
@@ -64,9 +64,6 @@ export function createAutomaticThreadTitles(generate = generateThreadTitle) {
const current = pending.get(threadId);
if (current && turnId && (room || current.turnId === undefined)) current.turnId = turnId;
},
- replyReceived(threadId: string, turnId: string | undefined, text: string) {
- if (text.trim()) void finish(threadId, turnId, text.trim());
- },
turnEnded: (threadId: string, turnId?: string, reply?: string) => void finish(threadId, turnId, reply?.trim() || undefined),
drop,
};
diff --git a/server/index.ts b/server/index.ts
index 509df8711c..39b9489922 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -6348,7 +6348,6 @@ bus.subscribe((event: RuntimeEvent) => {
}
pushMessage({ role: "bot", kind: "text", text: spoken.text, turnId, ...(event.type === "item.completed" && event.itemId ? { itemId: event.itemId } : {}) });
lastReply.set(event.threadId, spoken.text);
- if (!replayed) automaticTitles.replyReceived(event.threadId, turnId, spoken.text);
};
const landParkedFiles = () => {
const { files, strays } = takeParkedFiles(turnAttachmentsByTurn, event.threadId, event.turnId);
diff --git a/server/thread-title-auto.e2e.test.ts b/server/thread-title-auto.e2e.test.ts
index febb748dd0..3ba0041ca9 100644
--- a/server/thread-title-auto.e2e.test.ts
+++ b/server/thread-title-auto.e2e.test.ts
@@ -28,3 +28,23 @@ it("names a real fixture conversation from both its request and reply", async ()
rmdirSync(dir);
}
}, 120_000);
+
+it("titles a failed turn from the request without its interim progress", async () => {
+ const dir = mkdtempSync(join(tmpdir(), "omb-title-failed-e2e-"));
+ const title = join(dir, "title.txt"), dump = join(dir, "title-dump.json"), script = join(dir, "stream.json");
+ writeFileSync(title, "Payroll export");
+ writeFileSync(script, JSON.stringify({ "Fix payroll export": [{ say: "Inspecting the ledger." }, { fail: "Fixture terminal failure" }] }));
+ const fixture = await launchVerificationServer({ ...process.env, FAKE_CLAUDE_TEXT_FILE: title, FAKE_CLAUDE_TEXT_DUMP: dump, FAKE_STREAM_SCRIPT: script, FAKE_STREAM_CADENCE: "100:1" });
+ const control = (...args: string[]) => runControlOmb([...args, "--url", fixture.info.url]) as Promise<any>;
+ try {
+ const { bot } = await control("new-bot", "--name", "Title fixture");
+ await control("send", "--bot", bot.id, "--text", "Fix payroll export");
+ expect(await control("wait", "--bot", bot.id, "--timeout", "30")).toMatchObject({ status: "settled", state: "failed" });
+ await expect.poll(() => { try { return JSON.parse(readFileSync(dump, "utf8")).prompt; } catch { return ""; } }, { timeout: 15_000 }).toContain("Fix payroll export");
+ const { prompt } = JSON.parse(readFileSync(dump, "utf8"));
+ expect(prompt).not.toContain("Inspecting the ledger.");
+ } finally {
+ await fixture.close();
+ rmSync(dir, { recursive: true, force: true });
+ }
+}, 120_000);