|
3 | 3 | EventId, |
4 | 4 | MessageId, |
5 | 5 | ORCHESTRATION_V2_WS_METHODS, |
| 6 | + RunId, |
6 | 7 | ThreadId, |
7 | 8 | TurnItemId, |
8 | 9 | type OrchestrationV2ThreadDetailSnapshot, |
@@ -36,7 +37,7 @@ import * as ConnectionWakeups from "../connection/wakeups.ts"; |
36 | 37 | import * as EnvironmentSupervisor from "../connection/supervisor.ts"; |
37 | 38 | import * as Persistence from "../platform/persistence.ts"; |
38 | 39 | import * as RpcSession from "../rpc/session.ts"; |
39 | | -import { v2Projection, v2ThreadId } from "./orchestrationV2TestFixtures.ts"; |
| 40 | +import { v2Now, v2Projection, v2ThreadId } from "./orchestrationV2TestFixtures.ts"; |
40 | 41 | import * as ThreadHistoryController from "./threadHistoryController.ts"; |
41 | 42 | import { |
42 | 43 | EMPTY_ENVIRONMENT_THREAD_STATE, |
@@ -1210,6 +1211,52 @@ describe("EnvironmentThreads", () => { |
1210 | 1211 | }), |
1211 | 1212 | ); |
1212 | 1213 |
|
| 1214 | + // regression: #24192 reopening a running thread on mobile waited on the server with a blank view |
| 1215 | + it.effect("caches a running thread once when its view closes, not on each update", () => |
| 1216 | + Effect.gen(function* () { |
| 1217 | + const scope = yield* Scope.make(); |
| 1218 | + const harness = yield* makeHarness().pipe(Effect.provideService(Scope.Scope, scope)); |
| 1219 | + const running: OrchestrationV2ThreadProjection = { |
| 1220 | + ...BASE_PROJECTION, |
| 1221 | + runs: [ |
| 1222 | + { |
| 1223 | + id: RunId.make("run-running"), |
| 1224 | + threadId: THREAD_ID, |
| 1225 | + ordinal: 1, |
| 1226 | + providerInstanceId: BASE_PROJECTION.thread.providerInstanceId, |
| 1227 | + modelSelection: BASE_PROJECTION.thread.modelSelection, |
| 1228 | + providerThreadId: null, |
| 1229 | + userMessageId: MessageId.make("message-running"), |
| 1230 | + rootNodeId: null, |
| 1231 | + activeAttemptId: null, |
| 1232 | + status: "running", |
| 1233 | + requestedAt: v2Now, |
| 1234 | + startedAt: v2Now, |
| 1235 | + completedAt: null, |
| 1236 | + checkpointId: null, |
| 1237 | + contextHandoffId: null, |
| 1238 | + }, |
| 1239 | + ], |
| 1240 | + }; |
| 1241 | + yield* Queue.offer(harness.inputs, snapshot(running, 4)); |
| 1242 | + yield* Queue.offer(harness.inputs, titleUpdated("Streaming update", 5)); |
| 1243 | + yield* awaitThreadState( |
| 1244 | + harness.observed, |
| 1245 | + (value) => |
| 1246 | + Option.isSome(value.data) && value.data.value.thread.title === "Streaming update", |
| 1247 | + ); |
| 1248 | + yield* TestClock.adjust("10 seconds"); |
| 1249 | + expect(yield* Ref.get(harness.savedThreads)).toHaveLength(0); |
| 1250 | + |
| 1251 | + yield* Scope.close(scope, Exit.void); |
| 1252 | + const saved = yield* Ref.get(harness.savedThreads); |
| 1253 | + expect(saved).toHaveLength(1); |
| 1254 | + expect(saved[0]?.snapshotSequence).toBe(5); |
| 1255 | + expect(saved[0]?.projection.thread.title).toBe("Streaming update"); |
| 1256 | + expect(saved[0]?.projection.runs[0]?.status).toBe("running"); |
| 1257 | + }), |
| 1258 | + ); |
| 1259 | + |
1213 | 1260 | it.effect("preserves data after a domain failure and resumes on a replacement session", () => |
1214 | 1261 | Effect.gen(function* () { |
1215 | 1262 | const harness = yield* makeHarness({ cached: BASE_PROJECTION }); |
|
0 commit comments