Skip to content

Make mobile composer behavior focus-driven - #1263

Merged
ymichael merged 7 commits into
mainfrom
bb/fix-typing-in-collapsed-prompt-thr_f2d8xkew3m
Aug 11, 2026
Merged

ymichael merged 7 commits into
mainfrom
bb/fix-typing-in-collapsed-prompt-thr_f2d8xkew3m

Conversation

@ymichael

@ymichael ymichael commented Aug 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • make composer collapse follow settled focus state instead of timeline pointer activity, so scrolling cannot create a focused-but-collapsed prompt box
  • collapse correctly when the editor blurs to the page, while preserving focus in composer-owned portaled overlays
  • use interactive-widget=resizes-content for the standards-based Android keyboard path and limit the Visual Viewport shell workaround to iOS WebKit
  • keep the iOS shell aligned to the last reported viewport until keyboard-dismissal geometry arrives, avoiding the composer jumping below the visible viewport on blur

Testing

  • pnpm exec turbo run test --filter=@bb/app --force (324 files, 2,447 tests)
  • pnpm exec turbo run typecheck --filter=@bb/app
  • pnpm exec turbo run lint --filter=@bb/app (passes with existing warnings)
  • Android Chrome mobile smoke test at 390x844: focus expands, timeline touch preserves focus and expansion, blur collapses, and the composer remains within the viewport

@SawyerHood

Copy link
Copy Markdown
Collaborator

🚨 SLOP COP 🚨 · review

I am SlopCop. I am reviewing this pull request now.

I will check security, code quality, performance, architecture, and the mobile user path.

