Repository navigation
Conversation
[Low impact] The documentation change appears safe to merge. SummaryAdds instructions for attaching BetterWright to a prepared remote Chrome profile.
Reviews (1) · Last reviewed commit: "Describe attaching to a prepared Chrome ..." · Reviewed by Greptile |
E2E review: PR #244 at
|
| Journey | Result |
|---|---|
Profile prepared by hand in the remote Chrome (localStorage marker + cookie), then CLI run with BETTERWRIGHT_CDP_URL |
passed: reads the prepared state from the existing context and tab |
SDK new BetterWright() with the env var set |
passed: resolves { cdpUrl } and reads the prepared state |
MCP betterwright mcp → browser tool with the env var set |
passed |
| Env var left off one CLI call while the daemon is attached | passed: fails closed with a "BetterChromium is required" error, no silent fallback; remote tabs untouched |
Non-loopback ws:// endpoint / dead port |
passed: rejected (must use wss://) / ECONNREFUSED |
| Prepared state after the remote Chrome restarts | passed: marker and cookie are still on disk |
betterwright close --all with a single prepared tab |
unexpected: BetterWright closed the tab it had taken over, so desktop Chrome exited |
| Hosted Cloudbrowser desktop, and the linked guide | not tested: I did not open the third-party link and used no provider account |
bun run lint, bun run typecheck |
passed |
bun run test:unit |
1340 passed, 2 failed. The failures come from this test machine and are unrelated to the PR: the chromium-package tests need Python ≥3.11 hashlib.file_digest, and the host has 3.10 |
Finding: cleanup can close the prepared browser (behavior already on main, missing from the docs). On attach, the worker reuses browser.contexts()[0] (src/worker.ts ~L1469) and takes over an existing tab as the session page. betterwright close, close --all, and the 15-minute idle reaper all close that tab (sessionClose / reaper in src/worker.ts).
- With 3 tabs open, only the tab it took over was closed.
- With a single tab, desktop Chrome exits because its last window closed.
A reader following this new section would lose the running prepared session that way. The profile on disk survives. Suggested addition to the section: "BetterWright takes over an existing tab and closes it when the session closes or idles out. Keep another tab open (or have the provider keep the browser alive) if the prepared browser must outlive the session."
Items for maintainers to decide:
- The section adds a commercial third-party link, and the PR says it was submitted on behalf of Cloudbrowser. The provider table elsewhere lists built-in integrations only, so it is up to maintainers whether a vendor link belongs in the generic CDP section.
- For the CLI, every call needs the env var, not only the first launch. As written, "at launch" can read as one-time.
- The existing guard-proxy and
wss://limits are documented elsewhere on the page, so the new text doesn't need to repeat them.
Recording (3571344): profile preparation, then the CLI, SDK, MCP, failure-case and cleanup runs. Raw 30-second capture, CDP id redacted.
MP4: https://app.devin.ai/api/presigned_proxy?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjpudWxsLCJidWNrZXRfbmFtZSI6ImRldmluYXR0YWNobWVudHMiLCJidWNrZXRfa2V5IjoiYXR0YWNobWVudHNfcHJpdmF0ZS9vcmctYmQ0NTliYTUyOTRiNDEyMGJiYWRhNmE1Y2JmODIyZTUvZDEyZjM2NWMtNmFmNi00ZDVkLThkOGQtM2U3NmQ1YjQ2NGVhIiwiaWF0IjoxNzk1NzEyMDk5LCJvcmdfaWQiOiJvcmctYmQ0NTliYTUyOTRiNDEyMGJiYWRhNmE1Y2JmODIyZTUiLCJmaWxlbmFtZSI6InByMjQ0LWUyZS0zNTcxMzQ0Lm1wNCJ9._Unrv5x_4Yku04V0bZvoBqakHnxWdZ6t1bNdOiY9mhM. This is a Devin attachment link and may require Devin org access. GitHub's API does not support uploading an MP4 directly to a comment, so the animated WebP above is the inline copy.
This is not a merge approval. Merging stays a human decision.
|
The setup PR #244 documents (commit 3571344) works, but I found one gap the new section doesn't mention. I posted the E2E report with the recording on the PR. Gap: when BetterWright attaches, it takes over a tab already open in the prepared browser. It closes that tab on What passed: attaching with Unit tests: 1340 passed, 2 failed. Both failures are packaging tests that need Python 3.11+, and this VM has 3.10. For maintainers: the PR adds a commercial Cloudbrowser link, submitted on the vendor's behalf. Whether it belongs is your call. Not covered:
Merging is your decision; I stopped there. This response includes attachments — view them in Devin |
|
I added the cleanup note in c987ec3. I repeated the check with the published BetterWright 2.9.1 CLI and a disposable headless Chrome profile on macOS. The adopted tab closed with both one and two initial tabs. With two tabs, the other tab stayed open. The note covers explicit close and idle expiry, which share the same session cleanup. |
E2E review: PR #244 at
|
| Claim / journey | Result |
|---|---|
One prepared tab, CLI run with BETTERWRIGHT_CDP_URL reads the prepared localStorage and cookie |
passed |
"closes the tabs it uses when you close the session": betterwright close |
passed: closes only the tab it adopted (1 tab) |
"or when the idle timeout expires": BETTERWRIGHT_SESSION_TTL_SECONDS=30, two tabs |
passed: the adopted tab closed about 40–50 s after the last call, and the other tab stayed |
"Closing the last tab can also close the Chrome window": one tab, then close |
passed: the Chrome process exited |
"Leave a separate tab open": two tabs, then close / daemon shutdown |
passed: Chrome stays up with one tab left |
| Which existing tab gets adopted (8 runs, both launch orders) | not deterministic: it took the "keep-open" tab 6 of 8 times, including 3 runs where that tab was opened second |
SDK new BetterWright() → run → bw.close() |
passed, but close() only disconnects. The adopted tab is not closed. |
bun run lint, bun run typecheck |
passed |
bun run test:unit |
1340 passed, 2 failed, 24 skipped. Both failures are chromium-package tests that need Python 3.11 hashlib.file_digest, and this VM has 3.10. They are unrelated to this PR. |
| MCP entry point | not re-run: the runtime is unchanged since 3571344, where it passed |
| Hosted Cloudbrowser desktop and the linked guide | not tested: no provider account, and I treated the third-party link as untrusted |
Suggested wording (optional):
- BetterWright adopts the first unowned tab Playwright reports (
ensureSessionPageinsrc/worker.ts), and you can't choose which one. The tab a reader keeps as "separate" may be the one that gets closed. The advice still keeps the window open. A more accurate line: "BetterWright takes over one of the existing tabs, so keep at least two tabs open if the desktop must stay available." - The closing behavior comes from the CLI session daemon. A direct SDK
bw.close()leaves the adopted tab open. Saying "CLI session" or namingbetterwright closewould avoid implying the SDK does the same.
Recording (SHA c987ec3, both scenarios: one tab, where close makes Chrome exit; and two tabs, where close removes the adopted "Keep-open" tab and Chrome stays up):
MP4: https://app.devin.ai/api/presigned_proxy?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjpudWxsLCJidWNrZXRfbmFtZSI6ImRldmluYXR0YWNobWVudHMiLCJidWNrZXRfa2V5IjoiYXR0YWNobWVudHNfcHJpdmF0ZS9vcmctYmQ0NTliYTUyOTRiNDEyMGJiYWRhNmE1Y2JmODIyZTUvMDIyZjA1OGEtYTM5ZC00MjEwLThiNzYtNmI1Y2EyNDg3NDU4IiwiaWF0IjoxNzk1NzEzNTEyLCJvcmdfaWQiOiJvcmctYmQ0NTliYTUyOTRiNDEyMGJiYWRhNmE1Y2JmODIyZTUiLCJmaWxlbmFtZSI6InByMjQ0LXRhYi1jbGVhbnVwLWM5ODdlYzMubXA0In0.uMaL6pxwNaHyKIHBzhd2a808cLYaGa0gmYnbfRyghPE. This is a Devin attachment link and may need a Devin login. GitHub's API can't attach an MP4 to a comment, so an animated WebP of the same recording is embedded above.
Platform: Linux only, no macOS. Merging is a maintainer decision.
|
I posted the E2E report on PR #244 for c987ec3. The new tab-cleanup paragraph is accurate for the CLI, and I found no code bug, so there's no fix PR. I tested on Linux with a throwaway local Chrome attached over CDP and a local test site. The PR only changes docs, and it comes from a fork, so I ran What checked out:
Two wording gaps, posted as optional suggestions:
Checks: Lint and typecheck passed. Unit tests: 1340 passed and 2 failed. Both failures are packaging tests that need Python 3.11+, and this machine has 3.10. Not covered:
Merging is the maintainers' decision. This response includes attachments — view them in Devin |
E2E review: PR #244 at
|
| Claim / journey | Result |
|---|---|
CLI run with BETTERWRIGHT_CDP_URL reads the prepared localStorage marker and cookie |
passed |
"a CLI session closes … the tabs it used, including the existing tab it selected": betterwright close |
passed: closes the adopted tab and a tab opened with openPage. The tab it did not use stays open. |
"… or reaches its idle timeout": BETTERWRIGHT_SESSION_TTL_SECONDS=30 |
passed: the adopted tab closed 40–45 s after the last call, and the other tab stayed |
"Closing the last tab can also close the Chrome window": one tab, then close |
passed: the Chrome process exited |
"SDK bw.close() disconnects … and leaves its tabs open" |
passed: the adopted tab and the tab the SDK opened both stayed, and Chrome stayed up |
MCP betterwright mcp → browser tool, then the client disconnects |
reads the prepared state. On shutdown it behaves like the SDK: no tabs are closed. The docs don't mention this case. |
bun run lint, bun run typecheck |
passed |
bun run test:unit |
1340 passed, 2 failed, 24 skipped. Both failures are native … archive packaging tests that need Python 3.11 hashlib.file_digest, and this VM has 3.10. This is an environment issue unrelated to the PR. |
Recording (67 s, tested SHA 21bf8c0). It shows CLI close with 2 tabs, SDK close, and CLI close with 1 tab. The visible Chrome is on the left and the test output is on the right. Full MP4: https://app.devin.ai/api/presigned_proxy?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjpudWxsLCJidWNrZXRfbmFtZSI6ImRldmluYXR0YWNobWVudHMiLCJidWNrZXRfa2V5IjoiYXR0YWNobWVudHNfcHJpdmF0ZS9vcmctYmQ0NTliYTUyOTRiNDEyMGJiYWRhNmE1Y2JmODIyZTUvMTI3YmI0YWQtYzAxMy00Nzk1LWJlMzctMGZiOTczNGIyNWI0IiwiaWF0IjoxNzk1NzE0MjM5LCJvcmdfaWQiOiJvcmctYmQ0NTliYTUyOTRiNDEyMGJiYWRhNmE1Y2JmODIyZTUiLCJmaWxlbmFtZSI6InByMjQ0LTIxYmY4YzAtdGFiLWNsZWFudXAubXA0In0.Cp8_JDAjwtTqJm0oXtDa9aTAzuGXIe2jaFxCBZKY2uY (a Devin attachment link that may require a Devin login). The animated preview below is the same recording:
Optional wording note: MCP clients use the same SDK path, so tabs stay open when the MCP server exits. If you want the docs to cover that, you could change "The JavaScript SDK's bw.close()" to "The JavaScript SDK's bw.close() (and the MCP server on exit)".
Not covered:
- Cloudbrowser: I had no provider account and did not open the linked guide. Whether the vendor link belongs in the docs is the maintainers' call.
- macOS: I tested on Linux only.
- MP4 link: I couldn't check it from this VM because app.devin.ai is blocked (access request pending). The embedded WebP preview is served through a Devin presigned link, which I also could not check from here.
Merging is the maintainers' decision.
|
I couldn't confirm the video links open. app.devin.ai is still blocked on this VM (the access request is pending), and both the MP4 link and the animated preview in the comment are served from there. The E2E report for PR #244 at 21bf8c0 is posted. The new cleanup paragraph matches what the CLI and SDK actually do, and I found no bugs, so there's no fix PR. I ran What checked out:
Optional wording note: the MCP server leaves tabs open on exit, like the SDK, and the docs don't mention that case. Checks: lint and typecheck passed. Unit tests: 1340 passed and 2 failed; both failures are packaging tests that need Python 3.11+, and this VM has 3.10. Not covered: the Cloudbrowser hosted desktop (no account, and I didn't open the linked guide) and macOS. Merging is the maintainers' decision. This response includes attachments — view them in Devin |
Adds a short example for readers who need to prepare a hosted Chrome profile before handing it to BetterWright over CDP. It covers starting the browser at the provider, reusing the existing context, and handling the endpoint as a control credential.
I am submitting on behalf of Cloudbrowser. The linked setup guide is ours and documents how to start or resume a Chrome desktop and obtain its CDP URL.
I tested the generic attachment flow with BetterWright 2.9.1 and an isolated local Chrome. BetterWright, started with BETTERWRIGHT_CDP_URL, read a local-storage marker set in the Chrome profile before attachment.