Skip to content

Prevent text selection in app chrome and non-content controls - #1428

Closed
ariofrio wants to merge 16 commits into
get-bb:mainfrom
ariofrio:bb/fix-cmd-a-app-wide-text-selection-thr_n3m9kkh45r
Closed

ariofrio wants to merge 16 commits into
get-bb:mainfrom
ariofrio:bb/fix-cmd-a-app-wide-text-selection-thr_n3m9kkh45r

Conversation

@ariofrio

@ariofrio ariofrio commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What was wrong

Blink treated text throughout the application shell as document content because bb had no shell-level user-select policy. Dragging across navigation, controls, or empty layout surfaces selected interface labels, while native Select All could span the main conversation, side chats, and the composer. A blanket user-select: none was insufficient: useful reading surfaces and editors needed explicit selection behavior. Electron's native Edit ▸ Select All role also preempted the renderer's scoped behavior. See #1440.

What changed

  • Default the bb application shell to non-selectable UI while keeping editors and intentional .select-text reading surfaces statically selectable.
  • Route Cmd/Ctrl-A through one root AppSelectAllController. Editors keep native handling; non-editing controls retain their nearest reading scope; app chrome is suppressed; and a reading surface participates only when it explicitly declares data-select-all-scope.
  • Replace Electron's native selectAll role with a desktop command that routes application windows through the renderer controller and falls back to native webContents.selectAll() for browser views and DevTools.
  • Keep drag selection and Select All scopes as separate concepts. Generic .select-text utilities and portal infrastructure do not silently acquire keyboard behavior.
  • Declare scopes at actual content surfaces, including conversations, file previews, diffs, terminal/tool/system output, plugin panels, metadata, queued drafts, crash details, setup diagnostics, and displayed commands.
  • Keep every keyboard selection within one browser-representable DOM root. Pierre file and diff viewers have their own shadow-content scopes; light-DOM notices and footers have separate scopes; light-DOM padding around a shadow-only viewer still resolves to the viewer's shadow root.
  • Split reading ranges at inline editors so selecting surrounding conversation text cannot include an unsent draft.
  • Track only in-memory scope/root/anchor references. Pointer and focus tracking no longer injects styles or attributes into open shadow roots, and the composed walk is linear rather than repeatedly scanning ancestors.
  • Keep the controller above AppErrorBoundary, so crash details retain the same behavior after the application subtree is replaced.

How you verified

The regression assertions were added during TDD and observed failing before their corresponding implementation changes.

  • Focused selection and surface suites: 67 app tests and 12 desktop tests passed.
  • Full @bb/app suite: 408 files passed; 3,132 tests passed and 3 skipped.
  • Full @bb/desktop suite: 34 files and 221 tests passed, including the package-compatible preload build in hidden Electron.
  • Full @bb/desktop-contract suite: 3 files and 19 tests passed.
  • pnpm exec turbo run typecheck --filter=@bb/app --filter=@bb/desktop --filter=@bb/desktop-contract --force passed.
  • pnpm exec turbo run lint --filter=@bb/app --force passed with 0 errors and 145 pre-existing warnings.
  • pnpm exec turbo run build --filter=@bb/app --filter=@bb/desktop --force passed.
  • A hidden Chromium probe against the bundled production selection helper verified that each reading segment excludes an intervening contenteditable draft, light-DOM padding resolves to a shadow-only viewer, the viewer's complete text is selected, and interaction leaves shadow markup unchanged. The probe used no OS-level keystrokes or clipboard changes.

Fixes #1440

Written by Codex

AGENT GENERATED: by GPT-5 Codex

@ariofrio
ariofrio force-pushed the bb/fix-cmd-a-app-wide-text-selection-thr_n3m9kkh45r branch from f5912a1 to 58e9e5e Compare August 12, 2026 22:46
@bb-slop-cop

bb-slop-cop Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I am SlopCop. I started a security, code quality, performance, architecture, and end-to-end review of this pull request.

Comment thread apps/app/src/views/PluginPanelView.tsx Resolved
Comment thread apps/app/src/app.css Resolved

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚨 SLOP COP 🚨 · review

ELI5

This PR stops accidental text selection across app controls. It restores selection for important content.

The basic idea works. However, some user text becomes unselectable, while some button labels remain selectable.

