Skip to content

cli: add --await and --tab flags to bbx eval#13

Merged
koltyakov merged 1 commit into
koltyakov:mainfrom
Eridanus117:cli-eval-await
Jun 9, 2026
Merged

cli: add --await and --tab flags to bbx eval#13
koltyakov merged 1 commit into
koltyakov:mainfrom
Eridanus117:cli-eval-await

Conversation

@Eridanus117

Copy link
Copy Markdown
Contributor

Problem

`page.evaluate` at the protocol layer already supports `awaitPromise` (passes it to CDP `Runtime.evaluate`), but the `bbx eval` CLI command had no way to set it. Async IIFEs return `{}` (a Promise object serialized by value) instead of the resolved value.

Fix

Add `--await` flag: `bbx eval --await "fetch('/api').then(r => r.json())"` waits for the Promise and returns the final value.

Also adds `--tab` support (same `extractTabFlag` pattern as other commands).

Test plan

  • `bbx eval --await "new Promise(r => setTimeout(() => r(42), 500))"` → `{"value": 42, "type": "number"}`
  • `bbx eval "1+1"` still works without `--await` (no behavior change)
  • `bbx eval --tab --await "..."` targets the explicit tab

page.evaluate already supports awaitPromise at the protocol and
extension layers (Runtime.evaluate({awaitPromise: true})), but the
`bbx eval` CLI command had no way to set it.

Now: `bbx eval --await "fetch('/api').then(r => r.json())"` waits for
the Promise to resolve and returns the final value, instead of `{}`.

Also adds --tab support (same extractTabFlag pattern as other commands).

Usage: bbx eval [--tab <id>] [--await] <expression>
@koltyakov koltyakov merged commit 05cc578 into koltyakov:main Jun 9, 2026
4 checks passed
koltyakov added a commit to Eridanus117/browser-bridge that referenced this pull request Jun 9, 2026
Kept both handleFetchInterceptRequest (this PR) and handleActivateTab
(from koltyakov#14) in background.js; combined intercept help lines with the
updated eval usage line (from koltyakov#13) in command-registry.js.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants