fix(task-input): prefill repo dropdown when starting task from sidebar "+" icon#2712
Open
mp-hog wants to merge 4 commits into
Open
fix(task-input): prefill repo dropdown when starting task from sidebar "+" icon#2712mp-hog wants to merge 4 commits into
mp-hog wants to merge 4 commits into
Conversation
…d modes The TASKS sidebar "+" button (and the command menu's "new task in folder") passes a `folderId` to the new-task screen, but `folderId` only ever prefilled the local directory selector — never the cloud repo dropdown. In Cloud mode the prefill was invisible, so clicking "+" on a repo left the cloud dropdown on the last-used (wrong) repo, and tasks could be started against the wrong repo. Make `folderId` drive both selectors. A registered folder already carries both `path` (local) and `remoteUrl` (the resolved `owner/repo` slug), so it is a single source of truth for the local directory and the cloud repo. New `useInitialRepoSelectionFromFolderId` hook + pure `resolveRepoSelectionForFolder` resolver: - always prefill the local directory from the folder path; - prefill the cloud repo when the folder's remote is a real `owner/repo` that is a connected GitHub integration; - keep the user's current workspace mode when it can represent the repo, and only switch (Cloud -> last-used local mode) when it can't (local-only repo while in Cloud). The mode switch uses the non-persisting setter so it does not overwrite the user's mode preference. The cloud/mode decision is gated on the integrations list having loaded, and runs once per `folderId` so it never clobbers a manual change. Replaces the directory-only `useInitialDirectoryFromFolderId` (removed). Call sites are unchanged, so every folder-scoped new-task entry point benefits. Known limits (out of scope): a cloud-only group with no registered local folder falls back to defaults; in Cloud mode, "+" on a repo whose org is not a connected integration intentionally switches to Local. Generated-By: PostHog Code Task-Id: 50f73c6f-d922-4d90-b547-a450102c770c
…ill guard
Address PR review feedback on the sidebar "+" repo prefill.
P1 (corrected): the cloud/mode readiness guard previously required
`repositories.length > 0`, which never becomes true for users in cloud
mode with zero connected GitHub integrations — so clicking "+" on a
local-only folder silently did nothing for them. The reviewer's proposed
fix (`!isLoadingRepos` alone) reintroduces the transient-empty race the
length check guarded against (the window where loading has cleared but
per-installation repo queries haven't populated yet), wrongly switching
users with integrations to Local on the common path. Instead, extract a
pure `areReposReady({ isLoadingRepos, repositoriesCount,
hasGithubIntegration })` helper: ready when not loading AND
(repos present OR no GitHub integration). Fixes the no-integration cohort
while preserving the transient-window guard for the common path.
P2: fold the resolver cases into an `it.each` table (per CLAUDE.md test
guidance), add the settled-empty `repositories` row, and add a
parameterised `areReposReady` table covering the transient-window and
no-integration cases.
Generated-By: PostHog Code
Task-Id: 50f73c6f-d922-4d90-b547-a450102c770c
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
packages/ui/src/features/task-detail/hooks/useInitialRepoSelectionFromFolderId.test.ts:241-267
**Missing "waits for folders to load" test case**
The deleted `useInitialDirectoryFromFolderId.test.ts` explicitly tested the scenario where `folders` starts empty and the target folder arrives in a later render. That case is absent from the new test file. The hook bails early when `folders.find()` returns `undefined` and intentionally leaves `dirInitRef.current` unset so the effect retries once `folders` loads — but without a test for this path, a future regression (e.g., accidentally setting `dirInitRef.current` before finding the folder) would go unnoticed.
### Issue 2 of 2
packages/ui/src/features/task-detail/hooks/useInitialRepoSelectionFromFolderId.ts:22-29
**`areReposReady` permanently returns `false` when integration exists but repos are empty**
When `hasGithubIntegration = true` and `repositoriesCount = 0` is not a transient gap (e.g., a user installed the GitHub App then revoked access to every repository), `areReposReady` never returns `true`. As a result `reposLoaded` stays `false` in the hook, `repoModeInitRef.current` is never set, and clicking "+" on a local-only folder while in Cloud mode silently leaves the user in Cloud mode. The directory prefill still fires, so the failure is partial rather than total — but the mode switch the fix promises never happens for this cohort.
Reviews (1): Last reviewed commit: "fix(task-input): distinguish settled-emp..." | Re-trigger Greptile |
Contributor
|
Reviews (2): Last reviewed commit: "Merge branch 'main' into posthog-code/pr..." | Re-trigger Greptile |
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
In the Tasks sidebar each repo group header has a hover "+" button to start a new task. Clicking it did not scope the new-task screen with that repo in cloud-mode, so that tasks were started under wrong repo.
It's this relation:
Fix
Make
folderIddrive both selectors. A registered folder already carries bothpath(local) andremoteUrl(the resolvedowner/reposlug), so it's a single source of truth.New
useInitialRepoSelectionFromFolderIdhook + pureresolveRepoSelectionForFolderresolver:owner/repothat is a connected GitHub integrationBehavior
Testing
areReposReady, and the hook cover every branch incl. the loading-gate and once-per-folderIdguard.@posthog/uitypecheck + biome clean; task-detail suite green (22/22); full@posthog/uisuite green (752/752).Known limits (out of scope)
folderId/remoteUrlto key off).