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

feat(code): add inline GitHub disconnect to onboarding step - #1999

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

k11kirky merged 1 commit into
mainfrom
05-04-feat_code_add_inline_github_disconnect_to_onboarding_step

Conversation

@k11kirky

@k11kirky k11kirky commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Users who connect their personal GitHub account during onboarding have no way to disconnect it without leaving the app. This makes it difficult to switch accounts or revoke access without going directly to GitHub or PostHog settings.

Changes

  • Adds a Disconnect button to the GitHub integration section of the onboarding Git Integration step, visible when a GitHub integration is active.
  • Clicking the button opens a confirmation AlertDialog that explains the scope of the disconnection (personal authorization only; the GitHub App installation in the org is unaffected).
  • On confirmation, calls a new disconnectGithubUserIntegration API method that sends a DELETE request to /api/users/@me/integrations/github/{installationId}/.
  • After a successful disconnect, relevant GitHub-related queries are invalidated and a success toast is shown. Errors surface via an error toast.
  • Extracts the query invalidation logic into a shared invalidateGithubQueries helper so it can be reused across the connect and disconnect flows.

@greptile-apps

greptile-apps Bot commented May 4, 2026

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

---

### Issue 1 of 1
apps/code/src/renderer/features/onboarding/components/GitIntegrationStep.tsx:595-608
**Dialog closes immediately on click, bypassing loading state**

`AlertDialog.Action` calls `onOpenChange(false)` synchronously when clicked (the event bubbles up from the inner `Button`). At that moment, `disconnectMutation.isPending` is still `false` in the `onOpenChange` closure — React hasn't committed the state update from `mutate()` yet. So the `onOpenChange` guard passes, `setDisconnectConfirmOpen(false)` is called, and the dialog closes immediately rather than staying open to show the spinner.

`e.preventDefault()` doesn't help here — it only prevents the browser's native default action, not programmatic React handlers higher in the tree.

Since `onSuccess` already closes the dialog explicitly, the simplest fix is to move the confirm button out of `AlertDialog.Action`:

```tsx
<Flex gap="3" mt="4" justify="end">
  <AlertDialog.Cancel asChild>
    <Button variant="soft" color="gray" disabled={disconnectMutation.isPending}>
      Cancel
    </Button>
  </AlertDialog.Cancel>
  <Button
    variant="solid"
    color="red"
    onClick={() => disconnectMutation.mutate()}
    disabled={disconnectMutation.isPending}
  >
    {disconnectMutation.isPending ? <Spinner size="1" /> : null}
    Disconnect
  </Button>
</Flex>
```

This keeps the `onOpenChange` guard meaningful and allows the spinner to be visible during the request.

Reviews (1): Last reviewed commit: "feat(code): add inline GitHub disconnect..." | Re-trigger Greptile

Comment on lines +595 to +608
<AlertDialog.Action>
<Button
variant="solid"
color="red"
onClick={(e) => {
e.preventDefault();
disconnectMutation.mutate();
}}
disabled={disconnectMutation.isPending}
>
{disconnectMutation.isPending ? <Spinner size="1" /> : null}
Disconnect
</Button>
</AlertDialog.Action>

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.

P1 Dialog closes immediately on click, bypassing loading state

AlertDialog.Action calls onOpenChange(false) synchronously when clicked (the event bubbles up from the inner Button). At that moment, disconnectMutation.isPending is still false in the onOpenChange closure — React hasn't committed the state update from mutate() yet. So the onOpenChange guard passes, setDisconnectConfirmOpen(false) is called, and the dialog closes immediately rather than staying open to show the spinner.

e.preventDefault() doesn't help here — it only prevents the browser's native default action, not programmatic React handlers higher in the tree.

Since onSuccess already closes the dialog explicitly, the simplest fix is to move the confirm button out of AlertDialog.Action:

<Flex gap="3" mt="4" justify="end">
  <AlertDialog.Cancel asChild>
    <Button variant="soft" color="gray" disabled={disconnectMutation.isPending}>
      Cancel
    </Button>
  </AlertDialog.Cancel>
  <Button
    variant="solid"
    color="red"
    onClick={() => disconnectMutation.mutate()}
    disabled={disconnectMutation.isPending}
  >
    {disconnectMutation.isPending ? <Spinner size="1" /> : null}
    Disconnect
  </Button>
</Flex>

This keeps the onOpenChange guard meaningful and allows the spinner to be visible during the request.

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: 595-608

Comment:
**Dialog closes immediately on click, bypassing loading state**

`AlertDialog.Action` calls `onOpenChange(false)` synchronously when clicked (the event bubbles up from the inner `Button`). At that moment, `disconnectMutation.isPending` is still `false` in the `onOpenChange` closure — React hasn't committed the state update from `mutate()` yet. So the `onOpenChange` guard passes, `setDisconnectConfirmOpen(false)` is called, and the dialog closes immediately rather than staying open to show the spinner.

`e.preventDefault()` doesn't help here — it only prevents the browser's native default action, not programmatic React handlers higher in the tree.

Since `onSuccess` already closes the dialog explicitly, the simplest fix is to move the confirm button out of `AlertDialog.Action`:

```tsx
<Flex gap="3" mt="4" justify="end">
  <AlertDialog.Cancel asChild>
    <Button variant="soft" color="gray" disabled={disconnectMutation.isPending}>
      Cancel
    </Button>
  </AlertDialog.Cancel>
  <Button
    variant="solid"
    color="red"
    onClick={() => disconnectMutation.mutate()}
    disabled={disconnectMutation.isPending}
  >
    {disconnectMutation.isPending ? <Spinner size="1" /> : null}
    Disconnect
  </Button>
</Flex>
```

This keeps the `onOpenChange` guard meaningful and allows the spinner to be visible during the request.

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

@k11kirky
k11kirky force-pushed the 05-04-feat_code_show_persistent_error_state_for_github_connect_failures branch from c7a6575 to ed45726 Compare May 4, 2026 14:14
@k11kirky
k11kirky force-pushed the 05-04-feat_code_add_inline_github_disconnect_to_onboarding_step branch from 666b43f to 2f25fac 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:06 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 4, 3:14 PM UTC: @k11kirky merged this pull request with Graphite.

@k11kirky
k11kirky changed the base branch from 05-04-feat_code_show_persistent_error_state_for_github_connect_failures to graphite-base/1999 May 4, 2026 14:56
@k11kirky
k11kirky changed the base branch from graphite-base/1999 to main May 4, 2026 15:04
@k11kirky
k11kirky force-pushed the 05-04-feat_code_add_inline_github_disconnect_to_onboarding_step branch from 2f25fac to 5a06832 Compare May 4, 2026 15:05
@k11kirky
k11kirky merged commit 00b490b into main May 4, 2026
16 checks passed
@k11kirky
k11kirky deleted the 05-04-feat_code_add_inline_github_disconnect_to_onboarding_step branch May 4, 2026 15:14
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