← Back to Pull requests

Describe the controls above and below the viewport in observations #1312

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 25, 2026 13:20 UTC
Author

Only elements in the viewport get an action id, but the description observe() returns covers the whole page. A link below the fold was rendered as its text alone, and a field below the fold not at all. A caller reading the description could not tell that the page links somewhere, or has a field further down.

Example: on the Alan Turing Wikipedia article (1120×780), "Bletchley Park" sits ~3.2k characters into the below-viewport text with nothing marking it as a link. Asked "Does this article link to the Bletchley Park article?" through check(), the Jev decider answered p(YES) 0.34 / 0.33 / 0.34. With this change it answers 0.84 / 0.88 / 0.85.

Fix

Links, buttons, fields and options above or below the viewport are rendered like the controls in view, but without an id, like the disabled controls from #1295:

_[:]He worked at the
_[:]<a>Government Code and Cypher School</a>
_[:]at
_[:]<a>Bletchley Park</a>
_[:]<input type="email" placeholder="Email"></input>

They offer no action, and their nodes have the new DomNode.offscreen set. Once scrolled into view they get ids as before.

  • Which elements: in buildDomNode.js, an element entirely above or below the viewport (and across it horizontally) whose tag or ARIA role makes it a link, button, field or option. It goes through the same nesting rules as in view (handleHighlighting). Generic clickables (a <div> with a pointer cursor) are not described off-screen: they are often wrappers, which duplicate_clickables tells apart only in view. Disabled controls above or below the viewport are now described too (_[:]<button disabled>…).

  • Hidden content (#1306): hidden controls stay out. They are not rendered (display: none, visibility: hidden, a closed <details>, hidden="until-found"), or they are clipped to an empty box. Content left or right of the viewport (off-canvas menus, skip links, carousel slides) stays text, since scrolling does not reveal it.

  • Size: off-screen elements are rendered with their tag, role, an input's type, and their text. Their name attributes (aria-label, title, alt, placeholder, value) appear only when they have no text. href and title are dropped: with them, the Wikipedia article's description doubled (142k → 285k chars). Off-screen links and buttons with neither text nor name (heading anchors, icon buttons) are left out because they say nothing (292 on MDN's <a> page).

  • Latency: interactivity off-screen is decided by tag and role, without the pointer-cursor check. That check reads every :hover rule of the page per element, and running it below the fold made the DOM build ×4 slower on Wikipedia and ×5.7 on IKEA. Off-screen elements also get no live state or accessible name.
  • Ids, actions and the description of the viewport are unchanged.

    Effect on real pages

    main → this branch, on the same loaded page (local headless Chromium, 1280×1080). DOM build is the median of 5 alternating runs of parse_dom.

    | page | description chars | actions | DOM build ms |
    |---|---|---|---|
    | en.wikipedia.org/wiki/Alan_Turing | 142,167 → 162,432 (+14%) | 107 → 107 | 691 → 726 |
    | en.wikipedia.org/wiki/List_of_programming_languages | 23,025 → 28,341 (+23%) | 114 → 114 | 254 → 283 |
    | github.com/microsoft/playwright | 24,387 → 29,354 (+20%) | 110 → 110 | 1677 → 1721 |
    | developer.mozilla.org <a> reference | 35,018 → 42,835 (+22%) | 80 → 80 | 421 → 448 |
    | arxiv.org/list/cs.AI/recent | 26,570 → 30,311 (+14%) | 79 → 79 | 99 → 112 |
    | python.org | 6,569 → 7,383 (+12%) | 34 → 34 | 113 → 113 |
    | gov.uk | 5,236 → 5,769 (+10%) | 14 → 14 | 87 → 89 |
    | jqueryui.com/datepicker | 4,874 → 5,121 (+5%) | 50 → 50 | 49 → 50 |
    | docs.python.org asyncio-task | 60,773 → 62,071 (+2%) | 55 → 55 | 272 → 261 |
    | news.ycombinator.com | 15,253 → 15,347 (+1%) | 216 → 216 | 65 → 64 |
    | bbc.com/news, ikea.com (cookie dialog open: only the dialog is described) | unchanged | unchanged | 68 → 63, 989 → 1036 |

    Snapshots

  • Golden observe.txt (+2% to +26%): only description lines change. Off-screen link and button text becomes _[:]<a>…</a> / _[:]<button>…</button>. Off-screen fields that had no line at all now have one, e.g. the checkout pages' "First name", "City" and "Phone" inputs, and an off-screen <select> now holds its option lines. Each added line is a link, button, field or select below the viewport.

  • Golden actions.json, the action lists in observe.txt, characterization snapshots and scrape outputs: unchanged.
  • Tests

    tests/browser/test_dom_offscreen_controls.py (real browser, local fixture) checks a below-the-fold link, button, field and disabled button described without actions. It also checks that hidden, nameless and left-of-viewport links stay out or stay text, and that after scrolling they get ids while the link now above the viewport is described without one. It fails on main.

    🤖 Generated with Claude Code

    <!-- codesmith:footer -->
    ---
    <a href="https://app.blacksmith.sh/nottelabs/codesmith/notte/pr/1312?autoLogin=true&ref=codesmith_pr_footer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v3.svg"><img alt="View with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png" width="162" height="28"></picture></a> <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1795526430&installation_model_id=8247&pr_number=1312&ref=codesmith_pr_footer&repository=nottelabs%2Fnotte&return_to=https%3A%2F%2Fgithub.com%2Fnottelabs%2Fnotte%2Fpull%2F1312&signature=ca2a9de787338ea42c08163ac82f4811444ae997b59fd153d244d19de26eb464"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png" width="190" height="28"></picture></a>
    <sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup>

    <!-- codesmith:autofix:disabled -->
    <!-- /codesmith:footer -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Page observations now include eligible links, buttons, and form controls located outside the viewport, with their available labels and details. These controls are marked as off-screen and do not offer actions until scrolled into view.
    Once brought into view, previously off-screen controls can appear as available actions.

    Documentation
    * Updated the SDK reference and changelog to describe off-screen controls and their behavior.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: greptile-apps[bot] Review duration: 9m
    All Vouch review confidence checks passed
    Residual risk 0.36 = Change Risk (0.52) × (1 − Review Confidence (0.32)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 57% · Reviewer familiarity: 35%
    31%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1312"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 31.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 31.5% · Lower = rushed or shallow review
    31.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 35.6% · Moderate risk
    35.6%