Skip to content

feat(fork): collapse iOS New agent project list into top dropdown - #544

Merged
NoahHendrickson merged 3 commits into
customfrom
t3/ios-project-selector-collapse
Nov 27, 2026
Merged

NoahHendrickson merged 3 commits into
customfrom
t3/ios-project-selector-collapse

Conversation

@NoahHendrickson

@NoahHendrickson NoahHendrickson commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

On the iOS New agent screen, selecting a project left the full project list open, so scrolling or focusing the composer could push the selected project out of view and leave it unclear which project was active.

Once a project (or No project) is picked, the visible project rows now morph and collapse together on the UI thread inside a GlassContainer into a single top dropdown pill showing the selected project with a chevron, and "What should we do?" centered in the open space below it (staying visible with the keyboard up). Tapping the dropdown dismisses the keyboard and expands the list back out to switch projects; opening header Search while collapsed expands the list for filtering and collapses back on pick or close.

Reviewed with sol-loop: 4 rounds with gpt-6.2-sol on high. Sol verdict: approved.

Built with Gemini 4 Neon via Antigravity.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XL labels Nov 26, 2026

@NoahHendrickson NoahHendrickson left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Code-quality review of 3ccf431 (base 2d07bf6). Not approving: the behaviour looks deliberate, but the way it's built leaves ProjectTiles much harder to reason about than it needs to be.

No3yNewAgent.tsx goes from 481 to 936 lines. Almost all of that growth is in ProjectTiles, which is now a single ~480-line function. That function holds a four-state phase machine, two effects, three refs, four useStates for scroll and viewport, two shared values, and a second copy of the row UI. It stays under 1k lines, but it already reads as a file that needs splitting.

1. The phase machine is effect-driven state sync. Derive it instead.

expanded is already derived in render. Then prevExpandedRef plus effect #1 watches it and copies changes into phase, and effect #2 watches phase and starts the animation. phase is in effect #1's dependency list, so that effect runs again on every phase change and returns early only because of the ref. This is the "sync state in an effect" pattern the repo's rules warn against.

A simpler shape:

  • Keep one piece of state, settled (the last expanded value whose animation finished).
  • Derive phase from expanded and settled: equal means expanded or collapsed; different means expanding or collapsing.
  • Use one effect that runs collapse.set(withTiming(expanded ? 0 : 1, …, done => scheduleOnRN(setSettled, expanded))).

Under Reduce Motion that same effect just sets the value. This deletes prevExpandedRef, the PickerPhase writes inside effect #1, and the finishExpand closure. The search-query clear moves into the settle callback, in one place.

2. Keep one scroll position, not three.

The scroll position currently lives in scrollYRef, anchorScrollY (a shared value), transitionScrollY (state) and expandScrollY (state). The only consumer of transitionScrollY is participatesInCollapse, and that only feeds the row's rowStyle worklet. So:

  • Use a single scrollY shared value written by useAnimatedScrollHandler.
  • Put the viewport height in a shared value too.
  • Compute "is this row near the viewport" inside rowStyle.

transitionScrollY, the participatesInCollapse prop, and both copies of the no3yRowVisibleForCollapse({...}) block go away.

3. Build the rows as one list. The "No project" and tile branches are copies of each other.

Both branches pass the same set of props. The participatesInCollapse block is repeated word for word. selectedIndex is a nested ternary wrapped in an IIFE, and it exists only because "No project" sits outside tiles (hence rowOffset). Instead:

  • Build rows: { key, label, leading, selected, disabled, onPress }[] once, with "No project" at index 0 when shown.
  • selectedIndex = rows.findIndex(r => r.selected).
  • rowIndex becomes the map index.

rowOffset, the IIFE and the duplicated JSX all disappear.

4. The collapsed pill is a second implementation of ProjectRow.

The phase === "collapsed" branch rebuilds the selected row by hand: glass layer, leading icon, label, chevron. It also needs selectedLeading, which pulls favicon fields through four selectedScope?.representative.X ?? flow.selectedProject.X fallbacks plus a magic "Project" label. The selected row already has its own leading, label and chevron state at collapse = 1.

