Skip to content

Engine: a WebKit field is focused caret first with no posted click, the hold's cap counts from the events under a 300 ms ceiling on strict timers, and the delivery record tells the real freeze (#324) - #329

Merged
SSFSKIM merged 8 commits into
mainfrom
fix/324-caret-first
Nov 8, 2026

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Summary

#324 asked which posted clicks still showed a window raise after the screen hold. Measured against the real frozen spans, none did on main. The earlier "after the hold" counts were a misread: the fallback click's delivery record was dropped from the meta.

This PR makes the real behaviour better and its reporting truthful:

  • Safari set_value and select_text focus a field caret first, with no posted click. The field never reorders, the page sees no pointer event, and the freeze drops from about 300 to about 100 ms.
  • The hold's cap counts from the click's events, under a 300 ms ceiling.
  • The hold's timers fire on time.
  • The delivery record carries the fallback click's record and the real release time.

Closes #324

The rules (design session rulings 8c206e91, a47484f9, eecaccfe and 5e4f745d; the spec's #324 Decision Log entry)

  1. Caret first on WebKit fields. When set_value or select_text needs to focus a text-entry field in a WebKit page:

    • write AXSelectedTextRange {0,0} and read focus back (300 ms);
    • if it is still unfocused, use the field's AXPress and read back again;
    • otherwise answer clickUnconfirmed, with nothing written.

    It never writes AXFocused and never posts a click. It applies in both desktop modes and covers password fields, after a hosted 20 of 20 with 0 raises. The meta gains fieldFocus {focus, focusStep}.

  2. AppKit fields keep main's AXFocused write: 16/16, no raise. select_text on an unfocused NSTextField now focuses it first, where it used to answer selectionNotSettable.

  3. focusingClick keeps the fallback click's delivery record, whose loss caused Gecko: shared-mode page clicks take #282's element route and #283's focus route, since Firefox refuses first mouse #315's misread.

  4. The hold-until-order cap (Shared-mode posted click in Safari can raise Safari's window over the frontmost app's (raiseLeft false) #321) is 200 ms from the click's events, with a ceiling of 300 ms from the hold's start. There is no uncapped variant.

  5. The hold's release timers are strict: a one-shot DispatchSource with .strict and zero leeway, on a queue of their own (scheduleHoldRelease) that does nothing but release. The after-action watch stays off it (review round 3). The App Nap activity lead was built, measured and removed: it made no difference.

  6. delivery.frozenMs is the hold's span until SLSReenableUpdate is called. The guard waits at most 100 ms for the stamp, then answers without it. The Unix times are read before that wait (review round 1).

  7. Corrections: Gecko: shared-mode page clicks take #282's element route and #283's focus route, since Firefox refuses first mouse #315's evidence and its Decision Log item 11 are marked "corrected 2026-11-08 (Shared-mode posted click still reorders the target window above the person's; #321's hold only hides it #324)", and Engine: a shared-mode pointer into a background Firefox page is element-routed, focused by its press or refused, as on Chromium (#315) #327's body was corrected after the merge.

Plugin 0.27.8.

Fixed bug: Safari set_value in dedicated mode answered success while writing nothing

On main, in dedicated mode, set_value and select_text on an unfocused Safari page field answered success in 24 of 24 tries. The posted click focused the field, but the value stayed "" and the selection didn't move. With caret first they deliver 24 of 24.

Cost

  • Freeze per click:
    • a typical natural shared click freezes for a median of about 197 ms (p95 205–215, max 218 ms);
    • the worst case is 300 ms to the release call (measured max 303.6), on the about 2% of clicks whose activation is slow, with the display back within about 26 ms after it;
    • Safari set_value and select_text now freeze for a flat ~100 ms, down from about 300.
  • Latency: the response may wait up to 100 ms for the release stamp when releases are queued. Normally it waits about 0.

Limits: invisible, not absent

Live proof (GitHub-hosted macOS, main 74fe29f against the branch, behind a frontmost TextEdit; visibility judged against SLS-logged frozen spans)

The evidence is in docs/evidence/2026-11-08-raise-after-hold/.

Check Main Branch
Safari shared, set_value and select_text on unfocused fields (80) 80/80 delivered, 58 reorders inside the hold, a pointer event on the page in every one, freeze 262–301 ms 80/80, 0 reorders, 0 page events, freeze 108–125 ms
Safari dedicated (24) 0/24: success, nothing written 24/24
Safari password field (20) 20/20, posted click 20/20 caret first, 0 reorders
select_text, unfocused NSTextField (6) 0/6 6/6
AppKit, Chrome, Firefox – unchanged
Ceiling's real freeze to the call (p50 / max) 368.5 / 378.2 ms (timers late) 300.7 / 303.6 ms
Injected slow activation (60) 47 visible 3 visible

Runs:

The kit is probe/324-measure, off main.

Tests and review

Sminos-Session: cursor235#b93055dd (cua on macbook)

…ss, never by an AXFocused write or a posted click; the pointer hold is capped 200 ms after its events under a 300 ms ceiling; the fallback click's delivery record and the hold's real release time ride in the meta (refs #324)

- set_value's and select_text's focusField: a text-entry field in a WebKit web area (#313's classification) that
  needs focusing gets AXSelectedTextRange {0, 0}, its focus read back, then its AXPress where advertised, read back
  again; still unfocused it is refused (clickUnconfirmed) with nothing written. Recorded as meta.fieldFocus. Both
  device modes. Password fields keep main's path behind caretFirstCoversSecureFields (off).
- AppKit, native, Chromium and Gecko fields keep main's AXFocused write and fallback.
- focusingClick copies the fallback click's delivery record into the method's meta.
- #321's hold: capped activationPointHoldCapMs (200) after the pointer's events, never past
  activationPointHoldCeilingMs (300) from the hold's start, whichever is first.
- delivery.frozenMs: the hold's span to the moment SLSReenableUpdate is called on the release queue (ReenableStamp);
  screenHoldMs unchanged.
- select_text: an unfocused field whose range is not settable (an NSTextField) is focused first and checked again.

Sminos-Session: cursor235#b93055dd (cua on macbook)
The slow case asserted the ceiling by its own constant, so lowering it to 250 survived the mutation run.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…hidden inside the hold, plugin 0.27.8 (refs #324)

- The spike's findings, the rulings (caret first on WebKit fields, AppKit's AXFocused write kept, the delivery record,
  the cap from the events under a 300 ms ceiling, frozenMs, select_text on an NSTextField), the costs, the limits and
  what the hosted check must verify, password fields at 20 reps included.
- #315's item 11, its hosted-check line, WebAreaFocus.swift's note and docs/evidence/2026-11-08-gecko-routes/README.md
  corrected in place, marked "corrected 2026-11-08 (#324)".
- #321's item 3 marked amended; the service's delivery comment names frozenMs.

Sminos-Session: cursor235#b93055dd (cua on macbook)
… for the release's stamp (refs #324)

The review of 74fe29f..2821788 (one P2): the Unix clock was read after waiting up to 100 ms for the stamp, so
holdStartedAt, releasedAt and postedAt moved forward by the wait. It is now read with the guard's end, before the
release. A test pins it with a stamp 60 ms of real time late, and pins ruling a47484f9's bound: a stamp that never
comes is waited for 100 ms and no longer, and the record answers without frozenMs. Decision Log item 6 and the counts
updated (49 mutations, each fails a test).

Sminos-Session: cursor235#b93055dd (cua on macbook)
… and its process latency-critical, each behind a constant; the stamp-wait test on the fake clock (refs #324)

- caretFirstCoversSecureFields on (ruling eecaccfe: Safari password set_value 20/20, 0 raises, no page events, a
  124 ms freeze).
- holdTimerStrict: every hold timer (#321's cap and ceiling, main's 100 ms cap) is a one-shot strict DispatchSource
  timer with no leeway on its own userInteractive queue (scheduleHoldTimer); off, asyncAfter as before.
- holdHoldsActivity: each screen-update hold begins ProcessInfo.beginActivity([.userInitiated, .latencyCritical]) just
  before SLSDisableUpdate and ends it with its one release (FakeActivation.takeHold), on every release path.
- ActivationSystem.awaitReenable and unixNow: the stamp wait and the Unix anchor through the seam, so the test of the
  anchor and of the 100 ms bound runs on the fake clock (ci-gate run 42480881696 failed the real-time version).
- Decision Log: the hosted A/B's measurements (runs 42480471918, 42480982911), item 6b with the re-measure's
  placeholders, 60 mutations.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…tivity removed; #324's item 6b filled from the re-measure (refs #324)

Run 42487558851 (kit probe/324-measure b279af9; rulings eecaccfe and 5e4f745d): the strict timer alone brings the
ceiling's real freeze to the SLSReenableUpdate call to 300.7 / 302.8 / 303.6 ms (p50 / p95 / max), against
368.5 / 375.6 / 378.2 with neither; the activity alone measured 360.5 / 375.8 / 377.9, and both no better than strict
alone. holdHoldsActivity, its seam, its test and its six mutations are removed. The Decision Log's item 6b carries the
table, main's 100 ms hold (100.8 / 103.2 / 103.2 against 124.3 / 149.9 / 158.1), guard-ended releases on time, the
window server's 8 to 26 ms re-enable, the App Nap lead ruled out, the trade past 250 ms (3 of 60 under an injected
slow activation), and the worst case: 300 ms to the call, the display back within about 26 ms. Item 9 states the
limit as invisible, not absent. 54 mutations, each fails a test.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…ction watch's samples stay off the strict queue (refs #324)

The review of e2e452c..5dc2e65 (one P1): making scheduleHoldTimer ActivationSystem.schedule's default also put the
after-action watch's samples (window-order reads, AXRaise repairs that may block for the 1 s AX timeout) on the
strict serial queue, so a blocking sample could hold every hold's cap and ceiling behind it (a 300 ms release fired
at 514 ms in the reviewer's repro). ActivationSystem.scheduleHoldRelease (default scheduleHoldTimer) now carries only
the three hold releases (the activation's ceiling or 100 ms cap, the guard's own hold's opening timer, the cap after
the events); schedule is the global queue's asyncAfter again, for the watch. Tests: each release goes through
scheduleHoldRelease and the watch's samples through schedule (the seam); a live block blocking on schedule leaves a
release on scheduleHoldRelease to fire before it ends. 59 mutations, each fails a test.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…en spans (refs #324)

Sminos-Session: cursor235#b93055dd (cua on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T15:30:32.206857Z f8b952d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8b952d222

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +164 to +167
if let fieldFocus {
var focus: [String: Any] = ["focus": fieldFocus.focus.rawValue, "focusStep": fieldFocus.step.rawValue]
if let error = fieldFocus.caretWriteError { focus["caretWriteError"] = Int(error) }
wire["fieldFocus"] = focus

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Forward the new fieldFocus record through the service

When set_value or select_text takes the new caret-first route, the engine emits fieldFocus, but src/services/engine/service.mjs forwards optional input metadata only through OPTIONAL_INPUT_META, which does not include this key. Consequently, both successful and unconfirmed focus attempts lose the new focus-step and caret-write diagnostics before reaching the client. Add fieldFocus to that whitelist and reset cua/fieldFocus in PER_CALL so subsequent calls cannot retain stale diagnostics.

Useful? React with 👍 / 👎.

@SSFSKIM
SSFSKIM merged commit 73b4456 into main Nov 8, 2026
6 checks passed
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.

Shared-mode posted click still reorders the target window above the person's; #321's hold only hides it

1 participant