Skip to content

docs: add the browser runtime to the agent guide - #67

Merged
cardmagic merged 4 commits into
mainfrom
docs/browser-agent-guide
Oct 8, 2026
Merged

cardmagic merged 4 commits into
mainfrom
docs/browser-agent-guide

Conversation

@cardmagic

Copy link
Copy Markdown
Owner

Why

The agent guide (docs/agents.md) covered only Node.js. An agent that read it could not tell when the browser runtime fits, which entry point to import, or what fails on a real page. The consumer skill points agents to this guide, so the browser facts must be here.

What changed

  • Step 12, "Use the browser runtime": the fit and the simpler tools, the install with @sqlite.org/sqlite-wasm, the entry points, a module worker example, authorization in the browser, the rules for browser actors, the platform limits, transmit to a Node.js or Rails server, and the checks.
  • examples/browser/draft-worker.js and examples/browser/page.js: the guide example. test/browser/agent-guide-example.browser.ts runs them in Chromium. It checks three things:
    • state survives a reload and concurrent edits;
    • two tabs share one draft;
    • the second tab continues after the holder tab closes.
  • scripts/check-documentation.mjs: requires the guide to embed both example files verbatim. The link check now skips fenced code, where ref[operation](value) is code and not a link. An audit of every current doc found no relative link inside a fence, so the change hides no existing link.
  • Step 3 points to step 12, step 11 separates the WebSocket client from the browser runtime, and docs/releasing.md names the new check.
  • Version 0.17.3 and its changelog section.

Correctness notes

  • The failover test first failed with actor invocation timed out after 5000ms ... waitingOn=activationHeld. A closed tab does not shut down its runtime, so with the default lease settings the remaining tab waits for the old lease. The example keeps the short lease settings that the API reference recommends, and the guide says why.
  • Every fact in step 12 comes from docs/api.md, docs/support.md, the README, or the Rails ingest source. The one exception is navigator.storage.persist(), a standard Storage API call.

Validation

  • pnpm run format:check, pnpm run check, pnpm run test:coverage (588 passed, 32 database skips), pnpm run build, pnpm run pack:check (the tarball contains both example files), pnpm run test:package, pnpm run test:recovery, pnpm run test:browser (11 passed), pnpm audit --audit-level=high (no known vulnerabilities).
  • pnpm exec playwright test test/browser/agent-guide-example.browser.ts --repeat-each 5: 10 passed.

The agent guide covered only Node.js, so an agent that read it could not
tell when the browser runtime fits, which entry point to import, or what
fails on a real page. Step 12 adds the fit, the install with the SQLite
WASM peer dependency, the entry points, a module worker example,
authorization in the browser, the platform limits, transmit to a Node.js
or Rails server, and the checks.

The example lives in examples/browser/ and the Chromium suite runs it:
state survives a reload, two tabs share one draft, and the second tab
continues after the holder tab closes. The failover test first failed
with "actor invocation timed out after 5000ms ... waitingOn=activationHeld"
under the default lease settings, so the example keeps the short lease
settings that the API reference recommends, and the guide says why.

check-documentation now requires the guide to embed both example files,
and its link check skips fenced code, where ref[operation](value) is code
and not a link.
@context7

context7 Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Docs7 for cardmagic/solid-objects-js

Result Status Action
Deployment ➖ Not used —
Content review ✅ Passed. No problems found. View findings

Commit a755fc7

@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds browser runtime documentation and example code.

The PR appears safe to merge; the latest commit fixes the takeover test.

What we checked:

  • Takeover test closes the holder: The first tab completes a call before the second tab imports the page module. Its worker gets the database lock first and keeps it until the tab closes.

Summary

Adds browser-runtime guidance, runnable worker and page examples, and browser tests. The latest commit makes the takeover test start the database holder first.

  • The guide covers storage, browser limits, authorization, and sending writes to a server.
  • Documentation checks keep the embedded examples in sync.
  • The latest change fixes the previous finding. No new findings remain.

Reviews (3) · Last reviewed commit: "test: make the closed tab hold the share..." · Reviewed by Greptile

Comment thread examples/browser/page.js
Comment thread docs/agents.md Outdated
Comment thread test/browser/agent-guide-example.browser.ts Outdated
Comment thread test/browser/agent-guide-example.browser.ts Outdated
Comment thread test/browser-server.mjs Outdated
- The page example rejects waiting and later calls when the worker fails
  to load. A browser test routes the worker to a 404; before the fix the
  call timed out after 10 seconds with no answer.
- registerTransmit never reads the HTTP response, so a server 422 stops
  retries only when deliver throws NonRetryableError. The agent guide
  now shows that deliver callback, docs/api.md says so, and a new test
  proves one attempt and a dead letter. The same test with a plain Error
  fails with "expected 8 to be 1".
- The two-tab test now sends overlapping edits from both tabs.
- The test helper uses concrete call and result types.
- The example route in the test server has no nested condition.
@cardmagic

Copy link
Copy Markdown
Owner Author

@greptileai Please review the latest commit, e7b3c46. It addresses each finding:

  1. Worker failures leave calls waiting: fixed. worker.onerror rejects every waiting call and remembers the failure, so later calls reject too. A new browser test routes the worker to a 404. Before the fix, the call hung until the 10-second test timeout.
  2. HTTP 422 still allows retries: correct, and fixed. The guide now shows a deliver callback that throws NonRetryableError (from solid-objects/core, which passes the browser import check) for a 422. It also says that a normal return marks the write as delivered. docs/api.md had the same wrong claim and is fixed. A new test in test/transmit.test.ts proves one attempt and a dead letter. With a plain Error, the same test fails with "expected 8 to be 1".
  3. Two-tab edits never overlap: fixed. The two-tab test sends overlapping edits from both tabs, then closes the holder tab.
  4. Call types hide mistakes: fixed with a DraftCall union and a number | DraftSnapshot result.
  5. New route nests simple checks: fixed with guard clauses.

Validation: pnpm run format:check, pnpm run check, pnpm test (589 passed), pnpm run test:browser (12 passed), pnpm run pack:check, pnpm run test:package, and the example tests with --repeat-each 5 (15 passed).

Comment thread test/browser/agent-guide-example.browser.ts
The overlapping edits started both workers together, so either tab could
win the database lock. When the second tab won, closing the first tab did
not test failover. A first call from the first tab now makes it the
holder before the second tab starts its worker.
@cardmagic

Copy link
Copy Markdown
Owner Author

@greptileai Please review the latest commit, a755fc7. Failover can go untested: fixed as you suggested. A snapshot call from the first tab runs before the overlapping edits. The second tab's worker starts only on its first call, so the first tab holds the database when it closes. --repeat-each 5: 15 passed. The re-anchored Worker failures leave calls waiting comment refers to code that e7b3c46 already fixed (worker.onerror and the 404 browser test).

@cardmagic
cardmagic merged commit 81e12b8 into main Oct 8, 2026
20 checks passed
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