Fix live ingestion acceptance checkout and observation races

This commit is contained in:
Dotta committed 2026-11-03 17:06:22 -06:00
1 parent 86153ed937
commit 98a5c05971
2 files changed
+11 -8

No files matched your search

+8 -6
View File
@@ -76,6 +76,7 @@ try {
const active = runs.find(run => run.status === "running");
if (!active) return null;
const text = normalizeVisible(await visibleAgentText());
const visibleAt = Date.now();
const rows = await eventsFor(active.id);
const delta = rows.map(row => row.payload?.prpEvent).find(event => event?.eventType === "item.delta"
&& event.payload.kind === "agentMessage" && normalizeVisible(event.payload.text).length >= 12
@@ -83,15 +84,16 @@ try {
if (!delta) return null;
// Re-read status after observing the matching UI text. A completed run
// discovered on the next poll cannot establish streaming visibility.
if ((await api(`/api/heartbeat-runs/${active.id}`)).status !== "running") return null;
const observedRun = await api(`/api/heartbeat-runs/${active.id}`);
if (observedRun.status !== "running") return null;
return { runId: active.id, sourceEventId: delta.sourceEventId, sourceSeq: delta.sourceSeq,
emittedAt: delta.emittedAt, visibleText: text.slice(-1000) };
emittedAt: delta.emittedAt, visibleText: text.slice(-1000), visibleAt,
run: runSummary(observedRun), statusObservedAt: Date.now() };
}, Boolean);
journey.visibleDelta = streaming;
journey.firstVisibleAt = Date.now();
const during = await taskRuns(created.issueId);
journey.streamingRunStatuses = during.map(runSummary);
journey.visibleBeforeTerminal = during.some(run => ["queued", "running"].includes(run.status));
journey.firstVisibleAt = streaming.visibleAt;
journey.streamingRunStatuses = [streaming.run];
journey.visibleBeforeTerminal = streaming.run.status === "running";
expect(journey.visibleBeforeTerminal).toBe(true);
await page.screenshot({ path: join(config.evidenceDir, "live-streaming.png"), fullPage: true });
const finished = await poll("completed native run", () => taskRuns(created.issueId), runs =>
+3 -2
View File
@@ -22,7 +22,7 @@ try {
const { prepareTestDriveEnvironment, bootstrapTestDrive } = await import(pathToFileURL(join(repository, "cli/src/commands/test-drive.ts")).href);
const options = { dataDir, companyName: "Native ingestion live acceptance", agentName: "Live ingestion agent",
harness: "opencode", model, apiKeyEnv: credentialName, browser: false };
await prepareTestDriveEnvironment(options, repository);
const { linkedWorktree } = await prepareTestDriveEnvironment(options, repository);
process.env.PAPERCLIP_UI_DEV_MIDDLEWARE = "false";
process.env.NODE_ENV = "production";
process.env.SERVE_UI = "true";
@@ -36,7 +36,8 @@ try {
const origin = `http://${server.host}:${server.listenPort}`;
const { PaperclipApiClient } = await import(pathToFileURL(join(repository, "cli/src/client/http.ts")).href);
const api = new PaperclipApiClient({ apiBase: origin });
const fixture = await bootstrapTestDrive({ api, options, linkedWorktree: true, instanceId: "default", env: process.env });
const fixture = await bootstrapTestDrive({ api, options, linkedWorktree,
instanceId: process.env.PAPERCLIP_INSTANCE_ID ?? "default", env: process.env });
if (fixture.reused || !fixture.agent) throw new Error("Fresh live-provider fixture was not created");
await api.patch("/api/instance/settings/experimental", { enableNativeRunner: true });
const agent = await api.patch(`/api/agents/${fixture.agent.id}`, {