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