Skip to content

Open the selection menu below touch selections on Android - #6567

Merged
ymichael merged 1 commit into
mainfrom
fix/android-selection-menu-6132
Oct 29, 2026
Merged

ymichael merged 1 commit into
mainfrom
fix/android-selection-menu-6132

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

On a touch selection, the timeline selection menu ("Add to chat", side chat, plugin actions) had no pointer anchor, so TimelineSelectionMenu fell back to side="top" and placed it just above the selected line. Android always opens its native selection toolbar (Copy / Share / Select all / Web search) above the selection too, and a web page cannot move or hide it. The native toolbar covered BB's menu, so on Android Chrome, the PWA and the Android app the BB actions could not be reached. Reported in #6132, with a second report in the comments.

What changed

  • SelectableMessageProse.tsx: when the last pointer down was touch or pen, the reported selection now carries a bottom anchor placed under the last selected line, plus TOUCH_SELECTION_HANDLE_CLEARANCE_PX (24px) so the menu clears Android's teardrop selection handles. Mouse and keyboard selections are unchanged.
  • iOS WebKit (Safari and the bb iOS app, detected with the existing isIOSWebKit) keeps the previous top anchor. In iOS Simulator Safari the edit menu opens below selections in roughly the upper half of the screen, so moving BB's menu below on iOS would collide there. iOS opens its menu above selections lower on the screen, so those still overlap on iOS, as on main. This PR does not fix that case.
  • This follows the issue comment's option 1 (open below on touch), restricted to non-iOS. The bottom-pinned bar (option 2) and the menu width cap the comment mentions are not included.

How you verified

  • New test in SelectableMessageProse.events.test.tsx: a two-line touch selection is anchored below its last line with the handle clearance, and a later mouse press goes back to the unanchored default. It fails without the change. A second test checks that iOS touch selections keep the default anchor. The coarse-pointer test in TimelineSelectionMenu.test.tsx now asserts the bottom side for touch-anchored selections.
  • pnpm exec turbo run test --filter=@bb/app -- src/components/thread/timeline/SelectableMessageProse src/components/thread/timeline/TimelineSelectionMenu: 117 passed. turbo run typecheck lint --filter=@bb/app is clean; oxfmt is clean.
  • Android emulator (Pixel 9, API 36, Chrome), with a real long-press via adb. On main, BB's menu sits under Android's toolbar with only its lower edge visible, matching the issue screenshot. With this change, on a Ladle story and on a real thread served by pnpm start:worktree, BB's menu sits below the handles at both upper and lower positions. Tapping "Add to chat" delivered the selected text.
  • iOS Simulator (iPhone 17 Pro, iOS 26.5 Safari), long-press via Maestro: the result is the same as on main. Selections at 44% and 51% of the screen height are clear; at 57% and 62% iOS's menu covers BB's, on main and on this branch.

Fixes #6132

AGENT GENERATED

🤖 Generated with Claude Code

On Android, long-pressing text in an assistant reply opens the native
selection toolbar above the selection, exactly where BB's "Add to chat"
and side-chat menu was anchored, so BB's actions were hidden and
unreachable. Touch selections now anchor the menu below the last
selected line, clear of the selection handles.

iOS Safari opens its edit menu below a long-press selection, so iOS
WebKit keeps the menu above the selection as before.

Fixes #6132

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 12d54aa into main Oct 29, 2026
30 checks passed
@ymichael
ymichael deleted the fix/android-selection-menu-6132 branch October 29, 2026 17:56
ymichael added a commit that referenced this pull request Nov 3, 2026
## Human comments

## What was wrong

`@bb/app` had grown to 657 test files and 6,809 tests. Many tests
checked a contract that another test already covered more strongly.
Others only exercised wiring, tested a third-party library, or held
assertions that could not fail. A few production `export`s and one
parameter existed only for these tests. This made the suite slower to
run and maintain without catching any extra bugs.

## What changed

Test files only, apart from removing test-only exports. Net −1,077 test
lines across 58 files (+290 / −1,367), four whole files deleted, and
6,809 → 6,750 tests. Production changes are +8 / −11 across 7 files,
with no behaviour change.

