Files
openchamber/packages/vscode/webview/api/github.ts
T
Tom RochetteandBohdan Triapitsyn 7b1b3167a4 feat: server-side GitHub search for issue/PR pickers (#1352)
Replace local-only filtering in GitHub issue/PR picker dialogs with
server-side GitHub Search API queries. Search text is sent as a query
parameter to the server, which uses the GitHub Search API
(issuesAndPullRequests endpoint) with repo: qualifiers including fork
network support. Results are debounced at 350ms to respect API rate
limits.

- Add query parameter to GitHubAPI issuesList/prsList interface
- Server routes use Search API when query is present, standard list
  endpoint when absent
- Fork networks handled via repo:owner/repo OR repo:owner/upstream
- PR search fetches full PR details after Search API for head/base/draft
  fields
- Remove local filter memos from all three picker dialogs
- Add debounced search effect with abort controller cleanup
- Update VS Code backend and webview API for parity
- Update search placeholders in all locales

Closes #1350

Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
2026-06-08 15:37:42 +03:00

69 lines
3.7 KiB
TypeScript

import type {
GitHubAPI,
GitHubAuthStatus,
GitHubIssueCommentsResult,
GitHubIssueGetResult,
GitHubIssuesListResult,
GitHubPullRequestContextResult,
GitHubPullRequestsListResult,
GitHubPullRequest,
GitHubPullRequestCreateInput,
GitHubPullRequestMergeInput,
GitHubPullRequestMergeResult,
GitHubPullRequestReadyInput,
GitHubPullRequestReadyResult,
GitHubPullRequestUpdateInput,
GitHubPullRequestStatus,
GitHubDeviceFlowComplete,
GitHubDeviceFlowStart,
GitHubRepoUpstreamResult,
GitHubUserSummary,
} from '@openchamber/ui/lib/api/types';
import { sendBridgeMessage } from './bridge';
export const createVSCodeGitHubAPI = (): GitHubAPI => ({
authStatus: async () => sendBridgeMessage<GitHubAuthStatus>('api:github/auth:status'),
authStart: async () => sendBridgeMessage<GitHubDeviceFlowStart>('api:github/auth:start'),
authComplete: async (deviceCode: string) =>
sendBridgeMessage<GitHubDeviceFlowComplete>('api:github/auth:complete', { deviceCode }),
authDisconnect: async () => sendBridgeMessage<{ removed: boolean }>('api:github/auth:disconnect'),
authActivate: async (accountId: string) =>
sendBridgeMessage<GitHubAuthStatus>('api:github/auth:activate', { accountId }),
me: async () => sendBridgeMessage<GitHubUserSummary>('api:github/me'),
prStatus: async (directory: string, branch: string) =>
sendBridgeMessage<GitHubPullRequestStatus>('api:github/pr:status', { directory, branch }),
prCreate: async (payload: GitHubPullRequestCreateInput) =>
sendBridgeMessage<GitHubPullRequest>('api:github/pr:create', payload),
prUpdate: async (payload: GitHubPullRequestUpdateInput) =>
sendBridgeMessage<GitHubPullRequest>('api:github/pr:update', payload),
prMerge: async (payload: GitHubPullRequestMergeInput) =>
sendBridgeMessage<GitHubPullRequestMergeResult>('api:github/pr:merge', payload),
prReady: async (payload: GitHubPullRequestReadyInput) =>
sendBridgeMessage<GitHubPullRequestReadyResult>('api:github/pr:ready', payload),
issuesList: async (directory: string, options?: { page?: number; query?: string }) =>
sendBridgeMessage<GitHubIssuesListResult>('api:github/issues:list', { directory, page: options?.page ?? 1, query: options?.query ?? '' }),
issueGet: async (directory: string, number: number, options?: { sourceRepo?: { owner: string; repo: string } | null }) =>
sendBridgeMessage<GitHubIssueGetResult>('api:github/issues:get', { directory, number, sourceRepo: options?.sourceRepo ?? null }),
issueComments: async (directory: string, number: number, options?: { sourceRepo?: { owner: string; repo: string } | null }) =>
sendBridgeMessage<GitHubIssueCommentsResult>('api:github/issues:comments', { directory, number, sourceRepo: options?.sourceRepo ?? null }),
prsList: async (directory: string, options?: { page?: number; query?: string }) =>
sendBridgeMessage<GitHubPullRequestsListResult>('api:github/pulls:list', { directory, page: options?.page ?? 1, query: options?.query ?? '' }),
prContext: async (directory: string, number: number, options?: { includeDiff?: boolean; includeCheckDetails?: boolean; sourceRepo?: { owner: string; repo: string } | null }) =>
sendBridgeMessage<GitHubPullRequestContextResult>('api:github/pulls:context', {
directory,
number,
includeDiff: Boolean(options?.includeDiff),
includeCheckDetails: Boolean(options?.includeCheckDetails),
sourceRepo: options?.sourceRepo ?? null,
}),
repoUpstream: async (directory: string) =>
sendBridgeMessage<GitHubRepoUpstreamResult>('api:github/repo:upstream', { directory }),
repoBranches: async (owner: string, repo: string) =>
sendBridgeMessage<string[]>('api:github/repo:branches', { owner, repo }),
});