Skip to content

fix(github): load PR diffs for Enterprise remotes - #8932

Merged
AmethystLiang merged 24 commits into
stablyai:mainfrom
wonjerry:fix-ghes-work-item-diffs
Jul 21, 2026
Merged

AmethystLiang merged 24 commits into
stablyai:mainfrom
wonjerry:fix-ghes-work-item-diffs

Conversation

@wonjerry

@wonjerry wonjerry commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #8935.

Fix GitHub Enterprise Server PR work item details so file diffs and file contents are loaded against the Enterprise host instead of falling back to github.com.

This routes PR detail GitHub CLI calls through the Enterprise repo slug discovered from the remote URL when the standard GitHub.com owner/repo lookup is unavailable. It also encodes PR file-content paths by path segment so filenames containing characters like # or ? do not break the GitHub contents API URL.

Screenshots

No visual change. Behavior was verified locally in the dev app by opening a GitHub Enterprise work item and confirming the file diff now loads.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test - latest full passing run: 2,871 test files passed, 30,430 tests passed; 6 files / 45 tests skipped
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Additional targeted verification:

  • pnpm exec oxlint src/main/github/work-item-details.ts src/main/github/work-item-details.test.ts
  • pnpm exec vitest run --config config/vitest.config.ts src/main/github/work-item-details.test.ts
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts -t "cancels deferred cleanup on a new command and retires identity at its later shell"
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • pnpm run tc:node
  • pnpm run build:electron-vite
  • git diff --check

Notes from local runs: the repo currently emits a Node engine warning because this machine is running Node v22.22.3 while package.json wants Node 24. The full lint/test/build commands completed successfully on the latest pushed code. One earlier full pnpm test run hit an unrelated flaky terminal-pane test; the exact failed test, its full test file, and a subsequent full pnpm test run all passed. The full build also emitted existing Vite/CSS/chunk warnings, a non-fatal /usr/local/bin/orca-dev symlink permission warning, and native macOS build warnings.

AI Review Report

Codex reviewed the change for GHES/GitHub.com routing regressions, command argument construction, fallback behavior when owner/repo metadata is unavailable, and cross-platform compatibility. The review explicitly checked that the touched logic avoids shell-specific behavior and keeps command arguments as argv arrays, so macOS, Linux, and Windows behavior should remain consistent. No shortcuts, labels, paths, renderer UI, or Electron platform-specific behavior are changed by this PR.

CodeRabbit flagged that encodeURI(args.path) could leave characters such as # and ? unescaped in GitHub contents API paths. This was addressed by encoding each path segment with encodeURIComponent while preserving /, and the test coverage now includes a PR file path containing both # and ?.

Security Audit

Codex reviewed input handling, command execution, auth, and IPC risk for the touched code. The Enterprise host comes from the existing remote URL parsing helper, and it is passed as a single gh argv value rather than interpolated into a shell string. PR file paths are encoded by segment before being placed in the GitHub contents API path. No secrets, tokens, dependencies, filesystem writes, IPC surfaces, or permission flows are introduced.

Follow-up: while testing the dev app, existing gh pr checks --json warnings appeared for the local environment, but that path is caught/logged and is separate from the PR diff loading fix.

Notes

This fixes the PR diff/file content path used by work item details for GitHub Enterprise remotes. Issue timeline calls can now accept an optional host, but the current issue lookup path still depends on GitHub.com owner/repo metadata and may need separate follow-up for Enterprise issue-only work items.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5f5a42ed-1bbb-41d3-a1a9-2e5889ac156c

📥 Commits

Reviewing files that changed from the base of the PR and between 77789a8 and ce2e9c4.

📒 Files selected for processing (21)
  • src/main/github/client-file-viewed.test.ts
  • src/main/github/client-pr-check-details.test.ts
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/client-pr-local-runtime.test.ts
  • src/main/github/client-work-items.test.ts
  • src/main/github/client.test.ts
  • src/main/github/default-branch-stale-pr.test.ts
  • src/main/github/github-api-repository.test.ts
  • src/main/github/github-repository-identity.fork-owner-repo.test.ts
  • src/main/github/issues.test.ts
  • src/main/github/work-item-details-concurrency.test.ts
  • src/main/github/work-item-details-enterprise-host.test.ts
  • src/main/github/work-item-details-file-viewed.test.ts
  • src/main/github/work-item-details-pr-files.test.ts
  • src/main/github/work-item-details.test.ts
  • src/main/runtime/runtime-rpc.test.ts
  • src/renderer/src/components/github-project/ProjectPicker.tsx
  • src/renderer/src/components/new-workspace/SmartWorkspaceNameField.tsx
  • src/renderer/src/lib/repo-slug-index.ts
  • src/shared/repo-icon.test.ts
  • src/shared/repo-icon.ts
🚧 Files skipped from review as they are similar to previous changes (16)
  • src/main/github/work-item-details-concurrency.test.ts
  • src/shared/repo-icon.test.ts
  • src/shared/repo-icon.ts
  • src/main/github/client-pr-check-details.test.ts
  • src/main/github/work-item-details-enterprise-host.test.ts
  • src/main/github/github-api-repository.test.ts
  • src/main/github/work-item-details-pr-files.test.ts
  • src/main/github/client-work-items.test.ts
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/client-file-viewed.test.ts
  • src/renderer/src/lib/repo-slug-index.ts
  • src/main/github/work-item-details.test.ts
  • src/renderer/src/components/github-project/ProjectPicker.tsx
  • src/main/github/client-pr-local-runtime.test.ts
  • src/main/github/client.test.ts
  • src/renderer/src/components/new-workspace/SmartWorkspaceNameField.tsx

📝 Walkthrough

Walkthrough

The change adds GitHub host identity handling across repository resolution, CLI execution, rate-limit accounting, API clients, ProjectV2 operations, RPC and preload boundaries, mobile actions, renderer caches, links, avatars, and authentication diagnostics. Enterprise repositories are resolved and authenticated by host, CLI calls receive host-qualified execution options, rate-limit breakers track runtime and host scopes, and PR/work-item operations preserve repository identity through reads, mutations, caching, and content retrieval.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also includes broad host-scoping refactors across rate limiting, projects, auth, mobile, and renderer code beyond #8935. Split the unrelated host-scoping refactors into separate PRs and keep this change focused on PR diff/content routing and path encoding.
Docstring Coverage ⚠️ Warning Docstring coverage is 26.80% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: loading PR diffs for Enterprise remotes.
Description check ✅ Passed The description includes the required summary, screenshots, testing, AI review, security, and notes sections with substantive details.
Linked Issues check ✅ Passed The core fix routes PR file/diff loading through GHES repo resolution and segment-encodes contents paths as required by #8935.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/github/work-item-details.ts (1)

1143-1144: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Fix path encoding for files with special characters.

Using encodeURI(args.path) preserves /, but it fails to encode characters like ? or # which are valid in Git filenames. This breaks the API URL structure when querying files containing these characters, as they will incorrectly act as query parameter delimiters.

Use split('/').map(encodeURIComponent).join('/') to safely encode each path segment while preserving the directory separators.

🛠️ Proposed fix to path encoding
-        ...ghApiHostArgs(args.ownerRepo),
-        `repos/${args.ownerRepo.owner}/${args.ownerRepo.repo}/contents/${encodeURI(args.path)}?ref=${encodeURIComponent(args.ref)}`
+        ...ghApiHostArgs(args.ownerRepo),
+        `repos/${args.ownerRepo.owner}/${args.ownerRepo.repo}/contents/${args.path.split('/').map(encodeURIComponent).join('/')}?ref=${encodeURIComponent(args.ref)}`

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 23bacb35-a07a-4b2a-9c17-591126682db6

📥 Commits

Reviewing files that changed from the base of the PR and between 78d2b95 and cf03c715999473c1f63d9c396a3cb670091f12d1.

📒 Files selected for processing (2)
  • src/main/github/work-item-details.test.ts
  • src/main/github/work-item-details.ts

@wonjerry

Copy link
Copy Markdown
Contributor Author

Addressed the CodeRabbit path-encoding nit in 5eb2f55 by encoding GitHub contents API paths per segment while preserving directory separators. Also added coverage for a PR file path containing both # and ?.\n\nVerification on the latest pushed code:\n- pnpm lint\n- pnpm typecheck\n- pnpm test (latest full passing run: 2,871 files / 30,430 tests passed)\n- pnpm build\n\n@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

@wonjerry Thanks for the update — encoding each path segment individually while preserving / separators is the right approach for handling special characters like # and ? in GitHub contents API paths. Glad to see dedicated test coverage added for that case too. Verification results look solid. Kicking off a fresh review now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for the PR. reviewing it now

