feat(pull-requests): link multiple pull requests to threads (#10839)
This commit is contained in:
1 parent
383cc40f4d
commit
afb84898be
172 files changed
+12063
-914
No files matched your search
@@ -10,8 +10,10 @@ import type {
|
||||
OrchestrationSession,
|
||||
OrchestrationThread,
|
||||
OrchestrationThreadActivity,
|
||||
ThreadPullRequestLink,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import { threadPullRequestKeysEqual } from "@t3tools/shared/threadPullRequests";
|
||||
import { isImportedAgentSessionMessageId } from "@t3tools/contracts";
|
||||
import { compareDateTimeStrings } from "@t3tools/shared/dateTime";
|
||||
|
||||
@@ -20,6 +22,29 @@ export type ThreadDetailReducerResult =
|
||||
| { readonly kind: "deleted" }
|
||||
| { readonly kind: "unchanged" };
|
||||
|
||||
/** Keep only a legacy route supplied by the server; detail events cannot resolve project hosts. */
|
||||
function withPullRequests(
|
||||
thread: OrchestrationThread,
|
||||
pullRequests: ReadonlyArray<ThreadPullRequestLink>,
|
||||
updatedAt: string,
|
||||
): ThreadDetailReducerResult {
|
||||
return {
|
||||
kind: "updated",
|
||||
thread: {
|
||||
...thread,
|
||||
pullRequests,
|
||||
linkedPullRequest:
|
||||
thread.linkedPullRequest &&
|
||||
pullRequests.some(
|
||||
(link) => link.source !== "stack-dismissed" && link.url === thread.linkedPullRequest?.url,
|
||||
)
|
||||
? thread.linkedPullRequest
|
||||
: null,
|
||||
updatedAt,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const proposedPlanOrder = O.combine<OrchestrationThread["proposedPlans"][number]>(
|
||||
O.mapInput(O.String, (p) => p.createdAt),
|
||||
O.mapInput(O.String, (p) => p.id),
|
||||
@@ -109,6 +134,7 @@ export function applyThreadDetailEvent(
|
||||
snoozedUntil: null,
|
||||
snoozedAt: null,
|
||||
deletedAt: null,
|
||||
pullRequests: [],
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
activities: [],
|
||||
@@ -253,6 +279,40 @@ export function applyThreadDetailEvent(
|
||||
},
|
||||
};
|
||||
|
||||
case "thread.pull-request-linked": {
|
||||
const link = event.payload.link;
|
||||
const others = thread.pullRequests.filter(
|
||||
(existing) => !threadPullRequestKeysEqual(existing, link),
|
||||
);
|
||||
return withPullRequests(thread, [...others, link], event.payload.updatedAt);
|
||||
}
|
||||
|
||||
case "thread.pull-request-unlinked":
|
||||
return withPullRequests(
|
||||
thread,
|
||||
thread.pullRequests.filter(
|
||||
(existing) => !threadPullRequestKeysEqual(existing, event.payload),
|
||||
),
|
||||
event.payload.updatedAt,
|
||||
);
|
||||
|
||||
case "thread.pull-request-synced": {
|
||||
if (
|
||||
!thread.pullRequests.some((existing) => threadPullRequestKeysEqual(existing, event.payload))
|
||||
) {
|
||||
return { kind: "unchanged" };
|
||||
}
|
||||
return withPullRequests(
|
||||
thread,
|
||||
thread.pullRequests.map((existing) =>
|
||||
threadPullRequestKeysEqual(existing, event.payload)
|
||||
? { ...existing, snapshot: event.payload.snapshot, stack: event.payload.stack }
|
||||
: existing,
|
||||
),
|
||||
event.payload.updatedAt,
|
||||
);
|
||||
}
|
||||
|
||||
case "thread.runtime-mode-set":
|
||||
return {
|
||||
kind: "updated",
|
||||
|
||||
Reference in new issue
Block a user