Skip to content

feat(github): bind projects to a specific gh account - #13664

Merged
nwparker merged 9 commits into
stablyai:mainfrom
llevintza:llevintza/bug-create-worktree-github-issue-pr-search-ignor
Sep 19, 2026
Merged

nwparker merged 9 commits into
stablyai:mainfrom
llevintza:llevintza/bug-create-worktree-github-issue-pr-search-ignor

Conversation

@llevintza

@llevintza llevintza commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When a user is signed in to gh with both work and personal GitHub accounts, Orca used whichever account was globally active. A project could therefore search issues as the wrong account and show no results.

This change lets each project use a selected GitHub login for its repository-scoped GitHub actions.

What changed

  • Added an optional per-project GitHub account binding (host + user), persisted through the desktop, runtime, preload, and web-client layers.
  • Repository-scoped gh calls now resolve a short-lived token for the selected login and inject it into that child process only. Ambient GH_TOKEN, GH_HOST, and GH_REPO values are removed from bound calls.
  • Binding is available only when the execution host supports multi-account gh (2.40+). Capability state is scoped separately for native, WSL, and SSH hosts.
  • If the selected account or host is unavailable, Orca fails with a project-specific error instead of silently using another account.
  • Added Repository settings controls to select or clear a keyring-backed account. The refresh action is a compact, secondary icon beside the Account label.
  • Project View and account-diagnosis surfaces remain on the ambient login by design.

Why

Fixes #13612. The previous behavior could silently query GitHub with the wrong identity. Per-child token injection keeps simultaneous project requests isolated, and fail-closed behavior prevents an unavailable binding from falling back to the wrong account.

Related: #16244 and #16294 (the same multi-account failure mode and clearer REST errors).

Related: #13347 (Tasks GitHub source account binding; Project View remains an ambient-login follow-up).

Visual proof

Settings → Repository in the macOS dev build. The screenshot shows the account picker with the low-emphasis refresh control beside Account.

GitHub account refresh control

Testing

  • Focused account-binding, worktree-resolution, RPC, and settings tests pass locally (including 54 direct resolver tests)
  • pnpm tc
  • pnpm run check:code-quality:changed
  • Background Electron verification through CDP: opened Project Settings → Repository and confirmed the Account picker and secondary refresh control render correctly.
  • Existing account-binding, capability, token, runtime, RPC, persistence, hosted-review, direct PR worktree, and GitHub repository tests remain covered.

Manual platform coverage: macOS local and SSH-backed repository. Windows/WSL behavior is covered by the execution-host unit tests, but was not manually exercised here.

