feat(task-input): cache cloud default branch for instant "start on trunk"#3496
Conversation
…unk"
Persist the last-known default ("trunk") branch per cloud repo so a cold
start can pre-select trunk in the branch picker immediately, instead of
waiting on the slow live branch list to resolve.
The picker already auto-selects the default branch when nothing is
selected; feeding it a cached value makes that fire with zero wait. The
fresh value from the live query takes over the moment it arrives and is
written back to the cache.
Generated-By: PostHog Code
Task-Id: 562fb90f-d823-425d-b53c-5f482b55a8b2
|
😎 Merged successfully - details. |
|
React Doctor found 4 issues in 2 files · 4 warnings. 4 warnings
Reviewed by React Doctor for commit |
Seed the known default ("trunk") branch as a real, pickable list item in
the cloud branch picker while the remote branch list is still loading, with
a "Loading branches…" row rendered directly below it. This makes the open
dropdown usable for the common "start on trunk" case with zero wait, and
signals that the rest of the branches are still on the way.
Only seeds when there's no active search — once the user types, the list is
purely what the remote returns.
Generated-By: PostHog Code
Task-Id: 562fb90f-d823-425d-b53c-5f482b55a8b2
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 593d7444c6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
Multi-perspective review (paul + xp + security-audit) surfaced low/nit items; this addresses the actionable ones: - Extract the duplicated "Loading branches…" literal into a shared LOADING_BRANCHES_LABEL const so the two render sites can't drift. - Clarify the TaskInput comment: the cached default is best-effort — a default branch renamed since it was cached stays seeded until the user picks another (the auto-select only fires while nothing is selected). - Lock the empty-state gating with a test asserting "No branches found." keeps the `hidden` class when the seeded trunk row makes the list non-empty, so it never flashes above the seeded row. security-audit: 0 findings (API-derived branch name → auto-escaped React text + the pre-existing selection path; no new sink). Generated-By: PostHog Code Task-Id: 562fb90f-d823-425d-b53c-5f482b55a8b2
Generated-By: PostHog Code Task-Id: 562fb90f-d823-425d-b53c-5f482b55a8b2
There was a problem hiding this comment.
No showstoppers. The stale-cache/wrong-branch concern from both bot comments is real but acknowledged in the diff's own code comments as an accepted trade-off, is visible to the user (who can correct it before submitting), and only bites in a rare renamed-default-branch scenario. All other aspects are clean: correct layer placement, no API contract changes, good test coverage.
Four reviewers (qa-swarm's paul + xp, plus the org Codex and veria-ai bots) independently flagged that a stale cached default branch never self-corrects: the picker auto-selects the cached "trunk", and the existing effect's `!selectedBranch` guard then blocks re-selection once the live default arrives, so a task could start on a branch that is no longer the default. Track the branch we auto-selected in a ref and re-select when the default changes out from under our own auto-pick — while never clobbering a branch the user chose deliberately. Adds tests for both the self-heal and the user-choice-preserved paths, and updates the TaskInput comment to match. Generated-By: PostHog Code Task-Id: 562fb90f-d823-425d-b53c-5f482b55a8b2
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
There was a problem hiding this comment.
The inline bot comments about stale-cache mis-selection are addressed in the current diff: the autoSelectedBranchRef mechanism lets BranchSelector distinguish its own auto-picks from user picks, and the updated effect re-selects the live default when it arrives and differs from a stale auto-selection. The new test "re-selects the default when a stale cached default is replaced by the live one" verifies this path. The worst case is a brief wrong pre-selection that self-corrects on live data arrival — visible to the user, not silent corruption. No showstoppers.
|
/trunk merge |
Problem
Launching the app and opening the branch picker for a cloud repo means waiting on a slow live branch list (thousands of branches) before anything is usable — even for the common case of just wanting to start on trunk. Raised in a Slack thread.
Changes
Persist the last-known default ("trunk") branch per cloud repo (keyed by
owner/repo) in the settings store, alongside the existing cached repository map. The branch picker already auto-selects the default branch when nothing is selected, so on a cold start we feed it the cached value and trunk gets pre-selected with zero wait. The fresh value from the live query takes over the moment it arrives and is written back to the cache.cachedCloudDefaultBranchMap+setCachedCloudDefaultBranchin the settings store (no-ops when the value is unchanged).TaskInputserves the cached default until the live branch list resolves, and persists fresh defaults for the next cold start.How did you test this?
pnpm --filter @posthog/ui typecheck(clean)pnpm --filter @posthog/ui test settingsStore BranchSelector(40 passing, including new tests for caching, persistence, no-op-on-unchanged, and rehydration)biome checkon the changed filesAutomatic notifications
Created with PostHog from a Slack thread