fix: honor waitUntil when opening a tab, not just when navigating - #212
Open
rajarshidattapy wants to merge 3 commits into
Open
fix: honor waitUntil when opening a tab, not just when navigating#212rajarshidattapy wants to merge 3 commits into
rajarshidattapy wants to merge 3 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. |
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
#106 reported
navigatehard-codingwaitUntil: 'load'. That fix landed inactions.ts, but the same root cause had a second call site that was never covered:newPage, which backswebcmd browser tab new --url <url>and the hosted tab-open path.Before this PR:
So
browser navigate --wait-until noneworked whilebrowser tab new --urlstill blocked on the load event. On a site that never goes idle — a streaming dashboard, a long-poll app shell, a page with a hanging subresource — opening a tab still hung. Same failure #106 was filed about, different entry point.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. I did not do that, because a mapping duplicated across two files is exactly what let this bug survive the #106 fix.Instead the mapping lives in one exported helper that both call sites use:
navigateandnewPagenow both call it. A futuregotoin this runtime has one obvious thing to reach for, and the reason for the'commit'translation is documented once rather than as an inline comment at whichever site happened to be written first.Changes
session-manager.tstoGotoWaitUntil(); widenednewPageinput withwaitUntil?: 'load' | 'none'; replaced the hardcoded'load'actions.tstabs/newnow forwardscommand.waitUntil;navigateswitched to the shared helperprovider.test.tsType of Change
Checklist
Notes on the checklist:
npx tsc --noEmitreports one error that is not from this change:src/fetch/client.ts(2,23): Cannot find module 'impit'.impit@0.14.3is listed independenciesbut was absent from mynode_modules— a stale local install. No file touched by this PR is involved. Worth a second look in CI.waitUntil, or passing'load', still waits for the load event exactly as before. Only the explicit'none'case differs, and only for tab-open, which previously ignored it.Adapter Notes
Not applicable — this is runtime plumbing, no adapter is added or modified.
CliErrorsubclasses instead of rawErrorScreenshots / Output
The added test mirrors the existing
navigatepair, so both branches of the tab-open path are now pinned:The pre-existing assertion that tab-open defaults to
waitUntil: 'load'is untouched and still passes.Branch fix/newpage-wait-until is based on upstream/main, still uncommitted and unpushed — commit and git push -u origin fix/newpage-wait-until before opening. Base the PR on main.
One thing to settle first: run npm install and re-run npx tsc --noEmit locally. If the impit error clears, delete that checklist bullet from the body — no reason to draw a reviewer's attention to a problem that only existed on my machine. If it persists after a clean install, it's worth its own issue, and the bullet should stay.