Skip to content

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

Sidebar: Simple mode quotes a wait's note after a step, not the step

luishron123528eac91c78b
diff --git a/src/components/sidebar-preview.test.ts b/src/components/sidebar-preview.test.ts
index b533894fc8..6cc059b893 100644
--- a/src/components/sidebar-preview.test.ts
+++ b/src/components/sidebar-preview.test.ts
@@ -39,6 +39,16 @@ describe("sidebar previews", () => {
expect(botPreview(bot, [message({ text: "Earlier reply" }), message({ role: "user", text: "Tidy my inbox" }), step("Bash")], [], false)).not.toBe("Earlier reply");
});
+ it("quotes a wait's note in Simple mode after a step that went fine, but not a person's line written the same way", () => {
+ const note = message({ role: "user", text: "[Wait finished: report] Summarize.", automated: true } as Partial<Message>);
+ expect(botPreview(bot, [note], [], false)).toBe("Following up on the wait: report");
+ expect(botPreview(bot, [note, step("Read")], [], false)).toBe("Following up on the wait: report");
+ expect(botPreview(bot, [message({ text: "Earlier reply" }), note, step("Read")], [], false)).toBe("Following up on the wait: report");
+ const typed = message({ role: "user", text: "[Wait finished: report] Summarize." });
+ expect(botPreview(bot, [message({ text: "Earlier reply" }), typed, step("Read")], [], false)).not.toBe("Earlier reply");
+ expect(botPreview(bot, [message({ text: "Earlier reply" }), typed, step("Read")], [], false)).not.toBe("Following up on the wait: report");
+ });
+
it("keeps a failed step's error line and a recovery or notice line as they are", () => {
const failed = [message({ role: "user", text: "Tidy my inbox" }), message({ text: "On it." }), message({ kind: "activity", tool: { name: "error: Gmail is not connected", ok: false } } as Partial<Message>)];
expect(botPreview(bot, failed, [], false)).toContain("Gmail is not connected");
diff --git a/src/components/sidebar-preview.ts b/src/components/sidebar-preview.ts
index c31ea6cef9..ad426f612a 100644
--- a/src/components/sidebar-preview.ts
+++ b/src/components/sidebar-preview.ts
@@ -40,12 +40,12 @@ function plainStep(message: Message): boolean {
return Boolean(tool) && tool!.ok !== false && !message.dataResult && failedTurnCause(tool!.name) === null && !isStoppedTurnName(tool!.name) && !STATUS_MARKER.test(tool!.name);
}
-/** Simple mode quotes the bot: a step that went fine gives way to the newest thing said since the person last wrote. */
+/** Simple mode quotes the bot: a step that went fine gives way to the newest thing said since the person last wrote. A wait's note is the app's line, said, not the person's. */
function quotedLine(messages: readonly Message[], last: Message, advanced: boolean): Message {
if (advanced || !plainStep(last)) return last;
for (let index = messages.length - 1; index >= 0; index--) {
const message = messages[index]!;
- if (message.role === "user") break;
+ if (message.role === "user") return automationNote(message, knownWaits(messages)) ? message : last;
if (message.kind !== "activity" && !isReceipt(message) && message.kind !== "screen") return message;
}
return last;