The automated checks cover the changed application paths, packaging, Windows boundaries, Git compatibility, and mobile compatibility gates. The final run passed typecheck, static analysis, all eight test shards, Linux packaging, Git compatibility, and mobile verification. Windows packaging passed after pinning mobile/patches/*.patch to stable checkout bytes in .gitattributes. The readiness checklist scenarios that are not exercised by this PR are transport fault injections such as Wi-Fi sleep/resume, DNS or half-open TCP failures, SSH reconnects and mid-flight drops, relay restart ownership, FIDO2 fallback, and low-connectivity parity. Those remain broader transport residual risk; this PR does not claim zero regressions or full network fault coverage.

  • I manually tested these changes locally
  • Automated tests added/updated

Release recommendation

Roll this out in a canary cohort first. Monitor account-binding validation failures, gh_bound_account_* errors, GitHub request failures, and support reports while comparing bound-project success rates with ambient-login projects. Expand only after the canary is clean; keep the prior build available for rollback. The binding is optional and unbound projects retain the existing ambient-login path.

Review notes

  • Security: Tokens are short-lived, cached in memory, never logged, and placed only in the spawned gh process environment. Host and repository signals are checked against the binding.
  • Compatibility: ghAccount is optional. Older remote runtimes that drop it are reported as "not enforced". No new stream opcode was added.
  • Remote SSH: SSH-backed repositories keep the binding and run the local gh, matching the existing GitHub integration.
  • Performance: Capability and token results are cached per execution host. Transient failures are not negative-cached.
  • Mobile: No mobile surface changed.

AI disclosure

Claude Opus 5 and Claude Fable 5.1 assisted with implementation, rebases, and review follow-ups.

Checklist

  • The change is scoped to per-project GitHub account binding and its cross-layer plumbing
  • I explained what changed and why
  • Before/after or current visual proof is attached for the UI change
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Focused lint, typecheck, and test checks pass locally (pnpm build remains covered by CI)

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 081add4e-f876-45f5-bceb-43f20cd9c4ae

📥 Commits

Reviewing files that changed from the base of the PR and between 6f2acc1a275f5694b68532ea0cc4ab66bd3cfc86 and ef934e4.

⛔ Files ignored due to path filters (1)
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (10)
  • src/main/runtime/orca-runtime-restore-structured-agent-session-tabs-once.ts
  • src/main/runtime/rpc/methods/github-account-binding-methods.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/rpc-contract/github-account-binding-params.ts
  • src/shared/rpc-contract/repo-update-params.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/ja.json

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Adds repository-scoped GitHub account bindings across persistence, GitHub CLI execution, IPC/RPC, preload APIs, runtime routing, and repository settings. Bound tokens are resolved from gh auth token --user, injected only into child processes, and cached by execution host. The change adds host validation, capability detection, rate-limit handling, WSL fallback support, account inventory and validation, repository update handling, UI controls, localization, and tests.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to ef934

The reviewed changes do not show a concrete unresolved risk requiring changes before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Most coding requirements in #13612 are implemented. The PR adds Repo.ghAccount persistence, IPC/RPC and renderer settings, host-aware token resolution, child-only environment injection, runtime prop… Apply the repository binding to Project View's repository-scoped gh operations, including the required execution options and tests. Keep authentication diagnostics ambient only if that behavior is confirmed as an accepted clarification of…
Docstring Coverage ⚠️ Warning Docstring coverage is 35.21% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 71 functions across 59 files. (5 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes remain connected to #13612. Token caching, capability detection, rate-limit handling, host-argument validation, persistence, IPC/RPC plumbing, renderer settings, localization, and regressi…
Title check ✅ Passed The title clearly and concisely describes the main change: binding projects to a specific GitHub CLI account.
Description check ✅ Passed The description is detailed and covers the change, rationale, linked issue, visual proof, testing, AI disclosure, compatibility, security, and checklist items. It provides a current UI screenshot rath…
Full details: Linked Issues check

Explanation

Most coding requirements in #13612 are implemented. The PR adds Repo.ghAccount persistence, IPC/RPC and renderer settings, host-aware token resolution, child-only environment injection, runtime propagation, validation, fail-closed errors, fallback handling, and tests. However, src/main/github/project-view/internals.ts documents that Project View keeps ambient authentication and has no executable binding propagation. This does not satisfy #13612's requirement that Projects views use the bound account. Authentication diagnostics remain ambient, which the PR scope explicitly allows.

Resolution

Apply the repository binding to Project View's repository-scoped gh operations, including the required execution options and tests. Keep authentication diagnostics ambient only if that behavior is confirmed as an accepted clarification of #13612.

Full details: Docstring Coverage

Explanation

Docstring coverage is 35.21% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 71 functions across 59 files. (5 skipped: 5 unsupported.)

  • Fix all pre-merge checks with AI

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.

Actionable comments posted: 11

Caution

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

⚠️ Outside diff range comments (3)
src/main/git/runner.ts (1)

1497-1512: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Reject or host-qualify attached -R values.

GitHub CLI accepts -Rhost/owner/repo and -R=host/owner/repo. These forms bypass collectGhArgvHostSignals and remain unchanged in applyGhHostToArgs, so a bound call can target another host with the bound token. Handle both forms in the host parsers, or reject them before spawn. Add regression cases in src/main/git/runner-gh-account-binding.test.ts.

src/main/runtime/orca-runtime.ts (1)

18939-18966: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Remove ghAccount from the Pick<Repo, ...> list

Repo.ghAccount does not include null, so the duplicate intersection collapses the effective type to GhAccountBinding | undefined. This rejects the ghAccount: null clear sentinel handled by updateRepo. Keep ghAccount only in the intersected object.

src/renderer/src/store/slices/repos.ts (1)

130-142: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

ghAccount is declared in both the Pick<...> union and the nullable intersection member, so null is not assignable. Both update types list 'ghAccount' inside Partial<Pick<Repo, ...>> and again as ghAccount?: Repo['ghAccount'] | null. TypeScript intersects the two property types, producing GhAccountBinding | undefined, which drops the null clear signal. sourceControlAi and externalWorktreeDiscoverySuppressedAt show the correct pattern: they appear only in the intersection member.

  • src/renderer/src/store/slices/repos.ts#L130-L142: remove | 'ghAccount' from the Pick union in RepoUpdate and keep the nullable member on Line 142.
  • src/preload/api-types.ts#L1270-L1282: remove | 'ghAccount' from the Pick union in repos.update and keep the nullable member on Line 1282.
🧹 Nitpick comments (3)
src/renderer/src/components/settings/RepositoryGitHubAccountSection.test.tsx (1)

5-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a mismatched-binding case and split the assertions into separate tests.

The current test covers exact match, missing echo, clear-with-no-echo, and clear-with-echo. It does not cover the case where echoed holds a different account than requested, which is the main mixed-version symptom the helper detects. It also does not cover case differences, even though the title mentions "normalized" bindings.

Separate it blocks also report which case failed instead of stopping at the first assertion.

🧪 Suggested additional cases
+  it('rejects a binding the host echoed as a different account', () => {
+    expect(
+      isGhAccountBindingEnforced(
+        { host: 'github.com', user: 'Alice' },
+        { host: 'github.com', user: 'Bob' }
+      )
+    ).toBe(false)
+    expect(
+      isGhAccountBindingEnforced(
+        { host: 'github.com', user: 'Alice' },
+        { host: 'ghe.example.com', user: 'Alice' }
+      )
+    ).toBe(false)
+  })
src/renderer/src/components/settings/RepositoryGitHubAccountSection.tsx (2)

79-129: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Do not reassign the next parameter; use a separate constant.

Line 108 reassigns the next parameter with the validated binding. The reassignment makes the value passed to updateRepo on Line 110 and to isGhAccountBindingEnforced on Line 121 depend on control flow above it. A dedicated constant states the intent directly.

♻️ Proposed refactor
-  const applyBinding = async (next: GhAccountBinding | null) => {
+  const applyBinding = async (requested: GhAccountBinding | null) => {
     if (saving) {
       return
     }
     setSaving(true)
     setError(null)
     setNotEnforced(false)
     try {
-      if (next) {
-        const validation = await validateRepositoryGhAccountBinding(runtimeTarget, repo, next)
+      let resolved = requested
+      if (requested) {
+        const validation = await validateRepositoryGhAccountBinding(runtimeTarget, repo, requested)
         if (!validation.ok) {
           ...
           return
         }
-        next = validation.binding
+        resolved = validation.binding
       }
-      const result = await Promise.resolve(updateRepo(repo.id, { ghAccount: next }))
+      const result = await Promise.resolve(updateRepo(repo.id, { ghAccount: resolved }))

191-229: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the existing shadcn Select primitive for this account control. It supports disabled items and matches the settings style guide and focus behavior.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b641d137-f0eb-44c3-9af8-5da7a35a8949

📥 Commits

Reviewing files that changed from the base of the PR and between c0c893d and d2d2d6e65adff135ec02a85e9413ea8a7dd8a313.

📒 Files selected for processing (35)
  • src/main/git/runner-gh-account-binding.test.ts
  • src/main/git/runner.ts
  • src/main/github/client.ts
  • src/main/github/gh-account-binding-inventory.ts
  • src/main/github/gh-account-token.test.ts
  • src/main/github/gh-account-token.ts
  • src/main/github/gh-capability-state.test.ts
  • src/main/github/gh-capability-state.ts
  • src/main/github/github-repository-identity.gh-account.test.ts
  • src/main/github/github-repository-identity.ts
  • src/main/github/project-view/internals.ts
  • src/main/github/rate-limit.ts
  • src/main/github/work-item-details.ts
  • src/main/ipc/github.ts
  • src/main/ipc/repos.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/main/runtime/rpc/methods/repo-update-schema.ts
  • src/main/runtime/rpc/methods/repo.test.ts
  • src/main/source-control/hosted-review-git-options.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/settings/RepositoryGitHubAccountSection.test.tsx
  • src/renderer/src/components/settings/RepositoryGitHubAccountSection.tsx
  • src/renderer/src/components/settings/RepositoryPane.tsx
  • src/renderer/src/components/settings/repository-github-account.ts
  • src/renderer/src/components/settings/repository-search.ts
  • src/renderer/src/store/slices/repos.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/github-account-binding.test.ts
  • src/shared/github-account-binding.ts
  • src/shared/github-auth-types.ts
  • src/shared/types.ts

Comment thread src/main/github/gh-capability-state.ts Resolved
Comment thread src/main/github/gh-capability-state.ts Resolved
Comment thread src/main/ipc/github.ts Resolved
Comment thread src/main/runtime/orca-runtime.ts Resolved
Comment thread src/main/git/runner.ts Resolved
Comment thread src/main/github/client.ts Resolved
Comment thread src/main/github/client.ts Resolved
Comment thread src/shared/github-account-binding.ts Resolved
Comment thread src/main/persistence.ts Resolved
Comment thread src/main/github/gh-account-token.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/settings/RepositoryGitHubAccountSection.tsx (1)

161-172: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the missing githubAccountKeyword locale key to the catalog.

The keyword entry uses the key auto.components.settings.repository.search.githubAccountKeyword. en.json's repository.search namespace defines githubAccount and githubAccountDescription, but not githubAccountKeyword. This key is missing from the catalog.

Run the localization sync script to add this key, or add it manually to en.json under auto.components.settings.repository.search.

Run the following script to confirm the key is absent from the catalog:

#!/bin/bash
# Description: Check whether githubAccountKeyword exists under repository.search in en.json.
python3 - <<'PY'
import json
with open("src/renderer/src/i18n/locales/en.json") as f:
    data = json.load(f)
section = data.get("auto", {}).get("components", {}).get("settings", {}).get("repository", {}).get("search", {})
print("repository.search keys:", sorted(section.keys()))
print("githubAccountKeyword present:", "githubAccountKeyword" in section)
PY
🔧 Proposed fix
             "projectRuntimeDescription": "Choose whether this project runs on Windows or WSL.",
             "githubAccount": "GitHub Account",
-            "githubAccountDescription": "Bind a keyring gh login for this project's GitHub API calls."
+            "githubAccountDescription": "Bind a keyring gh login for this project's GitHub API calls.",
+            "githubAccountKeyword": "github account"

Source: Learnings


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ff7a0103-7ebf-4eeb-9527-c28f9bf085bd

📥 Commits

Reviewing files that changed from the base of the PR and between d2d2d6e65adff135ec02a85e9413ea8a7dd8a313 and f4772e9f83f5f42dc203b1f67f6e53ccbc9b2737.

📒 Files selected for processing (24)
  • src/main/git/runner.ts
  • src/main/github/auth-diagnose.ts
  • src/main/github/client.ts
  • src/main/github/gh-account-binding-inventory.ts
  • src/main/github/gh-account-token.test.ts
  • src/main/github/gh-account-token.ts
  • src/main/github/gh-capability-state.ts
  • src/main/github/work-item-details.ts
  • src/main/ipc/github.ts
  • src/main/ipc/repos.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/repo-update-schema.ts
  • src/preload/api-types.ts
  • src/renderer/src/components/settings/RepositoryGitHubAccountSection.test.tsx
  • src/renderer/src/components/settings/RepositoryGitHubAccountSection.tsx
  • src/renderer/src/components/settings/RepositoryPane.tsx
  • src/renderer/src/components/settings/repository-github-account.ts
  • src/renderer/src/components/settings/repository-search.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/store/slices/repos.ts
  • src/shared/github-account-binding.test.ts
  • src/shared/github-account-binding.ts
  • src/shared/github-auth-types.ts
🚧 Files skipped from review as they are similar to previous changes (15)
  • src/renderer/src/components/settings/repository-search.ts
  • src/main/ipc/repos.ts
  • src/shared/github-account-binding.test.ts
  • src/main/runtime/rpc/methods/repo-update-schema.ts
  • src/shared/github-auth-types.ts
  • src/renderer/src/components/settings/RepositoryPane.tsx
  • src/renderer/src/components/settings/RepositoryGitHubAccountSection.test.tsx
  • src/shared/github-account-binding.ts
  • src/main/github/gh-account-token.test.ts
  • src/main/github/gh-account-token.ts
  • src/main/persistence.ts
  • src/renderer/src/store/slices/repos.ts
  • src/preload/api-types.ts
  • src/main/github/gh-capability-state.ts
  • src/main/runtime/orca-runtime.ts

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@llevintza
llevintza force-pushed the llevintza/bug-create-worktree-github-issue-pr-search-ignor branch from c745c19 to 1055eca Compare August 12, 2026 14:49
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@llevintza
llevintza force-pushed the llevintza/bug-create-worktree-github-issue-pr-search-ignor branch from 1055eca to cf8d7dd Compare August 13, 2026 21:03
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@llevintza
llevintza force-pushed the llevintza/bug-create-worktree-github-issue-pr-search-ignor branch from cf8d7dd to ed738d6 Compare August 15, 2026 03:26
@nwparker nwparker removed the P2 label Aug 19, 2026
@danchamorro

Copy link
Copy Markdown

This would be very helpful. I personally have separate work and personal accounts.

@llevintza

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor
✅ 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.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Note

The previously reviewed commits are no longer reachable (likely due to a force-push or rebase), so CodeRabbit is performing a full review instead of an incremental one. This review may take a little longer.

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: fe82be50-7f2b-4814-8713-37b64bff35c5

📥 Commits

Reviewing files that changed from the base of the PR and between 7f8eb90 and 4d550cb30297adca740cce59c5a551e7647a646b.

📒 Files selected for processing (65)
  • src/main/git/command-runner/gh-bound-account-env.ts
  • src/main/git/command-runner/gh-exec-file.ts
  • src/main/git/command-runner/gh-host-args.ts
  • src/main/git/runner-gh-account-binding.test.ts
  • src/main/git/runner-gh-host-args.test.ts
  • src/main/github/auth-diagnose.ts
  • src/main/github/client/create/create-github-pull-request.ts
  • src/main/github/client/create/pull-request-template.ts
  • src/main/github/gh-account-binding-inventory.ts
  • src/main/github/gh-account-token.test.ts
  • src/main/github/gh-account-token.ts
  • src/main/github/gh-capability-state.test.ts
  • src/main/github/gh-capability-state.ts
  • src/main/github/github-repository-identity.gh-account.test.ts
  • src/main/github/github-repository-identity.ts
  • src/main/github/project-view/internals.ts
  • src/main/github/rate-limit.ts
  • src/main/ipc/github-account-handlers.ts
  • src/main/ipc/github-ipc-channel-parity.test.ts
  • src/main/ipc/github-repo-routing.ts
  • src/main/ipc/github.ts
  • src/main/ipc/hosted-review.test.ts
  • src/main/ipc/hosted-review.ts
  • src/main/ipc/repos/repo-update-handler.ts
  • src/main/persistence-update-repo.test.ts
  • src/main/persistence/loading-store/repo-lifecycle-operations.ts
  • src/main/persistence/tracking-repos/repo-hydration.ts
  • src/main/persistence/tracking-repos/repo-sanitization.ts
  • src/main/persistence/tracking-repos/repo-update-operations.ts
  • src/main/project-runtime-git-options.ts
  • src/main/runtime/orca-runtime-restore-structured-agent-session-tabs-once.ts
  • src/main/runtime/rpc/methods/github-account-binding-methods.ts
  • src/main/runtime/rpc/methods/github.ts
  • src/main/runtime/rpc/methods/repo-update-schema.ts
  • src/main/runtime/rpc/methods/repo.test.ts
  • src/main/runtime/runtime-github-issue-comment-commands.ts
  • src/main/runtime/runtime-github-repository-query-commands.ts
  • src/main/runtime/runtime-github-review-mutation-commands.ts
  • src/main/runtime/runtime-github-review-query-commands.ts
  • src/main/runtime/runtime-repository-command-surface.ts
  • src/main/runtime/runtime-repository-settings-controller.ts
  • src/main/source-control/hosted-review-git-options.ts
  • src/preload/api-types.ts
  • src/preload/api/gh-bridge-mutations-and-projects.ts
  • src/preload/api/github-account-api.ts
  • src/preload/api/repository-api.ts
  • src/renderer/src/components/settings/RepositoryGitHubAccountSection.test.tsx
  • src/renderer/src/components/settings/RepositoryGitHubAccountSection.tsx
  • src/renderer/src/components/settings/RepositoryPane.tsx
  • src/renderer/src/components/settings/repository-github-account.ts
  • src/renderer/src/components/settings/repository-search.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/store/repos/repo-state.ts
  • src/renderer/src/store/repos/repo-update.ts
  • src/renderer/src/web/preload-api/web-github-api.ts
  • src/renderer/src/web/preload-api/web-github-routes.ts
  • src/renderer/src/web/web-preload-api-github.test.ts
  • src/shared/github/account-binding.test.ts
  • src/shared/github/account-binding.ts
  • src/shared/github/auth-types.ts
  • src/shared/repo-types.ts
🚧 Files skipped from review as they are similar to previous changes (20)
  • src/main/ipc/hosted-review.test.ts
  • src/renderer/src/components/settings/RepositoryGitHubAccountSection.tsx
  • src/main/github/rate-limit.ts
  • src/main/github/project-view/internals.ts
  • src/main/github/github-repository-identity.gh-account.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/main/runtime/rpc/methods/repo.test.ts
  • src/main/github/auth-diagnose.ts
  • src/main/source-control/hosted-review-git-options.ts
  • src/main/ipc/hosted-review.ts
  • src/renderer/src/components/settings/repository-search.ts
  • src/main/runtime/rpc/methods/repo-update-schema.ts
  • src/renderer/src/components/settings/RepositoryPane.tsx
  • src/main/github/gh-account-binding-inventory.ts
  • src/main/github/gh-account-token.test.ts
  • src/main/github/gh-account-token.ts
  • src/renderer/src/components/settings/repository-github-account.ts
  • src/main/github/gh-capability-state.ts
  • src/main/project-runtime-git-options.ts
  • src/main/github/gh-capability-state.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/renderer/src/i18n/locales/ko.json Resolved
@Velm14

Velm14 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Ran your rebased head (6396a42) on Ubuntu 24.04 / WSL2, Node 24, gh 2.97, since CI hasn't been approved for this PR yet:

  • pnpm tc: clean
  • pnpm test over src/main/git, src/main/github, src/main/ipc/github*, hosted-review, repos, persistence*, runtime/rpc/methods, runtime-repository*, src/shared/github, the Repository settings components, the web GitHub preload API and the renderer repo store: 4836 passed / 471 files, 0 failed
  • oxlint, oxfmt --check and check:code-quality:changed on the 60 changed files: clean

I had also rebased your previous head independently before you did; the two ports landed the hook, IPC, persistence, runtime and preload changes in the same modules, so the relocation looks right.

Two things I noticed while reading the runner path, neither a blocker:

  1. resolveGhAccountToken now goes through ghExecFileAsync, so it hits the rate-limit breaker gate. While the core bucket is blocked, gh auth token (a local keyring read) is never spawned, the failure is negative-cached for 30s and surfaces as "Bound GitHub account … is unavailable" rather than a rate-limit error. createGhRateLimitBlockedError sets ghRateLimitBlocked: true, so isTransientTokenResolveFailure could treat that as transient (no negative cache) and let the original error through.
  2. The breaker scope key is runtime:host with no account dimension (ghRateLimitScopeKey). GitHub rate limits are per account, so once the ambient login trips the breaker, bound calls for the other login on the same host are blocked for the reset window too, and vice versa. Adding options.ghAccount?.user to the scope key would keep the two quotas apart.

Happy to run the same checks on native Windows and a WSL-routed repo next and post the steps here.

@llevintza
llevintza force-pushed the llevintza/bug-create-worktree-github-issue-pr-search-ignor branch from 6396a42 to 31b4da1 Compare September 7, 2026 15:51
@llevintza

Copy link
Copy Markdown
Contributor Author

Thanks for the WSL2 run and for reading the runner path closely — both points are right.

  1. gh auth token behind the breaker — fixed in 6f2acc1a27. gh auth token … is a local keyring read, so it is now exempt from the rate-limit gate (same exemption as the rate_limit probe). A tripped core bucket no longer turns the bound-token resolve into a 30 s negative-cached "unavailable"; the bound API call itself still fails fast with the rate-limit error. Regression tests cover both sides.

  2. Breaker scope per login — deliberately left host/runtime-scoped in this PR (noted at the top of src/main/github/rate-limit.ts as accepted Part A bleed). The blocker is the reset probe: it runs gh api rate_limit on the tripping scope, so a per-login scope also needs the probe to run as that login and the parser/keys to carry it. That is a contained follow-up once this lands rather than more surface here.

A native Windows and WSL-routed pass would be very welcome — the branch was rebased onto today's main (single commit, -R… host-drift tests and the shadcn picker included), so please use the new head.

@llevintza

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor
✅ 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.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Adds per-project `Repo.ghAccount` so repo-scoped gh calls (create-worktree
issue/PR search, work items, hosted-review reads and mutations) run as the bound
account via ephemeral child-env token injection instead of the globally active
gh login. Multi-account resolution is capability-gated (gh >= 2.40) and fails
closed when the bound account or host is unavailable; Project View stays
ambient by design.

Repository settings gains a section for selecting or clearing a keyring-backed
account (shadcn `Select`), with mixed-version "not enforced" handling for older
remote runtimes. Attached `-Rhost/owner/repo` forms are covered by the host-drift
guard and its tests; es/ja/ko/zh catalogs carry the section's strings.

`getLocalProjectGhExecOptions` centralizes the binding lookup so every gh
execution path picks it up, including the Electron `hostedReview:*` handlers
that previously stayed on the ambient login. `gh auth token` (a keyring read)
is exempt from the rate-limit breaker gate so a tripped bucket cannot turn a
bound-token resolve into a false "unavailable".

The `ghAccount` update field and the two binding RPC methods live in the shared
RPC params contract; the generated catalog is regenerated.

Fixes stablyai#13612

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012B3QEP5iP4WGGEpPLtkHqA
@llevintza
llevintza force-pushed the llevintza/bug-create-worktree-github-issue-pr-search-ignor branch from 6f2acc1 to ef934e4 Compare September 11, 2026 15:02
@llevintza

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor
✅ 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.

@nwparker

Copy link
Copy Markdown
Contributor

Updated the GitHub account settings UX:

  • Removed the prominent Retry button.
  • Added a compact secondary refresh control beside Account.
  • Preserved accessible labeling, tooltip, disabled state, and loading feedback.

github-account-refresh-secondary.png

Validated with the focused component tests, typecheck, changed-code quality checks, and background Electron visual verification.

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]: Create-worktree GitHub issue/PR search ignores directory-scoped GH_TOKEN (direnv) and uses the globally active gh account

6 participants