fix(mobile): preserve active thread state
Keep executing runs visible when newer work is queued, expose provider errors in compact shells, and preserve mobile creation metadata for fork and merge operations. Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
ae3a25649a
commit
e56b1c3dde
16 files changed
+230
-44
No files matched your search
@@ -0,0 +1,71 @@
|
||||
import { MessageId, RunId, type OrchestrationV2RunStatus } from "@t3tools/contracts";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { v2Projection } from "./orchestrationV2TestFixtures.ts";
|
||||
import {
|
||||
deriveLatestThreadRun,
|
||||
deriveThreadActivityRun,
|
||||
deriveThreadRuntime,
|
||||
threadRuntimeHasInterruptibleRun,
|
||||
} from "./threadExecution.ts";
|
||||
|
||||
const now = DateTime.makeUnsafe("2026-07-28T10:00:00.000Z");
|
||||
|
||||
function run(id: string, ordinal: number, status: OrchestrationV2RunStatus) {
|
||||
return {
|
||||
id: RunId.make(id),
|
||||
threadId: v2Projection.thread.id,
|
||||
ordinal,
|
||||
providerInstanceId: v2Projection.thread.providerInstanceId,
|
||||
modelSelection: v2Projection.thread.modelSelection,
|
||||
providerThreadId: null,
|
||||
userMessageId: MessageId.make(`message-${id}`),
|
||||
rootNodeId: null,
|
||||
activeAttemptId: null,
|
||||
status,
|
||||
requestedAt: now,
|
||||
startedAt: status === "queued" ? null : now,
|
||||
completedAt: null,
|
||||
checkpointId: null,
|
||||
contextHandoffId: null,
|
||||
};
|
||||
}
|
||||
|
||||
describe("thread execution presentation", () => {
|
||||
it("keeps live activity attached to an executing run when a newer run is queued", () => {
|
||||
const runningRun = run("run-running", 1, "running");
|
||||
const queuedRun = run("run-queued", 2, "queued");
|
||||
const projection = { ...v2Projection, runs: [queuedRun, runningRun], updatedAt: now };
|
||||
|
||||
expect(deriveLatestThreadRun(projection)?.runId).toBe(queuedRun.id);
|
||||
expect(deriveThreadActivityRun(projection)).toMatchObject({
|
||||
runId: runningRun.id,
|
||||
status: "running",
|
||||
});
|
||||
|
||||
const runtime = deriveThreadRuntime(projection);
|
||||
expect(runtime).toMatchObject({
|
||||
status: "queued",
|
||||
activeRunId: runningRun.id,
|
||||
});
|
||||
expect(threadRuntimeHasInterruptibleRun(runtime)).toBe(true);
|
||||
});
|
||||
|
||||
it("does not expose a queued-only run as interruptible", () => {
|
||||
const queuedRun = run("run-queued", 1, "queued");
|
||||
const projection = { ...v2Projection, runs: [queuedRun], updatedAt: now };
|
||||
|
||||
expect(deriveThreadActivityRun(projection)).toMatchObject({
|
||||
runId: queuedRun.id,
|
||||
status: "queued",
|
||||
});
|
||||
|
||||
const runtime = deriveThreadRuntime(projection);
|
||||
expect(runtime).toMatchObject({
|
||||
status: "queued",
|
||||
activeRunId: null,
|
||||
});
|
||||
expect(threadRuntimeHasInterruptibleRun(runtime)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user