fix: honor waitUntil when opening a tab, not just when navigating - #212
Open
rajarshidattapy wants to merge 4 commits into
Open
fix: honor waitUntil when opening a tab, not just when navigating#212rajarshidattapy wants to merge 4 commits into
rajarshidattapy wants to merge 4 commits into
Conversation
…duce the bug: - session-manager.ts:24-33 — new exported toGotoWaitUntil() carrying the 'none' → 'commit' mapping and the explanatory comment that previously lived inline at the navigate site. - session-manager.ts:248 — newPage input widened with waitUntil?: 'load' | 'none'. - session-manager.ts:260 — the hardcoded 'load' replaced with toGotoWaitUntil(input.waitUntil). - actions.ts:161 — tabs/new now passes waitUntil: command.waitUntil through, which it was silently dropping. - actions.ts:113 — navigate switched to the same helper, so both paths share one implementation. I used a shared helper rather than copying the ternary into newPage. Duplicating it would have been a two-line diff, but a duplicated mapping in two files is precisely what let this bug survive the agentrhq#106 fix. Verification - npx vitest run --project unit src/browser/runtime/local-cloak/provider.test.ts — 27 passed. That includes a new test mirroring the existing navigate pair: tabs/new with waitUntil: 'none' now asserts goto receives 'commit'. The pre-existing test at line 318 still asserts the default is 'load', so both branches are covered. - npx tsc --noEmit reports one error, and it is not from this change: src/fetch/client.ts(2,23): Cannot find module 'impit'. impit@0.14.3 is in package.json dependencies but absent from node_modules here — a stale local install, not a code problem. Run npm install and it should clear; worth confirming on your side before you push, since I can't distinguish "not installed locally" from "genuinely broken on main" without it.
…wpage-wait-until
Contributor
🟢 No documentation gap found — medium confidenceThe automated review found no documentation gap in the supplied changes. This review is advisory and does not block merging. |
# Conflicts: # docs/cli-reference.mdx # skills/webcmd-browser/SKILL.md # src/browser/command-catalog.ts # src/cli.test.ts # src/cli.ts
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.
Description
waitUntilwas plumbed through every layer of the local Cloak runtime except one:newPage. #106 reportednavigatehard-codingwaitUntil: 'load'and that fix landed inactions.ts, but the same root cause had a second call site that was never covered.Before this PR:
On a site that never goes idle — a streaming dashboard, a long-poll app shell, a page with a hanging subresource — opening a page still blocked on the load event even when the caller explicitly asked to skip it.
Closes #210
Why it survived the first fix
newPagehad nowaitUntilin its signature, and its only caller dropped the field even though it was reading it off the same command object:Every other layer was already plumbed —
protocol.tscarrieswaitUntil?: 'load' | 'none'onBrowserRuntimeCommand, andbase-page.ts,cdp.ts, andpage.tsall accept and honor it.newPage's input type was the only link in the chain missing it.Approach
The three-line version of this fix would copy the
'none' ? 'commit' : 'load'ternary intonewPage. That mapping duplicated across two files is exactly what let this bug survive the #106 fix, so instead it lives in one exported helper that both call sites use:Scope change after merging main
This PR was opened against a
mainthat still exposedwebcmd browser tab new --url <url>as a CLI command. That surface no longer exists: the public browser surface is nowtabs,bind,run,snapshot, andclose, andtabsis list-only.The CLI-facing half of the original PR has therefore been dropped as obsolete:
--wait-untiloption ontab newand itsresolveBrowserWaitUntilhelper incli.tscli.test.tscasestab/newoption contract incommand-catalog.tsdocs/cli-reference.mdx"Browser Runtime" section and theSKILL.mdbrowser tab newrowThe runtime bug itself is unaffected by that restructure and is still live on
maintoday (session-manager.tsstill hardcodeswaitUntil: 'load',actions.tsstill dropscommand.waitUntil). The path is now reached through the adapter-facingIPage.newTab()API rather than from the CLI, so the fix still matters — it just no longer needs a CLI flag attached to it.Changes
session-manager.tstoGotoWaitUntil(); widenednewPageinput withwaitUntil?: 'load' | 'none'; replaced the hardcoded'load'actions.tstabs/newnow forwardscommand.waitUntil;navigateswitched to the shared helperpage.ts,types.tsnewTab(url?, options?: { waitUntil?: 'load' | 'none' })page.test.ts,provider.test.tsType of Change
Hosted mode
This fix is local-Cloak only. Hosted
newTabignores the wait condition entirely, and hostednavigatemaps'none'todomcontentloadedrather thancommit, so hosted behavior still diverges after this merges. Tracked separately in agentrhq/webcmd-cloud#30 — this PR should not be read as closing that gap.Verification
Run against
mainmerged into this branch:check:hosted-contractis unchanged becausecommand-catalog.tsnow matchesmainexactly.No behavior change for the default path: omitting
waitUntil, or passing'load', still waits for the load event exactly as before. Only the explicit'none'case differs.The
Cannot find module 'impit'error mentioned in the original description was a stale localnode_modulesand does not reproduce on a clean install. No action needed.