@AmethystLiang
AmethystLiang self-requested a review July 16, 2026 04:36
@AmethystLiang

Copy link
Copy Markdown
Contributor

Fixed a few issues around GitHub Enterprise host routing, GraphQL retries, and native/WSL rate-limit fallback behavior. Will land it tomorrow and release it.

@wonjerry

Copy link
Copy Markdown
Contributor Author

@AmethystLiang Thanks! 👍

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b881c2cd-a357-44b7-b1cb-bba18c1f8cac

📥 Commits

Reviewing files that changed from the base of the PR and between 5eb2f551afecbbd2ae3905cf832ea84a5db73b94 and 861f763051ef4c885ce3ae3e9cdcb8478d354f33.

📒 Files selected for processing (39)
  • src/main/git/gh-rate-limit-breaker.test.ts
  • src/main/git/gh-rate-limit-breaker.ts
  • src/main/git/runner-gh-host-args.test.ts
  • src/main/git/runner-gh-rate-limit-breaker.test.ts
  • src/main/git/runner-wsl-gh-fallback.test.ts
  • src/main/git/runner.ts
  • src/main/github/client-create-pr.test.ts
  • src/main/github/client-file-viewed.test.ts
  • src/main/github/client-issue-source.test.ts
  • src/main/github/client-pr-check-details.test.ts
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/client-pr-local-runtime.test.ts
  • src/main/github/client-work-items.test.ts
  • src/main/github/client.test.ts
  • src/main/github/client.ts
  • src/main/github/github-api-repository.test.ts
  • src/main/github/github-api-repository.ts
  • src/main/github/github-enterprise-repository.test.ts
  • src/main/github/github-enterprise-repository.ts
  • src/main/github/issues.test.ts
  • src/main/github/issues.ts
  • src/main/github/merged-pr-commit-membership.ts
  • src/main/github/rate-limit.test.ts
  • src/main/github/rate-limit.ts
  • src/main/github/work-item-details-file-viewed.test.ts
  • src/main/github/work-item-details-pr-files.test.ts
  • src/main/github/work-item-details.test.ts
  • src/main/github/work-item-details.ts
  • src/main/runtime/rpc/methods/github.test.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/preload/index.ts
  • src/renderer/src/components/right-sidebar/checks-panel-async-result-key.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel-async-result-key.ts
  • src/renderer/src/store/slices/github-checks.test.ts
  • src/renderer/src/store/slices/github-checks.ts
  • src/renderer/src/store/slices/github.test.ts
  • src/renderer/src/store/slices/github.ts
  • src/shared/github-repository-identity-key.ts
  • src/shared/types.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b881c2cd-a357-44b7-b1cb-bba18c1f8cac

📥 Commits

Reviewing files that changed from the base of the PR and between 5eb2f551afecbbd2ae3905cf832ea84a5db73b94 and 861f763051ef4c885ce3ae3e9cdcb8478d354f33.

📒 Files selected for processing (39)
  • src/main/git/gh-rate-limit-breaker.test.ts
  • src/main/git/gh-rate-limit-breaker.ts
  • src/main/git/runner-gh-host-args.test.ts
  • src/main/git/runner-gh-rate-limit-breaker.test.ts
  • src/main/git/runner-wsl-gh-fallback.test.ts
  • src/main/git/runner.ts
  • src/main/github/client-create-pr.test.ts
  • src/main/github/client-file-viewed.test.ts
  • src/main/github/client-issue-source.test.ts
  • src/main/github/client-pr-check-details.test.ts
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/client-pr-local-runtime.test.ts
  • src/main/github/client-work-items.test.ts
  • src/main/github/client.test.ts
  • src/main/github/client.ts
  • src/main/github/github-api-repository.test.ts
  • src/main/github/github-api-repository.ts
  • src/main/github/github-enterprise-repository.test.ts
  • src/main/github/github-enterprise-repository.ts
  • src/main/github/issues.test.ts
  • src/main/github/issues.ts
  • src/main/github/merged-pr-commit-membership.ts
  • src/main/github/rate-limit.test.ts
  • src/main/github/rate-limit.ts
  • src/main/github/work-item-details-file-viewed.test.ts
  • src/main/github/work-item-details-pr-files.test.ts
  • src/main/github/work-item-details.test.ts
  • src/main/github/work-item-details.ts
  • src/main/runtime/rpc/methods/github.test.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/preload/index.ts
  • src/renderer/src/components/right-sidebar/checks-panel-async-result-key.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel-async-result-key.ts
  • src/renderer/src/store/slices/github-checks.test.ts
  • src/renderer/src/store/slices/github-checks.ts
  • src/renderer/src/store/slices/github.test.ts
  • src/renderer/src/store/slices/github.ts
  • src/shared/github-repository-identity-key.ts
  • src/shared/types.ts
🛑 Comments failed to post (4)
src/main/git/runner.ts (1)

1430-1437: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the relevant symbols and nearby code
rg -n "function applyGhHostToArgs|hasGhHostnameFlag|ghRateLimitScope|options\.host|--hostname" src/main/git/runner.ts

# Show the surrounding implementation for the mentioned lines
sed -n '1400,1485p' src/main/git/runner.ts

# Find tests covering hostname preservation / routing
rg -n "applyGhHostToArgs|ghRateLimitScope|hostname|options\.host|preserving-hostname|Enterprise scope" src/main/git -g '*.{ts,tsx,js,jsx}'

# Inspect any targeted tests if present
fd -a -t f "runner.*test" src/main/git

Repository: stablyai/orca

Length of output: 10065


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1488,1535p' src/main/git/runner.ts
printf '\n--- runner-gh-host-args.test.ts ---\n'
sed -n '1,180p' src/main/git/runner-gh-host-args.test.ts
printf '\n--- runner-gh-rate-limit-breaker.test.ts ---\n'
sed -n '1,180p' src/main/git/runner-gh-rate-limit-breaker.test.ts
printf '\n--- runner-command-exec.test.ts (host-related) ---\n'
sed -n '1,220p' src/main/git/runner-command-exec.test.ts

Repository: stablyai/orca

Length of output: 18341


Reject conflicting host arguments. applyGhHostToArgs preserves an existing --hostname, but ghRateLimitScope still buckets by options.host. With options.host = github.acme-corp.com and --hostname github.com, the command runs against GitHub.com while breaker accounting uses the Enterprise host; normalize the host or throw on mismatches, and update the preserving-hostname test to cover that case.

src/main/github/client.ts (2)

1047-1078: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Paginate the merged work-item stream, not each source independently.

Page N currently selects page N from issues and PRs separately, then merges and truncates them. Interleaved items from earlier source pages are skipped. Fetch enough leading entries from both sources, merge/sort them, then apply the global page offset and limit.

Also applies to: 1166-1244, 1305-1361


1161-1197: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Host-qualify Enterprise work-item list requests.

These paths never merge githubHostExecOptions(issueOwnerRepo/prOwnerRepo). For connection-backed GHES repositories there is no cwd, so gh api and gh pr list --repo owner/repo can target the default GitHub.com host.

Use separate issue and PR execution options in both list functions.

Proposed fix
 const ghOptions = ghRepoExecOptions(repoContext)
+const issueGhOptions = {
+  ...ghOptions,
+  ...githubHostExecOptions(issueOwnerRepo)
+}
+const prGhOptions = {
+  ...ghOptions,
+  ...githubHostExecOptions(prOwnerRepo)
+}

-? ghExecFileAsync(issueRequest.args, ghOptions)
+? ghExecFileAsync(issueRequest.args, issueGhOptions)

-? ghExecFileAsync(prRequest.args, ghOptions)
+? ghExecFileAsync(prRequest.args, prGhOptions)

Also applies to: 1283-1344

src/main/github/work-item-details.ts (1)

979-1007: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## outline: work-item-details.ts\n'
ast-grep outline src/main/github/work-item-details.ts --view expanded || true

printf '\n## relevant symbols in work-item-details.ts\n'
rg -n "function getWorkItemDetails|getWorkItemDetails\\(|getWorkItem\\(|getOriginGitHubApiRepository|isGitHubDotComRepository|getWorkItemByOwnerRepo" src/main/github/work-item-details.ts

printf '\n## locate getWorkItem and getOwnerRepo\n'
rg -n "function getWorkItem|const getWorkItem|export .*getWorkItem|getOwnerRepo|function getOwnerRepo|const getOwnerRepo" src/main/github -g '!**/dist/**' -g '!**/build/**'

Repository: stablyai/orca

