feat(code): add github repo and branch refresh controls#1752
Merged
Conversation
Prompt To Fix All With AIThis is a comment left during a code review.
Path: apps/code/src/renderer/hooks/useIntegrations.ts
Line: 191-216
Comment:
**Missing null guard on `client` before calling `refreshGithubRepositories`**
`useAuthenticatedClient()` can return `null` when the user is unauthenticated. Because the early-return only checks `githubIntegrations.length`, a null `client` will still reach the `client.refreshGithubRepositories(...)` call, throwing a `TypeError` whose raw message surfaces in the error toasts added by callers.
```suggestion
const refreshRepositories = useCallback(async () => {
if (!githubIntegrations.length || !client) {
return;
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: apps/code/src/renderer/api/posthogClient.ts
Line: 1130-1155
Comment:
**Duplicated repo-normalization logic (OnceAndOnlyOnce)**
`refreshGithubRepositories` (lines 1150–1154) copies the exact same response-mapping from `getGithubRepositories` (lines 1122–1127). Extracting a small private helper keeps the two in sync and avoids the duplication:
```ts
private normalizeRepos(data: unknown): string[] {
const repos =
(data as { repositories?: unknown[] }).repositories ??
(data as { results?: unknown[] }).results ??
(Array.isArray(data) ? data : []);
return (repos as (string | { full_name?: string; name?: string })[]).map(
(repo) => {
if (typeof repo === "string") return repo;
return (repo.full_name ?? repo.name ?? "").toLowerCase();
},
);
}
```
Then both methods call `return this.normalizeRepos(data);`.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: apps/code/src/renderer/features/inbox/components/DataSourceSetup.tsx
Line: 175-187
Comment:
**Stale `repo` selection after refresh, inconsistent with `TaskInput`**
After a successful refresh, if the previously selected repository is no longer present in the refreshed list, `repo` state retains the stale value. The submit button is blocked because `selectedIntegrationId` becomes `undefined`, but the picker still displays the non-existent repo name. `TaskInput.tsx` handles this correctly by deriving `selectedCloudRepository` from `repositories` and resetting `selectedRepository` when the value no longer exists (lines 231–246 in `TaskInput.tsx`). Consider clearing `repo` after refresh when it's no longer valid:
```ts
const handleRefreshRepositories = useCallback(() => {
void refreshRepositories()
.then(() => {
toast.success("Repositories refreshed");
if (repo && !repositories.includes(repo)) {
setRepo(null);
}
})
.catch(...)
}, [refreshRepositories, repo, repositories]);
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(code): add github repo and branch r..." | Re-trigger Greptile |
61652d3 to
04cbdab
Compare
9e344c5 to
a5fa69d
Compare
adboio
approved these changes
Apr 21, 2026
a5fa69d to
f48c1ed
Compare
sortafreel
approved these changes
Apr 22, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Let's avoid hitting GH API on repository/branch selection always, added refresh icon to force refresh it.
Changes