feat: fork-aware issue/PR listing & OpenCode startup loading indicator (#1061)
* Add design spec: OpenCode readiness loading indicator * Add implementation plan: OpenCode readiness loading indicator * feat: add useOpenCodeReadiness hook * feat: add i18n keys for common.loading * feat: add loading state to ModelSelector * feat: add loading state to AgentSelector * feat: add loading state to ModelControls chat selectors * update package-lock * feat(github): add shared fork detection utility * feat(github): make issue listing fork-aware * feat(github): make PR listing fork-aware * feat(types): add sourceRepo to issue/PR summary types * feat(ui): add source badges to GitHub integration dialog * feat(ui): add source badges to issue/PR picker dialogs * feat(github): pass headRemote in PR creation for fork support * feat(ui): add source→target label in PR tab for fork workflows * fix(github): allow PR section on base branch when upstream remote exists * fix(github): show PR section on any branch including main for fork→upstream PRs * fix(github): allow PullRequestSection to render on base branch when upstream remote exists * feat(github): auto-detect upstream repo for fork→upstream PR creation - Add GET /api/github/repo/upstream endpoint to discover fork's upstream - Fix PullRequestSection canShow to allow PR creation on base branch when repo is a fork - Add virtual upstream target in remote dropdown (no explicit upstream remote needed) - Add targetRepo parameter to /api/github/pr/create for direct upstream targeting - Add repoUpstream() API client method and GitHubRepoUpstreamResult type * feat(github): auto-detect upstream repo for fork→upstream PR creation - Add GET /api/github/repo/upstream endpoint to discover fork's upstream - Fix PullRequestSection canShow to allow PR creation on base branch when repo is a fork - Add virtual upstream target in remote dropdown (no explicit upstream remote needed) - Add targetRepo parameter to /api/github/pr/create for direct upstream targeting - Add repoUpstream() API client method and GitHubRepoUpstreamResult type * fix: complete fork→upstream PR workflow - Server: return defaultBranch from /api/github/repo/upstream endpoint - Server: fix cross-repo head ref construction (compare repos, not remote names) - Server: filterActiveRemoteBranches checks all remotes, not just origin - UI: set targetBaseBranch to upstream's default branch when using detected upstream - UI: include all remote branches in base branch dropdown when using detected upstream - UI: skip base===head check for cross-repo PRs (same branch name on different repos is valid) - Types: add defaultBranch to GitHubRepoUpstreamResult * chore: delete superpowers folder * feat: add (local)/(remote) labels to PR branch display and adapt Repository button to selected remote * feat: Repository button adapts to selected remote (upstream vs origin) * fix: complete fork→upstream PR feature gaps Server: - Extend /api/github/repo/upstream to return defaultBranchSha and remoteName - Reuse headRepo result instead of redundant resolveGitHubRepoFromDirectory call - Return clear error when headRepo is null (invalid GitHub URL) UI: - Add upstream's default branch to availableBaseBranches when using detected upstream - Use upstream's default branch SHA in git log for generate description (fixes 'No commits found in range main...main') - Show qualified names (owner/repo · branch) in base branch dropdown when using detected upstream Types: - Add defaultBranchSha and remoteName to GitHubRepoUpstreamResult * fix: move detectedUpstream state before availableBaseBranches to fix temporal dead zone * fix: fetch upstream branches from GitHub API for base branch dropdown - Add GET /api/github/repo/branches endpoint to fetch branches via Octokit - Add repoBranches() to GitHub API client and interface - Fetch upstream branches on detection and store in upstreamBranches state - Include upstreamBranches in availableBaseBranches when using detected upstream - Re-add availableBaseBranches memo and auto-correction effect that were lost - Remove unnecessary qualified names from dropdown (upstream is already selected) * fix: restore prStatusKey and statusEntry declarations lost during refactor * fix: cleanly re-apply all fork→upstream PR UI changes Restored PullRequestSection.tsx from clean base and re-applied: - Expand detectedUpstream type with defaultBranch, defaultBranchSha, remoteName - Add upstreamBranches state and fetch on upstream detection - Include upstream branches in availableBaseBranches when using detected upstream - Use upstream default branch SHA in generate description (fixes 'No commits found') - Adapt Repository button URL to selected remote - Add (local)/(remote)/(upstream) labels to branch display * fix: move detectedUpstream/upstreamBranches before availableBaseBranches to fix TDZ * style: add pill badge styling to upstream repo source labels * fix: don't cache error PR status responses, allow force-bypass of server cache * fix: resolve PR status cache bugs, stale directory fallback, and upstream re-detection * fix: keep collapse button visible when scrolling long user messages - Collapse button now sticks to top of scrollable user message content instead of scrolling away * fix: checkbox focus ring blends into sidebar background * fix: polish fork PR follow-ups * fix: remove user message collapse artifact * fix: tighten fork PR internals * fix: check all remotes for fork PR status * fix: recover sidebar PR status misses --------- Signed-off-by: Islam Nofl <islamnofl.official@gmail.com> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Bohdan Triapitsyn
parent
17650becc0
commit
21253d7fc2
@@ -14,6 +14,7 @@ import type {
|
||||
GitHubPullRequestReadyResult,
|
||||
GitHubPullRequestUpdateInput,
|
||||
GitHubPullRequestStatus,
|
||||
GitHubRepoUpstreamResult,
|
||||
GitHubDeviceFlowComplete,
|
||||
GitHubDeviceFlowStart,
|
||||
GitHubUserSummary,
|
||||
@@ -90,11 +91,12 @@ export const createWebGitHubAPI = (): GitHubAPI => ({
|
||||
return payload;
|
||||
},
|
||||
|
||||
async prStatus(directory: string, branch: string, remote?: string): Promise<GitHubPullRequestStatus> {
|
||||
async prStatus(directory: string, branch: string, remote?: string, options?: { force?: boolean }): Promise<GitHubPullRequestStatus> {
|
||||
const params = new URLSearchParams({
|
||||
directory,
|
||||
branch,
|
||||
...(remote ? { remote } : {}),
|
||||
...(options?.force ? { force: 'true' } : {}),
|
||||
});
|
||||
const response = await fetch(
|
||||
`/api/github/pr/status?${params.toString()}`,
|
||||
@@ -159,6 +161,30 @@ export const createWebGitHubAPI = (): GitHubAPI => ({
|
||||
return body;
|
||||
},
|
||||
|
||||
async repoUpstream(directory: string): Promise<GitHubRepoUpstreamResult> {
|
||||
const response = await fetch(
|
||||
`/api/github/repo/upstream?directory=${encodeURIComponent(directory)}`,
|
||||
{ method: 'GET', headers: { Accept: 'application/json' } }
|
||||
);
|
||||
const body = await jsonOrNull<GitHubRepoUpstreamResult & { error?: string }>(response);
|
||||
if (!response.ok || !body) {
|
||||
throw new Error(body?.error || response.statusText || 'Failed to detect upstream repo');
|
||||
}
|
||||
return body;
|
||||
},
|
||||
|
||||
async repoBranches(owner: string, repo: string): Promise<string[]> {
|
||||
const response = await fetch(
|
||||
`/api/github/repo/branches?owner=${encodeURIComponent(owner)}&repo=${encodeURIComponent(repo)}`,
|
||||
{ method: 'GET', headers: { Accept: 'application/json' } }
|
||||
);
|
||||
const body = await jsonOrNull<{ branches?: string[]; error?: string }>(response);
|
||||
if (!response.ok || !body) {
|
||||
throw new Error(body?.error || response.statusText || 'Failed to fetch repo branches');
|
||||
}
|
||||
return body.branches ?? [];
|
||||
},
|
||||
|
||||
async prsList(directory: string, options?: { page?: number }): Promise<GitHubPullRequestsListResult> {
|
||||
const page = options?.page ?? 1;
|
||||
const response = await fetch(
|
||||
@@ -175,7 +201,7 @@ export const createWebGitHubAPI = (): GitHubAPI => ({
|
||||
async prContext(
|
||||
directory: string,
|
||||
number: number,
|
||||
options?: { includeDiff?: boolean; includeCheckDetails?: boolean }
|
||||
options?: { includeDiff?: boolean; includeCheckDetails?: boolean; sourceRepo?: { owner: string; repo: string } | null }
|
||||
): Promise<GitHubPullRequestContextResult> {
|
||||
const url = new URL('/api/github/pulls/context', window.location.origin);
|
||||
url.searchParams.set('directory', directory);
|
||||
@@ -186,6 +212,10 @@ export const createWebGitHubAPI = (): GitHubAPI => ({
|
||||
if (options?.includeCheckDetails) {
|
||||
url.searchParams.set('checkDetails', '1');
|
||||
}
|
||||
if (options?.sourceRepo?.owner && options.sourceRepo.repo) {
|
||||
url.searchParams.set('owner', options.sourceRepo.owner);
|
||||
url.searchParams.set('repo', options.sourceRepo.repo);
|
||||
}
|
||||
const response = await fetch(url.toString(), { method: 'GET', headers: { Accept: 'application/json' } });
|
||||
const body = await jsonOrNull<GitHubPullRequestContextResult & { error?: string }>(response);
|
||||
if (!response.ok || !body) {
|
||||
@@ -207,11 +237,15 @@ export const createWebGitHubAPI = (): GitHubAPI => ({
|
||||
return payload;
|
||||
},
|
||||
|
||||
async issueGet(directory: string, number: number): Promise<GitHubIssueGetResult> {
|
||||
const response = await fetch(
|
||||
`/api/github/issues/get?directory=${encodeURIComponent(directory)}&number=${encodeURIComponent(String(number))}`,
|
||||
{ method: 'GET', headers: { Accept: 'application/json' } }
|
||||
);
|
||||
async issueGet(directory: string, number: number, options?: { sourceRepo?: { owner: string; repo: string } | null }): Promise<GitHubIssueGetResult> {
|
||||
const url = new URL('/api/github/issues/get', window.location.origin);
|
||||
url.searchParams.set('directory', directory);
|
||||
url.searchParams.set('number', String(number));
|
||||
if (options?.sourceRepo?.owner && options.sourceRepo.repo) {
|
||||
url.searchParams.set('owner', options.sourceRepo.owner);
|
||||
url.searchParams.set('repo', options.sourceRepo.repo);
|
||||
}
|
||||
const response = await fetch(url.toString(), { method: 'GET', headers: { Accept: 'application/json' } });
|
||||
const payload = await jsonOrNull<GitHubIssueGetResult & { error?: string }>(response);
|
||||
if (!response.ok || !payload) {
|
||||
throw new Error(payload?.error || response.statusText || 'Failed to load issue');
|
||||
@@ -219,11 +253,15 @@ export const createWebGitHubAPI = (): GitHubAPI => ({
|
||||
return payload;
|
||||
},
|
||||
|
||||
async issueComments(directory: string, number: number): Promise<GitHubIssueCommentsResult> {
|
||||
const response = await fetch(
|
||||
`/api/github/issues/comments?directory=${encodeURIComponent(directory)}&number=${encodeURIComponent(String(number))}`,
|
||||
{ method: 'GET', headers: { Accept: 'application/json' } }
|
||||
);
|
||||
async issueComments(directory: string, number: number, options?: { sourceRepo?: { owner: string; repo: string } | null }): Promise<GitHubIssueCommentsResult> {
|
||||
const url = new URL('/api/github/issues/comments', window.location.origin);
|
||||
url.searchParams.set('directory', directory);
|
||||
url.searchParams.set('number', String(number));
|
||||
if (options?.sourceRepo?.owner && options.sourceRepo.repo) {
|
||||
url.searchParams.set('owner', options.sourceRepo.owner);
|
||||
url.searchParams.set('repo', options.sourceRepo.repo);
|
||||
}
|
||||
const response = await fetch(url.toString(), { method: 'GET', headers: { Accept: 'application/json' } });
|
||||
const payload = await jsonOrNull<GitHubIssueCommentsResult & { error?: string }>(response);
|
||||
if (!response.ok || !payload) {
|
||||
throw new Error(payload?.error || response.statusText || 'Failed to load issue comments');
|
||||
|
||||
Reference in New Issue
Block a user