Skip to content

feat(code): add github repo and branch refresh controls#1752

Open
tatoalo wants to merge 1 commit intomainfrom
feat/cloud/cache-gh-repos-cloud-agent
Open

feat(code): add github repo and branch refresh controls#1752
tatoalo wants to merge 1 commit intomainfrom
feat/cloud/cache-gh-repos-cloud-agent

Conversation

@tatoalo
Copy link
Copy Markdown
Contributor

@tatoalo tatoalo commented Apr 21, 2026

Problem

Let's avoid hitting GH API on repository/branch selection always, added refresh icon to force refresh it.

CleanShot 2026-04-21 at 10  27 05

Changes

  • add a client call for the GitHub repository refresh endpoint
  • expose refresh state and refresh actions from the integrations hook
  • add refresh controls inside the repository dropdown and branch dropdown
  • wire refresh actions into the task input, onboarding, and GitHub data source setup flows
  • surface refresh failures in the UI instead of failing silently
  • tighten picker behavior so invalid refreshed selections do not continue through the flow

@tatoalo tatoalo self-assigned this Apr 21, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 21, 2026

Prompt To Fix All With AI
This 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

Comment thread apps/code/src/renderer/hooks/useIntegrations.ts
Comment thread apps/code/src/renderer/api/posthogClient.ts
@tatoalo tatoalo force-pushed the feat/cloud/cache-gh-repos-cloud-agent branch from 61652d3 to 04cbdab Compare April 21, 2026 09:32
@tatoalo tatoalo requested a review from a team April 21, 2026 10:15
@tatoalo tatoalo force-pushed the feat/cloud/cache-gh-repos-cloud-agent branch from 9e344c5 to a5fa69d Compare April 21, 2026 12:18
@tatoalo tatoalo force-pushed the feat/cloud/cache-gh-repos-cloud-agent branch from a5fa69d to f48c1ed Compare April 22, 2026 08:40
Copy link
Copy Markdown
Member

@VojtechBartos VojtechBartos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants