@generativereality/browser-automation 0.4.14 → 0.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,6 +46,24 @@ file under `~/.browser-automation/sessions/`.
46
46
  `focus --raise`, which calls `Target.activateTarget` and **genuinely takes the
47
47
  operator's screen**. `--raise` is the only one that does; reach for plain
48
48
  `focus` unless a person needs to see the tab.
49
+ - **Show the work: `--show` / `BAC_SHOW_TAB=1`.** A person watching the Chrome
50
+ window sees whichever tab is SELECTED, and the tabs you work in are background
51
+ tabs — so by default they watch one stale page while titles change elsewhere
52
+ (filmed: eleven minutes on one tab during a real round). `goto --show` and
53
+ `new --show` make your tab the selected one; `export BAC_SHOW_TAB=1` turns it
54
+ on for every `goto`/`new` in the shell, so a skill sets it once.
55
+ **It only selects when the automation Chrome is already the frontmost app**,
56
+ and otherwise does nothing and says `Tab not shown: another app … is in front`.
57
+ That is the design, not a limitation to work around: on current Chrome every
58
+ way of selecting a tab from outside (`Target.activateTarget`,
59
+ `Page.bringToFront`, `/json/activate`, a foreground `new`, `window.open`)
60
+ also brings Chrome in front of whatever the person is using — measured
61
+ 2026-09-29. When Chrome is already in front nothing gets raised, which is the
62
+ case of someone watching it. The person's everyday Chrome counts as "another
63
+ app": it is checked by process, not by name. ⛔ Do not reach for `focus --raise`
64
+ to "make it show" — that is the screen-taking version; keep it for the moments
65
+ a person must look (a sign-in, a CAPTCHA). macOS only; elsewhere `--show`
66
+ reports that it cannot tell and does nothing.
49
67
  - **Self-healing.** If the tab was closed (or Chrome restarted and reissued
50
68
  targetIds), the next `goto` just opens a fresh background tab for that session.
51
69
  - **Refs live in the DOM.** `snapshot` stamps `data-ba-ref="e7"` onto each
@@ -79,7 +97,7 @@ or a non-zero exit and the full renderer-wedge diagnosis. That matters because a
79
97
  held port, a `/json/version` that answers and a `list` full of targets are all
80
98
  properties of the browser **process**, and the way a long-lived Chrome dies is
81
99
  that it keeps all three while losing the ability to give any new tab a
82
- **renderer** (see Gotchas). Older CLIs printed `nothing to do.` in exactly that
100
+ **renderer** (see Gotchas, and [`references/renderer-health.md`](references/renderer-health.md)). Older CLIs printed `nothing to do.` in exactly that
83
101
  state — **if your `launch` ends without a `Renderer capacity:` line, you are on
84
102
  one of those; run `doctor`, which is the same probe.** Override the profile path
85
103
  with `BROWSER_AUTOMATION_PROFILE=...` and the CDP host with
