Skip to content

Share browser state files between Whirl and BrowserSim - #48

Merged
brynary merged 2 commits into
cli-settingsfrom
shared-state
Oct 5, 2026
Merged

brynary merged 2 commits into
cli-settingsfrom
shared-state

Conversation

@brynary

@brynary brynary commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

BrowserSim and Whirl previously saved different state files. Both now read and write whirl-state version 1 in *.state.json, so a captured state can move between the engines without conversion. A real BrowserSim → Whirl → BrowserSim test verifies cookies, localStorage, sessionStorage, IndexedDB records, binary aliases, and deleted auto-increment key history.

Stacked on #47 (cli-settings). The BrowserSim counterpart is local commit b0b0736 (Adopt shared Whirl browser state format).

  • Add the shared JSON schema, fixtures, strict validation, and IndexedDB codec to both repositories. Old state formats require recapture.
  • Restore state before application code runs. Capture all visited top-level origins in Whirl without application requests, including origins controlled by a service worker.
  • Preserve cookie scope, expiry, metadata, and the redaction flag. Report expired-cookie and redacted-state notices without exposing values.
  • Save atomically with mode 0600. Reject output aliases of input files, including symlinks and hard links.
  • Document explicit v1 limits: only the main page's sessionStorage is supported; partitioned cookies are rejected; BrowserSim restores one app storage origin. Unsupported state fails before the app runs.

Validation:

  • mise run check passes in Whirl, including six new real CLI browser tests and shared-state validation/file-writing tests.
  • BrowserSim's pinned acceptance suite passes: type checking, 273 browser tests, and production Next.js coverage. Two opt-in browser tests are skipped in that suite.
  • After the final storage-key and replay-scope fixes, 37 focused BrowserSim state/privacy/reload tests pass.
  • The opt-in BrowserSim → Whirl → BrowserSim round trip passes against the built Whirl CLI, including storage keys that shadow native methods and an IndexedDB database with an empty name.

brynary and others added 2 commits October 3, 2026 09:32
`-O` now sets every option, so these four flags were an arbitrary subset
of the 17 keys. Each is now a usage error that names its `-O` form, such
as `-O base=URL`. `--browser` stays: the accepted recording ADR keeps it
beside `--engine`, and `whirl doctor --browser` names browsers the same
way.

Tests, the example script, and the docs use `-O` instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brynary
brynary merged commit 55320f0 into mock Oct 5, 2026
3 checks passed
@brynary
brynary deleted the shared-state branch October 5, 2026 18:29
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