Length of output: 39825


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the relevant slices with line numbers
sed -n '1,260p' src/main/github/work-item-details.ts | cat -n
printf '\n----\n'
sed -n '260,520p' src/main/github/work-item-details.ts | cat -n
printf '\n----\n'
sed -n '520,860p' src/main/github/work-item-details.ts | cat -n
printf '\n----\n'
sed -n '860,1120p' src/main/github/work-item-details.ts | cat -n

Repository: stablyai/orca

Length of output: 42175


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find call sites of getWorkItemDetails and type handling
rg -n "getWorkItemDetails\(" src test . -g '!**/dist/**' -g '!**/build/**' -g '!**/node_modules/**'
printf '\n----\n'
rg -n "type\s*===\s*'pr'|type\s*===\s*'issue'|type\s*:\s*'pr'|type\s*:\s*'issue'" src/main/github -g '!**/dist/**' -g '!**/build/**'

Repository: stablyai/orca

Length of output: 4806


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the PR/issue branching inside getWorkItem and related helpers
sed -n '1980,2085p' src/main/github/client.ts | cat -n
printf '\n----\n'
sed -n '1,260p' src/main/github/github-api-repository.ts | cat -n
printf '\n----\n'
sed -n '1,260p' src/main/github/github-enterprise-repository.ts | cat -n
printf '\n----\n'
sed -n '1,220p' src/main/github/work-item-details.test.ts | cat -n
printf '\n----\n'
sed -n '500,740p' src/main/github/work-item-details.test.ts | cat -n

Repository: stablyai/orca

Length of output: 32256


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect owner/repo resolution to see what the generic PR branch gets on GHES
sed -n '1,360p' src/main/github/gh-utils.ts | cat -n
printf '\n----\n'
sed -n '1,340p' src/main/github/github-repository-identity.ts | cat -n
printf '\n----\n'
sed -n '1,220p' src/main/github/github-enterprise-repository.test.ts | cat -n
printf '\n----\n'
sed -n '430,730p' src/main/github/work-item-details.test.ts | cat -n

Repository: stablyai/orca

Length of output: 33455


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the PR fetch implementation used by getWorkItem
sed -n '104,240p' src/main/github/client.ts | cat -n
printf '\n----\n'
sed -n '240,420p' src/main/github/client.ts | cat -n
printf '\n----\n'
sed -n '420,560p' src/main/github/client.ts | cat -n

Repository: stablyai/orca

Length of output: 18646


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect fetchPullRequestWorkItem and any host-resolution logic around it
rg -n "function fetchPullRequestWorkItem|async function fetchPullRequestWorkItem|const fetchPullRequestWorkItem" src/main/github/client.ts
printf '\n----\n'
sed -n '1040,1305p' src/main/github/client.ts | cat -n

Repository: stablyai/orca

Length of output: 11995


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '920,1045p' src/main/github/client.ts | cat -n

Repository: stablyai/orca

Length of output: 5114


Preserve the GHES repo on the type-less PR path. getWorkItem(repoPath, number) still resolves PRs through getOwnerRepo, which drops the Enterprise host and can hit the default github.com PR instead of the same-number GHES PR. Pass originApiRepository through the PR lookup, or make type required.

@nwparker

Copy link
Copy Markdown
Contributor

Heads-up: opened a focused #8935 fix on current main as #9111, based on the original work-item-details approach here from @wonjerry (credited as co-author).

#8932’s broader host-aware rewrite is still valuable as follow-up; 9111 only lands the PR diff/content routing so Enterprise remotes stop showing empty files.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 60d5d0cd-e0dd-4d1a-94a0-0369e7487d8a

📥 Commits

Reviewing files that changed from the base of the PR and between 861f763051ef4c885ce3ae3e9cdcb8478d354f33 and aa50196d4fc2b9d46a4979723f94205368cf37cd.

📒 Files selected for processing (56)
  • mobile/src/session/github-pr-mutations.ts
  • mobile/src/session/github-pr-rpc.ts
  • mobile/src/session/github-pr-value-readers.ts
  • mobile/src/tasks/smart-source-paste-intent.test.ts
  • src/main/git/gh-rate-limit-breaker.test.ts
  • src/main/git/gh-rate-limit-breaker.ts
  • src/main/git/runner-gh-host-args.test.ts
  • src/main/git/runner-gh-rate-limit-breaker.test.ts
  • src/main/git/runner.ts
  • src/main/github/client-create-pr.test.ts
  • src/main/github/client-file-viewed.test.ts
  • src/main/github/client-issue-source.test.ts
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/client-pr-local-runtime.test.ts
  • src/main/github/client-work-items-query-paging.test.ts
  • src/main/github/client-work-items.test.ts
  • src/main/github/client.test.ts
  • src/main/github/client.ts
  • src/main/github/github-api-repository.ts
  • src/main/github/github-enterprise-repository.ts
  • src/main/github/issues.test.ts
  • src/main/github/issues.ts
  • src/main/github/project-view.test.ts
  • src/main/github/project-view.ts
  • src/main/github/project-view/internals.ts
  • src/main/github/project-view/mutations.test.ts
  • src/main/github/project-view/mutations.ts
  • src/main/github/project-view/project-error-classification.ts
  • src/main/github/rate-limit.test.ts
  • src/main/github/rate-limit.ts
  • src/main/github/work-item-details-file-viewed.test.ts
  • src/main/github/work-item-details-pr-files.test.ts
  • src/main/github/work-item-details.test.ts
  • src/main/github/work-item-details.ts
  • src/main/ipc/github.ts
  • src/main/repo-icon-autodetect.test.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/main/source-control/forge-provider.test.ts
  • src/main/source-control/forge-provider.ts
  • src/main/source-control/hosted-review-creation-eligibility.test.ts
  • src/main/source-control/hosted-review-creation.test.ts
  • src/main/source-control/hosted-review-creation.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/PullRequestPage.tsx
  • src/renderer/src/components/TaskPage.tsx
  • src/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/lib/github-links.test.ts
  • src/shared/github-links.ts
  • src/shared/github-project-types.ts
  • src/shared/github-repository-identity-key.ts
  • src/shared/repo-icon.ts
  • src/shared/terminal-github-pr-link-detector.test.ts
🚧 Files skipped from review as they are similar to previous changes (11)
  • src/main/github/issues.test.ts
  • src/main/github/github-enterprise-repository.ts
  • src/main/github/work-item-details-file-viewed.test.ts
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/work-item-details-pr-files.test.ts
  • src/main/github/client-file-viewed.test.ts
  • src/main/git/runner.ts
  • src/main/github/client-pr-local-runtime.test.ts
  • src/main/github/work-item-details.test.ts
  • src/main/github/work-item-details.ts
  • src/main/github/client.ts

Comment thread src/main/github/client.test.ts Resolved
Comment thread src/main/github/issues.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/components/github-project/GhAuthErrorHelp.tsx (1)

125-144: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Provide host-aware commands for all fallback and loading states.

Several fallback branches in buildRemediation—such as the !diag loading state, the !diag.ghAvailable state, and the final SAML SSO fallback—still use the static LOGIN_CMD and REFRESH_CMD constants. For users targeting a GitHub Enterprise Server, this drops the --hostname flag and generates a command that mistakenly signs them into github.com.

Pass host to buildRemediation so that the correct host-scoped commands can be generated even before the diagnostic completes or when it fails.

🛠️ Proposed fix across `buildRemediation` and its caller

