Repository navigation
Description
Problem
type_text presses a Tab, or a Return in a single-line field, only once the text before it reads back: #354's checkpoint. That checkpoint runs only when the read-back has a plan. When the snapshot can't read the field, there is nothing to check against, so the key goes out at once and the checkpoint does nothing (beforeUnit returns immediately). Two cases where the field can't be read:
- the AX value is capped;
- the selected range can't be read.
So type_text("query\n") into such a field sends the Return even if the app ignored or rewrote the text before it, and that Return can submit a form. Only the final answer, typeUnconfirmed, says anything went wrong, and by then the form may have been submitted.
It happens on both routes:
- The keyed route (
TypeReadback.swift) has done this since Engine: in background Safari, cmd+a then type_text can lose the first typed character, both calls answering success (the key equivalent's effect trails the next call) #354. - The paste route matches it under Engine: type_text through the paste route (non-Latin input sources) gets #354's exact read-back #361 (PR for
fix/361-paste-readback). There the Return still waits for Fix Chrome background paste clipboard-read timeouts in composing@textedit rows #187's effect evidence that the line landed, which is weaker than equality.
Found by #361's independent review (finding 2). The keyed route's behaviour was confirmed while building #361's fix.
What to do
Decide for both routes together. Options:
- Withhold a key that may submit after text that can't be verified. Answer
typeUnconfirmedwith "the Return was not sent", and give its count of what was entered. The cost is real: in such fields a typed newline would never submit, even when the text landed. - Keep sending, and say so. Make the docs explicit that in a field that can't be read, a Tab or a Return goes out without a check.
- A middle course: withhold only where neither the read-back nor some weaker target-side evidence saw the text land. The paste route already has such evidence (Fix Chrome background paste clipboard-read timeouts in composing@textedit rows #187's effect); the keyed route would need a cheap equivalent, such as a count or caret change.
Check
Stub tests on both routes, for a single-line field whose value is capped and one whose range can't be read:
- text followed by a newline;
- the app ignoring the text.
The chosen behaviour holds on both routes, and the docs state it.
Spawned by #361.
Activity
Evidence: #361's hosted qualification, and background Firefox's uncon…
macOS engine: type_text's paste route confirms by exact read-back, ke…