Unified · Split
| @@ -1720,13 +1720,14 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => { · 1719 unmodified lines | |||
| 1720 | worktreePath: `/tmp/${threadId}`, | 1720 | worktreePath: `/tmp/${threadId}`, |
| 1721 | }); | 1721 | }); |
| 1722 | } | 1722 | } |
| 1723 | const activeMessageId = MessageId.make("runtime-layer-queued-archived-target-active"); | ||
| 1723 | yield* orchestrator.dispatch({ | 1724 | yield* orchestrator.dispatch({ |
| 1724 | type: "message.dispatch", | 1725 | type: "message.dispatch", |
| 1725 | createdBy: "user", | 1726 | createdBy: "user", |
| 1726 | creationSource: "web", | 1727 | creationSource: "web", |
| 1727 | commandId: CommandId.make("runtime-layer-queued-archived-target-active"), | 1728 | commandId: CommandId.make("runtime-layer-queued-archived-target-active"), |
| 1728 | threadId: targetThreadId, | 1729 | threadId: targetThreadId, |
| 1729 | messageId: MessageId.make("runtime-layer-queued-archived-target-active"), | 1730 | messageId: activeMessageId, |
| 1730 | text: "Keep the target active.", | 1731 | text: "Keep the target active.", |
| 1731 | attachments: [], | 1732 | attachments: [], |
| 1732 | modelSelection, | 1733 | modelSelection, |
| @@ -1745,9 +1746,10 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => { · 12 unmodified lines | |||
| 1745 | modelSelection, | 1746 | modelSelection, |
| 1746 | dispatchMode: { type: "queue_after_active" }, | 1747 | dispatchMode: { type: "queue_after_active" }, |
| 1747 | }); | 1748 | }); |
| 1748 | const queuedRun = (yield* orchestrator.getThreadProjection(targetThreadId)).runs.find( | 1749 | const beforeMutation = yield* orchestrator.getThreadProjection(targetThreadId); |
| 1749 | (run) => run.userMessageId === queuedMessageId, | 1750 | const activeRun = beforeMutation.runs.find((run) => run.userMessageId === activeMessageId); |
| 1750 | ); | 1751 | const queuedRun = beforeMutation.runs.find((run) => run.userMessageId === queuedMessageId); |
| 1752 | assert.isDefined(activeRun); | ||
| 1751 | assert.isDefined(queuedRun); | 1753 | assert.isDefined(queuedRun); |
| 1752 | yield* orchestrator.dispatch({ | 1754 | yield* orchestrator.dispatch({ |
| 1753 | type: "thread.archive", | 1755 | type: "thread.archive", |
| @@ -1771,17 +1773,19 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => { · 17 unmodified lines | |||
| 1771 | }) | 1773 | }) |
| 1772 | .pipe(Effect.flip); | 1774 | .pipe(Effect.flip); |
| 1773 | assert.equal(editError._tag, "OrchestratorDispatchError"); | 1775 | assert.equal(editError._tag, "OrchestratorDispatchError"); |
| 1776 | assert.match(String(editError.cause), /Caller thread .* is not an active thread/); | ||
| 1774 | const promoteError = yield* orchestrator | 1777 | const promoteError = yield* orchestrator |
| 1775 | .dispatch({ | 1778 | .dispatch({ |
| 1776 | type: "queued-message.promote-to-steer", | 1779 | type: "queued-message.promote-to-steer", |
| 1777 | commandId: CommandId.make("runtime-layer-queued-archived-caller-promote"), | 1780 | commandId: CommandId.make("runtime-layer-queued-archived-caller-promote"), |
| 1778 | threadId: targetThreadId, | 1781 | threadId: targetThreadId, |
| 1779 | queuedRunId: queuedRun.id, | 1782 | queuedRunId: queuedRun.id, |
| 1780 | targetRunId: RunId.make("runtime-layer-queued-archived-target-active-run"), | 1783 | targetRunId: activeRun.id, |
| 1781 | policyCeiling, | 1784 | policyCeiling, |
| 1782 | }) | 1785 | }) |
| 1783 | .pipe(Effect.flip); | 1786 | .pipe(Effect.flip); |
| 1784 | assert.equal(promoteError._tag, "OrchestratorDispatchError"); | 1787 | assert.equal(promoteError._tag, "OrchestratorDispatchError"); |
| 1788 | assert.match(String(promoteError.cause), /Caller thread .* is not an active thread/); | ||
| 1785 | 1789 | ||
| 1786 | const projection = yield* orchestrator.getThreadProjection(targetThreadId); | 1790 | const projection = yield* orchestrator.getThreadProjection(targetThreadId); |
| 1787 | assert.equal( | 1791 | assert.equal( |