Skip to content

Commit 0232932

Browse files
fix(clients): prompt links find projects cloned from git.cafe (#26042)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent a56ecda commit 0232932

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎packages/client-runtime/src/promptLinks.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ describe("findPromptLinkProjects", () => {
3939
expect(ids("me", "t3code")).toEqual(["fork"]);
4040
expect(ids("gitlab", "x")).toEqual([]);
4141
});
42+
43+
it("matches a checkout of the repository's GitCafe mirror", () => {
44+
const projects = [
45+
{ id: "gitcafe", repositoryIdentity: identity("git.cafe/pingdotgg/t3code") },
46+
{ id: "staging", repositoryIdentity: identity("staging.git.cafe/pingdotgg/t3code") },
47+
{ id: "gitlab", repositoryIdentity: identity("gitlab.com/pingdotgg/t3code") },
48+
];
49+
expect(
50+
findPromptLinkProjects(projects, { owner: "pingdotgg", name: "t3code" }).map(
51+
(project) => project.id,
52+
),
53+
).toEqual(["gitcafe", "staging"]);
54+
});
4255
});
4356

4457
describe("pickPromptLinkPullRequestThread", () => {

‎packages/client-runtime/src/promptLinks.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import {
1818
visibleThreadPullRequests,
1919
} from "./threadPullRequests.ts";
2020

21-
const repositoryKey = (repository: PromptLinkRepository) =>
22-
`github.com/${repository.owner}/${repository.name}`.toLowerCase();
21+
// A link's `owner/name` is GitHub's. GitCafe syncs a repository two-way with GitHub under the
22+
// same path, so a checkout cloned from git.cafe counts as the linked repository.
23+
const PROMPT_LINK_REPOSITORY_HOSTS = ["github.com", "git.cafe", "staging.git.cafe"];
2324

2425
/**
2526
* The repository's projects in the order given. Callers pass projects most recently active
@@ -28,11 +29,12 @@ const repositoryKey = (repository: PromptLinkRepository) =>
2829
export function findPromptLinkProjects<
2930
P extends { readonly repositoryIdentity?: RepositoryIdentity | null | undefined },
3031
>(projects: ReadonlyArray<P>, repository: PromptLinkRepository): P[] {
31-
const key = repositoryKey(repository);
32+
const path = `${repository.owner}/${repository.name}`.toLowerCase();
33+
const keys = new Set(PROMPT_LINK_REPOSITORY_HOSTS.map((host) => `${host}/${path}`));
3234
return projects.filter(
3335
(project) =>
3436
project.repositoryIdentity != null &&
35-
repositoryGroupingKeyOf(project.repositoryIdentity).toLowerCase() === key,
37+
keys.has(repositoryGroupingKeyOf(project.repositoryIdentity).toLowerCase()),
3638
);
3739
}
3840

0 commit comments

Comments
 (0)