@@ -140,6 +158,7 @@ Page commands take a tab selector — `-s <session>` (default `$BAC_SESSION`, el
140
158
  | Inspect network (find the API, headers, bodies) | `browser-automation network -m bank --reload --filter api --headers --body` |
141
159
  | Screenshot a tab | `browser-automation screenshot -m op.fi --full -o shot.png` |
142
160
  | Make a hidden tab render (charts, video, polling) | `browser-automation focus -s work` (add `--raise` to really front it) |
161
+ | Let a person watching Chrome see the tab you work in | `goto --show` / `new --show`, or `export BAC_SHOW_TAB=1` once |
143
162
  | Prune stale session bookmarks + dead tabs | `browser-automation gc --dry` (then without `--dry`) |
144
163
  | Restart Chrome (LAST resort — closes ALL tabs, for EVERY session; only once `doctor` confirms the Mach name is absent) | `browser-automation launch --restart` |
145
164
  | Forget a session (tab stays open) | `browser-automation close -s work` |
@@ -209,83 +228,22 @@ There's no `state-save`/`state-load` to manage — the profile *is* the auth sto
209
228
  no `name`** (Viking Line's booking selectors — the visible fields are display
210
229
  shells; the real state lives in the framework, so `fill` and DOM value-setting
211
230
  do nothing at all).
212
- - **There is NO way to send real keystrokes, and `fill --native` is not one.** `--native` uses CDP
213
- `Input.insertText`, which fires `beforeinput`/`input` but **never `keydown`**. A combobox that
214
- filters its list on keystrokes therefore stays empty: the value lands in the DOM and no options
215
- ever render. npm’s "Select packages and scopes" picker is the canonical case (2026-08-22) — the
216
- field showed `generativereality` and the list stayed blank through `fill`, `fill --native`, and a
217
- React native-setter `eval`. There is no `press` or `type` command to escalate to.
218
- ⇒ Drop to raw CDP on the tab’s `webSocketDebuggerUrl` and dispatch `Input.dispatchKeyEvent`
219
- per character. Two traps, both hit:
220
- **(1) `keyDown` carrying `text` already inserts the character** — sending a `char` event as well
221
- types everything twice (`ggeenneerraattiivvee…`), which reads as a flaky page rather than a double
222
- dispatch. Send `keyDown` + `keyUp` only.
223
- **(2) Clear with real Backspaces, not select-all+Delete.** A value written by a JS setter is
224
- invisible to the component’s own state, so the framework keeps the old string and you end up
225
- appending to it. Backspacing drives the same path a person would.
226
- Also: the dropdown must actually be **open** first — typing into a collapsed picker’s hidden input
227
- does nothing, and looks identical to the events not landing.
228
- **Do NOT hand-roll a raw-CDP trusted click.** Burned 2026-08-22: wrote a
229
- bespoke `Input.dispatchMouseEvent` helper for exactly this, and it clicked
230
- stale coordinates (the panel had animated in) — `--trusted` already solves that
231
- with the actionability wait. Check `browser-automation click --help` before
232
- building anything.
233
- **A form can swallow a dispatched click and submit itself the wrong way.**
234
- npmjs.com's package-settings forms are the case (2026-08-22): a default click
235
- on the submit button did not reach the framework's handler, so the browser fell
236
- through to a plain native POST and the tab was replaced by a raw
237
- `{"message":"Not Found"}` — no error from the CLI, and nothing saved. It looks
238
- like the server rejected your data; it did not. `--trusted` submitted the same
239
- form correctly. On any settings page, verify by reloading and re-reading the
240
- saved state rather than trusting a click that "worked".
241
- - **WebAuthn / security keys need a genuinely focused, visible tab, and you
242
- cannot supply the touch.** `navigator.credentials.get()` refuses outright when
243
- `document.hasFocus()` is false or `visibilityState` is `hidden` — which is the
244
- normal state while you work in the terminal, since `--trusted` only fronts the
245
- tab for the instant of the click. The prompt then never opens and the page just
246
- sits there, so a 2FA step can look like it is waiting for the user when the
247
- browser has already declined to ask. Measured 2026-08-22 on npm's
248
- `Use security key` challenge: the form POST returned **200** and the challenge
249
- was live, but it could only be satisfied once the user brought that Chrome
250
- window to the front themselves. Check with
251
- `eval '({f:document.hasFocus(),v:document.visibilityState})'` before concluding
252
- anything, and hand hardware-2FA steps to the user with the window frontmost.
253
- - **Controlled-form state stickiness.** Form libraries that subscribe to React's
254
- internal value-setter (React Hook Form, Final Form, Formik with a `Controller`,
255
- Blocket/finn.no's `recommerce` editor) sometimes ignore the synthetic `input`
256
- event the default `fill` dispatches: the DOM input shows the new value, but
257
- the form's React state stays on the old one — and the next submit serializes
258
- the *old* value. Two ways out:
259
- 1. **`fill --native --verify <ref> <value>`** — drives character insertion
260
- through CDP `Input.insertText` (trusted events). `--verify` re-reads the
261
- field afterwards and warns if either the DOM value diverged from what you
262
- asked for, or if React's internal `_valueTracker` still holds the old
263
- value (the canonical state-stickiness signature). Use this first; it
264
- solves the vast majority of cases.
265
- 2. **API bypass** — when even `--native` doesn't stick (e.g. the form library
266
- binds to an external state machine that drives its own POST/PUT), grab the
267
- form's underlying endpoint and hit it directly:
268
- ```bash
269
- # Hook fetch and persist a real form-submit's body + headers via localStorage
270
- # (it survives the post-submit navigation, unlike window.* globals):
271
- browser-automation eval -s app "(function(){var f=window.fetch;window.fetch=function(u,o){if(o&&o.method==='PUT'&&u.toString().includes('/api/item/')){localStorage.setItem('__lastPut',o.body||'');localStorage.setItem('__lastHdrs',JSON.stringify(o.headers||{}));}return f.apply(this,arguments);};})()"
272
- # …then click Save once in the form so the hook captures the canonical PUT…
273
- browser-automation eval -s app "({body:localStorage.getItem('__lastPut'),headers:localStorage.getItem('__lastHdrs')})"
274
- # …gives you the endpoint, exact body shape, and custom headers
275
- # (e.g. Blocket uses E-Tag, not the standard If-Match — and the etag lives
276
- # in the JSON body, not the HTTP header).
277
- ```
278
- Then re-fetch the GET endpoint for current data + the current etag, PUT
279
- directly with the modified field(s) and the captured custom header, and
280
- **drive the form's terminal commit step through the UI** — many two-step
281
- editors (`edit → delivery → publish`) only persist `state: "edit"`
282
- server-side until that final Save fires the commit.
283
-
284
- Blocket's recommerce price field is the canonical case: default `fill e43 "500"`
285
- shows 500 in the input but submits 750. Fix: `fill --native --verify e43 "500"`
286
- (or, if --native doesn't stick: direct PUT to
287
- `/recommerce/create/api/item/<id>` with `E-Tag: <body.etag>`, then click
288
- Save on the delivery page to commit).
231
+ - **There is NO way to send real keystrokes, and `fill --native` is not one** — it never fires
232
+ `keydown`, so a combobox that filters on keystrokes stays empty. ⛔ **Do not hand-roll a
233
+ raw-CDP trusted click** — `--trusted` already waits for actionability; check
234
+ `browser-automation click --help` before building anything. A form can also swallow a
235
+ dispatched click and fall through to a native POST (a raw `{"message":"Not Found"}` page,
236
+ nothing saved): use `--trusted`, and on any settings page verify by reloading and re-reading.
237
+ → The raw-CDP `Input.dispatchKeyEvent` recipe and its two traps are in
238
+ [`references/input-and-forms.md`](references/input-and-forms.md).
239
+ - **WebAuthn / security keys need a genuinely focused, visible tab, and you cannot supply the
240
+ touch.** The prompt silently never opens on a backgrounded tab. Check
241
+ `eval '({f:document.hasFocus(),v:document.visibilityState})'` and hand hardware-2FA steps to
242
+ the user with the window frontmost. Detail: [`references/input-and-forms.md`](references/input-and-forms.md).
243
+ - **Controlled-form state stickiness.** The input shows the new value but the submit sends the
244
+ old one (React Hook Form, Formik, Blocket's price field). Use **`fill --native --verify`**
245
+ first; if even that does not stick, bypass to the form's API — the fetch-hook recipe is in
246
+ [`references/input-and-forms.md`](references/input-and-forms.md).
289
247
  - **Cross-origin iframes are separate CDP targets.** `read`/`snapshot` see the
290
248
  page's own document and same-origin frames, not cross-origin iframes (common
291
249
  for SSO bank login widgets and embedded captchas). If the content you need
@@ -298,254 +256,31 @@ There's no `state-save`/`state-load` to manage — the profile *is* the auth sto
298
256
  whose JS handler builds a client-side **blob** and clicks it via a *nested*
299
257
  synthetic click won't fire (Chrome activation quirk) — for those, grab the
300
258
  underlying export URL/endpoint and use `--url`, or the site's API.
301
- - **File upload.** Three paths. The first two mirror Playwright. For a static, snapshot-able
302
- `<input type=file>`, use `setfiles <ref> <path…>` — it resolves the ref and
303
- calls `DOM.setFileInputFiles` (a file input's `.files` is read-only to page JS,
304
- so a value-setter/`eval` can't populate it; CDP can, and fires trusted
305
- `input`/`change`). For a **custom "attach" button** that opens a native file
306
- chooser and reads a *transient* `<input type=file>` it creates+clicks on the fly
307
- (App Store Connect's "Attach File", many React dropzones), `setfiles` on the
308
- static input is useless — the handler uses its own throwaway input. Use
309
- `upload --click <ref> <path…>`: it arms `Page.setInterceptFileChooserDialog`,
310
- clicks the trigger, waits for `Page.fileChooserOpened`, and sets files on the
311
- `backendNodeId` Chrome reports. Paths are resolved from cwd; pass absolute paths
312
- to be safe. Multiple paths upload as a multi-file selection.
313
- **Verify by re-snapshot/screenshot, and DON'T blindly retry.** Apps reset the
314
- input to 0 right after consuming the file, so `upload` judges success by the
315
- `change` event (it reports "delivered"), not by residual `input.files` — a
316
- successful upload legitimately leaves `files=0`. The staged file often shows up
317
- as a row in an attachment *list* (e.g. ASC's "Message Attachments"), not a single
318
- chip, so confirm with `snapshot`/`screenshot` rather than assuming. Each
319
- successful run **adds another attachment** — retrying a "did it work?" upload a
320
- few times silently produces duplicates (this cost us a dozen copies on a live ASC
321
- reply). Upload once, verify, and only re-run if verification shows nothing staged.
322
- The **third path is drag-and-drop**, for zones with NO `<input type=file>` at
323
- all — a `drop` listener reading `e.dataTransfer.files` (vocalremover-style audio
324
- tools, many image/video drop zones). Neither `setfiles` nor `upload` applies;
325
- use `drop <ref> <path…>`. By default it fires a genuinely-**trusted** CDP drag
326
- (`Input.dispatchDragEvent`) carrying the real files from disk: it force-fronts
327
- the tab (bringToFront + focus emulation + active lifecycle — so the tab reports
328
- focused+visible even when the Chrome window isn't the frontmost OS window),
329
- waits for the zone to be actionable, then dragEnter→dragOver→drop. The
330
- force-front matters: drop-zone uploaders commonly do their work only inside a
331
- **user activation**, and CDP input grants no activation on a tab the renderer
332
- considers `hidden` — which it is whenever the window is occluded (the usual
333
- case while you work in the terminal). vocalremover.org is the canonical example:
334
- the file reaches its `change`/`drop` handler either way, but it only uploads +
335
- separates once activation is present. `--js` instead dispatches a synthetic
336
- (isTrusted=false) `DataTransfer` drop **without** force-fronting/stealing focus,
337
- for zones that accept synthetic events. The `<ref>` can be any snapshot element
338
- sitting over the drop region (a heading/button inside the zone) — the drop
339
- bubbles to the zone/document handler, so it works even when the drop div itself
340
- isn't snapshot-interactive. After the drop, `read`/`screenshot`/`network` to
341
- confirm processing started, then grab the result (often a download endpoint you
342
- can pull with `download --url`).
259
+ - **File upload — three paths:** `setfiles [ref] [path…]` for a static `<input type=file>`;
260
+ `upload --click [ref] [path…]` for a button that opens a native file chooser; `drop [ref]
261
+ [path…]` for a drag-and-drop zone with no file input (`--js` for a synthetic drop that does
262
+ not front the tab). ⛔ **Upload once, verify by `snapshot`/`screenshot`, and don't blindly
263
+ retry** — each successful run adds another attachment, and apps reset `files` to 0 after
264
+ consuming it. How each path works and when to pick it:
265
+ [`references/input-and-forms.md`](references/input-and-forms.md).
343
266
  - **A NEW tab's renderer can be slow rather than broken — do not restart Chrome for it.**
344
- ⚠️ **Read this before acting on the wedge diagnosis below.** Measured 2026-09-11 on
345
- Chrome 152.0.7977.83, time from `Target.createTarget` to the first `Runtime.evaluate`
346
- returning, 8 trials each:
347
-
348
- | how the target was created | median | worst |
349
- |---|---|---|
350
- | `background: true` (how this tool opens every tab) | 367ms | 12517ms, and >30s once |
351
- | `background: true` + `Target.activateTarget` | 19ms | 65ms |
352
- | `background: false` | 18ms | 22ms |
353
-
354
- The renderer **process exists** in every arm — `ps` gains a `--type=renderer` child either
355
- way. A background target is simply not given a renderer that answers promptly, and on a
356
- loaded machine (this one was at load average 38) the tail runs past any budget worth
357
- waiting. **This is not the wedge**, and a restart does nothing for it.
358
-
359
- It cost real work to learn: for three weeks `goto` reported this as the permanent,
360
- restart-only condition below, and `launch --restart` closes every tab of every session
361
- sharing this Chrome. It twice destroyed unrecoverable work belonging to another session —
362
- a finished AlternativeTo submission with hand edits, and an Azure signup flow mid-form.
363
-
364
- **Since fixed (v0.4.12+):** `new`/`goto` wait for a late renderer and, if it still has not
365
- answered, briefly activate the tab to force one and hand the window straight back (you get
366
- a `WARN` saying so). The probe retries with a doubling budget, and the verdict now names
367
- the permanent failure **only when its own signature is present**. On an older CLI, the
368
- cheap move is to retry, or to drive a tab that already works.
369
-
370
- **Whatever the version: before restarting anything, check the two corroborations.** Both
371
- were decisive and neither used to be consulted:
372
- ```bash
373
- launchctl print "gui/$(id -u)" | grep MachPortRendezvousServer.<browser-pid>
374
- ps -Ao command= | grep -c -- '--type=renderer'
375
- ```
376
- Mach name **present** + renderers **alive** ⇒ this is slowness, not the wedge. Retry, or use
377
- a live tab. Mach name **absent** ⇒ it is the wedge, and only then is a restart the answer.
378
-
379
- - **"The site is blocking us" — when it is really Chrome that cannot make renderers.**
380
- A browser process can permanently lose the ability to launch **renderer processes** while
381
- looking perfectly healthy. Every tab that already exists keeps working, so nothing seems wrong
382
- until you open a tab or navigate somewhere new, and then the errors read as the remote site's
383
- doing. Diagnosed 2026-08-22; it cost an hour of blaming ferry-operator bot protection.
384
- ⚠️ **This is a real condition and a rare one.** Confirm the Mach name is absent (above)
385
- before you believe it — a slow background renderer produces every symptom in this list.
386
-
387
- How it shows up:
388
- - `browser-automation new` + `goto` → `CDP Page.enable timed out after 30000ms`, **even for
389
- `example.com`**.
390
- - **Cross-origin** navigation of an existing, working tab → `navigate failed: net::ERR_ABORTED`.
391
- Site isolation puts a new origin in a new renderer — the exact thing Chrome can no longer do.
392
- - **Same-origin** navigation on that same tab keeps working perfectly (Skyscanner → Skyscanner
393
- with new query params was fine throughout). That asymmetry is what makes it masquerade as
394
- "only site X blocks us": the tab you were already using still behaves.
395
- - A target created at the browser level (`PUT /json/new?<url>`) appears in `/json/list` with the
396
- right URL but an **empty title forever**; every `Runtime.evaluate` against it times out.
397
- `Page.captureScreenshot` returns `Internal error`. The target shell exists; the renderer does not.
398
-
399
- **It gets SLOW before it fails outright — that is the early warning.** Observed 2026-09-07 on a
400
- Chrome that had been up 12 days: every `goto` took ~25–30s, and a batch of three blew a 120s
401
- timeout, hours before anything failed hard. That was misread as "large files, slow browser" and
402
- worked around with longer timeouts for many minutes; the actual fix was one `launch --restart`,
403
- after which the same pages loaded instantly and 14 `file://` tabs opened in two quick batches.
404
- **A `goto` that has quietly become slow is this, not your page.** Raise the timeout at most once,
405
- then run `doctor`.
406
-
407
- **Every cheap signal stays green, so do not take any of them as health.** On that same wedged
408
- browser: `launch` said `Already running on :9223 — nothing to do.`, `curl :9223/json/version`
409
- answered normally, and `list` cheerfully returned 10 targets — while `goto` exited 1 and `eval`
410
- died with `CDP Runtime.evaluate timed out after 30000ms`. Port held, HTTP endpoint answering and
411
- targets listed are all properties of the **browser** process; the thing that is broken is its
412
- ability to start a **renderer**, and only a probe that runs code in one can see it.
413
- **Since fixed:** `launch` now runs that probe itself and exits non-zero with the diagnosis
414
- instead of reporting "nothing to do", so this particular green-across-the-board trap is closed.
415
- It still will not restart for you — that stays something you type, because the tabs are not
416
- only yours. On a CLI old enough to lack it, `doctor` is the same probe; nothing cheaper
417
- substitutes for either.
418
-
419
- **The mechanism** (macOS, from Chrome's own log at `$TMPDIR/chrome-<port>.log` — `launch --restart`
420
- keeps the previous browser's log as `chrome-<port>.log.prev`, which is the one you want after a
421
- restart):
422
- ```
423
- ERROR:base/apple/mach_port_rendezvous_mac.cc:256]
424
- bootstrap_look_up com.google.Chrome.MachPortRendezvousServer.<pid>: (ipc/send) invalid destination port
425
- ERROR:base/memory/shared_memory_switch.cc:261]
426
- No rendezvous client, terminating process (parent died?)
427
- ```
428
- A Chrome child process gets its shared-memory handles by looking up a Mach bootstrap service the
429
- browser registers **once, at startup**, named `com.google.Chrome.MachPortRendezvousServer.<browser-pid>`.
430
- That registration had vanished from the user's launchd namespace — confirmed absent via
431
- `launchctl print gui/$UID | grep MachPortRendezvousServer.<pid>`, while two healthy Chromes on the
432
- same machine were both listed. From then on **every renderer Chrome launches kills itself within
433
- milliseconds**, which is why none ever appears in `ps` and why the browser only reports
434
- `Render process gone.` **What made the name vanish is not established.** Two things
435
- correlated and neither is proven: the binary on disk had moved to 151.0.7922.170 while the live
436
- browser was still running .138, and `GoogleUpdater` was FATAL-ing on its own `bootstrap_check_in`
437
- with error 141. But the first renderer failure (18:53) *preceded* the first updater FATAL (19:42)
438
- by ~50 minutes, so the update churn is at best a fellow symptom of a sick launchd bootstrap
439
- namespace, not the cause. Treat the trigger as unknown; the diagnosis and the recovery do not
440
- depend on it.
441
-
442
- **It is NOT about how many tabs are open.** That was the first theory and it is wrong: a freshly
443
- launched Chrome on the same machine was driven to **421 page targets / 435 live renderer
444
- processes, every one responsive**, and a 256-fd `ulimit` made no difference either (205 renderers,
445
- all fine). The broken browser had 66 tabs. The count was a coincidence — so do not treat a big
446
- tab count as evidence of this, and do not expect closing tabs to fix it.
447
-
448
- **Diagnose it:**
449
- ```bash
450
- browser-automation doctor # measures renderer capacity, not just reachability
451
- ```
452
- `doctor` now creates a throwaway tab, makes its renderer evaluate `1+1`, and closes it — the one
453
- round-trip that separates a wedged browser from a slow network or a hostile site. On failure it
454
- names the root cause (including the missing bootstrap service and the pid) and points at Chrome's
455
- log. On a healthy browser it reports e.g. `✓ Renderer capacity: a new tab got a live renderer in
456
- 73ms`. `goto` and `new` run the same probe automatically **on the error path only**, so a bare
457
- `Page.enable timed out` now arrives with the diagnosis attached instead of sending you to the
458
- site's bot-protection docs.
459
-
460
- **Recovery — cheapest first, and a restart only once the Mach name is confirmed absent.**
461
-
462
- 1. **Retry.** A new tab's renderer has been measured taking 12s and more on a loaded
463
- machine, and late is not broken.
464
- 2. **Drive a tab that already works.** An existing tab navigates same-origin without
465
- needing a new renderer, so it keeps working throughout even during a genuine wedge:
466
- ```bash
467
- browser-automation list
468
- browser-automation eval -t <id> "location.href='<url>'"
469
- ```
470
- 3. **`browser-automation doctor`** — re-measures, prints the two corroborations, and shows
471
- the recent probe-time distribution from `~/.browser-automation/renderer-probes.jsonl`.
472
- 4. **Only if `doctor` reports the Mach rendezvous service ABSENT**, restart. The bootstrap
473
- name is registered at startup and never re-registered, so nothing short of a new browser
474
- process helps; closing tabs does not, and plain `launch` will not either (idempotent by
475
- design — it sees a live browser and exits happy):
476
- ```bash
477
- browser-automation launch --restart # quit (CDP, then SIGTERM), wait for the profile, relaunch
478
- ```
479
- It reports how many tabs it is about to close. `Chrome released its profile but left its
480
- process running (normal on macOS); ending it.` is the **expected** line, not a fault: on
481
- macOS 27 / Chrome 153 the browser process never exits on its own after quitting, but it
482
- does flush and release the profile first, and that release is what the restart waits for.
483
- (Older CLIs waited only for the port to close and relaunched on top of the still-running
484
- Chrome — two browsers on one profile. If you see `Chrome did not exit on SIGTERM`, or no
485
- such line and then odd profile errors, you are on one of those.) **Those tabs belong to every parallel
486
- Claude Code session sharing this Chrome — ask Fred first, never restart unilaterally.**
487
-
488
- **Housekeeping is a different problem** — `browser-automation gc` prunes stale session bookmarks
489
- (they are never cleaned up otherwise; this machine had accumulated 234, only 5 of them live) and
490
- closes tabs whose renderer does not answer. Use `--dry` first. `list` now counts stale
491
- bookmarks instead of printing them (`list --all` to see them) — 105 stale lines above a
492
- 24-tab Chrome is how "there are a hundred tabs open" became the leading theory for a
493
- renderer failure that has nothing to do with tab count. It is genuinely useful, but it is
494
- **not** a fix for the wedge above, and it never closes a working tab unless you pass `--orphans`
495
- — tabs get addressed by `-m` and opened by hand, so "no session claims it" is not evidence that
496
- nobody wants it.
497
-
498
- **The false lead to resist:** a bare `curl` to a suspicious site may genuinely return a bot wall
499
- (vikingline.fi serves an Imperva "Pardon Our Interruption" page, HTTP 200), which feels like
500
- confirmation. It confirms nothing about the browser path — the persistent, cookie-bearing profile
501
- is a completely different client. Check the browser first: if `doctor` says renderer capacity is
502
- fine and a boring cross-origin URL loads, *then* start suspecting the site.
503
-
504
- - **A backgrounded tab may never paint at all — and `read`/`snapshot` will not tell you.** Distinct
505
- from "still loading": `document.readyState` reaches `complete`, but the SPA never renders, so
506
- `read` returns a stale shell (e.g. a bare "Loading") and `snapshot` lists none of the real
507
- controls. The trap is that this looks exactly like *the page does not have that element*, and you
508
- will go hunting for a different selector or conclude the flow changed. Measured 2026-09-02 on
509
- Google's `accounts.google.com/v3/signin/challenge/pwd`: `readyState: "complete"`,
510
- `body.innerText.length: 202` frozen on the previous step's text, and the password field present in
511
- the DOM but `offsetParent === null` for as long as the tab stayed backgrounded.
512
- **Diagnose** before changing your selector:
513
- ```bash
514
- browser-automation eval -s x '({ready:document.readyState,vis:document.visibilityState,len:document.body.innerText.length})'
515
- ```
516
- `visibilityState: "hidden"` with a **stuck `len`** is this, not a selector problem. Note the
517
- stuck `len` is the whole tell: `hidden` on its own is the normal, healthy state of every
518
- backgrounded tab — verified 2026-09-07, a background tab reporting `hidden` returned its real
519
- painted text — so never read `hidden` alone as a diagnosis.
520
- **Fix:** make the tab report itself visible.
521
- ```bash
522
- browser-automation focus -s x # quiet: no window moves, you keep your frontmost app
523
- ```
524
- `focus` emulates focus + visibility in the renderer, then **reads back what it actually
525
- achieved** rather than reporting that it sent the command — so a partial result says which half
526
- is missing instead of printing a tick over it. The page paints immediately. Add `--raise` only
527
- when a *person* needs to see the tab: that genuinely fronts it and **takes the operator's
528
- screen**, which is exactly what you normally want to avoid.
529
- Same root cause as the WebAuthn note above, different symptom: that one refuses, this one
530
- silently never renders.
531
- *(Older CLIs had no `focus`; the workaround was a `click --trusted` on a harmless wrapper `div`,
532
- which fronted the tab as a side effect of needing trusted input. Prefer `focus` — it says what it
533
- achieved, and it does not click anything.)*
534
-
535
- **Do not confuse this with the renderer wedge above.** Both present to an operator as "the page
536
- isn't there, but every tool says fine", and the fixes are opposite — one is a per-tab nudge, the
537
- other closes every tab in the browser. What separates them:
538
-
539
- | | backgrounded tab never paints | Chrome cannot make renderers |
540
- |---|---|---|
541
- | `goto` | succeeds, rc=0 (may be slow) | **rc=1**, or `Page.enable timed out` |
542
- | `eval` | works, returns a result | **`Runtime.evaluate` times out at 30000ms** |
543
- | scope | that one tab | **every** new tab / cross-origin nav |
544
- | `doctor` | `✓ Renderer capacity` | names the wedge + pid |
545
- | fix | `focus` on the tab | `launch --restart` (**ask first**) |
546
-
547
- `eval` is the fast discriminator: if it answers at all, the renderer is alive and you are in the
548
- painting case. If it times out, stop poking the page and run `doctor`.
267
+ ⛔ `launch --restart` closes **every tab of every session** sharing this Chrome (it has
268
+ destroyed other sessions' unrecoverable work). Retry, or drive a tab that already works.
269
+ Restart **only** once `doctor` reports the Mach rendezvous service **absent**, and **ask Fred
270
+ first — never restart unilaterally**.
271
+ - **"The site is blocking us" may really be Chrome unable to make renderers** — `Page.enable
272
+ timed out` even for `example.com`, cross-origin `net::ERR_ABORTED`, a `goto` that quietly
273
+ became slow, while `launch`, `/json/version` and `list` all look healthy. Run `doctor`
274
+ before blaming the site.
275
+ - **A backgrounded tab may never paint, and `read`/`snapshot` will not tell you** — it looks
276
+ like the page lacks the element. Diagnose before changing selectors:
277
+ `eval '({ready:document.readyState,vis:document.visibilityState,len:document.body.innerText.length})'`.
278
+ `hidden` with a stuck `len` ⇒ run `focus` on the tab (`hidden` alone is normal). If `eval`
279
+ itself times out, it is the renderer wedge instead: run `doctor`.
280
+ - → **Read [`references/renderer-health.md`](references/renderer-health.md)** whenever
281
+ `new`/`goto`/`eval` time out or turn slow, a site seems to block you, a page reads as a
282
+ frozen shell, or a restart is on the table. It has the measurements, the two corroborating
283
+ checks, the wedge mechanism, the recovery order, and the never-paints-vs-wedge table.
549
284
  - **Page still loading.** `goto` waits for the load event, but SPAs render after.
550
285
  If a `read`/`snapshot` looks empty, re-run after a moment, or snapshot again
551
286
  once a known element should be present.
@@ -580,37 +315,13 @@ case; drop to raw CDP only for cross-origin-iframe reads or one-off probes.
580
315
 
581
316
  ## Hit a shortcoming or bug? Fix it — it's open source
582
317
 
583
- This CLI is `@generativereality/browser-automation` (repo:
584
- `github.com/generativereality/browser-automation`). When you hit a missing
585
- capability or a bug (a site needs something the CLI can't do yet, an export
586
- won't trigger, a selector strategy fails), **fix it at the source rather than
587
- working around it forever**:
588
-
589
- 1. **Clone** next to your work: `gh repo clone generativereality/browser-automation`
590
- (or `git clone https://github.com/generativereality/browser-automation`).
591
- 2. **Fix** in `src/` — TypeScript. Commands live in `src/commands/<name>.ts`,
592
- the daemonless CDP core in `src/core/` (`cdp.ts` connection/eval/navigate,
593
- `dom.ts` injected snapshot/click/read JS, `download.ts`, `resolve.ts` tab
594
- selection). Add a command by creating `src/commands/x.ts` and registering it
595
- in `src/commands/index.ts`.
596
- 3. **Validate locally** against the running Chrome:
597
- `npm install && npm run typecheck && npm run build`, then run your build as
598
- **`node dist/index.js <cmd>`** from the clone. **Do NOT `npm link`** — it
599
- repoints the machine-global `browser-automation` bin, so a parallel Claude
600
- Code session (or the user's main session) would suddenly be running *your*
601
- work-in-progress clone instead of the installed release. Validate via the
602
- explicit `node dist/index.js` path instead. Reproduce the failure, confirm
603
- the fix, and re-test on a scratch tab you created (read-only-safe; never
604
- disrupt the user's live tabs).
605
- 4. **Propose a PR** for the user to review and contribute upstream — don't
606
- publish yourself (the maintainer cuts releases):
607
- ```bash
608
- git checkout -b fix/<short-desc>
609
- git commit -am "fix: <what and why>"
610
- gh pr create --fill --repo generativereality/browser-automation
611
- ```
612
- Then tell the user the branch/PR link and what it changes, and ask them to
613
- review and merge. After it's released, `npm install -g @generativereality/browser-automation@latest`.
318
+ This CLI is `@generativereality/browser-automation`
319
+ (`github.com/generativereality/browser-automation`). When a site needs something the CLI
320
+ can't do, or it misbehaves, **fix it at the source rather than working around it forever**.
321
+ ⛔ **Never `npm link`** a clone (it hijacks the machine-global bin for every parallel
322
+ session), and never publish yourself — propose a PR for the user. How to clone, where the
323
+ code lives, how to validate with `node dist/index.js`, and the PR steps:
324
+ [`references/contributing.md`](references/contributing.md).
614
325
 
615
326
  ## Troubleshooting
616
327
 
@@ -0,0 +1,36 @@
1
+ # Hit a shortcoming or bug? Fix it — it's open source
2
+
3
+ Reference for the `browser` skill. Read it when the CLI cannot do something a site needs,
4
+ or misbehaves, and you are about to work around it.
5
+
6
+ This CLI is `@generativereality/browser-automation` (repo:
7
+ `github.com/generativereality/browser-automation`). When you hit a missing
8
+ capability or a bug (a site needs something the CLI can't do yet, an export
9
+ won't trigger, a selector strategy fails), **fix it at the source rather than
10
+ working around it forever**:
11
+
12
+ 1. **Clone** next to your work: `gh repo clone generativereality/browser-automation`
13
+ (or `git clone https://github.com/generativereality/browser-automation`).
14
+ 2. **Fix** in `src/` — TypeScript. Commands live in `src/commands/<name>.ts`,
15
+ the daemonless CDP core in `src/core/` (`cdp.ts` connection/eval/navigate,
16
+ `dom.ts` injected snapshot/click/read JS, `download.ts`, `resolve.ts` tab
17
+ selection). Add a command by creating `src/commands/x.ts` and registering it
18
+ in `src/commands/index.ts`.
19
+ 3. **Validate locally** against the running Chrome:
20
+ `npm install && npm run typecheck && npm run build`, then run your build as
21
+ **`node dist/index.js <cmd>`** from the clone. **Do NOT `npm link`** — it
22
+ repoints the machine-global `browser-automation` bin, so a parallel Claude
23
+ Code session (or the user's main session) would suddenly be running *your*
24
+ work-in-progress clone instead of the installed release. Validate via the
25
+ explicit `node dist/index.js` path instead. Reproduce the failure, confirm
26
+ the fix, and re-test on a scratch tab you created (read-only-safe; never
27
+ disrupt the user's live tabs).
28
+ 4. **Propose a PR** for the user to review and contribute upstream — don't
29
+ publish yourself (the maintainer cuts releases):
30
+ ```bash
31
+ git checkout -b fix/<short-desc>
32
+ git commit -am "fix: <what and why>"
33
+ gh pr create --fill --repo generativereality/browser-automation
34
+ ```
35
+ Then tell the user the branch/PR link and what it changes, and ask them to
36
+ review and merge. After it's released, `npm install -g @generativereality/browser-automation@latest`.