// focusin event this listener also handles; pointerdown alone must not
// create a focused-but-collapsed composer.
if (
event.type === "pointerdown" &&

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚨 slopcop/review — This guard can leave the composer expanded after focus leaves.

This handler runs before the browser updates focus. A tap on non-focusable timeline text sees the editor as active and returns here. Chrome then moves focus to document.body. No outside focusin event occurs, so the composer never collapses.

I reproduced this on the mobile dev page. After a real timeline text click, the active element was BODY, but data-follow-up-composer-expanded remained set. The new test only calls outside.focus(), so it does not cover this path.

Please handle the focusout path or defer this check until the focus update completes. Add a regression test for an outside non-focusable target.

@SawyerHood SawyerHood left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚨 SLOP COP 🚨 · review

ELI5: The message box is like a small drawer. This change keeps it open while you move the page.

I found one P2 correctness issue.

A tap on non-focusable timeline text can move focus to the page without a new focusin event. The new pointerdown guard returns before that focus change. The composer then stays expanded after focus leaves. I left a detailed inline comment with a reproduction.

Security review found no issues. The change does not add a data path, a permission change, or an action trigger.

Performance review found no issues. The change adds one bounded DOM containment check per outside pointer start. It adds no listener, timer, render, or scroll handler.

The architecture scan found no duplicate composer focus implementation. The nearby viewport focus logic has a separate purpose, so a refactor would not help this change.

Validation completed:

  • The full @bb/app suite passed: 324 files and 2,444 tests.
  • The @bb/app type check passed.
  • The focused prompt-box suite passed all 22 tests.
  • The mobile dev page kept the focused composer expanded after a timeline touch start.
  • The same page reproduced the missed blur path after a real timeline text click.

Please fix the missed blur path and add a regression test for a non-focusable outside target.

@ymichael ymichael changed the title Keep focused mobile composer expanded while scrolling Make mobile composer behavior focus-driven Aug 10, 2026
@ymichael
ymichael force-pushed the bb/fix-typing-in-collapsed-prompt-thr_f2d8xkew3m branch from d546626 to 6ef1aa3 Compare August 10, 2026 20:35
@ymichael
ymichael force-pushed the bb/fix-typing-in-collapsed-prompt-thr_f2d8xkew3m branch from 6ef1aa3 to ee4d845 Compare August 10, 2026 22:28
@ymichael
ymichael force-pushed the bb/fix-typing-in-collapsed-prompt-thr_f2d8xkew3m branch from 73c3e56 to e834d54 Compare August 10, 2026 23:02
@ymichael
ymichael merged commit 7eaec8d into main Aug 11, 2026
10 checks passed
@ymichael
ymichael deleted the bb/fix-typing-in-collapsed-prompt-thr_f2d8xkew3m branch August 11, 2026 02:22
amadad pushed a commit to amadad/bb that referenced this pull request Aug 14, 2026
## Summary
- make composer collapse follow settled focus state instead of timeline
pointer activity, so scrolling cannot create a focused-but-collapsed
prompt box
- collapse correctly when the editor blurs to the page, while preserving
focus in composer-owned portaled overlays
- use `interactive-widget=resizes-content` for the standards-based
Android keyboard path and limit the Visual Viewport shell workaround to
iOS WebKit
- keep the iOS shell aligned to the last reported viewport until
keyboard-dismissal geometry arrives, avoiding the composer jumping below
the visible viewport on blur

## Testing
- `pnpm exec turbo run test --filter=@bb/app --force` (324 files, 2,447
tests)
- `pnpm exec turbo run typecheck --filter=@bb/app`
- `pnpm exec turbo run lint --filter=@bb/app` (passes with existing
warnings)
- Android Chrome mobile smoke test at 390x844: focus expands, timeline
touch preserves focus and expansion, blur collapses, and the composer
remains within the viewport
SawyerHood added a commit that referenced this pull request Aug 19, 2026
…routes, composer retention (E1, E6, E7, E10, D3, J3, J4, I6, B28) (#1900)

## What was wrong

On phones (iOS Safari, compact viewports) several app-side patterns made
every page and every thread heavier than it needed to be:

- Sidebar rows wrapped each row in a modal Radix ContextMenu whose 700
ms long-press set aria-hidden on #root, registered a non-passive
touchmove and flipped body pointer-events with the timeline mounted
behind the drawer (E1).
- dnd-kit's TouchSensor kept a permanent non-passive window touchmove
listener from sidebar DndContexts mounted at boot, and the SidebarInset
swipe-open registered another one for every content touch. Both make the
first move of every scroll wait for the main thread (E6, E7).
- Settings/Tools routes swapped the whole AppSidebar out; returning
remounted ProjectList in the closed drawer (E10).
- A pending permission/question swapped FollowUpPromptBox out of the
tree, rebuilding TipTap per approval (D3).
- The collapsed compact composer built the full TipTap editor during
thread mount (D5 (reverted, see below)).
- Fixed-panel storage was scanned and zod-parsed on every navigation and
re-written on mount (J3).
- Heavy per-thread caches used the default 5-minute gcTime (J4).
- PR check icons and the GitHub logo fetched light+dark PNGs from
github.githubassets.com (I6).
- Root compose showed only "Loading…" until the sidebar bootstrap
settled (B28).

## What changed

- E1: `CompactLongPressMenu` (long-press/right-click detector, nothing
mounted until first open) opens the existing responsive drawer with the
same DropdownMenu items; desktop keeps the context menu.
- E6: `SidebarTouchSensor` installs dnd-kit's listener only while the
compact drawer shows (external store written by SidebarProvider, no
context subscription); tab strip wires TouchSensor only when open with
2+ tabs.
- E7: only edge-zone touches (24-72 px) get the non-passive swipe path;
deeper touches keep the recognizer on a passive listener without
preventDefault.
- E10: on compact one persistent `<Sidebar>` panel hosts the AppSidebar
body (hidden while Settings/Tools body shows); `mobileHosted` mode on
AppSidebar/SectionSidebar; 220 ms close hold preserved.
- D3: `pendingInteraction` prop on FollowUpPromptBox keeps the editor
shell mounted and hidden, interaction as last stack item, footer pickers
read-only.
- D5 (reverted, see below): static 48 px compact row on compact + coarse
pointer; editor realizes after paint (idle/timeout, transition) or at
first tap (pointerdown mounts under an overlay, click focuses via
`focusEndForTap`); Stop/voice/drafted submit work from the row; #1771
handoff untouched.
- J3: prune once per page load from idle, lastUsedAt checked before
schema parse, no-op storage writes skipped.
- J4: `HEAVY_PAYLOAD_QUERY_POLICY` (60 s gc) on turn-summary details and
file previews; diff patches use a reader lease with a 60 s post-unmount
eviction (observer-less entries no longer gc while shown).
- I6: bundled GitHub glyph + theme-token status dot; logo via the shared
icon.
- B28: composer renders immediately with a loading project picker;
projectId-keyed queries gate on the settled bootstrap.

## How you verified

- `pnpm exec turbo run typecheck --filter=@bb/app`: pass.
- `pnpm exec turbo run lint --filter=@bb/app`: 0 errors (147
pre-existing warnings, unchanged count).
- `pnpm exec turbo run test --filter=@bb/app --force`: 364 files, 2906
passed, 3 skipped (one registry boundary test fixed in the last commit
and re-run green).
- New/updated tests: compact-long-press-menu.test.tsx,
useSidebarReorderDnd.test.tsx (sensor install/remove), sidebar.test.tsx
(passive vs non-passive registration), AppLayoutSidebar.test.tsx (single
panel + single mount across app -> settings -> tools -> app),
FollowUpPromptBox.test.tsx (editor DOM identity across pending
interaction; deferred compact editor lifecycle),
ThreadDetailPromptArea.test.tsx (composer retained + stack ordering),
fixed-panel-tabs-sync.test.ts (no rewrite, prune decisions),
use-environment-diff-patches.test.tsx (retention lease),
PluginNewThreadComposer.test.tsx (root composer before settle, gated
queries).

Fixes: mobile perf sweep findings E1, E6, E7, E10, D3, D5 (reverted, see
below), J3, J4, I6, B28.

## Update (2026-08-19)

The deferred compact follow-up editor (D5: static stand-in row +
pointerdown/click focus handoff) was removed from this PR after a device
test on iPhone showed the caret rendering above the composer after the
first tap and a ~11 px footer shift when the real editor replaced the
stand-in. The compact composer keeps the previously verified
always-mounted behavior (#1263, #1381, #1771). D5 stays open as a
follow-up once it can be verified on iOS.

Fixes: part of the mobile / iOS Safari performance program (verified
sweep report in the bb thread; no single issue).


## Stack context

Layer 21 of 22 in the `bb/mobile-perf/*` stack (bottom → top: quick wins
first, big rocks last).
- Prerequisite (layer below):
`bb/mobile-perf/markdown-streaming-and-containment` (#1899).
- Next layer: `bb/mobile-perf/diff-and-file-preview` (#1901).
- Audit findings addressed: see title IDs. Review: approved-with-fixes;
5 review fix commit(s).
- Deliberately not done here: D5: reverted after an iPhone test showed a
mispositioned caret and a footer shift; needs a device-verified handoff
before it returns
- Reviewer notes / follow-ups: Device/iOS Simulator verification still
needed for: D5 tap handoff (pointerdown-cancel + click focus with real
TipTap; jsdom mocks PromptBoxInternal), E7 deep-content passive swipe |
E1: ThreadActionsContextMenu/ProjectActionsContextMenu now branch on
useIsCompactViewport, so crossing the compact breakpoint (tablet
rotation, window resize) remounts every row's | J4: diff patches now
refetch after >60 s away from a thread; turn-summary details/file
previews gc after 60 s without observers (by design per audit).
- Wire/contract: None. No server/daemon wire, protocol, CLI, plugin API,
or DB changes; HOST_DAEMON_PROTOCOL_VERSION untouched. All changes are
in apps/app.

> AGENT GENERATED: by Claude Code (claude-mangosteen-eap)

---------

Co-authored-by: Claude <[email protected]>
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.

2 participants