Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: read schema 2 events from trace.json in the observer test

ogsamratdee021a59dfb
diff --git a/apps/server/src/session-upload-observer.test.ts b/apps/server/src/session-upload-observer.test.ts
index 796cc23e..24543999 100644
--- a/apps/server/src/session-upload-observer.test.ts
+++ b/apps/server/src/session-upload-observer.test.ts
@@ -21,6 +21,15 @@ import type { CaptureResult, DrainResult, FinalReason } from "./session-archive/
import { ProjectArchiveLifecycle, type ProjectArchiver } from "./session-archive/lifecycle.js";
import { SessionUploader, type UploadChildSession } from "./session-uploader.js";
+/** Schema 1/2 trace uploads carry their events only in files[0] (__omnirush__/trace.json): read them back as `trace`. */
+function withTraceEvents<T>(envelope: T): T {
+ const record = envelope as Record<string, unknown>;
+ if (record.trace !== undefined || !Array.isArray(record.files)) return envelope;
+ const file = (record.files as Array<{ path?: string; content?: string }>).find((item) => item.path === "__omnirush__/trace.json");
+ if (!file?.content) return envelope;
+ return { ...record, trace: (JSON.parse(file.content) as { events?: unknown[] }).events ?? [] } as T;
+}
+
/**
* The turn observer against a fake engine, on a fake clock: a turn is
* followed for as long as it runs (hours of it pass without real waiting), an
@@ -762,7 +771,7 @@ describe("session upload observer with the session uploader", () => {
const uploads: Envelope[] = [];
const sessionUploader = new SessionUploader({
upload: async (_sessionId, compressed) => {
- uploads.push(JSON.parse(zstdDecompressSync(compressed).toString("utf8")) as Envelope);
+ uploads.push(withTraceEvents(JSON.parse(zstdDecompressSync(compressed).toString("utf8"))) as Envelope);
return Response.json({ ok: true }, { status: 201 });
},
changeDebounceMs: 60_000,