Skip to content

Fix lost first tap on mobile follow-up submit - #1771

Merged
SawyerHood merged 1 commit into
get-bb:mainfrom
jshph:fix-mobile-submit-focus-race
Aug 18, 2026
Merged

SawyerHood merged 1 commit into
get-bb:mainfrom
jshph:fix-mobile-submit-focus-race

Conversation

@jshph

@jshph jshph commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

User-facing problem

On iPhone, submitting a follow-up can feel like the button ignored the first tap:

  1. The user taps Submit.
  2. The keyboard closes and the composer shrinks.
  3. The message remains unsent.
  4. The user has to tap Submit again.

This is especially confusing because it resembles network lag, even though the first submission never actually committed.

What this changes

The submit button now checks which DOM element the browser actually considers focused instead of relying on TipTap's event-derived focus flag.

During the brief iOS focus transition where those states can disagree, bb keeps the editor and keyboard stable long enough for the first tap to produce its click. After submission commits, the existing keyboard dismissal and compact-composer behavior continue normally.

The change is intentionally narrow: genuine focus outside the editor behaves as before, and desktop submission behavior is unchanged.

Verification

  • Added a regression test that models stale TipTap focus while the contenteditable still owns native focus.
  • All 98 PromptBoxInternal tests pass.
  • Turbo app typecheck passes.
  • Prettier and git diff checks pass.

AGENT GENERATED: by GPT-5

@SawyerHood
SawyerHood merged commit a17ef4c into get-bb:main Aug 18, 2026
9 checks passed
@SawyerHood

Copy link
Copy Markdown
Collaborator

Ty for this fix!

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