Findings

  • [P2] Some user content loses selection. The new shell rule requires every content surface to opt in. Queued drafts, approval details, and plan file paths do not opt in. Users could select this text before the change. They cannot select it after this change.
  • [P2] Some opt-in boundaries include controls. The plugin panel boundary includes all plugin controls. Diff and tool-detail boundaries also include buttons. Select All and drag selection therefore capture control labels with document content.

I left inline comments at the exact policy and component lines.

Architecture

The component-by-component select-text additions create two inverse failure modes. A developer can omit a content surface or include a complete control surface.

Use a shared selectable-content boundary with one nested-control policy. Add tests that distinguish selectable content from non-selectable controls.

Security and performance

The security review found no security or privacy problem. The performance review found no material selector or rendering problem.

Validation

  • @bb/app typecheck passed.
  • The full @bb/app suite passed with 340 files and 2,564 tests.
  • The PR dev app loaded without browser errors.
  • The shell computed to user-select: none.
  • The prompt editor computed to user-select: text.
  • A panel probe confirmed that a selectable parent also selects its button label.

I submitted a comment review. I did not approve the PR or request changes.

@ariofrio ariofrio changed the title Fix app-wide text selection Prevent text selection in app chrome and controls Aug 14, 2026
@ariofrio ariofrio changed the title Prevent text selection in app chrome and controls Prevent text selection in app chrome and non-content controls Aug 14, 2026
@ariofrio
ariofrio force-pushed the bb/fix-cmd-a-app-wide-text-selection-thr_n3m9kkh45r branch 2 times, most recently from 65e7f0e to 726c28d Compare August 19, 2026 03:32
@ariofrio
ariofrio marked this pull request as draft August 19, 2026 03:55
@ariofrio

ariofrio commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Marking as draft to address bugs found in #1440 (comment).

@ariofrio
ariofrio force-pushed the bb/fix-cmd-a-app-wide-text-selection-thr_n3m9kkh45r branch from 726c28d to 082f824 Compare August 19, 2026 04:49
@ariofrio

ariofrio commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor Author

@SawyerHood The draft PR is rebased onto current upstream/main, the report findings are addressed, and the final repo-native regression coverage is on head 84a9efde1. Please request a fresh Slop Cop review from the configured operator environment using the documented two-step flow:

bb slopcop check review 1428
bb slopcop dispatch review 1428

The local dev server attached to this checkout does not expose the slopcop command. A GitHub mention of @bb-slop-cop is not the review trigger.

Written by Codex

@ariofrio
ariofrio marked this pull request as ready for review August 19, 2026 05:39
@bb-slop-cop

bb-slop-cop Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I am SlopCop. I started a security, code quality, performance, architecture, and end-to-end review of this pull request.

const selection = window.getSelection();
if (selection === null) return;
const range = document.createRange();
range.selectNodeContents(activeRegion);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚨 slopcop/review — [P1] Include shadow-root text in Select All

Cmd/Ctrl-A builds a light-DOM range around the active region. Pierre renders diff and file-preview text inside open shadow roots.

The range cannot enter those roots. The copy result therefore omits the visible code. An isolated Chromium probe confirmed this result.

Remove the synthetic range, or build a composed-tree selection. Add a Chromium test that checks selected and copied Pierre text.

return (
<div
className="-m-4 flex min-h-0 flex-1 flex-col overflow-hidden md:-m-5"
className="-m-4 flex min-h-0 flex-1 select-text flex-col overflow-hidden md:-m-5"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚨 slopcop/review — [P1] Extend the selection boundary to plugin portals

This class affects only the plugin panel ancestor. Shared dialogs, popovers, and drawers move their content under document.body.

The portal props restore the plugin CSS scope, but they do not restore the selection scope. A portal click finds no selectable region.

Plugin dialog text therefore remains user-select: none. Add a selection boundary to each plugin portal root. Add a Chromium portal test.

Error details
</summary>
<pre className="mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md border border-border p-3 text-xs">
<pre className="mt-2 max-h-48 select-text overflow-auto whitespace-pre-wrap break-words rounded-md border border-border p-3 text-xs">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚨 slopcop/review — [P2] Keep the selection tracker alive on the crash screen

AppErrorBoundary replaces AppLayout after a crash. AppLayout owns the only selection tracking hook.

This new class needs that hook to add data-selection-active. The hook no longer exists in the fallback.

The stack trace remains unselectable, although the page asks users to send it. Move the tracker above the error boundary.

Comment thread apps/app/src/app.css Outdated
user-select: none !important;
}

