Skip to content

Engine: a click's caret effect can land after the next action (click, then select, then type puts the text in the wrong place) #359

Closed

Description

@SSFSKIM

Problem

A coordinate click's caret effect can land after the next action, and override it. Click into a field, select at once, then type: the click's caret reappears after the selection, so the typed text goes in the wrong place.

It was measured in #354's spike (kit probe/354-measure; evidence ~/.local/share/probe-354/click-order-facts.json on the MacBook):

  • Click, then a full selection by script at once, then type_text: the placement went wrong in Chrome for Testing 9/10, Safari 3/10, and Firefox 2/9, with 1 guard refusal.

  • In one Chrome trace:

    • the click returns;
    • the script's full selection completes at +4 ms;
    • type_text starts at +11 ms;
    • the click's caret at offset 3 reappears at +237 ms;
    • the first typed input arrives at +416 ms.

    The final text is OldNew typed sentence goes here. draft sentence goes here.

  • A model's real flow (click into a field, Cmd+A, type) is exposed the same way.

It is likely in #341's family: on Chromium, the click writes the caret with AXSelectedTextRange before any focus, and answers "placed" on the read-back. That read-back may pass before the write's effect has landed for good, or the page may re-apply it later.

Intent

A click answers only once its caret effect is final, so nothing later re-applies it. Measure first:

Constraints

Success criteria

Activity

  1. added
    bug
    status:ready-for-implementer
    priority:P1
    status:in-progress
    and removed
    status:ready-for-implementer
    on Nov 10, 2026
  2. SSFSKIM commented on Nov 17, 2026

    @SSFSKIM
    OwnerAuthor

    [board] in-progress: Taken by cursor235 per design 1ea561bc:777. Measurement first: kit probe/359-measure (offline f4ccd10) re-pinned to current main, smoke then full on hosted runners.

  3. added 4 commits that reference this issue on Nov 17, 2026
  4. SSFSKIM commented on Nov 17, 2026

    @SSFSKIM
    OwnerAuthor

    Measured cause, and the restated success criterion (ruling 1ea561bc:785)

    Cause (spike runs 44107967517, 44112583792, 44126242634; main 15acf09). This is a foreground posted-click ordering race, not #341's AX caret write. With the browser in the background (#341's route), 0 of 3,437 scorable attempts were wrong. In the foreground the click is a posted mouse event and answers at once, but the browser dequeues it late: the revert lands p50 14–19 ms after the click returns, and the worst case was +419 ms. AX actions (select_text, set_value, type_text's baseline read) can overtake it. Posted keys (Cmd+A) are queued behind the click: 0/20 wrong in every browser. type_text's false success came from a baseline read taken after the revert.

    Fix shape (ruling 785):

    • Within about 1 s after a posted pointer click to a pid, AX selection, value or baseline actions on that pid wait for a stable focused range (a 50 ms dwell, capped at about 300 ms).
    • After select_text, type_text's baseline waits until the range equals the range written.
    • If the cap runs out and the range still differs, type_text answers typeUnconfirmed: the selection changed after select_text.
    • set_value: within the window, a read-back that differs from the written value, or a caret moved off the written end, is reported instead of ok.
    • Posted keys don't wait.

    Success criteria (they replace the script-selection criterion):

  5. added 4 commits that reference this issue on Nov 17, 2026
  6. 9 remaining items

  7. SSFSKIM commented on Nov 17, 2026

    @SSFSKIM
    OwnerAuthor

    [review-trail] doperpowers:reviewer-high 136183a..ef998db incorrect (P1 earlier-read selection check, P2 truncation, P2 secure recheck) -> fixed f350ced, re-review correct.

  8. removed
    status:in-review
    on Nov 17, 2026
  9. SSFSKIM commented on Nov 17, 2026

    @SSFSKIM
    OwnerAuthor

    [board] done: Landed via PR #402 (cua 0.28.9)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:P1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions