Skip to content

refactor(browser): replace workspace with explicit sessions#1461

Merged
jackwener merged 1 commit into
mainfrom
refactor/browser-session-model
May 10, 2026
Merged

refactor(browser): replace workspace with explicit sessions#1461
jackwener merged 1 commit into
mainfrom
refactor/browser-session-model

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • replace the browser-facing --workspace model with required --session <name> on opencli browser *
  • remove bind guards/options (--domain, --path-prefix, --allow-navigate-bound) and remove browser namespace --keep-tab
  • route extension leases through structured metadata: session, surface, kind, with browser result/session docs updated
  • keep adapter browserSession.reuse: 'site' behavior unchanged; only the browser user surface changes here

Verification

  • npx tsc --noEmit
  • npm test -- --run clis/notebooklm/*.test.js src/cli.test.ts src/browser/page.test.ts src/browser/daemon-client.test.ts src/browser/network-cache.test.ts src/doctor.test.ts src/execution.test.ts src/observation/manager.test.ts src/observation/artifact.test.ts
  • npx vitest run --project extension extension/src/background.test.ts
  • npm run build
  • npm run typecheck && npm run build in extension/
  • npm run docs:build
  • npm run check:typed-error-lint
  • npm run check:silent-column-drop
  • git diff --check

Notes

Breaking by design: no backward compatibility for --workspace/bound: browser surface. Adapter site-continuity rename to siteSession: 'persistent' is a follow-up PR.

@jackwener jackwener force-pushed the refactor/browser-session-model branch 3 times, most recently from 5428321 to 8d058af Compare May 10, 2026 20:01
@jackwener jackwener force-pushed the refactor/browser-session-model branch from 8d058af to f613250 Compare May 10, 2026 20:15
@jackwener jackwener merged commit 9c06e84 into main May 10, 2026
14 checks passed
@jackwener jackwener deleted the refactor/browser-session-model branch May 11, 2026 18:20
@jackwener jackwener mentioned this pull request May 11, 2026
4 tasks
jackwener pushed a commit to hansnow/OpenCLI that referenced this pull request May 13, 2026
`pageScopedResult()` in extension/src/background.ts was spreading the
lease's session into the result `data` for every page-scoped command. For
the `exec` action — which routes user JavaScript through page.evaluate()
— this contaminated arbitrary user-JS returns:

* Array / primitive returns came back as `{ session, data: <value> }`
  envelopes. Adapters that did `Array.isArray(result)` got `false` and
  treated the page as having no rows. Visible repro:
  `opencli google search ...` and `opencli xiaohongshu search ...` —
  Chrome rendered results correctly but adapters extracted an empty array
  (reported in jackwener#1518 from the Browser Bridge v1.0.12 envelope).
* Plain-object returns had an extra `session` key spliced in, silently
  overwriting any user `session` field with the lease's value.

Fix in the extension layer instead of compensating client-side:
`pageScopedResult` now returns `{ id, ok, data, page }` — the same form
it had before jackwener#1461 added the workspace→session refactor. Client-side
unwrapping is no longer needed and the original PR jackwener#1518 `Page.evaluate`
heuristic is dropped (it only covered the array path and would have
missed the plain-object path).

Two adapter improvements kept from the original PR:

* `clis/google/search.js` — wait for `#rso a h3` (with a 5s timeout)
  before extracting. On Chrome 148 / Linux Wayland the DOM can settle
  before SERP anchors are populated, so the existing fixed `wait 2`
  could return empty even with the envelope fix.
* `clis/xiaohongshu/search.js` — extract initially visible cards before
  scrolling, then merge post-scroll rows by URL. Xiaohongshu's
  virtualized masonry can evict the initial note cards from the DOM
  after scroll, causing extraction to return [] even though the
  browser had rendered results correctly.

Extension version bumped to 1.0.14.

Repro environment (from jackwener#1518):

* OpenCLI 1.7.18
* Browser Bridge extension 1.0.12 → 1.0.14
* Chrome 148.0.7778.96
* Linux Wayland, Node 22.22.1

Tests: extension/src/background.test.ts navigate same-url assertion
updated to no longer expect `session` in `data`. Three Page.evaluate
unwrap test cases removed.
jackwener pushed a commit that referenced this pull request May 13, 2026
`pageScopedResult()` in extension/src/background.ts was spreading the
lease's session into the result `data` for every page-scoped command. For
the `exec` action — which routes user JavaScript through page.evaluate()
— this contaminated arbitrary user-JS returns:

* Array / primitive returns came back as `{ session, data: <value> }`
  envelopes. Adapters that did `Array.isArray(result)` got `false` and
  treated the page as having no rows. Visible repro:
  `opencli google search ...` and `opencli xiaohongshu search ...` —
  Chrome rendered results correctly but adapters extracted an empty array
  (reported in #1518 from the Browser Bridge v1.0.12 envelope).
* Plain-object returns had an extra `session` key spliced in, silently
  overwriting any user `session` field with the lease's value.

Fix in the extension layer instead of compensating client-side:
`pageScopedResult` now returns `{ id, ok, data, page }` — the same form
it had before #1461 added the workspace→session refactor. Client-side
unwrapping is no longer needed and the original PR #1518 `Page.evaluate`
heuristic is dropped (it only covered the array path and would have
missed the plain-object path).

Two adapter improvements kept from the original PR:

* `clis/google/search.js` — wait for `#rso a h3` (with a 5s timeout)
  before extracting. On Chrome 148 / Linux Wayland the DOM can settle
  before SERP anchors are populated, so the existing fixed `wait 2`
  could return empty even with the envelope fix.
* `clis/xiaohongshu/search.js` — extract initially visible cards before
  scrolling, then merge post-scroll rows by URL. Xiaohongshu's
  virtualized masonry can evict the initial note cards from the DOM
  after scroll, causing extraction to return [] even though the
  browser had rendered results correctly.

Extension version bumped to 1.0.14.

Repro environment (from #1518):

* OpenCLI 1.7.18
* Browser Bridge extension 1.0.12 → 1.0.14
* Chrome 148.0.7778.96
* Linux Wayland, Node 22.22.1

Tests: extension/src/background.test.ts navigate same-url assertion
updated to no longer expect `session` in `data`. Three Page.evaluate
unwrap test cases removed.
jackwener added a commit that referenced this pull request May 13, 2026
Per-PR e2e-headed Chrome was the dominant PR-time wait (~10-15 min on
two platforms) and on fork PRs blocks behind maintainer approval, while
the actually-blocking failures it caught in the last 30 days were all
e2e-test migrations missed by the authoring PR (#1461 / #1505 workspace
->session) rather than real regressions the unit/typecheck tier missed.

PR feedback path is now:
  - typecheck / unit / lint / adapter / build  ← `pull_request` (ci.yml)
  - extension typecheck / build                ← `pull_request` (build-extension.yml)
  - docs build                                  ← `pull_request` (doc-check.yml)
  - security audit                              ← `pull_request` (security.yml)

E2E-headed Chrome guards:
  - push to main / dev (watched paths)
  - push v* tag (release)
  - nightly cron 08:00 UTC (added: catches Chrome version drift / flake
    drift even when no commits touch watched paths)
  - workflow_dispatch (manual when a PR really wants e2e signal)

smoke-test was already gated on `schedule || workflow_dispatch` only
(ci.yml), so no change needed there.
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.

1 participant