This repository was archived by the owner on Aug 6, 2026. It is now read-only.
Repository navigation
feat(code): detect stale GitHub integration and offer Reconnect #2000
Merged
k11kirky
merged 1 commit into
main
from
05-04-feat_code_detect_stale_github_integration_and_offer_reconnect
May 4, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,10 +148,16 @@ function useAllUserGithubRepositories( | |
| })), | ||
| combine: (results) => { | ||
| const map: Record<string, UserRepositoryIntegrationRef> = {}; | ||
| const failedInstallationIds: string[] = []; | ||
| let pending = false; | ||
| for (const result of results) { | ||
| results.forEach((result, index) => { | ||
| if (result.isPending) pending = true; | ||
| if (!result.data) continue; | ||
| if (result.isError) { | ||
| const installationId = | ||
| githubIntegrations[index]?.installation_id ?? null; | ||
| if (installationId) failedInstallationIds.push(installationId); | ||
|
Comment on lines
+155
to
+158
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Any error that survives React Query's retry budget (network timeouts, 5xx server errors, etc.) will add the installation to If the API client surfaces HTTP status codes, consider restricting the stale signal to 401/403 responses only. Prompt To Fix With AIThis 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. |
||
| } | ||
| if (!result.data) return; | ||
| for (const repo of result.data.repos ?? []) { | ||
| if (!(repo in map)) { | ||
| map[repo] = { | ||
|
|
@@ -160,8 +166,12 @@ function useAllUserGithubRepositories( | |
| }; | ||
| } | ||
| } | ||
| } | ||
| return { repositoryMap: map, isPending: pending }; | ||
| }); | ||
| return { | ||
| repositoryMap: map, | ||
| isPending: pending, | ||
| failedInstallationIds, | ||
| }; | ||
| }, | ||
| }); | ||
| } | ||
|
|
@@ -489,8 +499,11 @@ export function useUserRepositoryIntegration() { | |
| useUserGithubIntegrations(); | ||
| const [isRefreshingRepos, setIsRefreshingRepos] = useState(false); | ||
|
|
||
| const { repositoryMap, isPending: reposPending } = | ||
| useAllUserGithubRepositories(githubIntegrations); | ||
| const { | ||
| repositoryMap, | ||
| isPending: reposPending, | ||
| failedInstallationIds, | ||
| } = useAllUserGithubRepositories(githubIntegrations); | ||
|
|
||
| const repositories = useMemo( | ||
| () => Object.keys(repositoryMap), | ||
|
|
@@ -555,6 +568,7 @@ export function useUserRepositoryIntegration() { | |
| isRefreshingRepos, | ||
| refreshRepositories, | ||
| hasGithubIntegration: githubIntegrations.length > 0, | ||
| failedInstallationIds, | ||
| }; | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
disconnectMutation.mutateAsyncfails (e.g. a 5xx from the backend), the error is swallowed andhandleConnectGitHub()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, andinvalidateGithubQueriesis never called (sinceonSuccessdoesn'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