Skip to content

perf(code): make task composer repo/branch selectors feel instant#2196

Open
fercgomes wants to merge 1 commit into
mainfrom
posthog-code/instant-task-selectors
Open

perf(code): make task composer repo/branch selectors feel instant#2196
fercgomes wants to merge 1 commit into
mainfrom
posthog-code/instant-task-selectors

Conversation

@fercgomes
Copy link
Copy Markdown

Summary

  • Fetch cloud branches as soon as a repo is selected — first page contains default_branch, so the branch button shows main/master immediately and the dropdown opens against a warm cache.
  • Add staleTime: 5 min to useGithubBranches and useUserGithubBranches so reopens within 5 min skip the network.
  • Drop the open gate on the local-mode branches query in BranchSelector (it's a fast local git call) and bump staleTime to 60s.
  • Remove the now-dead isCloudBranchPickerOpen state in TaskInput.

Why

The branch dropdown was empty until the user clicked it, and the trigger button stayed blank until that round-trip returned. Reopening refetched from scratch because the infinite query had no staleTime.

Test plan

  • pnpm --filter code typecheck passes
  • In cloud mode with a remembered repo, the branch button shows the default branch within one round-trip without clicking the dropdown
  • Opening the branch dropdown a second time within 5 min shows results without a loading row (warm cache)
  • Switching repos fires one branches request and updates the button when the new repo's first page returns
  • In local/worktree mode, the branch button populates without opening the dropdown

The new-task composer's branch dropdown was empty until the user clicked it
and the trigger button stayed blank in the meantime — the cloud-branches
query was gated on the picker being open. Reopening also refetched from
scratch because the infinite query had no staleTime. The local-branch query
in BranchSelector behaved the same way: gated on `open`, despite being a
fast local git call.

- Fetch cloud branches as soon as a repo is selected. The first page
  includes `default_branch`, so the branch button shows `main`/`master`
  immediately and the dropdown opens against a warm cache.
- Add `staleTime: 5 min` to both `useGithubBranches` and
  `useUserGithubBranches`, matching the repository hooks.
- Drop the `open` gate on local branches and bump `staleTime` to 60s.
- Remove the now-dead `isCloudBranchPickerOpen` state in TaskInput.

Generated-By: PostHog Code
Task-Id: 3359bdaf-6661-4001-beab-9ad6478f3e28
@fercgomes fercgomes marked this pull request as ready for review May 18, 2026 21:56
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 18, 2026

Reviews (1): Last reviewed commit: "perf(code): make task composer repo/bran..." | Re-trigger Greptile

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.

1 participant