Detect GitHub issue/PR URL in composer search

Pasting a GitHub issue or pull request URL into the composer's
issue/PR picker now searches by the number from the URL instead
of treating the full URL as a keyword that returns no matches.
This commit is contained in:
Mohamed Boudra
2026-05-07 15:23:45 +07:00
parent 0785ee31f0
commit bad304c2d3
2 changed files with 50 additions and 2 deletions
+12 -2
View File
@@ -933,11 +933,12 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
const readOptions: GitHubReadOptions = input.force
? { force: true, reason: input.reason }
: { force: false, reason: input.reason };
const query = normalizeGitHubSearchQuery(input.query);
const [issuesResult, prsResult] = await Promise.allSettled([
shouldFetchIssues
? this.listIssues({
cwd: input.cwd,
query: input.query,
query,
limit: input.limit,
...readOptions,
})
@@ -945,7 +946,7 @@ export function createGitHubService(options: CreateGitHubServiceOptions = {}): G
shouldFetchPullRequests
? this.listPullRequests({
cwd: input.cwd,
query: input.query,
query,
limit: input.limit,
...readOptions,
})
@@ -1171,6 +1172,15 @@ async function runGhCommand(
});
}
const GITHUB_ISSUE_OR_PR_URL_PATTERN =
/^https?:\/\/github\.com\/[^/\s]+\/[^/\s]+\/(?:pull|issues)\/(\d+)(?:[/?#].*)?$/i;
function normalizeGitHubSearchQuery(query: string): string {
const trimmed = query.trim();
const match = trimmed.match(GITHUB_ISSUE_OR_PR_URL_PATTERN);
return match ? match[1] : query;
}
function buildCacheKey(params: { cwd: string; method: string; args: unknown }): string {
return `${params.cwd}:${params.method}:${stableStringify(params.args)}`;
}