cli: honor --tab flag + retry-on-stale for shortcut commands#12
Merged
Conversation
bbx click / focus / type / hover / patch-style / patch-text / html silently dropped --tab when called as shortcuts. The flag fell through as a positional argument, the shortcut sent its request without tabId, and the bridge routed the work to whatever tab the access route happened to point at (typically the user's active tab). Symptom: agents calling `bbx click --tab 124461098 'el_xxx' ` after the user switched browser focus saw ELEMENT_STALE or "No element found", because the click landed on the user's now-focused tab — not the one the agent had been driving and resolved the elementRef against. Fix: route shortcut commands through extractTabFlag the same way `bbx call` and `bbx cdp-press-key` already do, and pass the resolved tabId to both resolveRef (so the selector is resolved against the target tab) and requestBridge (so the action runs on that tab). Verified live against a running daemon: with the bridge routed to a different tab, `bbx click --tab <other-tabId> 'selector'` now clicks the element in the explicit tab regardless of which tab is focused.
5c1377c to
1a38d21
Compare
1a38d21 to
5375187
Compare
When a shortcut command (click, type, focus, hover, etc.) is given a CSS selector (not an el_xxx ref), and the action returns ELEMENT_STALE, automatically re-resolve the selector and retry once. This handles the common agent workflow: 1. Agent queries a selector → gets elementRef el_abc 2. Page re-renders (React reconciliation, user interaction, SPA nav) 3. Agent calls `bbx click el_abc` → ELEMENT_STALE 4. Agent must manually re-query → retry With this change, `bbx click 'button[data-x=save]'` (selector form) will auto-retry: re-resolve the selector against the current DOM, get a fresh elementRef, and dispatch the action. The retry is at most once and only fires for selector-based inputs (el_xxx refs skip retry since there is no selector to re-resolve from).
5375187 to
06c0d7d
Compare
Owner
|
Sorry, I only now see all your @Eridanus117 PRs. Thank you!!! I will check and merge the remaining. |
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.
Two related CLI improvements for shortcut commands (
bbx click,focus,type,hover, etc.):1. Honor
--tabflag (commit 1)Shortcut commands silently dropped
--tab <id>— the flag fell through as a positional argument. The request always hit the default routed tab instead of the explicit target.Fix: Route shortcut commands through
extractTabFlag(same asbbx callandbbx cdp-press-key), and passtabIdto bothresolveRefandrequestBridge.2. Retry on ELEMENT_STALE (commit 2)
When a shortcut is given a CSS selector (not an
el_xxxref) and the action returnsELEMENT_STALE, the CLI now automatically re-resolves the selector against the current DOM and retries once.This handles the common agent pattern where a page re-renders (React reconciliation, SPA navigation) between element resolution and action dispatch. Without this, agents must manually detect the stale error, re-query, and retry.
Safety:
el_xxxrefs skip retry — no selector to re-resolve from)bbx: ELEMENT_STALE on "<selector>", re-resolving and retrying...to stderr on retryWhy one PR
Commit 2 depends on commit 1's
extractTabFlagintegration in the shortcut path. They can't be split into independent PRs without duplicating the refactor.Test plan
npm testpassesbbx click --tab <id> 'selector'targets the explicit tabbbx click 'selector'without--tabuses the default (no behavior change)