Skip to content

Browser Context: element and region annotations with inspectable selection mentions #1844

Closed

Description

@brsbl

Consolidated browser-annotation scope

This is the canonical tracker for #1318's element/region annotation experience and the Browser Context implementation. Preserve click-to-select, rectangular drag selection, comments, multiple annotations per draft, compact composer/sent-message mentions, captured previews, and cancellation on navigation or tab closure.

The later Browser Context architecture below governs the payload contract: screenshots are preview-only. The older #1318 proposal to send screenshots to the agent is superseded. Agents receive bounded structured page context; page-derived metadata is untrusted input. Browser Context owns capture/selection behavior on the general Browser runtime and generic inspectable mentions.

Additional acceptance carried from #1318:

  • Element and rectangular-region captures preserve the intended target and page identity.
  • Multiple captures and comments survive submission and remain independently inspectable.
  • Cancelling selection, navigating, or closing a tab leaves no stale actionable target.
  • Verify the desktop embedded-browser workflow; browser clients without the desktop bridge remain outside the initial scope.

The original prototype and screenshots remain available for interaction reference. They do not override the later payload contract or superseded-PR restrictions below. Consolidation is a tracking change, not a claim that the implementation is merged.

Summary

Browser Context provides a durable selection-and-comment workflow built on the general Browser-page runtime and BB's generic mention/composer primitives. Core does not own a Browser-specific selection schema, capture controller, or mention lifecycle.

Canonical plugin workflow

  1. Browser Context registers two Browser toolbar actions: page selection and explicit agent-control mode.
  2. Its reusable page-script library runs click/drag selection and annotation inside the exact Browser target through the general runtime.
  3. Each completed selection becomes one stable plugin mention in the existing composer; submitted comments remain ordinary editable text adjacent to it.
  4. The mention independently reopens a host inspector showing the immutable capture screenshot and comments.
  5. At send time, the provider resolves the immutable bounded DOM, React, accessibility, and geometry snapshot into hidden agent context.
  6. Screenshots are preview-only and are never added to the prompt or sent to the agent.
  7. Removing one mention does not remove its comment or any other reference.
  8. Agent-control state and notifications bind to clientId + windowId + tabId + navigationEpoch; navigation invalidates stale state.

The plugin owns the deterministic selection schema, locators, metadata formatting, preview content, comments, and reusable selection controller. It uses ordinary registerMentionProvider and composer.insertMention behavior plus the generic optional inspector hook.

Current implementation

  • Core runtime foundation: PR #1869 at 7b27bdec8ac5dc3966c1a49a6be654635fd77a02
  • Generic inspectable mentions: PR #1870 at 9a6617ec517d2fa4b021b06f08326b36593765bd
  • Native core stack: #1871
  • Replacement consumer: bb-plugins PR #72 at c6060ba54624a5da86679eba137d382903bee194

Old bb-plugins PRs #31/#30 and core PRs #1642/#1643 are superseded and must not be merged as-is.

Boundaries

  • No Browser-specific inspection result contract in core.
  • No composer attachment or screenshot-to-prompt API.
  • No permission beyond the general Browser runtime and existing generic mention/composer capabilities.
  • Mention identity and capture snapshots are immutable; authored comment text remains editable.
  • Preview UI uses BB components and theme tokens, including opaque surfaces and bounded scrolling.
  • Only Browser Context opts into SDK 0.4.9; unrelated plugins keep their capability-based SDK floors.
  • The deferred frame-collision/P2 work is not part of this implementation.

Frozen consumer provenance

  • Core top source: 9a6617ec517d2fa4b021b06f08326b36593765bd
  • @get-bb/[email protected] SHA-256: 0c2023c099ea00a54066be9c9a0f701b6716336779cc0ff8ed05a6a9bedc5930
  • Matching bb plugin [email protected] SHA-256: 7df5ca65550708db87443e65f87780ab08694811ac74f3fdad53dfd91ab7ece3

Completion criteria

  • click and drag selection, comments, repeated captures, cancel, and independent mention removal work in the real Browser UI
  • composer and sent timeline pills reopen the inspector by pointer and keyboard
  • send-time hidden context supports deterministic targeting and excludes screenshots
  • agent-control user/agent entry, scoped notification, realtime reconciliation, navigation invalidation, and exit pass
  • focused plugin checks and real desktop visual QA pass at representative widths
  • the consumer records immutable core source SHA, SDK archive digest, and matching builder provenance

Do not close this issue until the revised objective is merged.

Originating implementation thread: thr_p9qmfkggwm

AGENT GENERATED

