|
3 | 3 | EventId, |
4 | 4 | MessageId, |
5 | 5 | ORCHESTRATION_V2_WS_METHODS, |
| 6 | + RunId, |
6 | 7 | ThreadId, |
7 | 8 | TurnItemId, |
8 | 9 | type OrchestrationV2ThreadDetailSnapshot, |
@@ -43,7 +44,7 @@ import { |
43 | 44 | decodeOrDiscardOrchestrationCache, |
44 | 45 | } from "../platform/orchestrationCache.ts"; |
45 | 46 | import * as RpcSession from "../rpc/session.ts"; |
46 | | -import { v2Projection, v2ThreadId } from "./orchestrationV2TestFixtures.ts"; |
| 47 | +import { v2Now, v2Projection, v2ThreadId } from "./orchestrationV2TestFixtures.ts"; |
47 | 48 | import { EMPTY_THREAD_HISTORY_META } from "./threadHistoryMerge.ts"; |
48 | 49 | import * as ThreadHistoryController from "./threadHistoryController.ts"; |
49 | 50 | import { |
@@ -1724,6 +1725,52 @@ describe("EnvironmentThreads", () => { |
1724 | 1725 | }), |
1725 | 1726 | ); |
1726 | 1727 |
|
| 1728 | + // regression: #24192 reopening a running thread on mobile waited on the server with a blank view |
| 1729 | + it.effect("caches a running thread once when its view closes, not on each update", () => |
| 1730 | + Effect.gen(function* () { |
| 1731 | + const scope = yield* Scope.make(); |
| 1732 | + const harness = yield* makeHarness().pipe(Effect.provideService(Scope.Scope, scope)); |
| 1733 | + const running: OrchestrationV2ThreadProjection = { |
| 1734 | + ...BASE_PROJECTION, |
| 1735 | + runs: [ |
| 1736 | + { |
| 1737 | + id: RunId.make("run-running"), |
| 1738 | + threadId: THREAD_ID, |
| 1739 | + ordinal: 1, |
| 1740 | + providerInstanceId: BASE_PROJECTION.thread.providerInstanceId, |
| 1741 | + modelSelection: BASE_PROJECTION.thread.modelSelection, |
| 1742 | + providerThreadId: null, |
| 1743 | + userMessageId: MessageId.make("message-running"), |
| 1744 | + rootNodeId: null, |
| 1745 | + activeAttemptId: null, |
| 1746 | + status: "running", |
| 1747 | + requestedAt: v2Now, |
| 1748 | + startedAt: v2Now, |
| 1749 | + completedAt: null, |
| 1750 | + checkpointId: null, |
| 1751 | + contextHandoffId: null, |
| 1752 | + }, |
| 1753 | + ], |
| 1754 | + }; |
| 1755 | + yield* Queue.offer(harness.inputs, snapshot(running, 4)); |
| 1756 | + yield* Queue.offer(harness.inputs, titleUpdated("Streaming update", 5)); |
| 1757 | + yield* awaitThreadState( |
| 1758 | + harness.observed, |
| 1759 | + (value) => |
| 1760 | + Option.isSome(value.data) && value.data.value.thread.title === "Streaming update", |
| 1761 | + ); |
| 1762 | + yield* TestClock.adjust("10 seconds"); |
| 1763 | + expect(yield* Ref.get(harness.savedThreads)).toHaveLength(0); |
| 1764 | + |
| 1765 | + yield* Scope.close(scope, Exit.void); |
| 1766 | + const saved = yield* Ref.get(harness.savedThreads); |
| 1767 | + expect(saved).toHaveLength(1); |
| 1768 | + expect(saved[0]?.snapshotSequence).toBe(5); |
| 1769 | + expect(saved[0]?.projection.thread.title).toBe("Streaming update"); |
| 1770 | + expect(saved[0]?.projection.runs[0]?.status).toBe("running"); |
| 1771 | + }), |
| 1772 | + ); |
| 1773 | + |
1727 | 1774 | it.effect("preserves data after a domain failure and resumes on a replacement session", () => |
1728 | 1775 | Effect.gen(function* () { |
1729 | 1776 | const harness = yield* makeHarness({ cached: BASE_PROJECTION }); |
|
0 commit comments