Repository navigation
fix(web): new-sprint dialog uses the new agent project menu - #590
Conversation
Both project pickers in the New sprint dialog (Project and Also touches) now open the draft's project menu (DraftProjectPicker): search, sort, favicons, pins and the Add a project footer. Also touches uses a new multi-select mode (checked rows show a check, the list stays open). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NoahHendrickson
left a comment
There was a problem hiding this comment.
Code quality review, commit acc5697b292fbf7efe4c0fce30a945f852dbff0f. Not approving yet. Behavior looks right and no file comes near 1k lines (picker 263, hook 279, dialog 438). But the multi-select mode is bolted onto the picker through loose optional props, and the PR adds a second useSidebarProjectGroups next to the canonical one. Both can be fixed without changing what users see.
1. Multi-select is a set of optional props, not a mode (custom/DraftProjectPicker.tsx:66-195)
The new mode is spread across checkedValues?, anchor?, a sentinel value: "", and a pick that now means "toggle" instead of "set". The picker then checks checkedValues !== undefined in five places (multiple, value, onValueChange, selectedFill, the check icon). Nothing in the types ties these together: anchor is required for multi-select (see its own comment) but optional, and choices.value has no meaning in multi mode, so the caller passes "".
The worst part is onValueChange. Base UI already passes the new array, but the picker diffs it against checkedValues to find the one key that changed, then calls pick(key). The dialog then rebuilds the array with a toggle reducer (NewSprintDialog.tsx:317-323). The data goes array → key → toggle → set, which is the reverse of what the combobox already provides.
Suggested change: make the mode a typed prop and let the array pass straight through.
type PickerSelection =
| { readonly mode: "single"; readonly value: string; readonly onPick: (key: string) => void }
| {
readonly mode: "multiple";
readonly values: ReadonlyArray<string>;
readonly onValuesChange: (keys: ReadonlyArray<string>) => void;
readonly anchor: RefObject<Element | null>;
};With this:
- The diffing code is gone.
- The dialog's toggle reducer becomes
setAlsoKeys(new Set(keys)). anchoris required exactly when it is needed.DraftProjectMenuChoiceslosesvalue/pickand holds only row data (entries, recent keys, pin, No project).
That last point matches what the dialog already does: useSprintProjectRows returns Omit<DraftProjectMenuChoices, "value" | "pick">, which shows the type was mixing two things. The draft chip passes { mode: "single", value, onPick: choices.pick }.
One detail if you want zero behavior drift: alsoKeys currently keeps keys from another machine across a project switch. Merge those hidden keys back in, or decide on purpose that toggling drops them.
2. A second useSidebarProjectGroups with a different contract (custom/useDraftProjectChoices.ts:97-128)
~/hooks/useSidebarProjectGroups is upstream's canonical hook, used by Sidebar, the PR page and CollapsedThreadTabs. This PR exports another hook with the same name but a different signature (it takes projects), a different sort (sortLogicalProjectsForSidebar vs sortSidebarV2ProjectGroups) and no scratch grouping. Its doc comment says "as the sidebar draws them", which is not what the real sidebar hook does. Auto-import and grep will now mix the two up.
It also returns a grab-bag, { projectGroups, threads, projectGroupingSettings, primaryEnvironmentId }. The last two are only there so useDraftProjectChoices doesn't have to call two cheap selectors itself.
Either:
- Name it for what it is (for example
useDraftProjectGroups) and return only{ projectGroups, threads }, letting the draft hook read its own settings and primary environment. Or: - Check whether the sprint dialog can use the canonical hook directly. It filters to
sprintKeysanyway, so scratch grouping doesn't matter there. That would keep the extraction out of this PR entirely.
3. The sprint dialog builds its project list twice and makes up a "group" (custom/sprints/NewSprintDialog.tsx:45-102)
useSprintProjects()anduseSprintProjectRows()each calluseProjects()anduseScratchProject()and filter out scratch projects in slightly different ways. The second gets its candidate set through aSetof keys from the first. OneuseSprintProjectChoices()hook that owns the candidate list, the rows and the recent keys would leave one list instead of two that have to agree.- Each row's
groupis an object built by hand. ItsprojectKeyis a scoped project key, whilepinnedandmemberProjectsbelong to the logical group. It is half one thing and half the other, and it gets passed totogglePin. If the picker's entry type is what forces this shape, say so in the type: give the entry a row key separate from its pin target, rather than relabelling a group's fields. At minimum, put the construction in a small named helper with a one-line invariant. recentKeyswraps groups as{ group }only to fitrankRecentProjectEntries, then flattens members. That is fine on its own, but it is a third shape conversion in one hook.
Smaller
- The "Also touches"
choicesobject is built inline in JSX, including an O(n·m)alsoChoices.some(...)filter, the sentinelvalueand the reducer. After (1) and (3) it becomes{ ...rows, entries: alsoEntries }, withalsoEntriescomputed next toalsoChoices.
Verdict: request changes. (1) is the main blocker: it removes the diff logic, the sentinel and the optional-prop tangle. (2) is a canonical-name collision that should not merge as is.
🤖 Review by Claude Opus 5.5 (claude-opus-5-5) via Claude Code (T3 Code), reviewed commit acc5697b292fbf7efe4c0fce30a945f852dbff0f.
NoahHendrickson
left a comment
There was a problem hiding this comment.
Code review: acc5697b292fbf7efe4c0fce30a945f852dbff0f
No correctness issues found.
What I checked:
useSidebarProjectGroupsextraction. This only moves code.useDraftProjectChoicesstill buildsprojectGroupswith the same inputs: manual order, grouping settings, environment labels and thread-based sort.entries,recentKeysandpickdon't change, so the new agent chip and launchpad behave as before.- Multi-select toggle in
DraftProjectPicker. Base UI computes the new array from the controlledcheckedValues, so the before/after difference is always exactly one key.choices.pick(toggled)then flips it inalsoKeys. Single-select still goes through thetypeof value === "string"branch. A deselect (null) is ignored, as before. - Backspace in the search field. Base UI's multi-select Backspace-removes-last-value path (
ComboboxInput,@base-ui/react@1.9.0) runs only when a chips context exists. This menu renders no chips, so pressing Backspace in an empty search can't silently uncheck an "Also touches" project. - Anchoring.
ComboboxPopupfalls back tochipsRefonly whenanchoris unset, so passingalsoTriggeris what the multi-select picker needs. The single-select Project picker correctly leaves it unset. - Rows and keys. In the sprint rows,
group.projectKeyis the member's own scoped key. That matchesprojectKeyOf,recentKeys(flattened per member) andcheckedValues, so "Recent" sort, the check marks and the toggles all use the same key.sprintKeysstill applies the unarchived, non-scratch, has-a-No-project-machine filter. Also touches is still limited toalsoChoices, the same machine minus the main project. - Pins. These act on the full sidebar group (
memberProjectsandpinnedfrom the group), the same as the draft menu.pickableProjectGroupsfilters archived groups, not individual members, so the two menus operate on the same group members. useCreateSprintpayload. TheprojectandotherProjectsit receives are unchanged.
Non-blocking:
NewSprintFormnow subscribes touseQuietThreadShells()throughuseSidebarProjectGroups, so the open dialog re-renders when any thread shell changes. The draft chip already pays this cost and the dialog is short-lived, so I'm fine leaving it as is.
CI: the fast checks and the server shards pass. Test, Test Web 2 and Build and Typecheck were still pending when I posted this.
🤖 Signed: Claude Opus 5.5 (claude-opus-5-5) via Claude Code (T3 Code), automated review
Review follow-up on #590: DraftProjectPicker takes a selection prop (single: value + onPick; multiple: values + onValuesChange + anchor), so the array passes straight through with no diffing and the menu choices type holds rows only. The sprint dialog reads upstream's useSidebarProjectGroups instead of a second hook of the same name, and one useSprintProjectChoices owns its candidates, rows and ranking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. All three points are addressed in 2e531a8, plus a Storybook fix in ab3bd34. Nothing changes for the user: the dialog and the new agent chip look and behave as before (re-checked in a browser against a scratch dev server). 1. Multi-select is now a typed mode. 2. The second 3. One sprint choices hook. Smaller. Also fixed: Sol round 2 approved, with one finding: Checks: 🤖 Claude Opus 5.5 ( |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
Re the correctness review's non-blocking note (dialog re-renders on thread shell changes): this still applies after the refactor, because 🤖 Claude Opus 5.5 ( |
The New sprint dialog's Project field was a plain Select, and Also touches (optional) was a plain checkbox menu. Both showed a long list of names, unlike the project menu on the new agent screen.
Both fields now open that same menu (
custom/DraftProjectPicker), with its search, Recent/Name sort, favicons, pin buttons and "Add a project" footer. The trigger is drawn like the dialog's Model picker and shows the draft chip's folder icon and the project name.DraftProjectPickertakesselection: { mode: "single", value, onPick } | { mode: "multiple", values, onValuesChange, anchor }. In multiple mode, checked rows show a check instead of a fill and the list stays open.anchoris required because Base UI's multiple combobox otherwise anchors to chips this menu never draws.DraftProjectMenuChoicesnow holds row data only. Asideprop opens the menu downward in the dialog.useSprintProjectChoices()owns the dialog's candidates and rows. Each project is still its own row, because a sprint runs on one machine. A row's pin and recent use come from the project's group in upstream's~/hooks/useSidebarProjectGroups, so pinned and recent projects come first, as in the draft menu.useCreateSprintreceives (project,otherProjects).forkSprints.test.tspins both fields toDraftProjectPicker.forkNewAgentDraftnow guards the new single-pick dispatcher. The Storybook menu story passes the typed selection. Thefork-sprintsmanifest entry now mentions the shared menu.Checks:
vp run check:changed(typecheck across 44 packages, 157 test files, React Compiler), design-lint and the fork lint ratchet all pass. I also checked in a browser against a scratch dev server: search, picking a project, toggling Also touches rows on and off, the main project left out of Also touches, Add a project opening the palette over the dialog, and the new agent chip's menu unchanged.Reviewed with sol-loop: 2 rounds with GPT-6.1 Sol on high. Sol verdict: approved
🤖 Signed: Claude Opus 5.5 (
claude-opus-5-5) via Claude Code (T3 Code)Reviewer: GPT-6.1 Sol (
gpt-6.1-sol, high effort) via Codex. It approved both rounds; its one round-2 finding, the Storybook story, is fixed.🤖 Generated with Claude Code