Skip to content

fix(local-cloak): honour waitUntil when opening a tab with a url - #316

Open
Agnik47 wants to merge 1 commit into
agentrhq:mainfrom
Agnik47:fix/profile-teardown-prefix-match
Open

fix(local-cloak): honour waitUntil when opening a tab with a url#316
Agnik47 wants to merge 1 commit into
agentrhq:mainfrom
Agnik47:fix/profile-teardown-prefix-match

Conversation

@Agnik47

@Agnik47 Agnik47 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #210

The bug

#106 reported navigate hard-coding waitUntil: 'load'. That fix landed, but the same root cause had a second call site that was never covered:

// session-manager.ts — navigate, fixed by #106/#107
await lease.page.goto(url, { waitUntil });          // threaded through

// session-manager.ts — newPage, still hardcoded
await acquired.page.goto(input.url, { waitUntil: 'load' });

The gap was structural rather than a missed edit — newPage had no waitUntil in its signature at all, and its only caller dropped the field even though it was sitting on the command object being read:

// actions.ts — 'tabs' / 'new'
const lease = await manager.newPage({
  ...
  url: command.url,
  // command.waitUntil never passed
});

So webcmd browser navigate --wait-until none works while webcmd 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 / newPageAttempt now take a NewPageInput carrying an optional waitUntil, defaulting to 'load' so every existing caller is unaffected, and actions.ts passes 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 one toGotoWaitUntil helper, so a future waitUntil value 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.ts and page.ts implement webcmd's own BasePage, whose goto genuinely 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 with navigatePage.

Verification

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
@github-actions

Copy link
Copy Markdown
Contributor

🟠 Maintainer review suggested — low confidence

The automated review could not reach a fully supported conclusion.

Limitations

  • The automated review returned an invalid structured result.

This review is advisory and does not block merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

``waitUntil: 'load'is still hardcoded innewPage— the #106 fix reachednavigateonly, sotab new --url still hangs on never-idle sites

1 participant