Skip to content

Resolve facade locators and snapshot refs across frames - #2896

Open
miguelg719 wants to merge 27 commits into
evals/consolidation-05-locator-wait-contractfrom
evals/consolidation-06-frame-support
Open

miguelg719 wants to merge 27 commits into
evals/consolidation-05-locator-wait-contractfrom
evals/consolidation-06-frame-support

Conversation

@miguelg719

@miguelg719 miguelg719 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Composes facade locators through same-origin and out-of-process frames and preserves global snapshot references without duplicating unresolved frame maps. Adds operator documentation for ownership, deadlines, and disconnect behavior.

Also repairs failures exposed by stack CI:

  • Background-tab screenshots activate their target and serialize activation/capture across the browser. Setup and cleanup are serialized per page, so a stalled page cannot block other tabs. Capture deadlines stop waiting for stalled CDP responses; late responses cannot re-enter cleanup. Calls on a page with unfinished timeout recovery fail promptly until cleanup settles, after which screenshots resume.
  • The Vantech Journal scorer identifies the archive’s Load more link by destination and text instead of an obsolete absolute XPath. Strict DOM element-identity scoring and the 80% gate remain unchanged.
  • CLI test deadlines account for the bounded child processes they launch, including multi-command tests.

Validation: 24 local screenshot/lifecycle tests and 66 CLI/help tests passed, along with relevant typechecks and Go extension archive checks. Tests cover timeout rejection, isolation across tabs, and recovery after delayed setup/cleanup settles. Live Chrome verification accepts the recorded correct Vantech observation and rejects an unrelated element. Fresh CI is running on the updated head.

Stack position: 6/11 in the current review scope through #2901. Base: evals/consolidation-05-locator-wait-contract.

Reviewer entry points:

@changeset-bot

changeset-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3ae8d85

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@browserbasehq/stagehand-extension Patch
@browserbasehq/stagehand-go Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Architecture diagram
sequenceDiagram
    participant SDK as Stagehand SDK
    participant Facade as Facade Runtime
    participant RawPage as Raw Page
    participant Snap as Snapshot Capture
    participant FrameMap as Frame DOM Maps
    participant Ext as Extension (Frame Resolution)

    Note over SDK,Ext: Frame Locator Composition Flow

    SDK->>Facade: frameLocator("#outer")
    Facade->>Facade: Compile hop selectors
    Facade->>Facade: frameLocator("#middle")
    Facade->>Facade: locator("form input")
    Facade->>RawPage: locator("#outer >> #middle >> form input")
    RawPage-->>Facade: RawLocator

    Note over Facade,Snap: Frame-Scoped Semantic Query Flow
    
    SDK->>Facade: frameLocator("#checkout").getByRole("button", { name: "Save" })
    Facade->>Facade: Check role filter support
    alt Unsupported role filter
        Facade-->>SDK: Throw guidance error
    else Supported query
        Facade->>Snap: Get accessibility snapshot (includeIframes)
        Snap->>FrameMap: Resolve frame document roots
        FrameMap->>Ext: NEW: resolveFrameDocRootBackendId()
        alt Same-session child frame missing
            Ext-->>FrameMap: Return undefined (skip frame)
            FrameMap-->>Snap: Preserve parent map only
        else Valid frame found
            Ext-->>FrameMap: Backend node ID
            FrameMap-->>Snap: Frame-scoped XPath map
        end
        Snap-->>Facade: Snapshot with frame XPaths
        Facade->>Facade: Filter to hop iframe subtree
        alt Multiple matches
            Facade-->>SDK: Strict mode violation error
        else Single match
            Facade->>RawPage: locator("xpath=/.../iframe/html/.../button")
        end
    end
    
    Note over RawPage,Ext: Frame Exclusion Intervals
    RawPage->>Facade: Build frame exclusions
    Facade->>FrameMap: Resolve ignored frame roots
    alt Resolved frame
        FrameMap-->>Facade: Exclusion interval
    else Unresolved frame
        FrameMap-->>Facade: Skip (no parent interval inherited)
    end
    
    Note over SDK,Ext: contentFrame() Entry Flow
    SDK->>Facade: locator("iframe").contentFrame()
    alt Not pure CSS selector
        Facade-->>SDK: Throw unsupported error
    else Valid CSS
        Facade->>Facade: Compile into hop notation
        Facade->>RawPage: locator("#outer >> :is(iframe) >> button")
        RawPage-->>Facade: Frame-scoped RawLocator
    end
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/integrations/core/src/facade/runtime.ts Outdated
Comment thread packages/integrations/core/src/facade/runtime.ts Outdated
Comment thread packages/integrations/core/src/facade/runtime.ts Outdated
Comment thread packages/integrations/core/src/facade/runtime.ts
Comment thread packages/integrations/core/src/facade/runtime.ts Outdated
Comment thread packages/integrations/core/src/facade/runtime.ts
Comment thread packages/extension/understudy/a11y/snapshot/capture.ts
Comment thread packages/integrations/core/integration/facade-frames.test.ts Outdated
Comment thread .changeset/eval-frame-snapshot-maps.md Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/integrations/core/tests/facade-tools.test.ts Outdated
# Conflicts:
#	packages/sdk-go/internal/extensionassets/stagehand-extension.zip
# Conflicts:
#	packages/sdk-go/internal/extensionassets/stagehand-extension.zip
# Conflicts:
#	packages/sdk-go/internal/extensionassets/stagehand-extension.zip
@miguelg719
miguelg719 added this pull request to stack #2932 September 14, 2026 20:04

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/sdk-ts/tests/browser-runtime/stagehandLaunchConnectSmoke.test.ts Outdated
Comment thread packages/extension/understudy/frame.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 7 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/extension/understudy/page.ts Outdated
Comment thread .changeset/eval-frame-snapshot-maps.md Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/extension/understudy/screenshotUtils.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/extension/understudy/screenshotUtils.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/extension/understudy/page.ts
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