body.bb-app-shell [data-selectable-content-region][data-selection-active],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚨 slopcop/review — [P2] Avoid a full-history style update on region changes

Changing data-selection-active changes every descendant .select-text rule. The body:has() rule also changes editor styles across the document.

The timeline keeps all loaded rows in the DOM. An isolated Chromium probe measured 24 ms at 1,000 simple messages and 35 ms at 1,500.

Real timeline rows contain more elements. Keep the selection CSS static. Use dynamic state only for the Select All boundary.

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚨 SLOP COP 🚨 · review

Plain English summary

This PR stops accidental text selection on navigation and controls. It restores selection for messages, previews, logs, editors, and other content.

It also limits Select All to the content area that the user last touched. The main idea works, but four edge cases need fixes.

Findings

  • [P1] Select All omits visible diff and file-preview code. The new range selects only light DOM. Pierre stores this code in shadow roots.
  • [P1] Plugin portals lose their selection boundary. Dialogs and popovers move outside the selectable plugin panel ancestor.
  • [P2] Crash details remain unselectable. The error fallback removes the layout that owns the selection tracker.
  • [P2] Region activation scales with the loaded timeline. The dynamic selectors update all loaded selectable descendants.

I left inline comments on each changed line.

Architecture

The policy uses manual select-text classes. It also duplicates control selectors in CSS and TypeScript.

A shared selection-region abstraction should own active state, portal scope, and shadow-root behavior. This will reduce omissions and policy drift.

Security and performance

I found no security or privacy defect. The performance probe found a frame-time regression on large simple timelines.

Validation

  • All GitHub CI checks passed at the reviewed head.
  • An isolated Chromium harness passed gutter drag, multi-message drag, editor, sidebar, control, and ordinary Select All cases.
  • Edge probes confirmed shadow-root omission, portal boundary loss, and the inactive crash fallback.
  • A simple Chromium probe measured 24 ms at 1,000 messages and 35 ms at 1,500 messages.
  • I did not execute the fork code or start its development server.
  • GitHub currently reports a merge conflict with the base branch.

I submitted a comment review only. I did not approve the PR or request changes through GitHub.

@SawyerHood
SawyerHood force-pushed the bb/fix-cmd-a-app-wide-text-selection-thr_n3m9kkh45r branch from 84a9efd to 5ac455e Compare August 19, 2026 21:07
@ariofrio
ariofrio force-pushed the bb/fix-cmd-a-app-wide-text-selection-thr_n3m9kkh45r branch from 5ac455e to 702c5b0 Compare August 19, 2026 21:33
@ariofrio
ariofrio marked this pull request as draft August 19, 2026 23:48
@ariofrio
ariofrio force-pushed the bb/fix-cmd-a-app-wide-text-selection-thr_n3m9kkh45r branch 3 times, most recently from f01de0d to 11be827 Compare August 20, 2026 06:12
@ariofrio
ariofrio force-pushed the bb/fix-cmd-a-app-wide-text-selection-thr_n3m9kkh45r branch from 11be827 to f1f8483 Compare August 20, 2026 08:54
SawyerHood added a commit that referenced this pull request Aug 21, 2026
## What was wrong

The app set no `user-select` policy, so every element kept the browser
default (`auto`). Sidebar labels, the page header, the composer toolbar
and footer, and the visually hidden "Toggle Sidebar" label all joined
mouse-drag selections and Select All alongside the conversation. On
main, clicking empty sidebar space and pressing Ctrl-A selects `New
thread … Extensions … Automations … Settings … Report a bug … Project:
qa … Toggle Sidebar`, and a drag across the sidebar highlights its
labels. Issue: #1440. Report:
https://get-bb.github.io/reports/issues/1440.html

## What changed

App chrome regions opt out of selection with `select-none`; content
keeps the browser default.

