Commit Graph

99 Commits

Author SHA1 Message Date
mcfn.feng e4c2a6b72a [packages/cli-v2]fix: allow too_many_arguments on assert_cookie_shape in e2e test
Pre-existing clippy lint — CI runs --all-targets which includes tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 11:48:45 +08:00
mcfn.feng 4ec3705cc6 Merge remote-tracking branch 'origin/release/1.0.0' into bugfix/click-ref 2026-03-30 11:39:24 +08:00
mcfn.feng 7a1cc2207a [packages/cli-v2]fix: misc fixes from cookies, logs, wait, and CDP session
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 11:35:46 +08:00
mcfn fbfffeec6c [packages/cli-v2]test: assert storage set context 2026-03-30 10:33:54 +08:00
mcfn fb7c338a81 [packages/cli-v2]test: add storage e2e coverage 2026-03-30 10:27:13 +08:00
mcfn 58d9894a67 [packages/cli-v2]test: relax cookies expires assertion 2026-03-30 10:19:06 +08:00
mcfn f3845687fc [packages/cli-v2]test: pin cookies miss contract 2026-03-30 09:12:29 +08:00
mcfn 2eb6b2c0d2 [packages/cli-v2]test: add cookies e2e coverage 2026-03-30 09:06:49 +08:00
mcfn ec2700ab45 [packages/cli-v2]test: add condition timeout coverage 2026-03-30 01:14:44 +08:00
mcfn ba8d546973 [packages/cli-v2]test: add wait e2e coverage 2026-03-30 01:09:45 +08:00
mcfn b5906c858e [packages/cli-v2]test: extend logs filter coverage 2026-03-29 23:59:59 +08:00
mcfn 0e530e3965 [packages/cli-v2]test: add logs e2e coverage 2026-03-29 23:55:26 +08:00
mcfn.feng 29ce2f380b [packages/cli-v2]chore: merge release/1.0.0 and resolve cli-v2 conflicts
Integrate new commands from release/1.0.0 (pdf, query, hover, focus,
press, drag, upload, mouse-move, cursor-position, scroll, etc.) with
screenshot implementation. Deduplicate base64 dependency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 23:39:25 +08:00
mcfn dd6c46ec5b [packages/cli-v2]test: add pdf e2e coverage 2026-03-29 20:12:11 +08:00
mcfn 9e2d7321b6 [packages/cli-v2]test: cover disabled query state 2026-03-29 19:09:38 +08:00
mcfn 6e1bcca0fe [packages/cli-v2]test: add query e2e coverage 2026-03-29 19:00:43 +08:00
mcfn a95299fccd [packages/cli-v2]test: assert element not found details 2026-03-29 18:04:14 +08:00
mcfn 5541396a4d [packages/cli-v2]test: extend describe state coverage 2026-03-29 18:00:37 +08:00
mcfn c7a52a6cad [packages/cli-v2]test: add describe state e2e 2026-03-29 17:55:27 +08:00
mcfn 4558e2dfd0 [packages/cli-v2]test: add P1 JS exception propagation E2E tests
Add monkeypatch-based E2E tests for all three observation commands
(attrs, box, styles) to verify that when Runtime.callFunctionOn returns
exceptionDetails, the CLI surfaces ok=false / error.code=JS_EXCEPTION
instead of silently returning empty {}.

- styles_js_exception_propagated: patches window.getComputedStyle to throw
- box_js_exception_propagated: patches element.getBoundingClientRect to throw
- attrs_js_exception_propagated: patches element.attributes getter to throw

E2E suite now 13/13 green.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 17:48:56 +08:00
mcfn a70ed62ce0 [packages/cli-v2]test: add P1 E2E regression for JS_EXCEPTION via getComputedStyle monkeypatch 2026-03-29 17:48:56 +08:00
mcfn 41334bdc84 [packages/cli-v2]test: add P2 regression test for box no-scroll
Verifies browser box on off-screen element returns coordinates
without changing window.scrollY (read command must be stateless).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 17:48:56 +08:00
mcfn c2517be90c [packages/cli-v2]feat: add observation batch 2 2026-03-29 17:48:56 +08:00
mcfn.feng 5e219a8609 [packages/cli-v2]feat: implement browser screenshot command with annotate support
Add full implementation of `browser screenshot <path>` (§10.2) including:
- Core viewport screenshot via CDP Page.captureScreenshot
- --full flag for full-page capture using Page.getLayoutMetrics
- --selector flag to clip to a specific CSS element region
- --screenshot-format (png/jpeg) with extension inference
- --screenshot-quality for JPEG compression control
- --annotate flag that overlays numbered labels on interactive elements
  and returns annotations metadata (ref, number, role, name, box)

