Skip to content

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

fix(routines): keep the default line of a bare NEEDS INPUT line when clipping

AdityaUmaled030e2e05d29
diff --git a/server/automation-reports.test.ts b/server/automation-reports.test.ts
index 1e765a4816..78f59972d5 100644
--- a/server/automation-reports.test.ts
+++ b/server/automation-reports.test.ts
@@ -50,6 +50,9 @@ describe("routineRunNeedsReview", () => {
expect(routineRunNeedsReview({ status: "completed", output: clipRunOutput(reply, 2_000) })).toBe(routineRunNeedsReview({ status: "completed" }, reply));
expect(routineRunNeedsReview({ status: "completed", output: clipRunOutput(reply, 2_000) })).toBe(true);
}
+ const bare = `${"Long report. ".repeat(300)}\nNEEDS INPUT:\ndefault: ${"wait ".repeat(500)}`;
+ expect(routineRunNeedsReview({ status: "completed", output: clipRunOutput(bare, 2_000) })).toBe(routineRunNeedsReview({ status: "completed" }, bare));
+ expect(routineRunNeedsReview({ status: "completed", output: clipRunOutput(bare, 2_000) })).toBe(true);
expect(routineRunNeedsReview({ status: "cancelled" })).toBe(false);
});
});
diff --git a/server/routine-lines.test.ts b/server/routine-lines.test.ts
index be402f157b..81a3ebb06e 100644
--- a/server/routine-lines.test.ts
+++ b/server/routine-lines.test.ts
@@ -80,4 +80,10 @@ describe("clipRunOutput", () => {
expect(cut.startsWith("NEEDS INPUT: why")).toBe(true);
expect(cut.endsWith("…")).toBe(true);
});
+
+ it("keeps the default line of a bare NEEDS INPUT line too long to fit", () => {
+ const cut = clipRunOutput(`${long}\nNEEDS INPUT:\ndefault: ${"wait ".repeat(500)}`, 2_000);
+ expect(cut.length).toBe(2_000);
+ expect(cut.startsWith("NEEDS INPUT:\ndefault: wait")).toBe(true);
+ });
});
diff --git a/server/routine-lines.ts b/server/routine-lines.ts
index 729cf9030d..445ecd9383 100644
--- a/server/routine-lines.ts
+++ b/server/routine-lines.ts
@@ -103,6 +103,8 @@ export function clipRunOutput(text: string, max: number): string {
const tail = lines.slice(at).join("\n").trim();
if (tail.length > max) {
const question = lines[at]!.trim();
+ // A bare NEEDS INPUT: line asks through its default: line, so that line is kept (cut) with it.
+ if (!question.replace(CLOSING_QUESTION, "").trim()) return `${tail.slice(0, max - 1)}…`;
return question.length <= max ? question : `${question.slice(0, max - 1)}…`;
}
const room = max - tail.length - 3;