- `apps/app/src/components/ui/sidebar.tsx`: both sidebar panels (desktop
and compact drawer) and `SidebarTrigger`.
- `apps/app/src/components/layout/AppPageHeader.tsx`: the `<header>`
element.
- `apps/app/src/components/secondary-panel/ThreadSecondaryPanel.tsx`:
the right panel's top chrome stack (tab toolbar and diff toolbar).
- `apps/app/src/components/promptbox/PromptBoxInternal.tsx`,
`FollowUpPromptBox.tsx`, `NewThreadPromptBox.tsx`: the composer action
row and the footer strips below the prompt box. The editor and the
banners above it are untouched.
- `apps/app/src/app.css`: `.select-none :where(input, textarea,
[contenteditable])` gets `user-select: text`. `auto` resolves from the
parent, and WebKit carries a parent's `none` into editable controls;
this keeps the sidebar thread search and the inline thread-title rename
selectable.

Why opt out of chrome instead of `body { user-select: none }` plus
content opt-ins (the approach in #1428): in Blink a drag that starts on
a `user-select: none` element never begins a selection, so marking only
the chrome leaves gutter drags, multi-message drags, diagnostics (Info
panel, settings, toasts, dialogs) and plugin panels exactly as they
behave today. A shell-wide `none` needs every content surface to opt in,
and each missed surface becomes uncopyable text. The report measured two
such regressions in #1428 (gutter drag selects nothing; Ctrl-A
highlights the thread but Ctrl-C copies nothing); #1428 has since grown
to 115 files including an Electron menu rewrite and a renderer Select
All controller, and conflicts with main. This PR covers the issue's
title and its first three acceptance criteria with a class on each
chrome root.

