Skip to content

Commit 1d9e754

Browse files
fix(orchestration): persist linked pull requests
1 parent b9fa139 commit 1d9e754

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
@@ -1712,6 +1712,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
17121712
...(command.title === undefined ? {} : { title: command.title }),
17131713
...(command.branch === undefined ? {} : { branch: command.branch }),
17141714
...(command.worktreePath === undefined ? {} : { worktreePath: command.worktreePath }),
1715+
...(command.linkedPullRequest === undefined
1716+
? {}
1717+
: { linkedPullRequest: command.linkedPullRequest }),
17151718
// regenerateTitle: true arms the in-flight marker; a landing title
17161719
// or an explicit false (generation failed/abandoned) clears it.
17171720
...(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
@@ -1076,6 +1076,67 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => {
10761076
}),
10771077
);
10781078

1079+
it.effect("persists linked pull requests through projection rebuilds and unlinking", () =>
1080+
Effect.gen(function* () {
1081+
const orchestrator = yield* OrchestratorV2;
1082+
const maintenance = yield* ProjectionMaintenanceV2;
1083+
const threadId = ThreadId.make("runtime-layer-linked-pull-request-thread");
1084+
const linkedPullRequest = {
1085+
projectId: ProjectId.make("runtime-layer-linked-pull-request-project"),
1086+
repository: "pingdotgg/t3code",
1087+
number: 8160,
1088+
url: "https://github.com/pingdotgg/t3code/pull/8160",
1089+
} as const;
1090+
1091+
yield* orchestrator.dispatch({
1092+
type: "thread.create",
1093+
createdBy: "user",
1094+
creationSource: "web",
1095+
commandId: CommandId.make("runtime-layer-linked-pull-request-create"),
1096+
threadId,
1097+
projectId: linkedPullRequest.projectId,
1098+
title: "Linked pull request thread",
1099+
modelSelection,
1100+
runtimeMode: "full-access",
1101+
interactionMode: "default",
1102+
branch: null,
1103+
worktreePath: null,
1104+
});
1105+
yield* orchestrator.dispatch({
1106+
type: "thread.metadata.update",
1107+
commandId: CommandId.make("runtime-layer-linked-pull-request-link"),
1108+
threadId,
1109+
linkedPullRequest,
1110+
});
1111+
1112+
assert.deepEqual(
1113+
(yield* orchestrator.getThreadProjection(threadId)).thread.linkedPullRequest,
1114+
linkedPullRequest,
1115+
);
1116+
const linkedShell = yield* orchestrator.getThreadShell(threadId);
1117+
assert.isNotNull(linkedShell);
1118+
assert.deepEqual(linkedShell.linkedPullRequest, linkedPullRequest);
1119+
1120+
const rebuilt = yield* maintenance.rebuild;
1121+
assert.isTrue(rebuilt.valid);
1122+
assert.deepEqual(
1123+
(yield* orchestrator.getThreadProjection(threadId)).thread.linkedPullRequest,
1124+
linkedPullRequest,
1125+
);
1126+
1127+
yield* orchestrator.dispatch({
1128+
type: "thread.metadata.update",
1129+
commandId: CommandId.make("runtime-layer-linked-pull-request-unlink"),
1130+
threadId,
1131+
linkedPullRequest: null,
1132+
});
1133+
assert.isNull((yield* orchestrator.getThreadProjection(threadId)).thread.linkedPullRequest);
1134+
const unlinkedShell = yield* orchestrator.getThreadShell(threadId);
1135+
assert.isNotNull(unlinkedShell);
1136+
assert.isNull(unlinkedShell.linkedPullRequest);
1137+
}),
1138+
);
1139+
10791140
it.effect("persists rejected command receipts across retries", () =>
10801141
Effect.gen(function* () {
10811142
const orchestrator = yield* OrchestratorV2;

0 commit comments

Comments
 (0)