Repository navigation
Conversation
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
apps/code/src/renderer/features/onboarding/components/GitIntegrationStep.tsx:390-396
**Silent disconnect failure may leave dangling integration**
If `disconnectMutation.mutateAsync` fails (e.g. a 5xx from the backend), the error is swallowed and `handleConnectGitHub()` is still called. The old stale integration record remains in the database while a new OAuth flow starts. Depending on whether the backend enforces uniqueness per user, this can result in two integration rows, and `invalidateGithubQueries` is never called (since `onSuccess` doesn't fire), so the cache retains the stale entry until the reconnect completes.
Consider invalidating the relevant queries in the catch path so the UI doesn't remain in an inconsistent state even when disconnect fails.
### Issue 2 of 2
apps/code/src/renderer/hooks/useIntegrations.ts:155-158
**Stale detection triggers on any error, not just auth failures**
Any error that survives React Query's retry budget (network timeouts, 5xx server errors, etc.) will add the installation to `failedInstallationIds` and show "Reconnect needed" to the user, even when the GitHub token itself is still valid. This could prompt unnecessary reconnects during a temporary backend outage.
If the API client surfaces HTTP status codes, consider restricting the stale signal to 401/403 responses only.
Reviews (1): Last reviewed commit: "feat(code): detect stale GitHub integrat..." | Re-trigger Greptile |
| onClick={async () => { | ||
| if (!githubIntegration?.installation_id) return; | ||
| await disconnectMutation | ||
| .mutateAsync({ silent: true }) | ||
| .catch(() => undefined); | ||
| void handleConnectGitHub(); | ||
| }} |
There was a problem hiding this comment.
Silent disconnect failure may leave dangling integration
If disconnectMutation.mutateAsync fails (e.g. a 5xx from the backend), the error is swallowed and handleConnectGitHub() is still called. The old stale integration record remains in the database while a new OAuth flow starts. Depending on whether the backend enforces uniqueness per user, this can result in two integration rows, and invalidateGithubQueries is never called (since onSuccess doesn't fire), so the cache retains the stale entry until the reconnect completes.
Consider invalidating the relevant queries in the catch path so the UI doesn't remain in an inconsistent state even when disconnect fails.
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: 390-396
Comment:
**Silent disconnect failure may leave dangling integration**
If `disconnectMutation.mutateAsync` fails (e.g. a 5xx from the backend), the error is swallowed and `handleConnectGitHub()` is still called. The old stale integration record remains in the database while a new OAuth flow starts. Depending on whether the backend enforces uniqueness per user, this can result in two integration rows, and `invalidateGithubQueries` is never called (since `onSuccess` doesn't fire), so the cache retains the stale entry until the reconnect completes.
Consider invalidating the relevant queries in the catch path so the UI doesn't remain in an inconsistent state even when disconnect fails.
How can I resolve this? If you propose a fix, please make it concise.| if (result.isError) { | ||
| const installationId = | ||
| githubIntegrations[index]?.installation_id ?? null; | ||
| if (installationId) failedInstallationIds.push(installationId); |
There was a problem hiding this comment.
Stale detection triggers on any error, not just auth failures
Any error that survives React Query's retry budget (network timeouts, 5xx server errors, etc.) will add the installation to failedInstallationIds and show "Reconnect needed" to the user, even when the GitHub token itself is still valid. This could prompt unnecessary reconnects during a temporary backend outage.
If the API client surfaces HTTP status codes, consider restricting the stale signal to 401/403 responses only.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/hooks/useIntegrations.ts
Line: 155-158
Comment:
**Stale detection triggers on any error, not just auth failures**
Any error that survives React Query's retry budget (network timeouts, 5xx server errors, etc.) will add the installation to `failedInstallationIds` and show "Reconnect needed" to the user, even when the GitHub token itself is still valid. This could prompt unnecessary reconnects during a temporary backend outage.
If the API client surfaces HTTP status codes, consider restricting the stale signal to 401/403 responses only.
How can I resolve this? If you propose a fix, please make it concise.172b3fe to
c0863fa
Compare
666b43f to
2f25fac
Compare
c0863fa to
b10465c
Compare

Problem
When a GitHub app installation is uninstalled or its token is revoked, the integration appears as "Connected" even though it can no longer reach GitHub. Users have no way to know their integration is broken or how to fix it.
Changes
failedInstallationIdsfromuseUserRepositoryIntegrationso components can identify stale integrationsintegrationIsStalestate inGitIntegrationStepwhen the current integration's installation ID appears in the failed listsilentoption on the disconnect mutation to suppress the "GitHub disconnected" toast when reconnecting automatically