**Removed**
- **Duplicates:** the raw-thread-id title tests that #5261 copied into
`ThreadTitleMentions.resources.test.ts` but never removed from the
original. Also sibling tests repeating the same setup and assertion, and
mocked copies of scenarios that already run through the real code:
`composer-submissions`, `app-toast-title-overflow`, OnboardingGate,
AddMachineDialog expiry, ToolsView banners, provider-icon, plugin-slots,
the cache-owner rename, pin acknowledgement, the CommandPalette settings
page, QuestionForm, and the PromptBox/composer-contract rejection.
- **Wiring and constant pins:** small helpers tested directly when their
only caller is tested (`resolveUrlOpenTarget`, `parseLifecycleError`,
`buildAudioInputConstraints`, `resolvePaneArrangementLabel`); realtime
registry rows that `satisfies Record<…>` already enforces at typecheck;
a snapshot-identity check covered by a stricter structural-sharing test.
- **Third-party only:** `src/test/virtualizer-scroll-lifecycle.test.tsx`
tested `@tanstack/virtual-core` and guarded a repo patch that #5951
removed. Upstream now cancels the timer itself.
- **Vacuous:** a lifecycle-error row varying `hasPath`, which no code
reads; BrowserTabDeck rows that pass either way; a FollowUpPromptBox
placeholder test whose two placeholders were the same string; a dead
`vi.mock` of a module the code under test never imports.
- **Test-only production seams:** dropped `export` from
`buildAudioInputConstraints`, `buildDevWebSocketUrl`,
`resolveUrlOpenTarget`, `parseLifecycleError`, `threadTitleTextSegments`
and `resolvePaneArrangementLabel`. Removed
`getSecondaryPanelChromeStackClassName`'s `hasGitDiffToolbar` parameter;
its only caller passed `false`.

**Repaired** (assertions that could not fail)
- `plugin-bound-sdk`: the test promised cache updates but only checked
call shape. It now asserts that a created section reaches the sidebar
cache before `create` resolves. That behaviour (#5045) had no test
before.
- `split-layout/ops`: `if (root.type === "split")` guards could skip
every resize-clamp assertion; they now throw on a non-split root.
- `provider-icon`: `toBeDefined()` on a non-optional return replaced
with real `ariaLabel` checks.
- `use-composers`: the test named "lock or paint" now also exercises
`setTextEffect`.
- `ThreadMetadataContent`: `path: null` let the "provisioning" test pass
without its status check.
- Terminal UTF-8 split glyph: this tested the browser's `TextDecoder`.
It now writes through `writeTerminalOutput` into a real xterm.
- Early `focusEnd`, the voice transition while hidden or under reduced
motion, and the model-picker cycle-chord exception could all pass with
the guarded code removed. They now fail when it is.
- `dev-websocket-url` now goes through `buildBrowserWebSocketUrl`, which
also covers the production fallback URL.

## How you verified

- **Mutation checks.** Three independent reviewers worked on dedicated
worktrees of `main` and of this branch. For every removed or merged
test, they wrote the bug it caught as a mutation of the production code.
They confirmed the old test fails on `main` and that a remaining test
fails on this branch, then restored the source.
- About 110 mutations were run. 18 removals turned out to be the only
guard on their contract; 16 of those were restored.
- The most important restoration: a known raw thread id must display as
its title through the synchronous `resolveThreadTitleDisplayText`. The
rendered pills hide this bug, but the AppLayout title, archived-threads
settings and the parent-thread picker show it.
- Other restorations: the Meta+Enter `aria-keyshortcuts` label,
QueuedMessagesList open/close reporting and overflow toggling, older
touch actions at the former width threshold, the touch-selection menu
side (#6567), the terminal-view unmount, the plugin update-action icon,
the marketplace icon in AddPluginDialog, the ReuseEnvironmentPicker
secondary text, the app chrome row-height token, the focused
notification on title Show more, the mapper's unread-error indicator,
the `useThreadStorageLocation` fetch, the thread invalidation `maxWait`
bounds, and the sidebar info-tab id.
- Two gaps were left out on purpose: the `hasPath` lifecycle row (no
code reads `hasPath`) and a single `shrink-0` class pin.
- Each repaired assertion was shown to fail under a mutation that the
old assertion let through.
- **Baseline** at 51d8ddc: `pnpm exec turbo run test
--filter=@bb/app` ran 6,809 tests, with 6 failures at machine load ~89.
All six pass when run alone or at normal load.
- **After rebasing onto origin/main:** `pnpm exec turbo run lint
typecheck test --filter=@bb/app` gave 0 lint errors, a clean typecheck,
and 6,740 of 6,750 tests passing (9 skipped).
- The one failure, `CommandPalette` "runs an available shortcut … after
closing and restoring focus", timed out opening the palette at load ~79.
It failed the same way in the baseline run on `main`.
  - It passes in five isolated reruns, two of them uncached (`--force`).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

Co-authored-by: Claude Opus 5.5 <[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.

Android text-selection menu obscures BB reply and side-chat actions

1 participant