Update the function signature to accept host, resolve the target host, and use it in the loading state:

 function buildRemediation(
   errorMessage: string,
   kind: AuthErrorKind,
-  diag: GhAuthDiagnostic | null
+  diag: GhAuthDiagnostic | null,
+  host?: string
 ): Remediation {
+  const targetHost = diag?.requiredHost || host
   // Diagnostic still loading or unavailable — fall back to the canned advice
   // so the UI never gets worse than the pre-diagnosis behavior.
   if (!diag) {
     return {
       summary: errorMessage,
       commands: [
         {
           label: translate(
             'auto.components.github.project.GhAuthErrorHelp.b436c586d1',
             'Copy command'
           ),
-          command: kind === 'auth_required' ? LOGIN_CMD : REFRESH_CMD
+          command: kind === 'auth_required' ? loginCommandForHost(targetHost) : refreshCommandForHost(targetHost)
         }
       ]
     }

Update the remaining hardcoded branches to use targetHost:

   if (!diag.ghAvailable) {
     return {
       summary: 'GitHub CLI (`gh`) is not installed or not on PATH.',
       detail:
         'Orca uses `gh` to talk to GitHub Projects. Install it from cli.github.com, then sign in.',
       commands: [
         {
           label: translate(
             'auto.components.github.project.GhAuthErrorHelp.9c2da6353b',
             'Copy login command'
           ),
-          command: LOGIN_CMD
+          command: loginCommandForHost(targetHost)
         }
       ],
       docsUrl: 'https://cli.github.com/'
     }
   }
   if (kind === 'auth_required' || !active) {
     return {
       summary: 'You’re not signed in to GitHub via `gh`.',
       commands: [
         {
           label: translate(
             'auto.components.github.project.GhAuthErrorHelp.9c2da6353b',
             'Copy login command'
           ),
-          command: loginCommandForHost(diag.requiredHost)
+          command: loginCommandForHost(targetHost)
         }
       ]
     }
   }
 
   // Plain missing-scope case on a keyring login — refresh will work.
   if (diag.missingScopes.length > 0) {
     return {
       summary: `Your \`gh\` token is missing the ${diag.missingScopes
         .map((s) => `\`${s}\``)
         .join(
           ', '
         )} scope${diag.missingScopes.length === 1 ? '' : 's'} needed for GitHub Projects.`,
       detail:
         'Run the refresh command in a terminal. It will open a browser to authorize the new scopes, then come back here and reload.',
       commands: [
         {
           label: translate(
             'auto.components.github.project.GhAuthErrorHelp.3fefeebde4',
             'Copy refresh command'
           ),
-          command: refreshCommandForHost(diag.requiredHost)
+          command: refreshCommandForHost(targetHost)
         }
       ]
     }
   }
 
   // Scopes look fine but GitHub still rejected us — likely SAML SSO not
   // authorized for this org's token, or the project is in an org the token
   // can't see. Surface the most likely fix.
   return {
     summary: errorMessage,
     detail:
       'Your token has the required scopes but GitHub still denied access. If the project is in an org with SAML SSO, you must authorize this token for the org under Settings → Developer settings → Personal access tokens → Configure SSO.',
     commands: [
       {
         label: translate(
           'auto.components.github.project.GhAuthErrorHelp.3fefeebde4',
           'Copy refresh command'
         ),
-        command: REFRESH_CMD
+        command: refreshCommandForHost(targetHost)
       }
     ],
     docsUrl:
       'https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on'
   }

Finally, pass host when calling buildRemediation inside the component:

-  const remedy = buildRemediation(error.message, error.type, diag)
+  const remedy = buildRemediation(error.message, error.type, diag, host)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 02658a4c-4e9d-4dce-a76f-9e8ca640f585

📥 Commits

Reviewing files that changed from the base of the PR and between aa50196d4fc2b9d46a4979723f94205368cf37cd and 2be386ae04285ee74caf771f19f05f1a0cdd1f9c.

📒 Files selected for processing (7)
  • src/main/github/auth-diagnose.test.ts
  • src/main/github/auth-diagnose.ts
  • src/main/ipc/github.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/github-project/GhAuthErrorHelp.tsx
  • src/shared/github-auth-types.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/preload/api-types.ts
  • src/main/ipc/github.ts
  • src/preload/index.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/github/work-item-details.ts (1)

625-660: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Re-check the GraphQL budget before every viewed-state page.

The guard runs only once, but each page is separately debited and requested. If the first page exhausts the budget, later pages bypass the breaker and can trigger a 403.

Proposed fix
-  if (repositoryRateLimitGuard(ownerRepo, 'graphql', ghOptions).blocked) {
-    return null
-  }
   const viewedStates = new Map<string, GitHubPRFileViewedState>()
@@
   try {
     for (let fetched = 0; fetched < MAX_PR_FILES; fetched += 100) {
+      if (repositoryRateLimitGuard(ownerRepo, 'graphql', ghOptions).blocked) {
+        return null
+      }
       const args = [

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 46eb47cf-315b-4e49-a217-9b06248e0cdc

📥 Commits

Reviewing files that changed from the base of the PR and between aa50196d4fc2b9d46a4979723f94205368cf37cd and 20a806e635dd409ee83bc3143aa2e0f7b45d77a0.

📒 Files selected for processing (69)
  • mobile/app/h/[hostId]/tasks.tsx
  • mobile/src/components/pr-sidebar/PRCommentCard.tsx
  • mobile/src/session/github-pr-mutations.ts
  • mobile/src/session/github-pr-rpc.test.ts
  • mobile/src/session/github-pr-rpc.ts
  • mobile/src/session/github-pr-value-readers.ts
  • mobile/src/session/pr-action-mutation-contract.ts
  • mobile/src/session/pr-actions-engine.test.ts
  • mobile/src/session/pr-actions-engine.ts
  • mobile/src/session/pr-comment-actions.ts
  • mobile/src/session/use-mobile-pr-actions.test.ts
  • mobile/src/session/use-mobile-pr-comment-actions.ts
  • mobile/src/tasks/github-project-host-routing-source.test.ts
  • mobile/src/tasks/github-project-reference.test.ts
  • mobile/src/tasks/github-project-reference.ts
  • mobile/src/tasks/github-project-repo-match.test.ts
  • mobile/src/tasks/github-project-repo-match.ts
  • mobile/src/tasks/smart-source-paste-intent.test.ts
  • mobile/src/tasks/smart-source-paste-intent.ts
  • mobile/src/tasks/use-smart-workspace-source.ts
  • src/main/git/gh-rate-limit-breaker.test.ts
  • src/main/git/gh-rate-limit-breaker.ts
  • src/main/git/runner-gh-host-args.test.ts
  • src/main/git/runner-gh-rate-limit-breaker.test.ts
  • src/main/git/runner-wsl-gh-fallback.test.ts
  • src/main/git/runner.ts
  • src/main/github/auth-diagnose.test.ts
  • src/main/github/auth-diagnose.ts
  • src/main/github/client-create-pr.test.ts
  • src/main/github/client-file-viewed.test.ts
  • src/main/github/client-issue-source.test.ts
  • src/main/github/client-pr-check-details.test.ts
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/client-pr-local-runtime.test.ts
  • src/main/github/client-work-items-query-paging.test.ts
  • src/main/github/client-work-items.test.ts
  • src/main/github/client.test.ts
  • src/main/github/client.ts
  • src/main/github/github-api-repository.test.ts
  • src/main/github/github-api-repository.ts
  • src/main/github/github-enterprise-repository.test.ts
  • src/main/github/github-enterprise-repository.ts
  • src/main/github/github-remote-identity-parsing.test.ts
  • src/main/github/github-remote-identity-parsing.ts
  • src/main/github/github-repository-identity.ts
  • src/main/github/issues.test.ts
  • src/main/github/issues.ts
  • src/main/github/merged-pr-commit-membership.ts
  • src/main/github/pr-refresh-coordinator.test.ts
  • src/main/github/pr-refresh-coordinator.ts
  • src/main/github/project-view-host-auth.test.ts
  • src/main/github/project-view.test.ts
  • src/main/github/project-view.ts
  • src/main/github/project-view/internals.ts
  • src/main/github/project-view/mutations.test.ts
  • src/main/github/project-view/mutations.ts
  • src/main/github/project-view/project-error-classification.ts
  • src/main/github/rate-limit.test.ts
  • src/main/github/rate-limit.ts
  • src/main/github/work-item-details-concurrency.test.ts
  • src/main/github/work-item-details-file-viewed.test.ts
  • src/main/github/work-item-details-pr-files.test.ts
  • src/main/github/work-item-details.test.ts
  • src/main/github/work-item-details.ts
  • src/main/ipc/github.test.ts
  • src/main/ipc/github.ts
  • src/main/ipc/repos-remote.test.ts
  • src/main/ipc/repos.ts
  • src/main/repo-icon-autodetect.test.ts
🚧 Files skipped from review as they are similar to previous changes (20)
  • mobile/src/session/github-pr-value-readers.ts
  • src/main/github/issues.test.ts
  • src/main/github/auth-diagnose.ts
  • src/main/github/auth-diagnose.test.ts
  • src/main/git/gh-rate-limit-breaker.test.ts
  • src/main/github/project-view/project-error-classification.ts
  • src/main/github/work-item-details-file-viewed.test.ts
  • src/main/github/client-pr-check-details.test.ts
  • src/main/github/issues.ts
  • src/main/github/client-file-viewed.test.ts
  • src/main/github/project-view/mutations.test.ts
  • src/main/github/client-work-items-query-paging.test.ts
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/client-work-items.test.ts
  • src/main/github/project-view/internals.ts
  • src/main/github/client-pr-local-runtime.test.ts
  • src/main/github/project-view/mutations.ts
  • src/main/github/client.test.ts
  • src/main/git/gh-rate-limit-breaker.ts
  • src/main/github/project-view.ts

Comment thread mobile/app/h/[hostId]/tasks.tsx Resolved
@AmethystLiang
AmethystLiang force-pushed the fix-ghes-work-item-diffs branch from 20a806e to 60956b2 Compare July 17, 2026 05:32

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/main/github/work-item-details.ts (1)

620-648: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Re-check the GraphQL budget before every viewed-state page.

The guard runs once, but each page records another spend. If page one exhausts the bucket, later pages still execute.

Proposed fix
-  if (repositoryRateLimitGuard(ownerRepo, 'graphql', ghOptions).blocked) {
-    return null
-  }
   const viewedStates = new Map<string, GitHubPRFileViewedState>()
@@
   try {
     for (let fetched = 0; fetched < MAX_PR_FILES; fetched += 100) {
+      if (repositoryRateLimitGuard(ownerRepo, 'graphql', ghOptions).blocked) {
+        return null
+      }
       const args = [
src/renderer/src/components/github-project/ProjectCell.tsx (1)

346-379: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Clear stale issue types when the host-scoped refresh fails.

A non-OK or rejected request leaves the previous repository’s options visible after loading ends, potentially exposing issue types from another host.

Proposed fix
     let cancelled = false
     setLoading(true)
+    setOptions([])
@@
     request
       .then((res) => {
@@
         if (res.ok) {
           setOptions(res.types)
         }
       })
+      .catch(() => {
+        if (!cancelled) {
+          setOptions([])
+        }
+      })
       .finally(() => {

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 677e0fa4-6748-4db3-b476-3c1de7d1dac4

📥 Commits

Reviewing files that changed from the base of the PR and between 20a806e635dd409ee83bc3143aa2e0f7b45d77a0 and 60956b2.

📒 Files selected for processing (157)
  • mobile/app/h/[hostId]/tasks.tsx
  • mobile/src/components/pr-sidebar/PRCommentCard.tsx
  • mobile/src/session/github-pr-mutations.test.ts
  • mobile/src/session/github-pr-mutations.ts
  • mobile/src/session/github-pr-rpc.test.ts
  • mobile/src/session/github-pr-rpc.ts
  • mobile/src/session/github-pr-value-readers.test.ts
  • mobile/src/session/github-pr-value-readers.ts
  • mobile/src/session/pr-action-mutation-contract.ts
  • mobile/src/session/pr-actions-engine.test.ts
  • mobile/src/session/pr-actions-engine.ts
  • mobile/src/session/pr-comment-actions.test.ts
  • mobile/src/session/pr-comment-actions.ts
  • mobile/src/session/use-mobile-pr-actions.test.ts
  • mobile/src/session/use-mobile-pr-comment-actions.ts
  • mobile/src/tasks/github-project-host-routing-source.test.ts
  • mobile/src/tasks/github-project-reference.test.ts
  • mobile/src/tasks/github-project-reference.ts
  • mobile/src/tasks/github-project-repo-match.test.ts
  • mobile/src/tasks/github-project-repo-match.ts
  • mobile/src/tasks/smart-source-paste-intent.test.ts
  • mobile/src/tasks/smart-source-paste-intent.ts
  • mobile/src/tasks/use-smart-workspace-source.ts
  • src/main/git/gh-rate-limit-breaker.test.ts
  • src/main/git/gh-rate-limit-breaker.ts
  • src/main/git/runner-gh-host-args.test.ts
  • src/main/git/runner-gh-rate-limit-breaker.test.ts
  • src/main/git/runner-wsl-gh-fallback.test.ts
  • src/main/git/runner.ts
  • src/main/github/auth-diagnose.test.ts
  • src/main/github/auth-diagnose.ts
  • src/main/github/client-create-pr.test.ts
  • src/main/github/client-file-viewed.test.ts
  • src/main/github/client-issue-source.test.ts
  • src/main/github/client-pr-check-details.test.ts
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/client-pr-local-runtime.test.ts
  • src/main/github/client-work-items-query-paging.test.ts
  • src/main/github/client-work-items.test.ts
  • src/main/github/client.test.ts
  • src/main/github/client.ts
  • src/main/github/github-api-repository.test.ts
  • src/main/github/github-api-repository.ts
  • src/main/github/github-enterprise-repository.test.ts
  • src/main/github/github-enterprise-repository.ts
  • src/main/github/github-remote-identity-parsing.test.ts
  • src/main/github/github-remote-identity-parsing.ts
  • src/main/github/github-repository-identity.ts
  • src/main/github/issues.test.ts
  • src/main/github/issues.ts
  • src/main/github/merged-pr-commit-membership.ts
  • src/main/github/pr-refresh-coordinator.test.ts
  • src/main/github/pr-refresh-coordinator.ts
  • src/main/github/project-view-host-auth.test.ts
  • src/main/github/project-view.test.ts
  • src/main/github/project-view.ts
  • src/main/github/project-view/internals.ts
  • src/main/github/project-view/mutations.test.ts
  • src/main/github/project-view/mutations.ts
  • src/main/github/project-view/project-error-classification.ts
  • src/main/github/rate-limit.test.ts
  • src/main/github/rate-limit.ts
  • src/main/github/work-item-details-concurrency.test.ts
  • src/main/github/work-item-details-file-viewed.test.ts
  • src/main/github/work-item-details-pr-files.test.ts
  • src/main/github/work-item-details.test.ts
  • src/main/github/work-item-details.ts
  • src/main/ipc/github.test.ts
  • src/main/ipc/github.ts
  • src/main/ipc/repos-remote.test.ts
  • src/main/ipc/repos.ts
  • src/main/repo-icon-autodetect.test.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/main/runtime/rpc/methods/client-ui.test.ts
  • src/main/runtime/rpc/methods/github.test.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/main/source-control/forge-provider.test.ts
  • src/main/source-control/forge-provider.ts
  • src/main/source-control/hosted-review-creation-eligibility.test.ts
  • src/main/source-control/hosted-review-creation.test.ts
  • src/main/source-control/hosted-review-creation.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/GitHubItemDialog.tsx
  • src/renderer/src/components/PullRequestPage.tsx
  • src/renderer/src/components/TaskPage.tsx
  • src/renderer/src/components/github-enterprise-slug-routing-boundary.test.ts
  • src/renderer/src/components/github-item-dialog-source-boundary.test.ts
  • src/renderer/src/components/github-project/GhAuthErrorHelp.test.ts
  • src/renderer/src/components/github-project/GhAuthErrorHelp.tsx
  • src/renderer/src/components/github-project/ProjectCell.tsx
  • src/renderer/src/components/github-project/ProjectPicker.tsx
  • src/renderer/src/components/github-project/ProjectRow.tsx
  • src/renderer/src/components/github-project/ProjectViewList.tsx
  • src/renderer/src/components/github-project/ProjectViewWrapper.tsx
  • src/renderer/src/components/github-project/github-project-picker-filter.test.ts
  • src/renderer/src/components/github-project/github-project-picker-filter.ts
  • src/renderer/src/components/github-project/project-dialog-state.ts
  • src/renderer/src/components/github-project/project-picker-input.test.ts
  • src/renderer/src/components/github-project/project-row-filtering.test.ts
  • src/renderer/src/components/github-project/project-row-filtering.ts
  • src/renderer/src/components/github-project/project-view-wrapper-source-context-boundary.test.ts
  • src/renderer/src/components/github-project/slug-dialog/AssigneesEditor.tsx
  • src/renderer/src/components/github-project/slug-dialog/Comments.tsx
  • src/renderer/src/components/github-project/slug-dialog/LabelsEditor.tsx
  • src/renderer/src/components/github-project/slug-dialog/SlugDialogBody.tsx
  • src/renderer/src/components/github/IssueSourceIndicator.tsx
  • src/renderer/src/components/github/PRFilterDropdowns.tsx
  • src/renderer/src/components/new-workspace/SmartWorkspaceNameField-repo-slug-routing.test.ts
  • src/renderer/src/components/new-workspace/SmartWorkspaceNameField.tsx
  • src/renderer/src/components/pull-request-page-host-boundary.test.ts
  • src/renderer/src/components/right-sidebar/ChecksPanel.tsx
  • src/renderer/src/components/right-sidebar/checks-panel-async-result-key.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel-async-result-key.ts
  • src/renderer/src/components/right-sidebar/hosted-review-github-actions.ts
  • src/renderer/src/components/right-sidebar/use-hosted-review-actions.ts
  • src/renderer/src/components/settings/repository-icon-github.test.ts
  • src/renderer/src/components/settings/repository-icon-github.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts
  • src/renderer/src/hooks/useComposerState.ts
  • src/renderer/src/hooks/useGitHubSlugMetadata.test.tsx
  • src/renderer/src/hooks/useGitHubSlugMetadata.ts
  • src/renderer/src/lib/github-links.test.ts
  • src/renderer/src/lib/github-work-item-source-lookup.ts
  • src/renderer/src/lib/project-host-clone-url.test.ts
  • src/renderer/src/lib/project-host-clone-url.ts
  • src/renderer/src/lib/repo-slug-cache.test.ts
  • src/renderer/src/lib/repo-slug-cache.ts
  • src/renderer/src/lib/repo-slug-index.ts
  • src/renderer/src/lib/smart-github-submit.test.ts
  • src/renderer/src/lib/smart-github-submit.ts
  • src/renderer/src/store/slices/github-checks.test.ts
  • src/renderer/src/store/slices/github-checks.ts
  • src/renderer/src/store/slices/github-project-row-owner.ts
  • src/renderer/src/store/slices/github.test.ts
  • src/renderer/src/store/slices/github.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/github-auth-types.ts
  • src/shared/github-links.ts
  • src/shared/github-project-identity.test.ts
  • src/shared/github-project-identity.ts
  • src/shared/github-project-types.ts
  • src/shared/github-repository-identity-key.test.ts
  • src/shared/github-repository-identity-key.ts
  • src/shared/project-host-setup-projection.test.ts
  • src/shared/project-host-setup-projection.ts
  • src/shared/repo-icon.test.ts
  • src/shared/repo-icon.ts
  • src/shared/task-source-context.test.ts
  • src/shared/task-source-context.ts
  • src/shared/terminal-github-pr-link-detector.test.ts
  • src/shared/types.ts
🚧 Files skipped from review as they are similar to previous changes (69)
  • mobile/src/components/pr-sidebar/PRCommentCard.tsx
  • mobile/src/tasks/github-project-reference.test.ts
  • mobile/src/tasks/github-project-host-routing-source.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • mobile/src/session/pr-action-mutation-contract.ts
  • src/shared/github-auth-types.ts
  • src/main/source-control/forge-provider.test.ts
  • src/renderer/src/store/slices/github-checks.ts
  • src/main/github/github-remote-identity-parsing.test.ts
  • src/main/github/github-repository-identity.ts
  • mobile/src/tasks/github-project-repo-match.test.ts
  • src/main/repo-icon-autodetect.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel-async-result-key.ts
  • src/main/source-control/hosted-review-creation.ts
  • src/renderer/src/components/right-sidebar/checks-panel-async-result-key.test.ts
  • src/shared/github-repository-identity-key.ts
  • src/main/github/project-view/project-error-classification.ts
  • mobile/src/tasks/use-smart-workspace-source.ts
  • mobile/src/session/github-pr-value-readers.ts
  • src/renderer/src/store/slices/github-checks.test.ts
  • src/shared/github-links.ts
  • mobile/src/session/github-pr-rpc.ts
  • src/main/source-control/hosted-review-creation-eligibility.test.ts
  • mobile/src/tasks/smart-source-paste-intent.ts
  • src/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.test.ts
  • src/main/github/issues.test.ts
  • src/main/github/work-item-details-concurrency.test.ts
  • src/renderer/src/lib/github-links.test.ts
  • mobile/src/session/use-mobile-pr-comment-actions.ts
  • src/main/github/client-file-viewed.test.ts
  • src/main/ipc/repos-remote.test.ts
  • mobile/src/session/pr-actions-engine.ts
  • src/main/github/pr-refresh-coordinator.ts
  • src/main/github/project-view-host-auth.test.ts
  • src/main/source-control/hosted-review-creation.test.ts
  • src/main/github/merged-pr-commit-membership.ts
  • src/main/github/github-remote-identity-parsing.ts
  • src/main/github/client-pr-check-details.test.ts
  • src/main/source-control/forge-provider.ts
  • src/renderer/src/components/github-project/GhAuthErrorHelp.tsx
  • src/main/git/runner-gh-host-args.test.ts
  • src/main/ipc/github.test.ts
  • src/main/git/runner-gh-rate-limit-breaker.test.ts
  • src/main/github/project-view/mutations.test.ts
  • src/main/github/client-work-items.test.ts
  • src/main/git/runner-wsl-gh-fallback.test.ts
  • src/main/github/pr-refresh-coordinator.test.ts
  • mobile/src/session/pr-comment-actions.ts
  • src/main/github/client-create-pr.test.ts
  • src/main/github/rate-limit.test.ts
  • src/main/github/client-work-items-query-paging.test.ts
  • mobile/src/tasks/github-project-repo-match.ts
  • src/main/github/github-api-repository.test.ts
  • mobile/src/session/use-mobile-pr-actions.test.ts
  • src/main/github/client-pr-checks.test.ts
  • src/main/github/rate-limit.ts
  • src/main/github/client-issue-source.test.ts
  • src/main/github/github-enterprise-repository.test.ts
  • src/main/github/project-view/mutations.ts
  • src/main/git/runner.ts
  • src/main/github/work-item-details.test.ts
  • mobile/src/session/github-pr-mutations.ts
  • src/main/github/github-api-repository.ts
  • src/main/github/project-view/internals.ts
  • src/main/github/client.test.ts
  • src/main/ipc/github.ts
  • src/main/github/project-view.ts
  • mobile/app/h/[hostId]/tasks.tsx
  • src/main/github/client.ts

Comment thread src/renderer/src/lib/repo-slug-index.ts Resolved
Comment thread src/shared/repo-icon.ts Resolved
@AmethystLiang
AmethystLiang removed the request for review from brennanb2025 July 17, 2026 06:26
@AmethystLiang

Copy link
Copy Markdown
Contributor

@wonjerry can you try out this RC build to see if it fully works for you now? https://github.com/stablyai/orca/releases/tag/v1.4.145-rc.0.ghes
It's built from this branch.

Ended up expanding the scope of this branch to cover other places where the GitHub Enterprise remotes is used

@wonjerry

Copy link
Copy Markdown
Contributor Author

@AmethystLiang

I tested the RC build from https://github.com/stablyai/orca/releases/tag/v1.4.145-rc.0.ghes against our GitHub Enterprise remote. The PR work item file diff/content view now loads correctly for the Enterprise repo.

Thanks for the RC build!

@AmethystLiang

Copy link
Copy Markdown
Contributor

@wonjerry that's great to hear! will land the PR then so that it can be in the next stable build.

AmethystLiang and others added 18 commits July 20, 2026 12:35
- Pin `--host` on every gh call site so a process-level GH_HOST can't
  silently redirect requests, and qualify `-R`/`-R=` repo shorthand
  alongside the existing `--repo=` handling.
- Check the target scope for an active rate-limit block before each
  WSL/native or host fallback retry, not just on the initial attempt,
  so a blocked scope can't be hit again through a fallback path.
- Compute idempotency once per call instead of re-deriving it after
  fallback reassigns args.
- Thread `host` through mobile PR RPC params, IPC work-item lookups, and
  RPC schemas so GHES identity survives the renderer/mobile/main boundary
  instead of silently falling back to a same-named github.com repo.
- Qualify `--repo`/`-R` args for github.com too (not just GHES), since
  gh resolves bare shorthand against a process-level GH_HOST that can
  redirect pinned github.com commands.
- Cache `getOriginGitHubApiRepository` to avoid a per-call uncached
  `git remote get-url` round trip on connection-backed repos.
- Add a local-fork fallback in `getWorkItemDetails` so PRs living on a
  base repo (not visible via the origin slug) still resolve via cwd.
- Centralize the github.com-vs-GHES host predicate in
  `isDefaultGitHubHost` so cache keys, quota scoping, and identity
  checks can't drift out of sync.
Generalize the auth-gated enterprise resolver to any remote and build a
cached hosted-identity family (origin/issue/candidates/source) on top of
it, then migrate every github.com-only consumer: Tasks listing/counting,
branch-to-PR discovery, push targets, fork upstream, issue operations,
Projects, web links, avatars, and PR-link facts. Scope the rate-limit
breaker probe per runtime:host and classify WSL UNC cwds correctly.

Co-authored-by: Orca <help@stably.ai>
Updates the smart-source paste-intent test fixture to match the
repository slug shape that now carries a `host` field, keeping GHES
host identity intact through the paste-intent parsing path.
diagnoseGhAuth accepts the host a surface needs credentials for, scopes
the account/scope diagnosis to that host, and reports whether gh has any
login there; GhAuthErrorHelp renders host-qualified login/refresh
commands so an unauthenticated GHES host stops masquerading as a
github.com scope problem. Also fixes the mobile paste-intent expectation
for host-carrying parsed links.

Co-authored-by: Orca <help@stably.ai>
…ntity

Cap the origin-repo and host-auth caches like ownerRepoCache; keep ports
from remote/link URLs so GHES on a non-default port is a distinct
identity; make positional github.com slugs explicit against GH_HOST;
compare work-item sources by host-aware identity key; bail cwd-less
branch lookups when no repository candidate resolved; thread host
through the renderer work-item slug lookup.

Co-authored-by: Orca <help@stably.ai>
Incorporates ghes-issue-host-support (ed6bb96ef): one hosted issue
repository identity is resolved before the details fan-out so comments,
timeline, participants, and mention lookups cannot drift across hosts,
with SSH guards so unresolved issue/PR repositories never fall through
to gh's default host.

Co-authored-by: Orca <help@stably.ai>
getWorkItem's PR path probes upstream-then-origin hosted candidates
instead of origin alone, so fork checkouts resolve the base repo's PR
with the right host; issue detail resolution reuses the up-front hosted
identity and keeps the SSH unresolved-host guards.

Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Supersedes PR stablyai#9118 on this branch: http(s) remote ports identify the
Enterprise web/API endpoint and are preserved, while ssh/git transport
ports (including ssh.github.com:443) never leak into gh's host identity.
Replaces the ssh.github.com:443 special case with the structural
protocol split and ports the PR's parsing test suite.

Co-authored-by: Orca <help@stably.ai>
Parse GitHub host identity from work-item URLs and carry it through PR/issue mutations, labels, and assignments. Bound rate-limit and scope-probe caches (1024 and 512 entries) to prevent unbounded growth when interacting with multiple GHES instances. Normalize repository identity keys to include host so github.com and GHES slugs don't collide in cache and equality checks.
- Carry host identity through PR mutations and reads so fork PRs on
  different GHES instances don't collide in cache or state tracking.
- Validate host authentication before routing requests to unconfigured
  Enterprise servers; ambient credentials must never reach untrusted hosts.
- Scope rate-limit guards and spend tracking per host so GHES quota stays
  independent from github.com quota.
- Respect explicit --hostname arguments in gh CLI calls ahead of GH_HOST or
  ambient defaults, so breaker state follows the actual request target.
- Detect implicit WSL runtimes from UNC paths for consistent host auth and
  execution-options scoping across mobile and desktop clients.
Enterprise PRs must use their selected host consistently across diff, comments,
and file-content loads. Validate repository slugs before authenticated execution
to prevent path-injection via renderer overrides. Scope project browsing cache
and rate-limit tracking by host to prevent cross-host pollution. Use parsed
URLs as authoritative over ambient hosts for project resolution.
Preserve host identity on PR/issue work items throughout the mutation and diff
pipeline so Enterprise instances (including ported endpoints like
github.acme.test:8443) can execute mutations without ambiguity. Rate-limit gh
commands by the pre-qualified --repo host, cache auth state per ported host,
and surface Enterprise hosts in project metadata and error messages.
Both callers (project-view.ts, mutations.ts) moved to the host-scoped
repositoryRateLimitGuard/noteRepositoryRateLimitSpend; the bucket-only
re-export in internals.ts had zero importers left.

Co-authored-by: Orca <help@stably.ai>
@AmethystLiang
AmethystLiang force-pushed the fix-ghes-work-item-diffs branch from 60956b2 to 672489a Compare July 20, 2026 22:07

@AmethystLiang AmethystLiang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the GHES host-scoping refactor (rate-limit breaker, gh CLI runner, auth-diagnose, identity caches, PR-refresh coordinator) with a focus on reliability: cross-host/runtime isolation, bounded-cache eviction, WSL<->native fallback re-scoping, and error-handling on gh CLI failures. No blocking issues found — caches are TTL-pruned and size-capped, breaker re-scoping on fallback is explicitly unit-tested, and internal error handling is consistently fail-open/non-throwing through the call chain. A few non-blocking residual risks and testing gaps were logged for follow-up (GHES/WSL background refresh has no proactive rate-limit guard, only the reactive breaker; auth-status parsing can misreport during a github.com rate-limit window; no test locks in the null-repository fallback in the refresh coordinator).

Branch was rebased onto current main to resolve the prior merge conflict.

Move GHES/SSH host-routing cases out of work-item-details.test.ts so
the suite stays within the 800-line test max-lines budget.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/github/work-item-details-enterprise-host.test.ts (1)

154-162: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Tests don't exercise repository/host-unresolved fallback; 278-286 and 288-296 are exact duplicates.

getWorkItemMock.mockResolvedValue(null) makes getWorkItemDetails return via the early if (!item) { return null } guard, before enterprise-host/getEnterpriseGitHubRepoSlug resolution is ever attempted. So these three tests only verify "no work item found," not "SSH repository/host unresolved" as their titles claim — the exact scenario this PR is meant to fix (silent fallback to github.com when a found item's owner/repo can't be resolved to an Enterprise host) is left unverified. Additionally, Lines 278-286 and 288-296 are functionally identical (same mock setup, same 'pr' call, equivalent assertions).

A stronger replacement would resolve a real item (with prRepo/issue owner) but leave both getOwnerRepoMock and getEnterpriseGitHubRepoSlugMock unresolved, then assert no ghExecFileAsync call lacks a host option (or that none occur), which is the actual regression this test suite is meant to guard against.

♻️ Example of a strengthened "repository unresolved" test
-  it('does not query the default host when an SSH PR repository is unresolved', async () => {
-    getWorkItemMock.mockResolvedValue(null)
-
-    await expect(getWorkItemDetails('/remote/repo', 7, 'pr', 'ssh-1')).resolves.toBeNull()
-
-    expect(getWorkItemMock).toHaveBeenCalledWith('/remote/repo', 7, 'pr', 'ssh-1')
-    expect(getWorkItemByOwnerRepoMock).not.toHaveBeenCalled()
-    expect(ghExecFileAsyncMock).not.toHaveBeenCalled()
-  })
+  it('does not fall back to the default host when the PR repository cannot be resolved', async () => {
+    getWorkItemMock.mockResolvedValueOnce({
+      id: 'pr:7',
+      type: 'pr',
+      number: 7,
+      title: 'Unresolved PR',
+      state: 'open',
+      url: 'https://github.acme-corp.com/team/orca/pull/7',
+      labels: [],
+      updatedAt: '2026-07-16T00:00:00Z',
+      author: 'pr-author',
+      prRepo: { owner: 'team', repo: 'orca', host: 'github.acme-corp.com' }
+    })
+    getOwnerRepoMock.mockResolvedValue(null)
+    getEnterpriseGitHubRepoSlugMock.mockResolvedValue(null)
+
+    await getWorkItemDetails('/remote/repo', 7, 'pr', 'ssh-1')
+
+    expect(
+      ghExecFileAsyncMock.mock.calls.every(([, options]) => options?.host === undefined || options?.host === 'github.acme-corp.com')
+    ).toBe(true)
+  })

Also applies to: 278-296


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0b8519fc-54d0-49cc-929a-532603c3570b

📥 Commits

Reviewing files that changed from the base of the PR and between 672489a and 77789a8.

📒 Files selected for processing (2)
  • src/main/github/work-item-details-enterprise-host.test.ts
  • src/main/github/work-item-details.test.ts
💤 Files with no reviewable changes (1)
  • src/main/github/work-item-details.test.ts

- Route origin repository resolution through getOwnerRepoForRemote, not getOwnerRepo, to match production path
- Pin github.com host on origin results so host-less fixtures pass host gate in resolveGitHubApiRepository
- Add generation-based invalidation to prevent stale slug-cache writes from in-flight resolutions
- Fix ref-sync race in ProjectPicker: use useLayoutEffect so committed tree owns browse cache key
- Defer handledCrossRepoUrlRef assignment in SmartWorkspaceNameField until resolution succeeds
- Update Enterprise host routing: found work items must not silently fall back to default host when unresolved
- Normalize GHES avatar URLs: accept explicit port 443 as canonical form, not a fallback trigger
@AmethystLiang
AmethystLiang merged commit 971b167 into stablyai:main Jul 21, 2026
5 checks passed
@AmethystLiang

Copy link
Copy Markdown
Contributor

btw @wonjerry this is now in the stable releases

@wonjerry

Copy link
Copy Markdown
Contributor Author

@AmethystLiang I updated to the stable release and it’s working now. Thanks!!

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(github): load PR diffs for Enterprise remotes

* fix(github): encode PR content paths by segment

* Fix PR review actions failing on GitHub Enterprise remotes

- Threads GitHub host identity (not just owner/repo) through the client,
  work-item-details, issues, and RPC layers so gh commands target the
  correct Enterprise server instead of silently falling back to github.com
- Adds a shared github-api-repository helper to resolve/host-qualify repo
  identity consistently across REST, GraphQL, and CLI shorthand calls
- Scopes the gh rate-limit breaker and singleton rate-limit snapshot by
  host/runtime so a github.com block or probe can't affect GHES or WSL
- Coalesces concurrent host-auth probes and paginates PR file fetching
  beyond 100 results
- Propagates `host` through renderer PR caches, checks-panel keys, and
  preload IPC types so Enterprise and github.com data never collide

* Route gh host qualification through runner options instead of argv sniff

Move GHES/GH_HOST resolution from parsing --hostname/--repo out of gh argv to an explicit options.host passed through ghExecFileAsync, since SSH-backed repos spawn gh with no cwd and argv sniffing couldn't reliably detect the target host. The runner now injects --hostname and qualifies --repo/-R at spawn time from options.host, and rate-limit scoping/guards use the same explicit host instead of inferring it. Also adds a shared githubRepoIdentityKey helper to keep cache/store keys consistent with the new host-aware repository identity.

* Fix gh CLI GHES host pinning and rate-limit scope leaks

- Pin `--host` on every gh call site so a process-level GH_HOST can't
  silently redirect requests, and qualify `-R`/`-R=` repo shorthand
  alongside the existing `--repo=` handling.
- Check the target scope for an active rate-limit block before each
  WSL/native or host fallback retry, not just on the initial attempt,
  so a blocked scope can't be hit again through a fallback path.
- Compute idempotency once per call instead of re-deriving it after
  fallback reassigns args.

* Fix GitHub Enterprise host identity loss across PR/work-item paths

- Thread `host` through mobile PR RPC params, IPC work-item lookups, and
  RPC schemas so GHES identity survives the renderer/mobile/main boundary
  instead of silently falling back to a same-named github.com repo.
- Qualify `--repo`/`-R` args for github.com too (not just GHES), since
  gh resolves bare shorthand against a process-level GH_HOST that can
  redirect pinned github.com commands.
- Cache `getOriginGitHubApiRepository` to avoid a per-call uncached
  `git remote get-url` round trip on connection-backed repos.
- Add a local-fork fallback in `getWorkItemDetails` so PRs living on a
  base repo (not visible via the origin slug) still resolve via cwd.
- Centralize the github.com-vs-GHES host predicate in
  `isDefaultGitHubHost` so cache keys, quota scoping, and identity
  checks can't drift out of sync.

* Make repository identity host-aware across all GitHub surfaces

Generalize the auth-gated enterprise resolver to any remote and build a
cached hosted-identity family (origin/issue/candidates/source) on top of
it, then migrate every github.com-only consumer: Tasks listing/counting,
branch-to-PR discovery, push targets, fork upstream, issue operations,
Projects, web links, avatars, and PR-link facts. Scope the rate-limit
breaker probe per runtime:host and classify WSL UNC cwds correctly.

Co-authored-by: Orca <help@stably.ai>

* Fix expected slug to include host field in GitHub PR link test

Updates the smart-source paste-intent test fixture to match the
repository slug shape that now carries a `host` field, keeping GHES
host identity intact through the paste-intent parsing path.

* Surface per-host gh auth state for GitHub Enterprise

diagnoseGhAuth accepts the host a surface needs credentials for, scopes
the account/scope diagnosis to that host, and reports whether gh has any
login there; GhAuthErrorHelp renders host-qualified login/refresh
commands so an unauthenticated GHES host stops masquerading as a
github.com scope problem. Also fixes the mobile paste-intent expectation
for host-carrying parsed links.

Co-authored-by: Orca <help@stably.ai>

* Bound GHES identity caches and preserve non-default ports in host identity

Cap the origin-repo and host-auth caches like ownerRepoCache; keep ports
from remote/link URLs so GHES on a non-default port is a distinct
identity; make positional github.com slugs explicit against GH_HOST;
compare work-item sources by host-aware identity key; bail cwd-less
branch lookups when no repository candidate resolved; thread host
through the renderer work-item slug lookup.

Co-authored-by: Orca <help@stably.ai>

* Thread GitHub host through issue detail requests

Incorporates ghes-issue-host-support (ed6bb96ef): one hosted issue
repository identity is resolved before the details fan-out so comments,
timeline, participants, and mention lookups cannot drift across hosts,
with SSH guards so unresolved issue/PR repositories never fall through
to gh's default host.

Co-authored-by: Orca <help@stably.ai>

* Scope remaining GitHub rate-limit accounting

* Resolve typed PR lookups across hosted repository candidates

getWorkItem's PR path probes upstream-then-origin hosted candidates
instead of origin alone, so fork checkouts resolve the base repo's PR
with the right host; issue detail resolution reuses the up-front hosted
identity and keeps the SSH unresolved-host guards.

Co-authored-by: Orca <help@stably.ai>

* Refactor GitHub repository execution setup

* Carry host on smart-submit link intents

Co-authored-by: Orca <help@stably.ai>

* Carry the project host on GitHub item dialog origins

Co-authored-by: Orca <help@stably.ai>

* Keep GHES web ports but drop SSH transport ports in host identity

Supersedes PR stablyai#9118 on this branch: http(s) remote ports identify the
Enterprise web/API endpoint and are preserved, while ssh/git transport
ports (including ssh.github.com:443) never leak into gh's host identity.
Replaces the ssh.github.com:443 special case with the structural
protocol split and ports the PR's parsing test suite.

Co-authored-by: Orca <help@stably.ai>

* Support GitHub Enterprise diffs and mutations with host-scoped caches

Parse GitHub host identity from work-item URLs and carry it through PR/issue mutations, labels, and assignments. Bound rate-limit and scope-probe caches (1024 and 512 entries) to prevent unbounded growth when interacting with multiple GHES instances. Normalize repository identity keys to include host so github.com and GHES slugs don't collide in cache and equality checks.

* Support GitHub Enterprise diffs and mutations with host-scoped caches

- Carry host identity through PR mutations and reads so fork PRs on
  different GHES instances don't collide in cache or state tracking.
- Validate host authentication before routing requests to unconfigured
  Enterprise servers; ambient credentials must never reach untrusted hosts.
- Scope rate-limit guards and spend tracking per host so GHES quota stays
  independent from github.com quota.
- Respect explicit --hostname arguments in gh CLI calls ahead of GH_HOST or
  ambient defaults, so breaker state follows the actual request target.
- Detect implicit WSL runtimes from UNC paths for consistent host auth and
  execution-options scoping across mobile and desktop clients.

* Support GitHub Enterprise work-item diffs with host-scoped execution

Enterprise PRs must use their selected host consistently across diff, comments,
and file-content loads. Validate repository slugs before authenticated execution
to prevent path-injection via renderer overrides. Scope project browsing cache
and rate-limit tracking by host to prevent cross-host pollution. Use parsed
URLs as authoritative over ambient hosts for project resolution.

* Support GitHub Enterprise work-item diffs with host-scoped execution

Preserve host identity on PR/issue work items throughout the mutation and diff
pipeline so Enterprise instances (including ported endpoints like
github.acme.test:8443) can execute mutations without ambiguity. Rate-limit gh
commands by the pre-qualified --repo host, cache auth state per ported host,
and surface Enterprise hosts in project metadata and error messages.

* fix(review): drop dead rateLimitGuard/noteRateLimitSpend re-export

Both callers (project-view.ts, mutations.ts) moved to the host-scoped
repositoryRateLimitGuard/noteRepositoryRateLimitSpend; the bucket-only
re-export in internals.ts had zero importers left.

Co-authored-by: Orca <help@stably.ai>

* fix(ci): split Enterprise host work-item tests under max-lines

Move GHES/SSH host-routing cases out of work-item-details.test.ts so
the suite stays within the 800-line test max-lines budget.

* test(github): align mocks with host-scoped repository resolution

- Route origin repository resolution through getOwnerRepoForRemote, not getOwnerRepo, to match production path
- Pin github.com host on origin results so host-less fixtures pass host gate in resolveGitHubApiRepository
- Add generation-based invalidation to prevent stale slug-cache writes from in-flight resolutions
- Fix ref-sync race in ProjectPicker: use useLayoutEffect so committed tree owns browse cache key
- Defer handledCrossRepoUrlRef assignment in SmartWorkspaceNameField until resolution succeeds
- Update Enterprise host routing: found work items must not silently fall back to default host when unresolved
- Normalize GHES avatar URLs: accept explicit port 443 as canonical form, not a fallback trigger

---------

Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
Co-authored-by: Orca <help@stably.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: GitHub Enterprise PR work item diffs do not load

4 participants