Expand RefCache to store role/name (RefEntry) so annotate can build
complete annotation metadata without re-fetching the AX tree.

Includes 11 unit tests and 12 E2E tests covering happy paths
(json/text/jpeg/full/selector/annotate) and error paths
(invalid path, session/tab not found, missing args).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 17:47:45 +08:00
asensagent e00c48fd28 feat: implement all interaction commands for CLI v1.0.0 (#361)
* test: add hover command cases

* test: add hover text error coverage

* feat: implement browser hover command

Add the `browser hover <selector>` command. Resolves the selector to a
DOM node via the shared element module, then dispatches mouseenter,
mouseover, and mousemove events via Runtime.callFunctionOn for reliable
hover semantics in headless Chrome. Wired up across CLI parsing, action
enum, router, and output formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add focus command cases

* feat: implement browser focus command

Add the `browser focus <selector>` command. Resolves the selector via
the shared element module, uses DOM.focus to set focus on the target,
and compares pre/post active element by JS reference identity (===) to
correctly report focus_changed even for anonymous elements. Wired up
across CLI parsing, action enum, router, and output formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add press command cases

* feat: implement browser press command

Add the `browser press <key-or-chord>` command. Parses single keys and
chord combinations (e.g. Control+A, Shift+Tab), validates modifier
segments, and dispatches keyDown/keyUp via CDP Input.dispatchKeyEvent
with the appropriate modifiers bitmask. Wired up across CLI parsing,
action enum, router, and output formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add drag command cases

* feat: implement browser drag command

Adds drag-and-drop via CDP Input.dispatchMouseEvent sequence:
mousePressed at source → mouseMoved along path → mouseReleased at
destination. Destination accepts either a selector or x,y coordinates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: drag dispatch via viewport resize + CDP Input events

CDP Input.dispatchMouseEvent requires elements to be within the visible
viewport. The drag fixture positions elements at top:780px which exceeds
the default headless Chrome viewport (~469px). Fix by temporarily
enlarging the viewport via Emulation.setDeviceMetricsOverride before
the drag sequence, then clearing the override after completion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resize viewport before resolving drag coordinates

Move Emulation.setDeviceMetricsOverride before element resolution so
coordinates are captured under the final viewport. Avoids stale
coordinates on responsive pages where a post-resolution resize could
shift element positions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: preserve viewport width during drag, only expand height if needed

Read the current viewport dimensions and only override if the height is
too short for the drag endpoints. Width is preserved to avoid flipping
responsive breakpoints or triggering resize handlers. The override is
skipped entirely when the viewport is already tall enough.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add upload command cases

* feat: implement browser upload command

Adds `browser upload <selector> <file...> --session --tab` which sets
files on a file input via CDP DOM.setFileInputFiles. Validates that all
paths are absolute, resolves the target node, and returns a value_summary
with file list and count. All 10 e2e tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: require at least one file path in browser upload

Adds `#[arg(required = true, num_args = 1..)]` to the `files` field so
Clap rejects invocations with zero files at parse time, matching the
spec's `<file...>` contract. Adds a unit test for the missing-files case.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add eval command cases

* fix: update browser eval to return typed value, type, and preview per spec

- Return `data.value` as typed JSON (number/bool/string) instead of
  always stringifying
- Add `data.type` (JS type from CDP) and `data.preview` (string repr)
- Return null context for SESSION_NOT_FOUND
- Extract exception description for better EVAL_FAILED error messages
- Update cloud eval tests to assert typed values

All 11 eval tests pass (8 interaction + 3 cloud).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add eval context coverage

* fix: include tab URL and title in browser eval context

Fetches the current page URL and title after eval execution and returns
them in the response context, matching the spec contract for tab-scoped
commands. Tests now assert context.url and context.title are present.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add mouse-move command cases

* feat: implement browser mouse-move command

Adds `browser mouse-move <x,y> --session --tab` which dispatches a CDP
Input.dispatchMouseEvent (mouseMoved) at the given coordinates. Parses
and validates x,y format, tracks url/focus changes, returns context with
tab URL and title. All 8 e2e tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add cursor-position command cases

* test: add cursor-position text status check

* feat: implement browser cursor-position command

Adds cursor-position command that returns the last known cursor position
for a tab. Position is stored in SessionRegistry when mouse-move is
executed, using the existing session_id\0tab_id composite key pattern.

Wired in all 6 registration points: mod.rs, action.rs, cli.rs (enum +
to_action + command_name + context), router.rs, output.rs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: track cursor position in click, drag, and hover commands

cursor-position was only updated by mouse-move. Now click, drag, and
hover also store the final pointer coordinates in SessionRegistry so
that cursor-position reflects the true position after any mouse action.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add regression test for click -> cursor-position tracking

Verifies that cursor-position reflects coordinates from a click action,
not just mouse-move. Covers the contract gap identified in review.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add scroll command cases

* test: add scroll changed field checks

* feat: implement browser scroll commands

Adds scroll command with three subcommand forms:
- Directional: scroll up|down|left|right <pixels>
- Edge: scroll top|bottom
- Into-view: scroll into-view <selector> [--align start|center|end|nearest]

All forms support --container for scrolling within a specific element.
Tracks scroll_changed, url_changed, focus_changed in response data.
Wired in all 6 registration points.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add scroll xpath selector coverage

* fix: use resolved CDP nodes for scroll selectors instead of querySelector

Refactored scroll to resolve selectors via element::resolve_node +
DOM.resolveNode → objectId, then use Runtime.callFunctionOn for all
scroll operations. This correctly supports CSS, XPath, and @eN selectors
per the API contract, instead of raw querySelector which only handles CSS.

Added DOM.getDocument init call to ensure XPath DOM.requestNode works.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 15:13:54 +08:00
mcfn 027c0d1c98 [packages/cli-v2]fix: cover xpath selector path 2026-03-29 12:32:14 +08:00
mcfn 6ab915258e [packages/cli-v2]fix: return null for missing reads 2026-03-29 12:21:07 +08:00
mcfn 33019d55b6 [packages/cli-v2]feat: add observation batch 1 2026-03-29 12:16:09 +08:00
mcfn.feng 8f5ba34f73 [packages/cli-v2]fix: adapt snapshot/interaction/page_info e2e tests to new SessionGuard API
Migrate from old SessionGuard::new() (kill-daemon) to new
SessionGuard::new(&sid) (per-session cleanup). Error-path tests
that don't create sessions no longer need a guard.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 11:45:39 +08:00
mcfn.feng 21dc96056e [packages/cli-v2]fix: address code review findings in E2E test harness
- SoloEnv::Drop: wait for daemon exit + clean up daemon.sock/ready/pid
  files (SIGKILL prevents daemon's own cleanup)
- cloud_crash_recovery_endpoint_gone: add real assertions to all branches
  (was a no-op test that could never fail)
- Restore cloud_crash_recovery_reconnect test (was deleted in refactor)
- Add SessionGuard to lifecycle_close_s1t2 and lifecycle_double_close
  tests (prevent session leak on panic)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 11:45:01 +08:00
mcfn.feng c18c65c280 [packages/cli-v2]refactor: improve E2E test harness for reliability and maintainability
- Extract common helpers to harness.rs (assert_meta, assert_error_envelope,
  assert_tab_id, start_session, close_session, new_tab_json, etc.)
- Add local HTTP server to eliminate external network dependency
- Introduce SoloEnv for tests needing isolated ACTIONBOOK_HOME
- Replace fixed sleep(500ms) with per-test session isolation
- Fix TempDir leak in cloud_mode (ChromeGuard now owns TempDir)
- Add PID to unique_session IDs to prevent cross-run collisions
- HTTP server: thread-per-connection + Connection: close header
- Restore all cloud_mode tests (groups 5b-15) that were missing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 11:45:01 +08:00
mcfn a7b4e71d8b tests(e2e): fix inspect-point B1/B2 contract gaps
B1 (context.url + text header URL not pinned):
Already present in current head — context.url is_string() asserted in
JSON happy-path; header contains "about:blank" asserted in text happy-path.

B2 (parent ordering not verifiable):
- Add aria-label="Inner Container" and aria-label="Outer Container" to
  fixture divs so parents are distinguishable in the AX tree
- Replace weak "refs must be distinct" assertion with exact name checks:
  parents[0].name == "Inner Container" (nearest parent)
  parents[1].name == "Outer Container" (grandparent)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-29 11:19:57 +08:00
mcfn a2291720e4 [packages/cli-v2]test: strengthen inspect-point E2E with deterministic fixtures
Address Robin-Cx review (#116):
- Replace actionbook.dev with about:blank + injected DOM fixture
- Pin exact role/name/selector assertions on known button element
- Strengthen text happy-path: assert role "name", selector:, point: lines
- Assert exact parent count (2) and distinct refs for --parent-depth
- Pin INVALID_ARGUMENT error code for invalid coordinates
- Validate coordinates in stub execute() so error test passes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 11:19:57 +08:00
mcfn a06b293b66 [packages/cli-v2]test: browser inspect-point E2E + UT baseline (TDD)
§10.11 inspect-point command: TDD tests + NOT_IMPLEMENTED stub.

- 10 UTs for parse_coordinates (valid, decimals, spaces, negative, zero, errors)
- 10 E2E tests: happy JSON/text, parent-depth, no-element, session/tab not found, missing args, invalid coords
- Stub execute() returns NOT_IMPLEMENTED
- CLI/Action/Router/Output wiring complete
- Text format: role "name" / selector: ref / point: x,y

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 11:19:57 +08:00
Junliang Feng f3575a4d38 [packages/cli-v2] Setup PR2: interactive API key + browser config (#354) 2026-03-29 11:18:26 +08:00
Adcent 24c05c128c [codex] Implement browser interaction commands (#351)
* Add browser click interaction tests

* Expand browser click interaction coverage

* [packages/cli-v2]feat: implement browser click command with shared element resolution

Add full browser click implementation with CDP mouse event dispatch,
selector/coordinate parsing, --button/--count/--new-tab flags, navigation
detection, and XPath support. Extract element resolution into a shared
browser::element utility for reuse by future interaction commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* [packages/cli-v2]fix: use shared resolver for --new-tab href check and add click to help

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add browser type interaction tests

* [packages/cli-v2]feat: implement browser type command

Keystroke-by-keystroke text input via CDP Input.dispatchKeyEvent.
Resolves element through shared element utility, focuses and positions
cursor at end before typing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* [packages/cli-v2]fix: populate context URL/title and use char count in browser type

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add browser fill interaction tests

* [packages/cli-v2]feat: implement browser fill command

Direct value setting via native input setter with synthetic input event
dispatch. No keystroke simulation — replaces existing value entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* [packages/cli-v2]fix: pick native value setter based on element type in browser fill

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add textarea fill regression test

* Add browser select interaction tests

* [packages/cli-v2]feat: implement browser select command

Select dropdown options by value or visible text (--by-text flag).
Dispatches input and change events after selection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* [packages/cli-v2]fix: use resolved node for select instead of re-querying with querySelector

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Format interaction files for lint

* [packages/cli-v2]fix: scroll into view before click and replace fixed navigation delay

Scroll elements into the viewport via DOM.scrollIntoViewIfNeeded before
computing bounding-box coordinates, so clicks on off-screen elements
land correctly. Replace the hardcoded 500ms post-click sleep with a
polling loop that detects URL changes at 50ms intervals (2s timeout),
avoiding unnecessary delays for non-navigating clicks and catching
slow SPA transitions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 08:36:54 +08:00
mcfn 91cb301e99 [packages/cli-v2]fix: restore setup rerun defaults 2026-03-29 03:17:28 +08:00
mcfn 81398f2328 [packages/cli-v2]fix: clarify setup cloud migration 2026-03-29 03:12:51 +08:00
mcfn 01b59afe93 [packages/cli-v2]feat: add setup pr2 interactive flow 2026-03-29 03:07:32 +08:00
Junliang Feng 847afd8a16 [packages/cli-v2] feat: --cursor snapshot detection (#353) 2026-03-29 02:43:15 +08:00
mcfn.feng cbbd57fc5a [packages/cli-v2]feat: implement --cursor detection for snapshot
Detect cursor-interactive elements (cursor:pointer, onclick, tabindex,
contenteditable) via JS eval + CDP DOM resolution. Non-ARIA interactive
elements get refs and show "clickable [cursor:pointer, onclick]" in output.

Implementation:
- detect_cursor_elements() with guaranteed cleanup on error paths
- DFS integration: cursor-mapped nodes get ref + interactive=true + CursorInfo
- render_content appends cursor kind + hints after ref bracket
- Unhide --cursor flag from CLI
- JS skip-list includes iframe to avoid double-counting with AX Iframe role

Review fixes:
- Cursor detection errors surface as meta.warnings (not silently swallowed)
- data-__ab-ci cleanup runs even on early-exit errors (restructured cleanup)
- compact ordering: compact_tree_nodes before remove_empty_leaves (depth gap fix)
- __warnings extracted to meta.warnings in output.rs

67 UT + E2E tests. Tested on x.com: detects 2 onclick elements.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 00:37:27 +08:00
mcfn 1cb2c44e55 fix(e2e): add explicit goto after start_session in page_info tests
CI runners occasionally land on chrome-error://chromewebdata/ when
--open-url navigation races or fails on network hiccups. Adding an
explicit browser goto after browser start ensures the tab has a real
URL before any assertion runs.

Fixes url_text_happy_path CI failure:
  data.value must be a URL: got chrome-error://chromewebdata/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-29 00:04:14 +08:00
mcfn 548007e52b [packages/cli-v2]fix: start_session explicit goto to ensure page load (#t111)
--open-url starts navigation but doesn't block until load completes.
CI saw chrome-error://chromewebdata/ in url_text_happy_path because the
tab was still loading when browser url was called. Explicit goto after
start guarantees the page is fully loaded before tests query the URL.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-29 00:02:31 +08:00
mcfn 07e267e33b [packages/cli-v2]feat: implement browser title/url/viewport commands (#t111)
- title: Runtime.evaluate("document.title") → data.value; url in context
- url: Runtime.evaluate("document.URL") → data.value; url in context
- viewport: Runtime.evaluate innerWidth/innerHeight → data.width/height; url in context
- All context() fns populate url field from result data per §10.4/§10.5/§10.6
- fmt: reformat assert! in page_info.rs to satisfy cargo fmt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 23:14:17 +08:00
mcfn 8beb389640 feat: implement browser title/url/viewport commands (§10.4/§10.5/§10.6)
Implement the three observation commands using CDP Runtime.evaluate:
- browser.title: document.title → data.value (string)
- browser.url: document.URL → data.value (string)
- browser.viewport: window.innerWidth/innerHeight → data.width + data.height (numbers)

All three use __ctx_url sideband so context.url is populated per §2.5.
context() updated from stub (url: None) to extract __ctx_url from data.

Also resolve merge conflicts with release/1.0.0:
- observation/mod.rs: include both snapshot_transform and title/url/viewport
- tests/e2e/main.rs: include both snapshot and page_info test modules
- output.rs: include both browser.snapshot and browser.title/url/viewport cases

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 23:11:20 +08:00
mcfn 915913e242 tests(e2e): strengthen page_info happy-path contract assertions
Fix Robin-Cx B1/B2 blockers on PR #349:

B1 (context.url + text header):
- Assert context.url is present and references actionbook.dev in all
  three JSON happy-path tests (title/url/viewport)
- Assert header line contains URL after [sid tid] in all three text
  happy-path tests per §2.5

B2 (text body exact value):
- title_text_happy_path: run JSON first, extract data.value, assert
  text body line is exactly that value (no "title: " prefix allowed)
- url_text_happy_path: same pattern — pin body line to JSON data.value

TDD status unchanged: 6 happy-path tests still expected-fail against
stubs (stubs return NOT_IMPLEMENTED, context.url=None).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 23:01:32 +08:00
Junliang Feng 027d44d212 [packages/cli-v2] feat: snapshot transform pipeline (P0-P1) per §10.1 (#348) 2026-03-28 22:58:58 +08:00
mcfn efd4b321b6 [packages/cli-v2] test: browser title/url/viewport E2E + UT baseline (TDD)
Add E2E tests (21) and UT (5) for three new observation commands:
- browser.title (§10.4): data.value = page title string
- browser.url (§10.5): data.value = current URL
- browser.viewport (§10.6): data.width + data.height integers, text = WxH

Test coverage per command:
- Happy path JSON (§2.4 envelope + data contract + context)
- Happy path text (§2.5 format: [sid tid] header + value directly)
- SESSION_NOT_FOUND → context null
- SESSION_NOT_FOUND text mode
- TAB_NOT_FOUND → context.tab_id null
- Missing --session / --tab args

UT: format_viewport() in viewport.rs (5 cases)

Stub implementations return NOT_IMPLEMENTED; happy-path E2E tests are
expected-fail until implementation lands. Error-path tests pass against
the stub (error handling runs before command logic).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 22:53:06 +08:00
mcfn.feng 77def0d0e4 [packages/cli-v2]fix: W1-W3 cleanup + implement --selector via CDP DOM queries
W1: Remove dead filter functions (filter_interactive, filter_compact,
    apply_depth, apply_selector, build_stats) — all handled inline in DFS.
W2: Fix token estimation — use div_ceil(3) for conservative char-to-token
    ratio, accurate line length calculation.
W3: Implement --selector via CDP DOM.getDocument + DOM.querySelector +
    DOM.describeNode(depth=-1) → collect backendNodeIds → scope filter in DFS.
    Replaces UNSUPPORTED_OPERATION rejection with real subtree filtering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 22:48:10 +08:00
mcfn.feng e087ad1c0f [packages/cli-v2]test: update noise role test — StaticText is visible content, not noise
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 22:34:31 +08:00