Not changed: Select All is not scoped to the last-touched pane (a later
criterion added to the issue by #1428); Ctrl-A from the sidebar still
selects the conversation text, without any chrome. Timeline status rows
("Worked for 7s", "Working...") remain selectable as part of the
conversation.

No wire, CLI or plugin API change.

## How you verified

New tests, run against origin/main sources (`git checkout origin/main --
<7 source files>`) fail, and pass on this branch:

- `apps/app/src/components/layout/app-chrome-selection.test.tsx` (4
tests): sidebar panel, drawer, trigger, header, right-panel chrome carry
`select-none`; app.css restores selection on editable controls. Before:
`AssertionError: expected false to be true`, `expected 'shrink-0
bg-sidebar' to contain 'select-none'`.
- `FollowUpPromptBox.test.tsx` "keeps the status footer out of text
selection" and `PromptBoxInternal.test.tsx` "keeps the action row out of
text selection while the editor stays selectable". Before:
`AssertionError: expected false to be true`.

Commands on the committed tree (`git status --porcelain` empty):

- `pnpm exec turbo run typecheck --filter=@bb/app` → `Tasks: 3
successful, 3 total`
- `pnpm exec turbo run test --filter=@bb/app` → `Tasks: 4 successful, 4
total` (410 test files passed)

Manual check in headless Chromium 145 (Puppeteer via doobie) against my
dev instance, thread with one user message and one reply, same gestures
as the report's probes:

| gesture | main | this branch |
| --- | --- | --- |
| click empty sidebar, Ctrl-A | 308 chars incl. `New thread … Toggle
Sidebar` | 128 chars, conversation only |
| drag from empty sidebar over labels | `Settings\nRemote access\nReport
a bug…` | nothing selected |
| drag across composer footer (`Project: qa …`) |
`Project:\nqa\nEnvironment:…` | nothing selected |
| drag across header title | `Selection QA` | nothing selected |
| drag from gutter 200 px left of a message into it | `Run the shell
command: echo hello-144` | same |
| click message, Ctrl-A, Ctrl-C, paste into editor | whole page incl.
chrome | conversation text only (128 chars) |
| Ctrl-A inside the editor with a draft | draft only | draft only |

Computed `user-select`: body `auto`, sidebar label `none`, message
`auto`, Info panel directory value `auto`. Before/after screenshots of
Ctrl-A from the sidebar are attached to the batch notes. Not verified in
Electron or WebKit (no macOS/iOS here); the WebKit restore rule follows
the documented `user-select` inheritance behavior.

Fixes #1440

> AGENT GENERATED: by Claude Opus 5


## Independent verification

Verified by a second agent on a fresh worktree (`git fetch origin
bb/fix-1440-chrome-user-select && git checkout -b verify-1440-r1
FETCH_HEAD`, head `b728ba309`, `origin/main` is an ancestor, GitHub
reports `MERGEABLE`).

Commands run:

- `pnpm install --frozen-lockfile --prefer-offline && pnpm exec turbo
run build` → `Tasks: 18 successful, 18 total`
- Fail-before: `git checkout origin/main -- apps/app/src/app.css
apps/app/src/components/layout/AppPageHeader.tsx
apps/app/src/components/promptbox/{FollowUpPromptBox,NewThreadPromptBox,PromptBoxInternal}.tsx
apps/app/src/components/secondary-panel/ThreadSecondaryPanel.tsx
apps/app/src/components/ui/sidebar.tsx`, then `pnpm exec vitest run
src/components/layout/app-chrome-selection.test.tsx
src/components/promptbox/FollowUpPromptBox.test.tsx
src/components/promptbox/PromptBoxInternal.test.tsx` in `apps/app` →
`Tests 6 failed | 130 passed (136)`; failing assertions:
`AssertionError: expected false to be true` (sidebar
panel/trigger/header, compact drawer, footer, action row), `expected
'shrink-0 bg-sidebar' to contain 'select-none'`, and the app.css rule
match being `undefined`.
- Pass-after: `git checkout HEAD -- <same files>` and the same vitest
command → `Tests 136 passed (136)`.
- `pnpm exec turbo run typecheck --filter=@bb/app` → `Tasks: 3
successful, 3 total`
- `pnpm exec turbo run test --filter=@bb/app --force` → `Tasks: 4
successful, 4 total` (410 test files, 3162 tests passed, 3 skipped)
- Built CSS check: `apps/app/dist/assets/index-*.css` contains
`.select-none
:where(input,textarea,[contenteditable]:not([contenteditable=false])){-webkit-user-select:text;user-select:text}`,
so the WebKit prefix is emitted.

Repro on the fixed branch (headless Chromium 145 via doobie, own dev
instance, codex thread with one message + reply), same gestures run
against origin/main sources and this branch by swapping the 7 source
files under Vite HMR:

| gesture | origin/main sources | this branch |
| --- | --- | --- |
| click empty sidebar, Ctrl-A | 300 chars incl. `New thread … Settings …
Report a bug … Project: qa … Toggle Sidebar` | 128 chars, conversation
only |
| drag from empty sidebar up over labels | 221 chars (`Settings\nRemote
access\nReport a bug…`) | nothing (`type: None`) |
| drag across composer footer | `Project:\nqa\nEnvironment:\nWorking
locally\n\nmain\n` | nothing |
| drag from gutter 150 px left of a message into it | `Run the shell
command: echo hello-1440. Then reply` | same text |
| click message, Ctrl-A, Ctrl-C, paste into editor | whole page incl.
chrome (308 chars) | conversation only (128 chars) |
| type a draft in the editor, Ctrl-A | — | `draft xyz 1440` only,
anchor/focus inside the editor |
| sidebar thread search input (computed `user-select`) | — | `text`;
Ctrl-A and mouse drag select inside the input |
| header inline title rename input (computed `user-select`) | — | `text`
under a `none` header; Ctrl-A, drag (`Selec`) and Shift+End all work |

Computed `user-select` on this branch: body `auto`, sidebar panel
`none`, header `none`, composer footer `none`, action row `none`, editor
`auto`.

CI: all checks green on `b728ba309` (Checks, Tests app-1/2/3,
integration, packages, server, Package Smoke ubuntu/macos, version
checks).

Residual risks: the thread title in the page header is now copyable only
through the double-click rename input, not by dragging the label;
timeline status rows ("Worked for 7s", "Working...") and dialog/settings
labels keep the browser default; Select All is not scoped to the
interacted pane and the Electron Edit menu is untouched (later
acceptance criteria on the issue, out of scope here); Electron and
WebKit/iOS were not exercised (Linux host), the WebKit path relies on
the prefixed rule in the built CSS.

> AGENT GENERATED: by Claude Opus 5

Co-authored-by: Claude <[email protected]>
@ymichael

Copy link
Copy Markdown
Collaborator

superseded by #2171

@ymichael ymichael closed this Aug 21, 2026
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.

Prevent app chrome from being included in text selection

2 participants