Activity

  1. added
    enhancement
    desktop
    ui
    plugins
    on Aug 18, 2026
  2. changed the title [-]Browser selections cannot become inspectable composer mentions[/-] [+]Browser Context needs durable inspectable selection mentions[/+] on Aug 19, 2026
  3. brsbl commented on Aug 19, 2026

    @brsbl
    CollaboratorAuthor

    2026-08-18 architecture decision: Browser Context owns selection, comments, deterministic capture metadata, and its reusable page-script library. Core supplies only the general Browser runtime (#1869) and provider-agnostic mention inspection (#1870). Screenshots stay preview-only; hidden context resolves at send time. Prior core #1642/#1643 and bb-plugins #31/#30 are superseded and remain unmerged.

  4. brsbl commented on Aug 19, 2026

    @brsbl
    CollaboratorAuthor

    2026-08-18 core dependency status: the replacement Browser core stack is frozen for the Browser Context consumer.

    • Runtime/broker foundation: #1869 at bf227d3c46e1ef6b0c3ed92279e45ba3f672db22.
    • Generic inspectable mentions: #1870 at 4162466dfdb6de58fc05a750ec23e36a7b8da56c.
    • Native stack: #1871; all required checks pass.
    • Consumer SDK provenance: @get-bb/[email protected], SHA-256 b44992cbf539aa54ac785b6aab2df57ad3eb2aa2fbe17f6755aaf5ebfe4cc11e, generated from top head 4162466dfdb6de58fc05a750ec23e36a7b8da56c. Matching builder SHA-256: 55d54d85924fd3d3fcdf6cee74fa847068a2577a77886a06733df9b1aa261a0f from that same source head.

    The remaining work in this issue is the plugin-owned selection/comment consumer and its replacement bb-plugins stack. The core PRs and this issue remain unmerged/open.

  5. brsbl commented on Aug 19, 2026

    @brsbl
    CollaboratorAuthor

    2026-08-19 dependency status: the frozen core sources for the replacement Browser Context consumer are PR #1869 at 50f60f0b9393de09143a1ac521e398b823c0511e and PR #1870 at 83adae80d6d8c414b83528e7f9b7993085f67a02; all GitHub checks pass. The generated @get-bb/[email protected] artifact from the exact top head has SHA-256 0ee05853466d9d31ddc9fec2cb9f2c3b09db80f695dcce7a5c596e9d7ce341f0; matching @bb/[email protected] has SHA-256 55d54d85924fd3d3fcdf6cee74fa847068a2577a77886a06733df9b1aa261a0f. The public contract is unchanged by the toolbar follow-up. No plugin consumer or merge action was taken here.

  6. brsbl commented on Aug 19, 2026

    @brsbl
    CollaboratorAuthor

    2026-08-19 consumer status: replacement Browser Context PR brsbl/bb-plugins#72 is published at e182e56c2f479515d83e768fd2d74ef7b3a47bbf against refreshed core heads #1869 7b27bdec8ac5dc3966c1a49a6be654635fd77a02 → #1870 9a6617ec517d2fa4b021b06f08326b36593765bd. Exact Electron QA passed scoped user/agent control, navigation invalidation, selection without activating the page control, sequential comments with a fresh composer, mention staging, tooltip, and inspector reopening. Browser Context checks are 41/41; screenshots remain preview-only. No merge performed.

  7. brsbl commented on Aug 19, 2026

    @brsbl
    CollaboratorAuthor

    2026-08-19 final consumer head: brsbl/bb-plugins#72 is now c6060ba54624a5da86679eba137d382903bee194. Install-ref rebuild validation now consumes the plugin-local 0.4.9 builder rather than falling back to the repository 0.4.8 default. Browser UI behavior and the frozen core contract are unchanged.

  8. changed the title [-]Browser Context needs durable inspectable selection mentions[/-] [+]Browser Context: element and region annotations with inspectable selection mentions[/+] on Sep 9, 2026
  9. owesazevedo commented on Sep 10, 2026

    @owesazevedo

    Prototype from a non-technical person (not a PR)

    I am not an engineer. I needed a way to point at a specific element on a page inside bb's in-app browser while briefing an agent ("change this heading", "this card is too tall"), and bb already felt like the right place because it is a pool of tools I can actually build on. I did this work entirely with AI agents. If anyone reviews the code, please treat it as an AI-generated prototype from someone who needed the workflow, not as a proposed architecture.

    I searched open and closed issues. This is the canonical tracker (#1318 folded here). I am not opening a pull request. CONTRIBUTING.md asks for issue alignment and Discord #contributors sign-off first, and the comments here already say a core inspection schema is the superseded path.

    What I was trying to do

    1. Open a site (or a local HTML preview) in the desktop in-app browser.
    2. Click one element.
    3. Have that target land in the composer as a small chip, with enough page context for the agent.
    4. Keep using bb as the place I design and brief from, instead of bouncing to an external inspector.

    Prototype (local fork, messy on purpose)

    What the branch actually does today:

    • Desktop toolbar action Pick element for chat: overlay on the tab's WebContentsView (isolated world), click to select, Escape / navigation / replace cancels.
    • Captures tag, a short CSS path, truncated outerHTML, a small set of computed styles, rect, and a cropped screenshot.
    • Composer chip @el:… plus a hidden HTML comment payload for the agent.
    • Related: privileged HTML file-preview origin (bb-preview://preview.localhost) so local HTML can run as a real page in that desktop view, which I needed before picking elements on workspace sites.
    • Also in the same branch, and not proposed for merge: packaged bb-dev isolation (separate data dir / ports) so I can run my fork next to official bb.

    Gaps versus this issue's acceptance

    I read the frozen Browser Context shape here and know my prototype is the old core-baked path:

    • Selection/schema/mentions live in core (desktop-contract, Electron, TipTap nodes), not in a Browser Context plugin.
    • Click-to-select only. No rectangular drag, no per-annotation comments, no multiple independent inspectable mentions.
    • Screenshot currently rides along in the payload; this issue says screenshots are preview-only and must not go to the agent.
    • No generic mention inspector, no agent-control mode, no bb browser CLI / SDK surface.

    Happy to throw the prototype away and follow the plugin + general Browser runtime design if that is still the intended path. I mainly wanted to show the workflow I could not complete in stock bb, and that bb is already good enough that a non-technical person could try to grow it.

    I will also post in Discord #contributors and wait for maintainer alignment before any PR.

    AGENT GENERATED

  10. timurkhakhalev commented on Sep 14, 2026

    @timurkhakhalev
    Contributor

    Browser Annotate plugin prototype and API alignment request

    I built Browser Annotate, a plugin for selecting page elements, writing comments in a trusted BB editor, and sending the comments with per-element context and screenshots to the current thread.

    Demo:

    default.browser-annotate-demo-upload.mp4

    The workflow

    1. Open a page in BB's desktop Browser.
    2. Start annotation mode from a button beside the address bar or a configurable keyboard shortcut.
    3. Select elements and save comments in BB's editor, outside the page's web contents.
    4. Send the batch to the current thread, then inspect the saved annotations from the sent message.

    Selection, annotation data, capture, persistence, and formatting remain plugin-owned. Page-derived text and screenshots are untrusted evidence; comments confirmed in the trusted editor supply user instructions.

    Proposed host support

    The local prototype uses three experimental additions:

    • app.slots.experimental_browserToolbarAction: a plugin action beside the Browser address bar, with the active thread, tab, and URL.
    • experimental_registerShortcut on that action's props: a host-owned registration for a specific combination, scoped to the owning window/tab and action lifetime. It works while the embedded page has focus and does not forward arbitrary page keystrokes. This overlaps the plugin-registration part of Embedded Browser focus prevents app and plugin keyboard shortcuts #3184; it is not a proposed fix for every app shortcut covered there.
    • experimental_images in mention-provider resolution: bounded image inputs accompanying the plugin's resolved text context.

    The image proposal differs from this issue's accepted preview-only policy. Our plugin sends per-element screenshots to the agent so it can use the selected element's visual appearance alongside DOM metadata. I am explicitly asking whether a generic, opt-in mention-provider image capability is acceptable; I am not treating that policy change as already agreed. Toolbar and shortcut support can be reviewed independently if image inputs remain out of scope.

    Prototype and verification

    The toolbar and mention-image implementation is published in PR #3623, at commit 0b1a8b5c6d326478e2c4318f9caeee72009e8310. That PR was automatically closed by the contributor approval gate; I am seeking alignment here before reopening it.

    The additional shortcut implementation is currently local and is not in that published commit or PR. We built and ran a packaged macOS arm64 BB from that commit plus the local shortcut changes. With a fresh Browser tab open to example.com and focus inside the page, the configured Cmd+. shortcut enabled annotation mode on the first press, without first clicking the Annotate button; a second press disabled it. The user also confirmed that it works. The demo above shows the annotation workflow, not this later shortcut verification.

    This is evidence from the patched local build, not a claim that these APIs are available in an official release or that the changes have been rebased and verified against today's main.

    Requested direction

    Would you accept these generic extension points for a plugin-owned annotation workflow? In particular, should I update #3623 with toolbar/shortcut support and discuss mention-image inputs separately, or would you prefer this plugin to target an existing/planned API from the Browser Context work?

    I searched the existing issues and am posting here because #1844 is the canonical annotation tracker, with #3184 tracking the related focus/shortcut boundary. Please also let me know whether I can be approved to update and reopen the PR once the API scope is agreed.

    AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    desktopenhancementpluginsui

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions