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
@@ -9,18 +9,16 @@ describe("resolveThreadReferenceCopyTarget", () => {
|
||||
threadId: "thread-1",
|
||||
openPanelPullRequestUrl: null,
|
||||
linkedPullRequestUrl: "https://github.com/t3/pr/12",
|
||||
detectedPullRequestUrl: "https://github.com/t3/pr/13",
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("prefers the open panel pull request over linked and detected pull requests", () => {
|
||||
it("prefers the open panel pull request over the thread pull request", () => {
|
||||
expect(
|
||||
resolveThreadReferenceCopyTarget({
|
||||
threadId: "thread-1",
|
||||
openPanelPullRequestUrl: "https://github.com/t3/pr/14",
|
||||
linkedPullRequestUrl: "https://github.com/t3/pr/12",
|
||||
detectedPullRequestUrl: "https://github.com/t3/pr/13",
|
||||
}),
|
||||
).toMatchObject({
|
||||
kind: "pull-request",
|
||||
@@ -29,12 +27,11 @@ describe("resolveThreadReferenceCopyTarget", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("prefers a durable linked pull request", () => {
|
||||
it("uses the thread pull request when no panel is open", () => {
|
||||
expect(
|
||||
resolveThreadReferenceCopyTarget({
|
||||
threadId: "thread-1",
|
||||
linkedPullRequestUrl: "https://github.com/t3/pr/12",
|
||||
detectedPullRequestUrl: "https://github.com/t3/pr/13",
|
||||
}),
|
||||
).toMatchObject({
|
||||
kind: "pull-request",
|
||||
@@ -43,18 +40,6 @@ describe("resolveThreadReferenceCopyTarget", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses a pull request detected from the active branch", () => {
|
||||
expect(
|
||||
resolveThreadReferenceCopyTarget({
|
||||
threadId: "thread-1",
|
||||
detectedPullRequestUrl: "https://github.com/t3/pr/13",
|
||||
}),
|
||||
).toMatchObject({
|
||||
kind: "pull-request",
|
||||
value: "https://github.com/t3/pr/13",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to the thread ID", () => {
|
||||
expect(resolveThreadReferenceCopyTarget({ threadId: "thread-1" })).toEqual({
|
||||
kind: "thread",
|
||||
|
||||
@@ -11,11 +11,9 @@ export function resolveThreadReferenceCopyTarget(input: {
|
||||
/** Undefined means no PR panel; null means its URL is not available yet. */
|
||||
readonly openPanelPullRequestUrl?: string | null | undefined;
|
||||
readonly linkedPullRequestUrl?: string | null;
|
||||
readonly detectedPullRequestUrl?: string | null;
|
||||
}): ThreadReferenceCopyTarget | null {
|
||||
if (input.openPanelPullRequestUrl === null) return null;
|
||||
const pullRequestUrl =
|
||||
input.openPanelPullRequestUrl ?? input.linkedPullRequestUrl ?? input.detectedPullRequestUrl;
|
||||
const pullRequestUrl = input.openPanelPullRequestUrl ?? input.linkedPullRequestUrl;
|
||||
return pullRequestUrl
|
||||
? {
|
||||
kind: "pull-request",
|
||||
|
||||
Reference in new issue
Block a user