Skip to content

[Fix] Card probe crashed on pages with an active sort tab - #8

Closed
sirotaoleg wants to merge 1 commit into
ThinkFlowLab:jiuwen-jevfrom
sirotaoleg:pr/card-probe-sort-state-visible
Closed

sirotaoleg wants to merge 1 commit into
ThinkFlowLab:jiuwen-jevfrom
sirotaoleg:pr/card-probe-sort-state-visible

Conversation

@sirotaoleg

Copy link
Copy Markdown

Problem. browser_probe_cards failed with ReferenceError: visible is not defined (at extractSortState).

  • extractSortState() calls a helper, visible(), that exists only in a different generated script (the page-state metadata script).
  • It runs for every card. So on any page with an active sort control, the first card throws and the whole probe returns nothing. Such pages include Google Flights "Best / Cheapest", marketplace sort bars and Booking tabs.
  • The bug came in with the mirror of upstream fix(subagent): route browser through synchronous task tool openJiuwen-ai/agent-core#1147 (05db325). The existing tests only checked the JavaScript as a string, so they didn't catch it.

Fix. Define isRenderedElement() next to the other card-probe helpers, with the same semantics as the metadata script's visible(): rendered and non-zero size, but not clipped to the viewport. The sort control is page-level and is often scrolled out of view while the cards are read.

Result. 0 failures in 89 browser_probe_cards calls after the fix (before: every call on such pages failed).

Tests. A new test_browser_probe_cards_exec.py actually executes the generated probe under Node, against a small DOM double. It checks that:

  • cards and sort_state are returned;
  • a display:none tab is ignored;
  • a tab scrolled above the viewport is kept.

Note: the same line exists in the refactor branch (browser_move/runtime/probe_js.py) and in upstream openJiuwen.

browser_probe_cards failed with

  Error: page.evaluate: ReferenceError: visible is not defined
      at extractSortState (eval at evaluate ...)

extractSortState() in the card-probe script calls visible(), a helper
that only exists in build_browser_state_metadata_js(), a different
script. extractSortState() runs for every card, so on any page with an
element matching its sort selectors (an active [role="tab"], a
*sort*active* control: Google Flights "Best/Cheapest", marketplace sort
bars, Booking tabs) the first card throws and the whole probe returns
nothing. Introduced by 05db325 (mirror of upstream
openJiuwen-ai#1147).

Define isRenderedElement() next to the other card-probe visibility
helpers, with the body of the metadata script's visible(): connected,
at least 1x1 px, not display:none / visibility:hidden / opacity:0, and
not clipped to the viewport. The sort control is page-level and is
often scrolled out of view while cards are read, so the existing
isVisible() / isElementVisible() (both viewport-clipped, isVisible
also needs 20 px) would silently drop it.

Add test_browser_probe_cards_exec.py, which runs the generated probe
under Node against a small DOM double with three result cards and an
active sort tab: the probe returns the cards with sort_state, ignores a
display:none tab, and keeps a tab scrolled above the viewport. Skips
only when node is not installed.
@sirotaoleg

Copy link
Copy Markdown
Author

Superseded by #12

@sirotaoleg sirotaoleg closed this Oct 15, 2026
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.

1 participant