When collapsed, render that same row (from the rows model in #3) outside the ScrollView with onPress = reopenPicker. Pulling a shared ProjectRowFace out of both would also work. Either way, the parallel UI and the fallback chain go away. They are already drifting apart: the row puts gap on an inner view, the pill puts it on the Pressable.

A side effect of the duplicate: the fork guard's "<No3yGlassLayer radius={ROW_HEIGHT / 2} />" assertion now passes only because of the collapsed pill. It no longer checks the rows it was written for.

5. heroBottomInset re-derives how the parent builds bottomInset.

props.bottomInset - (insets.bottom + NO3Y_BOTTOM_NAV_CLEARANCE) undoes ThreadDetailScreen's composer-overlay height by assuming it contains no3yComposerBottomInset. If that ever changes, the hero silently drifts off centre.

The keyboard-aware inset should come through the No3yDraftSurface.content callback, from the owner that already knows it. The other option is a named helper next to no3yComposerBottomInset in flatGlassTheme.ts. Either beats subtracting another component's formula here.

6. No3yGlassLayer.active has three meanings.

undefined means "regular, never animate", while true and false mean "animated". So active ?? true and props.active === undefined encode two different invariants on one optional prop. Two clearer options:

  • Always pass the animated style object. The morph is a no-op when the value doesn't change.
  • Use a required, explicitly named prop, such as morph: { active: boolean } | undefined.

7. Smaller items (fold these into the restructure)

  • void Haptics.selectionAsync().catch(() => {}) appears three times. Use one local tick().
  • no3yExpandScrollOffset hard-codes <= 4 and - 2, and no3yRowVisibleForCollapse falls back to 800. Name them, or drop the fallback by not computing anything before layout (viewportHeight === 0).
  • availableHeroHeight falls back to 120 before layout. Same fix.
  • Effect #1 and finishCollapse read the module-level search directly instead of the hook snapshot. Once #1 is done there's only one clear site; read searchQuery there.

Suggested shape. Move the morph into its own module, e.g. fork/No3yProjectPicker.tsx or a useNo3yProjectPickerMorph hook. It would own the collapse shared value, the derived phase, scrollY/viewport shared values and the settle callback. ProjectTiles would then just build rows and render. That should bring No3yNewAgent.tsx back near its old size, with fewer concepts than this version rather than the same ones rearranged.


🤖 Signed: Opus 5.5 (claude-opus-5-5) via Claude Code

Comment thread apps/mobile/fork/No3yNewAgent.tsx Resolved
Comment thread apps/mobile/fork/No3yNewAgent.tsx Resolved
Comment thread apps/mobile/fork/No3yNewAgent.tsx Resolved
Comment thread apps/mobile/fork/No3yNewAgent.tsx Resolved
Comment thread apps/mobile/fork/No3yNewAgent.tsx Resolved
Comment thread apps/mobile/fork/No3yGlass.tsx Resolved

@NoahHendrickson NoahHendrickson left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Code review of 3ccf431136 (/code-review high, findings checked against the source).

Findings

  • Important: the header search query can stay applied, invisibly, after a collapse that never finishes (No3yNewAgent.tsx:433)
  • Important: the non-tab New agent surface opens collapsed with no project selected and hides the empty state (No3yNewAgent.tsx:315)
  • Nit: no3yExpandScrollOffset overestimates content height by one row gap (no3yProjectTiles.ts:96)
  • Nit: the fallback glass layer cuts to opacity 0 instead of morphing (No3yGlass.tsx:53)
  • Nit: VoiceOver still reads the hidden hero while the list is expanded (No3yNewAgent.tsx:547)
  • Nit: a trivial-logic test case (no3yProjectTiles.test.ts:86)
  • Pre-existing: a No-project request that resolves late overrides a newer pick (No3yNewAgent.tsx:483)

I dropped one candidate finding, about react/set-state-in-effect calls in the phase effect, because the Lint job passes on this commit.


🤖 Signed: Claude Opus 5.5 (claude-opus-5-5) via Claude Code

Comment thread apps/mobile/fork/No3yNewAgent.tsx Resolved
Comment thread apps/mobile/fork/No3yNewAgent.tsx Resolved
Comment thread apps/mobile/fork/no3yProjectTiles.ts Resolved
Comment thread apps/mobile/fork/No3yGlass.tsx Resolved
Comment thread apps/mobile/fork/No3yNewAgent.tsx Resolved
Comment thread apps/mobile/fork/No3yNewAgent.tsx Resolved
@NoahHendrickson
NoahHendrickson merged commit 001ca76 into custom Nov 27, 2026
33 checks passed
@NoahHendrickson
NoahHendrickson deleted the t3/ios-project-selector-collapse branch November 27, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants