A desktop coding agent with free access to frontier models.
TypeScript
fix: log a first prompt sent before the start scan ended
ogsamrate8f8811a932b
diff --git a/apps/server/src/session-uploader.ts b/apps/server/src/session-uploader.tsindex 13890253..1eb5ec36 100644--- a/apps/server/src/session-uploader.ts+++ b/apps/server/src/session-uploader.ts@@ -5363,9 +5363,14 @@ export class SessionUploader {async startScanned(sessionId: string, capMs: number): Promise<void> {const scanned = this.startScans.get(sessionId)?.promise;if (!scanned) return;+ // Fails open: a failed scan resolves too (startSession's finally), and the cap lets the prompt go, logged.let timer: ReturnType<typeof setTimeout> | undefined;- await Promise.race([scanned, new Promise<void>((resolveCap) => { timer = setTimeout(resolveCap, capMs); timer.unref?.(); })]);+ const outcome = await Promise.race([+ scanned.then(() => "scanned" as const),+ new Promise<"cap">((resolveCap) => { timer = setTimeout(() => resolveCap("cap"), capMs); timer.unref?.(); }),+ ]);clearTimeout(timer);+ if (outcome === "cap") this.log("warn", "OmniRush start scan not done before the first prompt; the prompt goes on", { sessionId, capMs });}/** `turnsBefore`: the turns a reopened chat already had, so capture context numbers its turns on from them. */diff --git a/apps/server/src/turn-diff.test.ts b/apps/server/src/turn-diff.test.tsindex f4c3177e..8aeae172 100644--- a/apps/server/src/turn-diff.test.ts+++ b/apps/server/src/turn-diff.test.ts@@ -67,7 +67,7 @@ function turnDiffEvents(uploads: Envelope[]): TurnDiffEvent[] {* sees each one first and may keep the upload (and the session's queue* behind it) waiting.*/-function recordingUploader(options: { stateDir?: string; snapshotMaxBytes?: number; hold?: (envelope: Envelope) => Promise<void> } = {}): { sessionUploader: SessionUploader; uploads: Envelope[] } {+function recordingUploader(options: { stateDir?: string; snapshotMaxBytes?: number; hold?: (envelope: Envelope) => Promise<void>; log?: (level: "info" | "warn", message: string) => void } = {}): { sessionUploader: SessionUploader; uploads: Envelope[] } {const { hold, ...rest } = options;const uploads: Envelope[] = [];const sessionUploader = new SessionUploader({@@ -422,6 +422,30 @@ describe("turn.diff events", () => {expect(await run(false)).toEqual([["raced.txt", "no_base"]]);});+ test("startScanned fails open: the cap lets the prompt go (logged), and a failed scan resolves it", async () => {+ const logs: string[] = [];+ const log = (level: "info" | "warn", message: string) => { logs.push(`${level} ${message}`); };+ const root = await tempDir("omnirush-turn-diff-open-");+ await writeFile(join(root, "a.txt"), "a\n");+ const capped = recordingUploader({ log }).sessionUploader;+ capped.startSession("session-turn-diff-capped", "workspace-turn-diff", root);+ const started = Date.now();+ await capped.startScanned("session-turn-diff-capped", 0);+ expect(Date.now() - started).toBeLessThan(1_000);+ expect(logs.some((line) => line.startsWith("warn OmniRush start scan not done"))).toBe(true);+ await capped.idle("session-turn-diff-capped");+ await capped.stop();+ // A folder that is gone: the scan fails, the wait ends with it (long before its cap), and the prompt goes on.+ logs.length = 0;+ const failing = recordingUploader({ log }).sessionUploader;+ failing.startSession("session-turn-diff-gone", "workspace-turn-diff", join(root, "missing"));+ const failedAt = Date.now();+ await failing.startScanned("session-turn-diff-gone", 20_000);+ expect(Date.now() - failedAt).toBeLessThan(10_000);+ expect(logs.some((line) => line.startsWith("warn OmniRush start scan not done"))).toBe(false);+ await failing.stop();+ }, 30_000);+test("startScanned resolves at once for a session with no start scan in progress", async () => {const { sessionUploader } = recordingUploader();const started = Date.now();