Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

feat(code): list all GitHub installations and allow adding another org - #2001

Merged
k11kirky merged 1 commit into
mainfrom
05-04-feat_code_list_all_github_installations_and_allow_adding_another_org
May 4, 2026
Merged

k11kirky merged 1 commit into
mainfrom
05-04-feat_code_list_all_github_installations_and_allow_adding_another_org

Conversation

@k11kirky

@k11kirky k11kirky commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Users with GitHub integrations connected to multiple organizations had no way to manage them individually — the UI only showed a single integration, and disconnect/reconnect actions were scoped to whichever integration happened to be first in the list.

Changes

  • The GitHub integration panel now renders a card for each connected installation, showing the account name, type (org vs. personal), and repo count
  • Disconnect is now per-installation: each card has its own "Disconnect" button, and the confirmation dialog names the specific account being removed
  • Reconnect and Settings actions are also scoped per-installation, with loading state tied to the specific installation being acted on
  • An "Add another GitHub org" button replaces the old single disconnect button at the bottom of the list, allowing users to connect additional organizations without removing existing ones
  • The status badge updates to show Connected (N) when more than one integration is active, and "Reconnect needed" is shown when any integration is stale
  • useUserRepositoryIntegration now exposes reposByInstallationId so each card can display the correct repo count for its installation

@k11kirky
k11kirky marked this pull request as ready for review May 4, 2026 11:59
@greptile-apps

greptile-apps Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
apps/code/src/renderer/features/onboarding/components/GitIntegrationStep.tsx:421-426
**Global loading state used per-installation card**

`isLoadingRepos` is a single boolean that is `true` as long as *any* installation's repo query is still pending. When a user has two orgs and one finishes loading before the other, the already-loaded card still displays "Loading…" instead of its actual repo count, because `isLoadingRepos` remains `true` until all queries settle.

A per-installation check would be more accurate — e.g. checking whether `reposByInstallationId[installationId]` is `undefined` (query hasn't resolved yet) vs. an array (already populated).

### Issue 2 of 3
apps/code/src/renderer/features/onboarding/components/GitIntegrationStep.tsx:440-450
**Shared `isConnecting` loading state across all Reconnect buttons**

`isConnecting` is global to the component. When a user clicks "Reconnect" on one stale installation and `handleConnectGitHub()` starts, all other "Reconnect" buttons will also enter a loading state simultaneously. If a user has two stale integrations, clicking Reconnect on one will visually indicate both are in-progress.

### Issue 3 of 3
apps/code/src/renderer/hooks/useIntegrations.ts:162-163
**`reposByInstallationId` not populated for error/loading states**

When a result is in error or still pending, `result.data` is falsy and the function returns early, leaving `reposByInstallationId[installationId]` undefined. In the component this correctly falls back to `[]` for stale installs (which show "Reconnect needed" instead), so the current behaviour is fine. However, it also means you can't distinguish "no repos returned by the API" (empty array) from "query hasn't completed yet" (undefined) at the component level — a distinction that would fix the per-installation loading concern above.

Reviews (1): Last reviewed commit: "feat(code): list all GitHub installation..." | Re-trigger Greptile

Comment thread apps/code/src/renderer/features/onboarding/components/GitIntegrationStep.tsx Outdated
Comment on lines +440 to +450
)}
<Button
size="1"
variant="soft"
color="gray"
onClick={() => {
const account = integration.account;
const url =
account?.type === "Organization" &&
account.name
? `https://github.com/organizations/${account.name}/settings/installations/${installationId}`

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.

P2 Shared isConnecting loading state across all Reconnect buttons

isConnecting is global to the component. When a user clicks "Reconnect" on one stale installation and handleConnectGitHub() starts, all other "Reconnect" buttons will also enter a loading state simultaneously. If a user has two stale integrations, clicking Reconnect on one will visually indicate both are in-progress.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/onboarding/components/GitIntegrationStep.tsx
Line: 440-450

Comment:
**Shared `isConnecting` loading state across all Reconnect buttons**

`isConnecting` is global to the component. When a user clicks "Reconnect" on one stale installation and `handleConnectGitHub()` starts, all other "Reconnect" buttons will also enter a loading state simultaneously. If a user has two stale integrations, clicking Reconnect on one will visually indicate both are in-progress.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +162 to +163
const installationRepos = result.data.repos ?? [];
reposByInstallationId[result.data.installationId] = installationRepos;

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.

P2 reposByInstallationId not populated for error/loading states

When a result is in error or still pending, result.data is falsy and the function returns early, leaving reposByInstallationId[installationId] undefined. In the component this correctly falls back to [] for stale installs (which show "Reconnect needed" instead), so the current behaviour is fine. However, it also means you can't distinguish "no repos returned by the API" (empty array) from "query hasn't completed yet" (undefined) at the component level — a distinction that would fix the per-installation loading concern above.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/hooks/useIntegrations.ts
Line: 162-163

Comment:
**`reposByInstallationId` not populated for error/loading states**

When a result is in error or still pending, `result.data` is falsy and the function returns early, leaving `reposByInstallationId[installationId]` undefined. In the component this correctly falls back to `[]` for stale installs (which show "Reconnect needed" instead), so the current behaviour is fine. However, it also means you can't distinguish "no repos returned by the API" (empty array) from "query hasn't completed yet" (undefined) at the component level — a distinction that would fix the per-installation loading concern above.

How can I resolve this? If you propose a fix, please make it concise.

@k11kirky
k11kirky force-pushed the 05-04-feat_code_detect_stale_github_integration_and_offer_reconnect branch from 172b3fe to c0863fa Compare May 4, 2026 14:14
@k11kirky
k11kirky force-pushed the 05-04-feat_code_list_all_github_installations_and_allow_adding_another_org branch from 039bbe6 to 72b415c Compare May 4, 2026 14:14

k11kirky commented May 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Merge activity

  • May 4, 2:36 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 4, 3:30 PM UTC: Graphite rebased this pull request as part of a merge.

@k11kirky
k11kirky changed the base branch from 05-04-feat_code_detect_stale_github_integration_and_offer_reconnect to graphite-base/2001 May 4, 2026 15:15
@k11kirky
k11kirky changed the base branch from graphite-base/2001 to main May 4, 2026 15:28
@k11kirky
k11kirky force-pushed the 05-04-feat_code_list_all_github_installations_and_allow_adding_another_org branch from 72b415c to bf99ac0 Compare May 4, 2026 15:29
@k11kirky
k11kirky merged commit e4ac7e5 into main May 4, 2026
16 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants