fix(local-cloak): honour waitUntil when opening a tab with a url - #316
Open
Agnik47 wants to merge 1 commit into
Open
fix(local-cloak): honour waitUntil when opening a tab with a url#316Agnik47 wants to merge 1 commit into
Agnik47 wants to merge 1 commit into
Conversation
agentrhq#106 reported `navigate` hard-coding `waitUntil: 'load'`. That fix landed on the `navigate` path, but the same root cause has a second call site that was never covered: `newPage` had no `waitUntil` in its signature at all, so `session-manager.ts` navigated a newly opened tab with a hardcoded literal and `actions.ts` dropped `command.waitUntil` when building the `tabs`/`new` input. The result is that `webcmd browser navigate --wait-until none` works while `webcmd browser tab new --url <url>` still blocks until the load event — so opening a tab on a site that never goes idle (a streaming dashboard, a long-poll app shell, an ad-heavy page with a hanging subresource) hangs, which is the exact failure agentrhq#106 was filed about. Thread the value through: `newPage` and `newPageAttempt` now take a `NewPageInput` carrying an optional `waitUntil`, defaulting to 'load' so existing callers are unaffected. The translation from the command vocabulary ('load' | 'none') to Playwright's ('load' | 'commit') also existed only as an inline ternary at the navigate call site, which is part of why the second site was easy to miss. Both call sites now go through one `toGotoWaitUntil` helper, so a future value reaches every Playwright-backed navigation at once. The session manager stays in Playwright vocabulary, matching `navigatePage`, with the boundary translation kept in the layer that owns it. Note that `cdp.ts` and `page.ts` keep their own 'load' | 'none' vocabulary deliberately — those implement webcmd's BasePage rather than driving Playwright, so they are not part of this boundary. Fixes agentrhq#210
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. Limitations
This review is advisory and does not block merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #210
The bug
#106 reported
navigatehard-codingwaitUntil: 'load'. That fix landed, but the same root cause had a second call site that was never covered:The gap was structural rather than a missed edit —
newPagehad nowaitUntilin its signature at all, and its only caller dropped the field even though it was sitting on the command object being read:So
webcmd browser navigate --wait-until noneworks whilewebcmd browser tab new --url <url>still blocks until the load event, and opening a tab on a site that never goes idle hangs — the exact failure #106 was filed about.The fix
newPage/newPageAttemptnow take aNewPageInputcarrying an optionalwaitUntil, defaulting to'load'so every existing caller is unaffected, andactions.tspasses the command's value through.I also folded in the related inconsistency the issue flagged. The command-vocabulary (
'load' | 'none') → Playwright-vocabulary ('load' | 'commit') translation existed only as an inline ternary at the navigate call site, which is part of why the second site was easy to miss. Both call sites now go through onetoGotoWaitUntilhelper, so a futurewaitUntilvalue reaches every Playwright-backed navigation at once.One deliberate scoping decision: I kept the helper at the local-cloak boundary rather than unifying all three files the issue mentions.
cdp.tsandpage.tsimplement webcmd's ownBasePage, whosegotogenuinely takes'load' | 'none'— they aren't driving Playwright, so their vocabulary is correct for their layer and collapsing it would be wrong. The two vocabularies only need reconciling where local-cloak hands off to a real Playwright page, and that is now a single function. The session manager stays in Playwright vocabulary, consistent withnavigatePage.Verification
session-manager.test.ts, driven end-to-end throughdispatchCloakActionso they cover theactions.tsplumbing that was actually broken, not just the session-manager signature.maps waitUntil none to commit when opening a tab with a url. The other three (tab default, navigatenone, navigate default) pass both before and after, which is the point: they are regression guards proving the default path and the [Bug]: local-cloak navigate hard-codes waitUntil 'load'; Page.goto never forwards waitUntil, so never-idle sites (zillow.com) always time out #106/fix: forward waitUntil through navigate so adapters can skip the load-event wait #107 navigate fix are unchanged.npm run typecheckclean;check:typed-error-lintreportsnew=0.--project unitsuite: 2477 passed with this branch vs 2473 onmain— exactly the 4 added tests. The 20 pre-existing failures across 6 unrelated files (discovery,docs-sync-review-cli,hosted/files,hosted/runner,plugin,site-memory/local-store) are identical on a cleanmaincheckout and are untouched by this change.