fix(server): link thread PRs without an open client (#10101)
Co-authored-by: Claude Fable 5.1 <[email protected]>
This commit is contained in:
1 parent
5fa35d2116
commit
223ff4490f
50 files changed
+2308
-1485
No files matched your search
@@ -306,50 +306,65 @@ describe("applyThreadDetailEvent", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("sets and clears a linked pull request", () => {
|
||||
const linkedPullRequest = {
|
||||
projectId: ProjectId.make("project-1"),
|
||||
repository: "pingdotgg/t3code",
|
||||
number: 42,
|
||||
url: "https://github.com/pingdotgg/t3code/pull/42",
|
||||
};
|
||||
const linked = applyThreadDetailEvent(baseThread, {
|
||||
...baseEventFields,
|
||||
sequence: 5,
|
||||
occurredAt: "2026-04-01T05:00:00.000Z",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.make("thread-1"),
|
||||
type: "thread.meta-updated",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
linkedPullRequest,
|
||||
updatedAt: "2026-04-01T05:00:00.000Z",
|
||||
},
|
||||
});
|
||||
it.each(["linkedPullRequest", "branchPullRequest"] as const)(
|
||||
"sets and clears %s without changing the other link",
|
||||
(field) => {
|
||||
const linkedPullRequest = {
|
||||
projectId: ProjectId.make("project-1"),
|
||||
repository: "pingdotgg/t3code",
|
||||
number: 42,
|
||||
url: "https://github.com/pingdotgg/t3code/pull/42",
|
||||
};
|
||||
const otherField =
|
||||
field === "linkedPullRequest" ? "branchPullRequest" : "linkedPullRequest";
|
||||
const otherPullRequest = {
|
||||
...linkedPullRequest,
|
||||
number: 43,
|
||||
url: "https://github.com/pingdotgg/t3code/pull/43",
|
||||
};
|
||||
const linked = applyThreadDetailEvent(
|
||||
{ ...baseThread, [otherField]: otherPullRequest },
|
||||
{
|
||||
...baseEventFields,
|
||||
sequence: 5,
|
||||
occurredAt: "2026-04-01T05:00:00.000Z",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.make("thread-1"),
|
||||
type: "thread.meta-updated",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
[field]: linkedPullRequest,
|
||||
updatedAt: "2026-04-01T05:00:00.000Z",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(linked.kind).toBe("updated");
|
||||
if (linked.kind !== "updated") return;
|
||||
expect(linked.thread.linkedPullRequest).toEqual(linkedPullRequest);
|
||||
expect(linked.kind).toBe("updated");
|
||||
if (linked.kind !== "updated") return;
|
||||
expect(linked.thread[field]).toEqual(linkedPullRequest);
|
||||
expect(linked.thread[otherField]).toEqual(otherPullRequest);
|
||||
|
||||
const cleared = applyThreadDetailEvent(linked.thread, {
|
||||
...baseEventFields,
|
||||
sequence: 6,
|
||||
occurredAt: "2026-04-01T06:00:00.000Z",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.make("thread-1"),
|
||||
type: "thread.meta-updated",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
linkedPullRequest: null,
|
||||
updatedAt: "2026-04-01T06:00:00.000Z",
|
||||
},
|
||||
});
|
||||
const cleared = applyThreadDetailEvent(linked.thread, {
|
||||
...baseEventFields,
|
||||
sequence: 6,
|
||||
occurredAt: "2026-04-01T06:00:00.000Z",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.make("thread-1"),
|
||||
type: "thread.meta-updated",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
[field]: null,
|
||||
updatedAt: "2026-04-01T06:00:00.000Z",
|
||||
},
|
||||
});
|
||||
|
||||
expect(cleared.kind).toBe("updated");
|
||||
if (cleared.kind === "updated") {
|
||||
expect(cleared.thread.linkedPullRequest).toBeNull();
|
||||
}
|
||||
});
|
||||
expect(cleared.kind).toBe("updated");
|
||||
if (cleared.kind === "updated") {
|
||||
expect(cleared.thread[field]).toBeNull();
|
||||
expect(cleared.thread[otherField]).toEqual(otherPullRequest);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("thread.message-sent", () => {
|
||||
|
||||
@@ -97,6 +97,7 @@ export function applyThreadDetailEvent(
|
||||
interactionMode: event.payload.interactionMode,
|
||||
branch: event.payload.branch,
|
||||
worktreePath: event.payload.worktreePath,
|
||||
branchPullRequest: null,
|
||||
latestTurn: null,
|
||||
createdAt: event.payload.createdAt,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
@@ -240,6 +241,9 @@ export function applyThreadDetailEvent(
|
||||
...(event.payload.linkedPullRequest !== undefined
|
||||
? { linkedPullRequest: event.payload.linkedPullRequest }
|
||||
: {}),
|
||||
...(event.payload.branchPullRequest !== undefined
|
||||
? { branchPullRequest: event.payload.branchPullRequest }
|
||||
: {}),
|
||||
updatedAt: event.payload.updatedAt,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user