Skip to content

Commit ba621a1

Browse files
fix(orchestration): persist linked pull requests
1 parent c01ff20 commit ba621a1

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
16821682
...(command.title === undefined ? {} : { title: command.title }),
16831683
...(command.branch === undefined ? {} : { branch: command.branch }),
16841684
...(command.worktreePath === undefined ? {} : { worktreePath: command.worktreePath }),
1685+
...(command.linkedPullRequest === undefined
1686+
? {}
1687+
: { linkedPullRequest: command.linkedPullRequest }),
16851688
// regenerateTitle: true arms the in-flight marker; a landing title
16861689
// or an explicit false (generation failed/abandoned) clears it.
16871690
...(command.regenerateTitle === true

‎apps/server/src/orchestration-v2/runtimeLayer.test.ts‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,67 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => {
740740
}),
741741
);
742742

743+
it.effect("persists linked pull requests through projection rebuilds and unlinking", () =>
744+
Effect.gen(function* () {
745+
const orchestrator = yield* OrchestratorV2;
746+
const maintenance = yield* ProjectionMaintenanceV2;
747+
const threadId = ThreadId.make("runtime-layer-linked-pull-request-thread");
748+
const linkedPullRequest = {
749+
projectId: ProjectId.make("runtime-layer-linked-pull-request-project"),
750+
repository: "pingdotgg/t3code",
751+
number: 8160,
752+
url: "https://github.com/pingdotgg/t3code/pull/8160",
753+
} as const;
754+
755+
yield* orchestrator.dispatch({
756+
type: "thread.create",
757+
createdBy: "user",
758+
creationSource: "web",
759+
commandId: CommandId.make("runtime-layer-linked-pull-request-create"),
760+
threadId,
761+
projectId: linkedPullRequest.projectId,
762+
title: "Linked pull request thread",
763+
modelSelection,
764+
runtimeMode: "full-access",
765+
interactionMode: "default",
766+
branch: null,
767+
worktreePath: null,
768+
});
769+
yield* orchestrator.dispatch({
770+
type: "thread.metadata.update",
771+
commandId: CommandId.make("runtime-layer-linked-pull-request-link"),
772+
threadId,
773+
linkedPullRequest,
774+
});
775+
776+
assert.deepEqual(
777+
(yield* orchestrator.getThreadProjection(threadId)).thread.linkedPullRequest,
778+
linkedPullRequest,
779+
);
780+
const linkedShell = yield* orchestrator.getThreadShell(threadId);
781+
assert.isNotNull(linkedShell);
782+
assert.deepEqual(linkedShell.linkedPullRequest, linkedPullRequest);
783+
784+
const rebuilt = yield* maintenance.rebuild;
785+
assert.isTrue(rebuilt.valid);
786+
assert.deepEqual(
787+
(yield* orchestrator.getThreadProjection(threadId)).thread.linkedPullRequest,
788+
linkedPullRequest,
789+
);
790+
791+
yield* orchestrator.dispatch({
792+
type: "thread.metadata.update",
793+
commandId: CommandId.make("runtime-layer-linked-pull-request-unlink"),
794+
threadId,
795+
linkedPullRequest: null,
796+
});
797+
assert.isNull((yield* orchestrator.getThreadProjection(threadId)).thread.linkedPullRequest);
798+
const unlinkedShell = yield* orchestrator.getThreadShell(threadId);
799+
assert.isNotNull(unlinkedShell);
800+
assert.isNull(unlinkedShell.linkedPullRequest);
801+
}),
802+
);
803+
743804
it.effect("persists rejected command receipts across retries", () =>
744805
Effect.gen(function* () {
745806
const orchestrator = yield* OrchestratorV2;

0 commit comments

Comments
 (0)