Skip to content

[feat]: add timeout support to locator inputs, highlight & upload - #3026

Open
seanmcguire12 wants to merge 3 commits into
share-operation-context-in-locator-actions-readsfrom
share-progress-in-locator-inputs-and-highlights
Open

seanmcguire12 wants to merge 3 commits into
share-operation-context-in-locator-actions-readsfrom
share-progress-in-locator-inputs-and-highlights

Conversation

@seanmcguire12

@seanmcguire12 seanmcguire12 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

why

fill(), type(), highlight(), & setInputFiles() perform multiple steps within one call. those steps need to share the caller's deadline, including typing fallbacks, intentional delays, & file preparation. otherwise, they can continue sending browser commands after the call times out

what changed

  • passed the progress object downstream through fill(), type(), highlight(), setInputFiles(), & their existing delegates
  • made both fill fallbacks reuse the original deadline. timeout or closed connection/session errors prevent fallback to typing. each browser reference is released once, including when an early release stalls.
  • bounded text preparation & keyboard commands. typing delays use the remaining budget & stop on expiry.
  • bounded highlight setup, drawing, duration, & refresh waits. successful durationMs: 0 calls still leave the highlight visible. timeout or failure triggers removal, including another removal attempt if a draw finishes late.
  • combined overlay removal & reference release into one bounded cleanup wait. cleanup failures cannot replace the action error.
  • included file normalization & encoding in the budget, with another check before injection. synchronous encoding can finish after expiry, but cannot trigger an upload afterward. clearing a file input follows the same path.

test plan

extended locatorActions.test.ts using shared setup, controlled time, & held browser responses to verify:

  • delegates & nested calls receive the same progress; both fill fallbacks get only the remaining time & stop on expiry or closure.
  • prepared fill inserts text or clears the field correctly, & stalled early cleanup does not release the same reference twice.
  • typing stops during a delay or stalled keyboard command without sending more characters. unlimited typing can finish.
  • highlight duration consumes the budget; zero-duration highlights remain visible on success. ordinary refresh failures can recover, while closure stops refreshes.
  • late highlight draws are removed. stalled cleanup does not add sequential waits, & cleanup failures preserve the original error.
  • expiry during normalization or encoding prevents file injection. stalled normalization cannot resume the upload after timeout.
  • upload injection respects finite & unlimited budgets; file contents & metadata are preserved, & an empty file list still clears the input.

Summary by cubic

Fixes fill(), type(), highlight(), and setInputFiles() so every step in a multi-step call shares the caller's deadline, preventing browser commands from being sent after the call has timed out.

  • Both fill() fallbacks reuse the original deadline; timeout or closed connection errors stop fallback to typing.
  • Typing delays use the remaining budget, and highlight refresh waits and duration consumption are bounded.
  • Zero-duration highlights stay visible on success; timeout or failure triggers removal, including a retry if a draw finishes late.
  • File normalization and encoding count against the budget, with a check before injection; clearing a file input follows the same path.
  • After a failed or timed-out action, cleanup runs without blocking the caller and cannot replace the original error, even when cleanup itself stalls.
  • Extended locatorActions.test.ts with controlled time and held browser responses to cover each deadline path.

Written for commit eb774b0. Summary will update on new commits.

Review in cubic

@changeset-bot

changeset-bot Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: eb774b0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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 5 files

Architecture diagram
sequenceDiagram
    participant Caller as Caller (Test/User)
    participant Loc as Locator
    participant Deep as DeepLocatorDelegate
    participant Frame as FrameLocatorDelegate
    participant Prog as Progress
    participant Sess as CDP Session
    participant DOM as DOM Scripts
    
    Note over Caller,DOM: Runtime Flow for fill/type/highlight/setInputFiles with deadline propagation
    
    Caller->>Loc: fill(value, progress)
    Loc->>Loc: resolveNode(progress)
    Loc->>Prog: consume budget for node resolution
    Prog-->>Loc: remaining time
    Loc->>Sess: Runtime.callFunctionOn (prepareElementForTyping)
    alt Preparation succeeds within budget
        Sess-->>Loc: input ready
        Loc->>Sess: Runtime.callFunctionOn (fillElementValue)
        Sess-->>Loc: value set
        Loc->>Prog: cleanup (release object)
    else Preparation fails or times out
        Loc->>Loc: fallback to type
        Loc->>Deep: type(text, options, progress)
        Deep->>Loc: type(text, options, progress)
        Loc->>Prog: delay per keystroke
        alt Budget remaining
            Loc->>Sess: Input.insertText
            Sess-->>Loc: typed
        else Budget expired
            Loc->>Loc: stop typing
            Loc->>Sess: Runtime.releaseObject
        end
    end
    
    Caller->>Loc: highlight(options, progress)
    Loc->>Loc: resolveNode(progress)
    Loc->>Sess: Overlay.enable
    Loc->>Sess: DOM.scrollIntoViewIfNeeded
    Loc->>Sess: DOM.enable
    Loc->>Sess: DOM.describeNode
    Sess-->>Loc: backendNodeId
    loop duration budget
        Loc->>Prog: delay(tick)
        Prog-->>Loc: remaining
        Loc->>Sess: Overlay.highlightNode
    end
    alt duration > 0
        Loc->>Sess: Overlay.hideHighlight
    else duration = 0 and success
        Loc->>Loc: keep highlight visible
    end
    Loc->>Prog: cleanup (hide if needed + release)
    
    Caller->>Loc: setInputFiles(files, progress)
    Loc->>Loc: resolveNode(progress)
    Loc->>Sess: Runtime.callFunctionOn (validate input)
    Loc->>Prog: normalize & encode files
    alt Empty file list
        Loc->>Sess: Runtime.callFunctionOn (clear)
    else Valid files
        Loc->>Sess: Runtime.callFunctionOn (inject payloads)
    end
    Loc->>Prog: cleanup (release object)
    Prog-->>Loc: throwIfStopped
    Loc-->>Caller: done
Loading

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

Re-trigger cubic

Comment thread packages/extension/understudy/locator.ts
@seanmcguire12
seanmcguire12 added this pull request to stack #3025 September 24, 2026 17:40
@seanmcguire12
seanmcguire12 force-pushed the share-progress-in-locator-inputs-and-highlights branch from a53fa9c to eb774b0 Compare September 25, 2026 22:09

This branch has not been deployed

No deployments
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