feat(browser-bridge): support --annotated with --frame - #271
Conversation
Remove the annotated_with_frame_unsupported error. The annotatedTextFn is self-contained and works identically when injected into a frame's document. Extract byteCapElements() helper to avoid duplicating the byte-cap loop across three paths (wake, standalone, frame). - service_worker.js: add annotated branch inside --frame path - protocol.js: extract byteCapElements() helper - Remove incompatibility notes from 6 doc files - Add 6 tests for byteCapElements 561 tests pass.
|
Reviewed while integration-testing this against five other open browser-bridge PRs. It merges clean with all of them and the merged tree is green (pytest 406/0; node 466 with only an unrelated intended failure from #277). Two things worth fixing before merge — the first I'd call blocking. 🔴
|
|
Heads-up: #278 just merged ( The conflictBoth PRs rewrite neighbouring rows in the ops table:
The resolution — take BOTH, one row eachKeep your
🔴 The byte gate is the trap here. Not a contradiction, in case it looks like oneAfter resolution the file says Still outstanding from my earlier reviewThe 🔴 |
# Conflicts: # scripts/browser-bridge/SKILL.md
…tated-in-frame The extension's service_worker.js and protocol.js changed but manifest.json stayed at 0.7.0, so `ping` reported 0.7.0 and `whoami`/`health` computed `extension_stale: false` whether or not the new build loaded — the exact tell that exists to catch a no-op brave://extensions reload was defeated for this change. Bump to 0.7.1 and update the two literal assertions that pin it (test_server.py; mutation-checked: reverting the manifest to 0.7.0 fails both with `assert '0.7.0' == '0.7.1'`). There is NO new wire op here, so `ping`'s `ops` list is byte-identical between builds and cannot discriminate. The discriminator is the capability itself, documented in extension/README.md: `--frame <id> text --annotated` errors `annotated_with_frame_unsupported` on 0.7.0 and returns `elements[]` on 0.7.1. Confirmed live against the deployed 0.7.0 build on the laptop host using the nested-OOPIF rig (top -> mid -> leaf, cross-origin): the plain frame read returns the leaf's text, the annotated frame read returns the old error. Also add two service_worker.test.mjs regression tests for the annotated+frame branch (injection targets the resolved frameId, reports the FRAME url, byte-cap applies). Both are RED at origin/main a0a5d73 with `annotated_with_frame_unsupported`, green at HEAD. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Correction: the "561 tests pass" figure was wrongFlagging this explicitly because the body has been edited and a reviewer may have read the original claim. The original body said "561 tests pass, 0 failures". That number is not reproducible and has been removed. Measured counts:
The 460 figure at Two counting gotchas worth recording, since they produce false numbers in this repo:
The 🔴 manifest finding is now addressed
Since there is no new wire op, and feeding the live 🔴 What is still unverified: the feature actually working in Brave. That needs a Also resolved here: the SKILL.md conflict with #278, using exactly the resolution posted above — this branch's |
What
Support
--annotatedwith--framefor thetextop. Previously this returnedannotated_with_frame_unsupported, butannotatedTextFnis self-contained and works identically when injected into a frame's document.Changes
annotated_with_frame_unsupportedthrow, add annotated branch inside the--framepathbyteCapElements()helper to deduplicate the byte-cap loop across 3 paths (wake, standalone, frame)test_server.pythat pin itextension/README.mdbyteCapElements, plus 2 regression tests inservice_worker.test.mjsfor the annotated-in-frame branchorigin/main(a0a5d73, fix(browser-bridge): nav/open --wake, fast ping, split routing errors, orientation telemetry, screenshot Read hint #278) — the SKILL.md ops-table conflict is resolved by taking this branch'stextrow and fix(browser-bridge): nav/open --wake, fast ping, split routing errors, orientation telemetry, screenshot Read hint #278'snav/wakerows. SKILL.md is 11,999 B vs the enforced 12,038 budget (39 B slack).Discriminator (why 0.7.1)
There is no new wire op, so
ping'sopslist is byte-identical between builds and cannot tell you which one Brave loaded. The version bump restores theextension_staletell, and the capability itself is the exact discriminator:Run it against a page that HAS an iframe — on a frameless page both builds fail identically with
frame_not_found.Verification
Live (laptop host
192.168.50.155, profilespersonal+work, deployed extension 0.7.0):Nested-OOPIF rig served on
127.0.0.1:8901,top.htmlopened +waked (neveractivate), tab closed after.frames→0(top) →4410(127.0.0.1.sslip.io/mid.html) →4411(127.0.0.1.nip.io/leaf.html), cross-origin, nested.Control
--frame 4411 text→"LEAF (site: 127.0.0.1.nip.io) — a GRANDCHILD OOPIF (nested inside mid)\n\nleaf-marker",url: http://127.0.0.1.nip.io:8901/leaf.html. The frame plumbing is sound.Discriminator, "before" reading
--frame 4411 text --annotated→annotated_with_frame_unsupported. This is the running 0.7.0 build, i.e. the error this PR removes is live and observable today.Staleness detection restored — fed the live
/healthversions into the server's ownannotate_staleness()(read-only, nothing deployed):🔴 NOT verified live: the feature working. The deployed extension is 0.7.0 and loading 0.7.1 needs a
home-manager switch+ an extension reload, neither of which was done here. Operator steps to complete it:home-manager switch→brave://extensions↻ →browser --instance <label> pingmust reportextensionVersion 0.7.1(if it still says0.7.0, the ↻ no-op'd — fully quit and reopen Brave) → re-run the discriminator above and expectelements[].Tests (measured on the merged tree, this branch @
325e73a):node --test --test-reporter=tap scripts/browser-bridge/tests/*.test.mjspython3 -m pytest scripts/browser-bridge/tests -q(pytest 9.0.2)test_surface_parity.py(#277) is not present on this branch, so its deliberateAGENT SURFACE PARTITIONfailure does not appear here.Red-before-change (base
origin/main=a0a5d73):service_worker.test.mjsannotated-in-frame tests → 2 fail, both withannotated_with_frame_unsupported: --annotated is not supported with --frame; the other 15 tests in the file pass, so the harness is sound and the failures are attributable.annotated.test.mjs→ the whole file fails to load at base (byteCapElementsis not exported).test_manifest_version_reads_current/..._falls_back_to_repo_when_not_deployed→ mutation-checked by revertingmanifest.jsonto0.7.0: both fail withassert '0.7.0' == '0.7.1'.Notes
--wake+--frameremains refused (wake_with_frame_unsupported, fix(browser-bridge): nav/open --wake, fast ping, split routing errors, orientation telemetry, screenshot Read hint #278's parse-time CLI guard). That is a different flag from--annotatedand is not a contradiction with the row above it in SKILL.md.