From c3fb746ca3684919b98325cc05c575e0b08d6494 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 9 Nov 2026 17:58:04 +0530 Subject: [PATCH 01/10] fix(ios): clear a secure field with deletes before the caret tap A fill on an empty secure field still ran the clear, whose caret tap lands at the field's right edge. A show/hide control drawn there took the tap, the app swapped the input, and the fill failed with TEXT_INPUT_NOT_FOCUSED (tester-army/e2e#1631). A masked value that shows nothing, or a placeholder that is not a mask, is no longer cleared. Any other masked value gets deletes first, after the readiness repeat tap at the field's center when its focus is unconfirmed, since deletes into a field without focus record an XCTest failure. iOS clears a secure field on its first delete after it takes focus, and deletes from a caret at the end reach the rest, so the caret tap runs only when the read-back does not show the field empty. A placeholder that is itself a mask reads the same as text of its length, so it is not taken as empty: the deletes run and read back. Fixture tests put a toggle over the field's right edge. They cover a fill over prefilled text in the masked field and in a native secure field, a secure field that refused the focus tap, a refill of a focused field whose text reads like its bullet placeholder (no extra tap), and the first fill of an empty secure field, both bare (no deletes sent) and showing a bullet placeholder as its value, as React Native does. --- .../AgentDeviceRunnerAppFixtures.m | 31 ++++- .../UnitTests/AgentDeviceTextEntryFields.h | 9 ++ .../UnitTests/AgentDeviceTextEntryFields.m | 53 +++++++ .../RunnerTests+TextEntry.swift | 68 ++++++++- .../RunnerTests+TextEntryPolicyTests.swift | 13 ++ .../RunnerTests+TextTypingTests.swift | 129 ++++++++++++++++++ src/commands/schema/cli-help-workflows.ts | 2 +- website/docs/docs/commands.md | 2 +- 8 files changed, 299 insertions(+), 8 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m index 901d18573c..a404f703b9 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m @@ -658,6 +658,13 @@ - (void)viewDidLoad { [NSProcessInfo.processInfo.arguments containsObject:@"--agent-device-text-entry-submit-clears"]; BOOL maskedValue = [NSProcessInfo.processInfo.arguments containsObject:@"--agent-device-text-entry-masked-value"]; + // A native secure field, which iOS clears on the first delete after it takes focus. + BOOL secureEntry = + [NSProcessInfo.processInfo.arguments containsObject:@"--agent-device-text-entry-secure-entry"]; + BOOL bulletPlaceholder = + [NSProcessInfo.processInfo.arguments containsObject:@"--agent-device-text-entry-bullet-placeholder"]; + BOOL refusesFirstFocus = + [NSProcessInfo.processInfo.arguments containsObject:@"--agent-device-text-entry-refuses-first-focus"]; BOOL countsValueReads = [NSProcessInfo.processInfo.arguments containsObject:@"--agent-device-text-entry-counts-value-reads"]; BOOL witnessesReplacement = @@ -674,6 +681,12 @@ - (void)viewDidLoad { textField = [[AgentDeviceSubmitClearingTextField alloc] init]; } else if (maskedValue) { textField = [[AgentDeviceMaskedTextField alloc] init]; + } else if (secureEntry) { + AgentDeviceSecureEntryField *secureField = [[AgentDeviceSecureEntryField alloc] init]; + secureField.secureTextEntry = YES; + secureField.reportsPlaceholderAsValue = bulletPlaceholder; + secureField.refusesFirstFocus = refusesFirstFocus; + textField = secureField; } else if (witnessesReplacement) { textField = [[AgentDeviceTextEntryWitnessField alloc] init]; } else if (countsValueReads) { @@ -819,10 +832,14 @@ - (void)viewDidLoad { [neighbour.heightAnchor constraintEqualToConstant:AgentDeviceTextEntryFieldHeight], ]]; } - if (maskedValue) { + if (maskedValue || secureEntry) { if ([NSProcessInfo.processInfo.arguments containsObject:@"--agent-device-text-entry-prefilled"]) { textField.text = @"stale-secret"; } + // While empty, the field then reads the same as one holding eight characters. + if (bulletPlaceholder) { + textField.placeholder = @"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"; + } // The show/hide toggle sits over the field's right edge, where the runner's caret edge-tap // lands. Counting its presses tells the test whether a repair reached for the field again. UIButton *toggle = [UIButton buttonWithType:UIButtonTypeSystem]; @@ -853,6 +870,18 @@ - (void)viewDidLoad { [self.maskedDeliveryStatus.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor], [self.maskedDeliveryStatus.topAnchor constraintEqualToAnchor:self.maskedToggleStatus.bottomAnchor constant:8], ]]; + if (secureEntry) { + UILabel *counts = [[UILabel alloc] init]; + counts.accessibilityIdentifier = @"agent-device-secure-entry-counts"; + counts.text = @"deletes=0 taps=0"; + counts.translatesAutoresizingMaskIntoConstraints = NO; + [self.view addSubview:counts]; + [NSLayoutConstraint activateConstraints:@[ + [counts.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor], + [counts.topAnchor constraintEqualToAnchor:self.maskedDeliveryStatus.bottomAnchor constant:8], + ]]; + ((AgentDeviceSecureEntryField *)textField).countLabel = counts; + } [self updateMaskedToggleStatus]; } if ([NSProcessInfo.processInfo.arguments containsObject:@"--agent-device-text-entry-app-owned-value"]) { diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.h b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.h index 3b42987af0..4b1631ac05 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.h +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.h @@ -9,6 +9,15 @@ @interface AgentDeviceValueReadCountingTextField : AgentDeviceMaskedTextField @end +@interface AgentDeviceSecureEntryField : UITextField +// Shows how many deletes and taps the field received. +@property(nonatomic, weak) UILabel *countLabel; +// Refuses the first focus, as a field whose first tap the app consumes does. +@property(nonatomic, assign) BOOL refusesFirstFocus; +// Reports the placeholder as the value while empty, as a React Native secure input does. +@property(nonatomic, assign) BOOL reportsPlaceholderAsValue; +@end + @interface AgentDeviceValueReadCountLabel : UILabel @property(nonatomic, weak) UITextField *countedField; @end diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.m b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.m index 81544e0244..1038c35d9d 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.m +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/UnitTests/AgentDeviceTextEntryFields.m @@ -12,6 +12,59 @@ - (NSString *)accessibilityValue { } @end +@implementation AgentDeviceSecureEntryField { + NSUInteger _deletes; + NSUInteger _taps; +} +- (instancetype)init { + self = [super init]; + if (self) { + UITapGestureRecognizer *tapCounter = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(countTap:)]; + tapCounter.cancelsTouchesInView = NO; + tapCounter.delegate = self; + [self addGestureRecognizer:tapCounter]; + } + return self; +} + +- (void)countTap:(UITapGestureRecognizer *)recognizer { + (void)recognizer; + _taps += 1; + [self showCounts]; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { + (void)gestureRecognizer; + (void)otherGestureRecognizer; + return YES; +} + +- (void)showCounts { + self.countLabel.text = [NSString stringWithFormat:@"deletes=%lu taps=%lu", (unsigned long)_deletes, (unsigned long)_taps]; +} + +- (BOOL)becomeFirstResponder { + if (self.refusesFirstFocus) { + self.refusesFirstFocus = NO; + return NO; + } + return [super becomeFirstResponder]; +} + +- (void)deleteBackward { + _deletes += 1; + [self showCounts]; + [super deleteBackward]; +} + +- (NSString *)accessibilityValue { + if (self.reportsPlaceholderAsValue && self.text.length == 0) { + return self.placeholder; + } + return [super accessibilityValue]; +} +@end + static NSUInteger AgentDeviceTextEntryValueReads = 0; @implementation AgentDeviceValueReadCountingTextField diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift index ca8ec50d42..ceb0d6e25a 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift @@ -395,10 +395,10 @@ extension RunnerTests { /// Clears the reader's input. Every post goes through `reader.dispatch` and every read back through /// `reader.input()`, so a bound target's clear stops at an input that took its place. On iOS a - /// readable value is selected whole and deleted, wherever the caret is. Otherwise, or when text is - /// left, delete bursts run from the caret, and a value longer than one burst is read again after - /// each burst until it reads empty, stops shortening, or has had at least one burst more than it - /// needs. + /// readable value is selected whole and deleted, wherever the caret is, and a masked value gets + /// deletes before any caret tap. Otherwise, or when text is left, delete bursts run from the caret, + /// and a value longer than one burst is read again after each burst until it reads empty, stops + /// shortening, or has had at least one burst more than it needs. func clearTextInput(app: XCUIApplication, reader: inout TextEntryReader) throws { guard let input = try reader.input() else { return @@ -410,13 +410,41 @@ extension RunnerTests { // clearing; and replacing into an already-empty field is a no-op anyway. // editableTextValue returns nil for secure (and unknown) fields, where we CANNOT confirm // emptiness — those must still be cleared, or replace would concatenate stale + new text. - // So distinguish nil (clear) from "" (skip). + // So distinguish nil (clear) from "" (skip). On iOS the masked route below can still prove a + // masked field empty. let existing = editableTextValue(for: input.attributes, treatingPlaceholderAsEmpty: true) if existing?.isEmpty == true { return } let defersCaretTap = reader.target.reusesCurrentFocus var valueLength = normalizedElementText(input.attributes.value).count +#if os(iOS) + // A masked value cannot aim the caret tap, which lands at the field's right edge, where an app + // often draws a show/hide control: pressing it swaps the input (tester-army/e2e#1631). iOS clears + // a secure field on its first delete after the field takes focus, and deletes from a caret left + // at the end reach the rest, so deletes go first and the caret moves only for masked text left. + if textValueRead(for: input.attributes) == .unreadable { + if maskedTextShown(by: input) == .empty { + return + } + // Deletes into a field without focus record an XCTest failure, which tears down the runner. The + // focus step can leave focus unconfirmed, so the field gets the readiness repeat at its center, + // clear of a control at the edge. + if input.snapshot.map({ snapshotHasKeyboardFocus($0) }) != true { + try reader.dispatch { try retapAt(read: input, app: app, element: input.element) } + } + let burst = Self.textClearBurst(valueLength: valueLength) + reader.dispatch { input.element.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: burst)) } + // An input that stops answering (#3060) goes on to the caret tap and burst below. + if let cleared = try reader.input() { + let shown = maskedTextShown(by: cleared) + NSLog("AGENT_DEVICE_RUNNER_TEXT_ENTRY_CLEAR route=masked-deletes shown=%@", String(describing: shown)) + if shown == .empty || shown == .maskPlaceholder { + return + } + } + } +#endif // The tap also focuses the field, which a clear can reach with focus unconfirmed. #if !os(tvOS) if !defersCaretTap { @@ -513,6 +541,36 @@ extension RunnerTests { remainingLength > 0 && remainingLength < clearedLength } + /// What a masked field shows about its text. + enum MaskedTextShown: Equatable { + /// No text, or a placeholder that is not itself a mask: the field is empty. + case empty + /// A placeholder that is itself a mask, which text of the same length shows too. + case maskPlaceholder + /// A mask other than the placeholder, so text is in the field. + case mask + /// Any other value, which says nothing about the text. Like `.mask`, it leaves the clear to the + /// caret tap; the clear's log line tells the two apart. + case unknown + } + + static func maskedTextShown(value: String, showsPlaceholder: Bool) -> MaskedTextShown { + let shown = value.trimmingCharacters(in: .whitespacesAndNewlines) + if shown.isEmpty { + return .empty + } + if showsPlaceholder { + return isMaskedTextValue(shown) ? .maskPlaceholder : .empty + } + return isMaskedTextValue(shown) ? .mask : .unknown + } + + /// `maskedTextShown(value:showsPlaceholder:)` for `input`, with the placeholder rule the shared read uses. + func maskedTextShown(by input: ResolvedTextEntryInput) -> MaskedTextShown { + let value = normalizedElementText(input.attributes.value) + return Self.maskedTextShown(value: value, showsPlaceholder: isPlaceholderValue(value, for: input.attributes)) + } + func isTextEntryElement(_ element: XCUIElement) -> Bool { switch element.elementType { case .textField, .secureTextField, .searchField, .textView: diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift index b5d7726509..5ff43ad064 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift @@ -141,6 +141,19 @@ extension RunnerTests { XCTAssertFalse(Self.textClearContinues(clearedLength: 501, remainingLength: 640)) } + // A secure field shows its placeholder when empty and a mask otherwise, so only a mask other than + // the placeholder proves text is in it; a placeholder that is itself a mask proves nothing + // (tester-army/e2e#1631). + func testMaskedTextShownProvesTextOnlyWithAMaskOtherThanThePlaceholder() { + let bullets = { (count: Int) in String(repeating: "\u{2022}", count: count) } + XCTAssertEqual(Self.maskedTextShown(value: "", showsPlaceholder: false), .empty) + XCTAssertEqual(Self.maskedTextShown(value: "Password", showsPlaceholder: true), .empty) + XCTAssertEqual(Self.maskedTextShown(value: bullets(8), showsPlaceholder: true), .maskPlaceholder) + XCTAssertEqual(Self.maskedTextShown(value: bullets(3), showsPlaceholder: false), .mask) + XCTAssertEqual(Self.maskedTextShown(value: "\u{25CF}\u{25CF}", showsPlaceholder: false), .mask) + XCTAssertEqual(Self.maskedTextShown(value: "hunter2", showsPlaceholder: false), .unknown) + } + // One read owns readability for every route: a secure field is unreadable whatever it reports, // a plain field is unreadable only while its value is a mask, and anything that is not a text // input has no text to read. diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift index e692526a79..c4ad26eeae 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift @@ -580,6 +580,135 @@ extension RunnerTests { XCTAssertEqual(togglePresses.label, "presses=0") } + // A masked value cannot aim the clear's caret tap, which lands on a show/hide toggle at the field's + // right edge; in React Native the press swaps the input and the fill fails (tester-army/e2e#1631). + // The fixture's masked field shows one bullet per two characters, so 8 bullets is the new text alone. + @MainActor + func testFillReplacesAPrefilledMaskedValueWithoutPressingItsEdgeToggle() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-masked-value", "--agent-device-text-entry-prefilled"], + field: { $0.textFields }, + expectedValue: String(repeating: "\u{2022}", count: 8) + ) + } + + @MainActor + func testFillReplacesAPrefilledSecureFieldWithoutPressingItsEdgeToggle() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-secure-entry", "--agent-device-text-entry-prefilled"], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16) + ) + } + + // An empty secure field with no placeholder shows nothing, so nothing is cleared. + @MainActor + func testFirstFillIntoAnEmptySecureFieldSkipsTheClear() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-secure-entry"], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16) + ) + XCTAssertEqual(try secureEntryCounts().deletes, 0) + } + + // A field that refuses the focus tap reaches the clear without focus, and deletes sent to it record + // an XCTest failure. The clear focuses it at its center first. + @MainActor + func testFillReplacesTextInASecureFieldThatRefusedTheFocusTap() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: [ + "--agent-device-text-entry-secure-entry", + "--agent-device-text-entry-prefilled", + "--agent-device-text-entry-refuses-first-focus", + ], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16) + ) + } + + // The issue's own case: its placeholder is eight bullets, which React Native reports as the value of + // the empty field. + @MainActor + func testFirstFillIntoASecureFieldShowingABulletPlaceholderDoesNotPressItsEdgeToggle() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-secure-entry", "--agent-device-text-entry-bullet-placeholder"], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16) + ) + } + + // iOS doesn't clear a field that kept its focus on its next edit, and eight characters read the same + // as the eight-bullet placeholder, so the refill must still clear them. It reads the field's focus, + // so it adds no tap to the first fill's one. + @MainActor + func testRefillOfAFocusedSecureFieldClearsTextThatReadsLikeItsBulletPlaceholder() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-secure-entry", "--agent-device-text-entry-bullet-placeholder"], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16), + afterFilling: "stale-pw" + ) + XCTAssertEqual(try secureEntryCounts().taps, 1) + } + + /// Fills "not-a-secret-123" the way the daemon sends `fill`, after `earlierText` when given, and checks + /// the field holds the new text alone while the toggle over its right edge stays unpressed. + @MainActor + private func assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: [String], + field: (XCUIApplication) -> XCUIElementQuery, + expectedValue: String, + afterFilling earlierText: String? = nil + ) throws { + app.launchArguments = [ + "--agent-device-text-entry-regression", + "--agent-device-text-entry-soft-keyboard", + ] + launchArguments + app.launch() + addTeardownBlock { [self] in + invalidateCachedTarget(reason: "unit_test_cleanup") + app.terminate() + } + XCTAssertTrue(app.waitForFixtureExistence(timeout: appExistenceTimeout)) + let input = field(app)["agent-device-hardware-keyboard-input"] + XCTAssertTrue(input.waitForFixtureExistence(timeout: appExistenceTimeout)) + let togglePresses = app.staticTexts["agent-device-masked-toggle-presses"] + XCTAssertTrue(togglePresses.waitForFixtureExistence(timeout: appExistenceTimeout)) + XCTAssertEqual(togglePresses.label, "presses=0") + if let earlierText { + let earlier = try executeTypeCommand( + activeApp: app, + command: try fillCommandFixture(commandId: "fill-earlier-text", text: earlierText, at: input) + ) + XCTAssertTrue(earlier.ok, String(describing: earlier.error)) + let earlierValue = String(repeating: "\u{2022}", count: earlierText.count) + let filled = XCTNSPredicateExpectation(predicate: NSPredicate(format: "value == %@", earlierValue), object: input) + XCTAssertEqual(XCTWaiter.wait(for: [filled], timeout: appExistenceTimeout), .completed, String(describing: input.value)) + } + + let failureCountBefore = currentXCTestFailureCount() + let response = try executeTypeCommand( + activeApp: app, + command: try fillCommandFixture(commandId: "fill-masked-input-beside-toggle", text: "not-a-secret-123", at: input) + ) + + XCTAssertTrue(response.ok, String(describing: response.error)) + XCTAssertFalse(didRecordXCTestFailure(since: failureCountBefore)) + let replaced = XCTNSPredicateExpectation(predicate: NSPredicate(format: "value == %@", expectedValue), object: input) + XCTAssertEqual(XCTWaiter.wait(for: [replaced], timeout: appExistenceTimeout), .completed, String(describing: input.value)) + XCTAssertEqual(togglePresses.label, "presses=0") + } + + /// The deletes and taps the secure entry fixture's field received. + @MainActor + private func secureEntryCounts() throws -> (deletes: Int, taps: Int) { + let label = app.staticTexts["agent-device-secure-entry-counts"].label + let counts = try label.split(separator: " ").map { try XCTUnwrap(Int($0.split(separator: "=").last ?? ""), label) } + XCTAssertEqual(counts.count, 2, label) + return (counts.first ?? -1, counts.last ?? -1) + } + private struct UnavailableTextEntrySynthesizer: TextEntrySynthesizing { func enterText( app _: XCUIApplication, diff --git a/src/commands/schema/cli-help-workflows.ts b/src/commands/schema/cli-help-workflows.ts index 38629854c4..4cc0a4f644 100644 --- a/src/commands/schema/cli-help-workflows.ts +++ b/src/commands/schema/cli-help-workflows.ts @@ -186,7 +186,7 @@ Stabilizers: Re-enable settings you changed before finishing. Text-entry quirks: - Local iOS fill reuses focus when the current command identifies the target input and reads its keyboard focus. Readable focused inputs use select-all/delete with read-back before any fallback caret tap. + Local iOS fill reuses focus when the current command identifies the target input and reads its keyboard focus. Readable focused inputs use select-all/delete with read-back before any fallback caret tap. Secure inputs that show nothing or a placeholder that is not a mask are not cleared; other secure inputs get deletes with read-back before any fallback caret tap. iOS Allow Paste cannot be exercised under XCUITest; prefill with clipboard write "some text" instead and test the system prompt manually. Android Gboard handwriting/stylus UI can capture text in an IME-owned input instead of the app field. If fill reports that input was captured by the keyboard/IME, use the diagnostic targetInput/actualInput details, inspect keyboard status/get if needed, and switch or disable handwriting outside the command plan before retrying. Do not keep retrying fill/type against the same field while the IME owns focus. If the exact target changes but app-owned formatting prevents raw equality, fill succeeds with verification: "unconfirmed" plus target-bound requested/before/after evidence; inspect that evidence instead of retrying the same mutation. iOS accessibility-driven fill types the replacement once and never clears and retypes a read-back mismatch. Exact settled text confirms the entry. Nonempty replacements wait until the confirmation deadline before reporting TEXT_ENTRY_MISMATCH. A value containing only characters in order from the post-clear value plus the request fails with TEXT_ENTRY_MISMATCH, including plain dropped characters and unchanged values; legitimate trimming or masks can also hit this limit ("5" into "$0.00" displaying "$0.05"). Other settled values return verification: "unconfirmed" with requested/before/after/target evidence, including grouping ("00 062 91 77" for "000629177"), currency ("$10.00" for "1000"), and OTP summaries. Missing, reordered, duplicated or stale text can also be unconfirmed, so assert the expected value with a value selector, get/is, or the resulting screen before continuing. For single-line fills ending in a submit key, any non-matching value observed on the same target succeeds unverified, including partial or cleared text; this exception skips dropped-character checks because the submit may change the field. Assert the resulting screen. Multiline fields compare newlines as content. Unreadable or removed fields remain unverified. The coordinate-driven fill route still requires an exact match. After TEXT_ENTRY_MISMATCH, inspect the field and retry fill only if it needs correction, using the --delay-ms value from the error hint. diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index fa5c560ad0..90671aa839 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -497,7 +497,7 @@ A `click` or `press` whose target the daemon resolves to a point (`@ref` or sele ### Text entry - `fill` replaces the field value. `type` appends to the focused field and accepts text only: use `fill @ref "text"` to target a field, or `press @ref` then `type "text"`. -- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. +- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. A secure input, whose value is a mask, is not cleared when it shows nothing or a placeholder that is not a mask. Otherwise it gets deletes with read-back first, and the caret tap at the field's right edge, where a show/hide control often sits, runs only when the read-back does not show the field empty. - Use plain `fill` or `type` first. Add `--delay-ms` only when a debounced or search-as-you-type field misses characters, or the app must receive each incremental update; delayed typing enters characters one at a time instead of using a clipboard-style fallback. - `fill --text-stdin` reads the text from stdin so a secret never appears in process arguments. Pipe it with `printf %s`. It reads at most 64 KiB, removes one trailing newline, and refuses a terminal, empty input, invalid UTF-8, or an extra text argument. Output shows the value as `${VAR}` with `--record-as ` and as `[REDACTED]` otherwise, including in error messages and details, and in the `requested`, `before`, and `after` read-back of an unconfirmed fill, which can hold a reformatted form of the value. With `--settle`, the diff line text and tail labels are replaced whole, so text around the value in the field is not shown either; refs and counts stay. While script recording is armed, pass `--record-as ` or `--no-record`; passing neither is an error. Batch steps don't accept it. - The privacy controls for typed input (`--text-stdin` and `--record-as`) keep the literal out of agent-device's own responses, diagnostics, and recorded scripts. They do not rewrite what the platform records: on iOS, XCTest writes its own diagnostic logs and its `.xcresult` bundle, and typed text can appear in both, on a simulator or a physical device. Treat those as sensitive, and use test-only credentials when they may be kept or shared. See [Security and trust](/docs/security-trust). From c53d4c75fb8fcfa5c9fdf13adf65e6715d6dcc23 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 10 Nov 2026 12:35:33 +0530 Subject: [PATCH 02/10] test(runner): set the secure-entry count label only on its own field With both the masked-value and secure-entry fixture flags, the masked field wins, and the count label setup sent its setter to a field that has none. The setup now uses the secure-entry field it built. --- .../AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m index a404f703b9..05fb6966e9 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m @@ -670,6 +670,7 @@ - (void)viewDidLoad { BOOL witnessesReplacement = [NSProcessInfo.processInfo.arguments containsObject:@"--agent-device-text-entry-witness"]; UITextField *textField; + AgentDeviceSecureEntryField *secureField = nil; if (digitCountValue) { textField = [[AgentDeviceDigitCountTextField alloc] init]; } else if (digitGroupingValue) { @@ -682,7 +683,7 @@ - (void)viewDidLoad { } else if (maskedValue) { textField = [[AgentDeviceMaskedTextField alloc] init]; } else if (secureEntry) { - AgentDeviceSecureEntryField *secureField = [[AgentDeviceSecureEntryField alloc] init]; + secureField = [[AgentDeviceSecureEntryField alloc] init]; secureField.secureTextEntry = YES; secureField.reportsPlaceholderAsValue = bulletPlaceholder; secureField.refusesFirstFocus = refusesFirstFocus; @@ -870,7 +871,7 @@ - (void)viewDidLoad { [self.maskedDeliveryStatus.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor], [self.maskedDeliveryStatus.topAnchor constraintEqualToAnchor:self.maskedToggleStatus.bottomAnchor constant:8], ]]; - if (secureEntry) { + if (secureField) { UILabel *counts = [[UILabel alloc] init]; counts.accessibilityIdentifier = @"agent-device-secure-entry-counts"; counts.text = @"deletes=0 taps=0"; @@ -880,7 +881,7 @@ - (void)viewDidLoad { [counts.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor], [counts.topAnchor constraintEqualToAnchor:self.maskedDeliveryStatus.bottomAnchor constant:8], ]]; - ((AgentDeviceSecureEntryField *)textField).countLabel = counts; + secureField.countLabel = counts; } [self updateMaskedToggleStatus]; } From 39d567ac5099b62486dd1e93df3d07699ab2c244 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 10 Nov 2026 12:35:33 +0530 Subject: [PATCH 03/10] docs(fill): describe the iOS clear for masked inputs The masked-value clear applies to any input whose value is a mask, not only secure fields. A masked input showing its placeholder is not cleared, except a secure field whose placeholder is bullets. --- src/commands/schema/cli-help-workflows.ts | 2 +- website/docs/docs/commands.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/schema/cli-help-workflows.ts b/src/commands/schema/cli-help-workflows.ts index 4cc0a4f644..2585cb3dd3 100644 --- a/src/commands/schema/cli-help-workflows.ts +++ b/src/commands/schema/cli-help-workflows.ts @@ -186,7 +186,7 @@ Stabilizers: Re-enable settings you changed before finishing. Text-entry quirks: - Local iOS fill reuses focus when the current command identifies the target input and reads its keyboard focus. Readable focused inputs use select-all/delete with read-back before any fallback caret tap. Secure inputs that show nothing or a placeholder that is not a mask are not cleared; other secure inputs get deletes with read-back before any fallback caret tap. + Local iOS fill reuses focus when the current command identifies the target input and reads its keyboard focus. Readable focused inputs use select-all/delete with read-back before any fallback caret tap. Masked inputs, such as secure fields, that show nothing or their placeholder are not cleared, except a secure field whose placeholder is bullets; other masked inputs get deletes with read-back before any fallback caret tap. iOS Allow Paste cannot be exercised under XCUITest; prefill with clipboard write "some text" instead and test the system prompt manually. Android Gboard handwriting/stylus UI can capture text in an IME-owned input instead of the app field. If fill reports that input was captured by the keyboard/IME, use the diagnostic targetInput/actualInput details, inspect keyboard status/get if needed, and switch or disable handwriting outside the command plan before retrying. Do not keep retrying fill/type against the same field while the IME owns focus. If the exact target changes but app-owned formatting prevents raw equality, fill succeeds with verification: "unconfirmed" plus target-bound requested/before/after evidence; inspect that evidence instead of retrying the same mutation. iOS accessibility-driven fill types the replacement once and never clears and retypes a read-back mismatch. Exact settled text confirms the entry. Nonempty replacements wait until the confirmation deadline before reporting TEXT_ENTRY_MISMATCH. A value containing only characters in order from the post-clear value plus the request fails with TEXT_ENTRY_MISMATCH, including plain dropped characters and unchanged values; legitimate trimming or masks can also hit this limit ("5" into "$0.00" displaying "$0.05"). Other settled values return verification: "unconfirmed" with requested/before/after/target evidence, including grouping ("00 062 91 77" for "000629177"), currency ("$10.00" for "1000"), and OTP summaries. Missing, reordered, duplicated or stale text can also be unconfirmed, so assert the expected value with a value selector, get/is, or the resulting screen before continuing. For single-line fills ending in a submit key, any non-matching value observed on the same target succeeds unverified, including partial or cleared text; this exception skips dropped-character checks because the submit may change the field. Assert the resulting screen. Multiline fields compare newlines as content. Unreadable or removed fields remain unverified. The coordinate-driven fill route still requires an exact match. After TEXT_ENTRY_MISMATCH, inspect the field and retry fill only if it needs correction, using the --delay-ms value from the error hint. diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index 90671aa839..d5c77e7451 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -497,7 +497,7 @@ A `click` or `press` whose target the daemon resolves to a point (`@ref` or sele ### Text entry - `fill` replaces the field value. `type` appends to the focused field and accepts text only: use `fill @ref "text"` to target a field, or `press @ref` then `type "text"`. -- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. A secure input, whose value is a mask, is not cleared when it shows nothing or a placeholder that is not a mask. Otherwise it gets deletes with read-back first, and the caret tap at the field's right edge, where a show/hide control often sits, runs only when the read-back does not show the field empty. +- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. A masked input, such as a secure field, is not cleared when it shows nothing or its placeholder, except a secure field whose placeholder is bullets, because text of that length reads the same. Otherwise it gets deletes with read-back first, and the caret tap at the field's right edge, where a show/hide control often sits, runs only when the read-back does not show the field empty. - Use plain `fill` or `type` first. Add `--delay-ms` only when a debounced or search-as-you-type field misses characters, or the app must receive each incremental update; delayed typing enters characters one at a time instead of using a clipboard-style fallback. - `fill --text-stdin` reads the text from stdin so a secret never appears in process arguments. Pipe it with `printf %s`. It reads at most 64 KiB, removes one trailing newline, and refuses a terminal, empty input, invalid UTF-8, or an extra text argument. Output shows the value as `${VAR}` with `--record-as ` and as `[REDACTED]` otherwise, including in error messages and details, and in the `requested`, `before`, and `after` read-back of an unconfirmed fill, which can hold a reformatted form of the value. With `--settle`, the diff line text and tail labels are replaced whole, so text around the value in the field is not shown either; refs and counts stay. While script recording is armed, pass `--record-as ` or `--no-record`; passing neither is an error. Batch steps don't accept it. - The privacy controls for typed input (`--text-stdin` and `--record-as`) keep the literal out of agent-device's own responses, diagnostics, and recorded scripts. They do not rewrite what the platform records: on iOS, XCTest writes its own diagnostic logs and its `.xcresult` bundle, and typed text can appear in both, on a simulator or a physical device. Treat those as sensitive, and use test-only credentials when they may be kept or shared. See [Security and trust](/docs/security-trust). From 35cf7dad38ba3519bcc48e3905bfb3e69b3d6020 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 10 Nov 2026 13:23:24 +0530 Subject: [PATCH 04/10] fix(ios): clear a masked field whose bullets match its placeholder A replacement skipped the clear whenever the value read as the placeholder, so a plain masked field holding text as long as its bullet placeholder kept the stale text and the fill appended to it. On iOS a bullet-only value is no longer proof of an empty field, even when it equals the placeholder: such a field goes to the masked clear, which deletes and reads it back. Readability and verification reads are unchanged. --- .../RunnerTests+TextEntry.swift | 25 ++++++++++--- .../RunnerTests+TextTyping.swift | 2 +- .../RunnerTests+TextTypingTests.swift | 35 ++++++++++++++----- src/commands/schema/cli-help-workflows.ts | 2 +- website/docs/docs/commands.md | 2 +- 5 files changed, 50 insertions(+), 16 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift index ceb0d6e25a..0f1a151bb1 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift @@ -408,11 +408,11 @@ extension RunnerTests { // be stale after the field repositions on focus (e.g. the Settings search bar jumps // bottom->top and reveals a "Suggestions" list) — tapping there navigates away instead of // clearing; and replacing into an already-empty field is a no-op anyway. - // editableTextValue returns nil for secure (and unknown) fields, where we CANNOT confirm - // emptiness — those must still be cleared, or replace would concatenate stale + new text. - // So distinguish nil (clear) from "" (skip). On iOS the masked route below can still prove a - // masked field empty. - let existing = editableTextValue(for: input.attributes, treatingPlaceholderAsEmpty: true) + // textValueForClear returns nil for secure (and unknown) fields, and on iOS for a placeholder + // that is itself a mask, where we CANNOT confirm emptiness — those must still be cleared, or + // replace would concatenate stale + new text. So distinguish nil (clear) from "" (skip). On iOS + // the masked route below can still prove a masked field empty. + let existing = textValueForClear(input.attributes) if existing?.isEmpty == true { return } @@ -807,6 +807,21 @@ extension RunnerTests { return value } + /// The text a clear can trust in the input `attributes` describe, with a placeholder read as empty; + /// nil when unreadable. On iOS a placeholder that is itself a mask is nil too, since text of its length + /// shows it as well: the masked clear reads that field back instead of skipping it. + func textValueForClear(_ attributes: (any XCUIElementAttributes)?) -> String? { + guard let value = editableTextValue(for: attributes, treatingPlaceholderAsEmpty: true) else { + return nil + } +#if os(iOS) + if value.isEmpty, Self.isMaskedTextValue(normalizedElementText(attributes?.value)) { + return nil + } +#endif + return value + } + /// Whether an accessibility value is a masked rendering of a secure field: one or more /// password bullets and nothing else. The bullet count need not match the typed length, so /// such a value carries no information about what the field holds. A field whose real text is diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift index 4ec331f5a0..21a5a0f617 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift @@ -123,7 +123,7 @@ extension RunnerTests { logTextEntryPhase(commandId: commandId, phase: "total", startedAt: totalStartedAt, chars: text.count, mode: repairMode) return TextEntryResult(verified: nil, repaired: false, expectedText: expectedText, observedText: nil) } - if currentText == nil || currentText?.isEmpty == false { + if textValueForClear(initialTarget?.attributes)?.isEmpty != true { let clearStartedAt = Date() try clearTextInput(app: app, reader: &reader) logTextEntryPhase( diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift index c4ad26eeae..37cfe1267c 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift @@ -638,6 +638,21 @@ extension RunnerTests { ) } + // A plain masked field whose eight bullets match its eight-bullet placeholder can't be told from empty + // either, so the refill still clears it. The fixture shows one bullet per two characters, so the 18 + // characters refilled show as 9 bullets, and kept stale text would show as 17. + @MainActor + func testRefillOfAMaskedFieldClearsTextThatReadsLikeItsBulletPlaceholder() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-masked-value", "--agent-device-text-entry-bullet-placeholder"], + field: { $0.textFields }, + text: "not-a-secret-12345", + expectedValue: String(repeating: "\u{2022}", count: 9), + afterFilling: "abcdefghijklmnop", + showing: String(repeating: "\u{2022}", count: 8) + ) + } + // iOS doesn't clear a field that kept its focus on its next edit, and eight characters read the same // as the eight-bullet placeholder, so the refill must still clear them. It reads the field's focus, // so it adds no tap to the first fill's one. @@ -652,14 +667,17 @@ extension RunnerTests { XCTAssertEqual(try secureEntryCounts().taps, 1) } - /// Fills "not-a-secret-123" the way the daemon sends `fill`, after `earlierText` when given, and checks - /// the field holds the new text alone while the toggle over its right edge stays unpressed. + /// Fills `text` the way the daemon sends `fill`, after `earlierText` when given (which the field shows + /// as `earlierValue`, one bullet per character by default), and checks the field holds the new text + /// alone while the toggle over its right edge stays unpressed. @MainActor private func assertFillLeavesTheEdgeToggleUnpressed( launchArguments: [String], field: (XCUIApplication) -> XCUIElementQuery, + text: String = "not-a-secret-123", expectedValue: String, - afterFilling earlierText: String? = nil + afterFilling earlierText: String? = nil, + showing earlierValue: String? = nil ) throws { app.launchArguments = [ "--agent-device-text-entry-regression", @@ -677,20 +695,21 @@ extension RunnerTests { XCTAssertTrue(togglePresses.waitForFixtureExistence(timeout: appExistenceTimeout)) XCTAssertEqual(togglePresses.label, "presses=0") if let earlierText { - let earlier = try executeTypeCommand( + // Only the field this fill leaves is the precondition: a result that shows as a bullet placeholder + // reads back as that placeholder, which fill's own check reports as a mismatch. + _ = try executeTypeCommand( activeApp: app, command: try fillCommandFixture(commandId: "fill-earlier-text", text: earlierText, at: input) ) - XCTAssertTrue(earlier.ok, String(describing: earlier.error)) - let earlierValue = String(repeating: "\u{2022}", count: earlierText.count) - let filled = XCTNSPredicateExpectation(predicate: NSPredicate(format: "value == %@", earlierValue), object: input) + let shown = earlierValue ?? String(repeating: "\u{2022}", count: earlierText.count) + let filled = XCTNSPredicateExpectation(predicate: NSPredicate(format: "value == %@", shown), object: input) XCTAssertEqual(XCTWaiter.wait(for: [filled], timeout: appExistenceTimeout), .completed, String(describing: input.value)) } let failureCountBefore = currentXCTestFailureCount() let response = try executeTypeCommand( activeApp: app, - command: try fillCommandFixture(commandId: "fill-masked-input-beside-toggle", text: "not-a-secret-123", at: input) + command: try fillCommandFixture(commandId: "fill-masked-input-beside-toggle", text: text, at: input) ) XCTAssertTrue(response.ok, String(describing: response.error)) diff --git a/src/commands/schema/cli-help-workflows.ts b/src/commands/schema/cli-help-workflows.ts index 2585cb3dd3..3336cd68a8 100644 --- a/src/commands/schema/cli-help-workflows.ts +++ b/src/commands/schema/cli-help-workflows.ts @@ -186,7 +186,7 @@ Stabilizers: Re-enable settings you changed before finishing. Text-entry quirks: - Local iOS fill reuses focus when the current command identifies the target input and reads its keyboard focus. Readable focused inputs use select-all/delete with read-back before any fallback caret tap. Masked inputs, such as secure fields, that show nothing or their placeholder are not cleared, except a secure field whose placeholder is bullets; other masked inputs get deletes with read-back before any fallback caret tap. + Local iOS fill reuses focus when the current command identifies the target input and reads its keyboard focus. Readable focused inputs use select-all/delete with read-back before any fallback caret tap. Masked inputs, such as secure fields, that show nothing or a placeholder that is not a mask are not cleared; other masked inputs get deletes with read-back before any fallback caret tap. iOS Allow Paste cannot be exercised under XCUITest; prefill with clipboard write "some text" instead and test the system prompt manually. Android Gboard handwriting/stylus UI can capture text in an IME-owned input instead of the app field. If fill reports that input was captured by the keyboard/IME, use the diagnostic targetInput/actualInput details, inspect keyboard status/get if needed, and switch or disable handwriting outside the command plan before retrying. Do not keep retrying fill/type against the same field while the IME owns focus. If the exact target changes but app-owned formatting prevents raw equality, fill succeeds with verification: "unconfirmed" plus target-bound requested/before/after evidence; inspect that evidence instead of retrying the same mutation. iOS accessibility-driven fill types the replacement once and never clears and retypes a read-back mismatch. Exact settled text confirms the entry. Nonempty replacements wait until the confirmation deadline before reporting TEXT_ENTRY_MISMATCH. A value containing only characters in order from the post-clear value plus the request fails with TEXT_ENTRY_MISMATCH, including plain dropped characters and unchanged values; legitimate trimming or masks can also hit this limit ("5" into "$0.00" displaying "$0.05"). Other settled values return verification: "unconfirmed" with requested/before/after/target evidence, including grouping ("00 062 91 77" for "000629177"), currency ("$10.00" for "1000"), and OTP summaries. Missing, reordered, duplicated or stale text can also be unconfirmed, so assert the expected value with a value selector, get/is, or the resulting screen before continuing. For single-line fills ending in a submit key, any non-matching value observed on the same target succeeds unverified, including partial or cleared text; this exception skips dropped-character checks because the submit may change the field. Assert the resulting screen. Multiline fields compare newlines as content. Unreadable or removed fields remain unverified. The coordinate-driven fill route still requires an exact match. After TEXT_ENTRY_MISMATCH, inspect the field and retry fill only if it needs correction, using the --delay-ms value from the error hint. diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index d5c77e7451..d9c0b522eb 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -497,7 +497,7 @@ A `click` or `press` whose target the daemon resolves to a point (`@ref` or sele ### Text entry - `fill` replaces the field value. `type` appends to the focused field and accepts text only: use `fill @ref "text"` to target a field, or `press @ref` then `type "text"`. -- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. A masked input, such as a secure field, is not cleared when it shows nothing or its placeholder, except a secure field whose placeholder is bullets, because text of that length reads the same. Otherwise it gets deletes with read-back first, and the caret tap at the field's right edge, where a show/hide control often sits, runs only when the read-back does not show the field empty. +- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. A masked input, such as a secure field, is not cleared when it shows nothing or a placeholder that is not a mask. Otherwise it gets deletes with read-back first, and the caret tap at the field's right edge, where a show/hide control often sits, runs only when the read-back does not show the field empty. - Use plain `fill` or `type` first. Add `--delay-ms` only when a debounced or search-as-you-type field misses characters, or the app must receive each incremental update; delayed typing enters characters one at a time instead of using a clipboard-style fallback. - `fill --text-stdin` reads the text from stdin so a secret never appears in process arguments. Pipe it with `printf %s`. It reads at most 64 KiB, removes one trailing newline, and refuses a terminal, empty input, invalid UTF-8, or an extra text argument. Output shows the value as `${VAR}` with `--record-as ` and as `[REDACTED]` otherwise, including in error messages and details, and in the `requested`, `before`, and `after` read-back of an unconfirmed fill, which can hold a reformatted form of the value. With `--settle`, the diff line text and tail labels are replaced whole, so text around the value in the field is not shown either; refs and counts stay. While script recording is armed, pass `--record-as ` or `--no-record`; passing neither is an error. Batch steps don't accept it. - The privacy controls for typed input (`--text-stdin` and `--record-as`) keep the literal out of agent-device's own responses, diagnostics, and recorded scripts. They do not rewrite what the platform records: on iOS, XCTest writes its own diagnostic logs and its `.xcresult` bundle, and typed text can appear in both, on a simulator or a physical device. Treat those as sensitive, and use test-only credentials when they may be kept or shared. See [Security and trust](/docs/security-trust). From a482a7c97e30cf58a5cc20982d3002f64fb51ead Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 10 Nov 2026 14:00:51 +0530 Subject: [PATCH 05/10] test(runner): check the refill tests' first fill by its length An empty field with a bullet placeholder shows the same bullets as the first fill's text, so waiting for them proved nothing. The masked fixtures now show the field's text length, and the refill tests wait for it before refilling. --- .../AgentDeviceRunnerAppFixtures.m | 16 ++++++++++++- .../RunnerTests+TextTypingTests.swift | 23 ++++++++++--------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m index 05fb6966e9..6017f73888 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerAppFixtures.m @@ -45,6 +45,7 @@ @interface AgentDeviceRunnerFixtureViewController () XCUIElementQuery, text: String = "not-a-secret-123", expectedValue: String, - afterFilling earlierText: String? = nil, - showing earlierValue: String? = nil + afterFilling earlierText: String? = nil ) throws { app.launchArguments = [ "--agent-device-text-entry-regression", @@ -696,14 +693,18 @@ extension RunnerTests { XCTAssertEqual(togglePresses.label, "presses=0") if let earlierText { // Only the field this fill leaves is the precondition: a result that shows as a bullet placeholder - // reads back as that placeholder, which fill's own check reports as a mismatch. + // reads back as that placeholder, which fill's own check reports as a mismatch. An empty field + // shows that placeholder too, so the app's length witness tells the two apart. _ = try executeTypeCommand( activeApp: app, command: try fillCommandFixture(commandId: "fill-earlier-text", text: earlierText, at: input) ) - let shown = earlierValue ?? String(repeating: "\u{2022}", count: earlierText.count) - let filled = XCTNSPredicateExpectation(predicate: NSPredicate(format: "value == %@", shown), object: input) - XCTAssertEqual(XCTWaiter.wait(for: [filled], timeout: appExistenceTimeout), .completed, String(describing: input.value)) + let length = app.staticTexts["agent-device-masked-text-length"] + let filled = XCTNSPredicateExpectation( + predicate: NSPredicate(format: "label == %@", "length=\(earlierText.count)"), + object: length + ) + XCTAssertEqual(XCTWaiter.wait(for: [filled], timeout: appExistenceTimeout), .completed, length.label) } let failureCountBefore = currentXCTestFailureCount() From fa2b299a81953f401ac705c3e7daa75d184f7e36 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 10 Nov 2026 14:00:51 +0530 Subject: [PATCH 06/10] docs(fill): name the masked-placeholder read-back that skips the tap After the deletes, the edge caret tap is also skipped when the field reads back as a masked placeholder, not only when it reads empty. --- website/docs/docs/commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index d9c0b522eb..45112c91b4 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -497,7 +497,7 @@ A `click` or `press` whose target the daemon resolves to a point (`@ref` or sele ### Text entry - `fill` replaces the field value. `type` appends to the focused field and accepts text only: use `fill @ref "text"` to target a field, or `press @ref` then `type "text"`. -- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. A masked input, such as a secure field, is not cleared when it shows nothing or a placeholder that is not a mask. Otherwise it gets deletes with read-back first, and the caret tap at the field's right edge, where a show/hide control often sits, runs only when the read-back does not show the field empty. +- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. A masked input, such as a secure field, is not cleared when it shows nothing or a placeholder that is not a mask. Otherwise it gets deletes with read-back first, and the caret tap at the field's right edge, where a show/hide control often sits, runs only when the read-back shows neither an empty value nor a masked placeholder. - Use plain `fill` or `type` first. Add `--delay-ms` only when a debounced or search-as-you-type field misses characters, or the app must receive each incremental update; delayed typing enters characters one at a time instead of using a clipboard-style fallback. - `fill --text-stdin` reads the text from stdin so a secret never appears in process arguments. Pipe it with `printf %s`. It reads at most 64 KiB, removes one trailing newline, and refuses a terminal, empty input, invalid UTF-8, or an extra text argument. Output shows the value as `${VAR}` with `--record-as ` and as `[REDACTED]` otherwise, including in error messages and details, and in the `requested`, `before`, and `after` read-back of an unconfirmed fill, which can hold a reformatted form of the value. With `--settle`, the diff line text and tail labels are replaced whole, so text around the value in the field is not shown either; refs and counts stay. While script recording is armed, pass `--record-as ` or `--no-record`; passing neither is an error. Batch steps don't accept it. - The privacy controls for typed input (`--text-stdin` and `--record-as`) keep the literal out of agent-device's own responses, diagnostics, and recorded scripts. They do not rewrite what the platform records: on iOS, XCTest writes its own diagnostic logs and its `.xcresult` bundle, and typed text can appear in both, on a simulator or a physical device. Treat those as sensitive, and use test-only credentials when they may be kept or shared. See [Security and trust](/docs/security-trust). From 939214c2598e5d694176cd0033b64c3b6480f12a Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 11 Nov 2026 01:30:26 +0530 Subject: [PATCH 07/10] fix(ios): focus an empty masked field before skipping its clear The masked clear returned for an empty field before its focus check, so an empty secure field whose focus tap was refused was typed into without focus, which records an XCTest failure. The old edge tap had focused it. From review: the clear's mask-placeholder rule now applies on every platform, the read-back has three cases, an input that stops answering after the deletes gets no caret tap (its one burst, as for #3060), and a test covers the caret-tap fallback for masked text the deletes can't reach. The rule stays out of textValueRead. There it turns a formatted read-back in a field that reports a bullet placeholder, such as a PIN field, from unconfirmed into TEXT_ENTRY_MISMATCH. --- .../RunnerTests+TextEntry.swift | 47 +++++++++---------- .../RunnerTests+TextEntryPolicyTests.swift | 13 +++-- .../RunnerTests+TextTypingTests.swift | 41 ++++++++++++++++ 3 files changed, 69 insertions(+), 32 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift index 0f1a151bb1..dd9728f126 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift @@ -408,8 +408,8 @@ extension RunnerTests { // be stale after the field repositions on focus (e.g. the Settings search bar jumps // bottom->top and reveals a "Suggestions" list) — tapping there navigates away instead of // clearing; and replacing into an already-empty field is a no-op anyway. - // textValueForClear returns nil for secure (and unknown) fields, and on iOS for a placeholder - // that is itself a mask, where we CANNOT confirm emptiness — those must still be cleared, or + // textValueForClear returns nil for secure (and unknown) fields, and for a placeholder that is + // itself a mask, where we CANNOT confirm emptiness — those must still be cleared, or // replace would concatenate stale + new text. So distinguish nil (clear) from "" (skip). On iOS // the masked route below can still prove a masked field empty. let existing = textValueForClear(input.attributes) @@ -424,24 +424,25 @@ extension RunnerTests { // a secure field on its first delete after the field takes focus, and deletes from a caret left // at the end reach the rest, so deletes go first and the caret moves only for masked text left. if textValueRead(for: input.attributes) == .unreadable { - if maskedTextShown(by: input) == .empty { - return - } - // Deletes into a field without focus record an XCTest failure, which tears down the runner. The - // focus step can leave focus unconfirmed, so the field gets the readiness repeat at its center, - // clear of a control at the edge. + // Deletes or text sent to a field without focus record an XCTest failure, which tears down the + // runner. The focus step can leave focus unconfirmed, so the field gets the readiness repeat at + // its center, clear of a control at the edge, even when it is empty and needs no clear. if input.snapshot.map({ snapshotHasKeyboardFocus($0) }) != true { try reader.dispatch { try retapAt(read: input, app: app, element: input.element) } } + if maskedTextShown(by: input) == .empty { + return + } let burst = Self.textClearBurst(valueLength: valueLength) reader.dispatch { input.element.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: burst)) } - // An input that stops answering (#3060) goes on to the caret tap and burst below. - if let cleared = try reader.input() { - let shown = maskedTextShown(by: cleared) - NSLog("AGENT_DEVICE_RUNNER_TEXT_ENTRY_CLEAR route=masked-deletes shown=%@", String(describing: shown)) - if shown == .empty || shown == .maskPlaceholder { - return - } + // An input that stops answering (#3060) has had its one burst, as below. + guard let cleared = try reader.input() else { + return + } + let shown = maskedTextShown(by: cleared) + NSLog("AGENT_DEVICE_RUNNER_TEXT_ENTRY_CLEAR route=masked-deletes shown=%@", String(describing: shown)) + if shown != .text { + return } } #endif @@ -547,11 +548,8 @@ extension RunnerTests { case empty /// A placeholder that is itself a mask, which text of the same length shows too. case maskPlaceholder - /// A mask other than the placeholder, so text is in the field. - case mask - /// Any other value, which says nothing about the text. Like `.mask`, it leaves the clear to the - /// caret tap; the clear's log line tells the two apart. - case unknown + /// Anything else, such as a mask other than the placeholder: text may be in the field. + case text } static func maskedTextShown(value: String, showsPlaceholder: Bool) -> MaskedTextShown { @@ -562,7 +560,7 @@ extension RunnerTests { if showsPlaceholder { return isMaskedTextValue(shown) ? .maskPlaceholder : .empty } - return isMaskedTextValue(shown) ? .mask : .unknown + return .text } /// `maskedTextShown(value:showsPlaceholder:)` for `input`, with the placeholder rule the shared read uses. @@ -808,17 +806,16 @@ extension RunnerTests { } /// The text a clear can trust in the input `attributes` describe, with a placeholder read as empty; - /// nil when unreadable. On iOS a placeholder that is itself a mask is nil too, since text of its length - /// shows it as well: the masked clear reads that field back instead of skipping it. + /// nil when unreadable. A placeholder that is itself a mask is nil too, since text of its length shows + /// it as well, so that field is cleared instead of skipped. Only the clear reads it this way: the + /// shared read keeps such a placeholder empty for verification, as a PIN field that shows its digits needs. func textValueForClear(_ attributes: (any XCUIElementAttributes)?) -> String? { guard let value = editableTextValue(for: attributes, treatingPlaceholderAsEmpty: true) else { return nil } -#if os(iOS) if value.isEmpty, Self.isMaskedTextValue(normalizedElementText(attributes?.value)) { return nil } -#endif return value } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift index 5ff43ad064..96cf147896 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextEntryPolicyTests.swift @@ -141,17 +141,16 @@ extension RunnerTests { XCTAssertFalse(Self.textClearContinues(clearedLength: 501, remainingLength: 640)) } - // A secure field shows its placeholder when empty and a mask otherwise, so only a mask other than - // the placeholder proves text is in it; a placeholder that is itself a mask proves nothing - // (tester-army/e2e#1631). - func testMaskedTextShownProvesTextOnlyWithAMaskOtherThanThePlaceholder() { + // A secure field shows its placeholder when empty and a mask otherwise. A placeholder that is not a + // mask proves it empty; one that is itself a mask proves nothing, since text of its length shows it + // too (tester-army/e2e#1631). + func testMaskedTextShownTellsAnEmptyFieldFromAMaskPlaceholder() { let bullets = { (count: Int) in String(repeating: "\u{2022}", count: count) } XCTAssertEqual(Self.maskedTextShown(value: "", showsPlaceholder: false), .empty) XCTAssertEqual(Self.maskedTextShown(value: "Password", showsPlaceholder: true), .empty) XCTAssertEqual(Self.maskedTextShown(value: bullets(8), showsPlaceholder: true), .maskPlaceholder) - XCTAssertEqual(Self.maskedTextShown(value: bullets(3), showsPlaceholder: false), .mask) - XCTAssertEqual(Self.maskedTextShown(value: "\u{25CF}\u{25CF}", showsPlaceholder: false), .mask) - XCTAssertEqual(Self.maskedTextShown(value: "hunter2", showsPlaceholder: false), .unknown) + XCTAssertEqual(Self.maskedTextShown(value: bullets(3), showsPlaceholder: false), .text) + XCTAssertEqual(Self.maskedTextShown(value: "hunter2", showsPlaceholder: false), .text) } // One read owns readability for every route: a secure field is unreadable whatever it reports, diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift index 1c87d227e1..507d299a9c 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift @@ -627,6 +627,47 @@ extension RunnerTests { ) } + // An empty one needs no clear, but the text typed next needs focus just as the deletes do. + @MainActor + func testFirstFillIntoAnEmptySecureFieldThatRefusedTheFocusTap() throws { + try assertFillLeavesTheEdgeToggleUnpressed( + launchArguments: ["--agent-device-text-entry-secure-entry", "--agent-device-text-entry-refuses-first-focus"], + field: { $0.secureTextFields }, + expectedValue: String(repeating: "\u{2022}", count: 16) + ) + XCTAssertEqual(try secureEntryCounts().deletes, 0) + } + + // Deletes from a caret moved to the start reach none of the text, so the clear falls back to the caret + // tap at the right edge, which in this fixture lands on the toggle: the limit `fill`'s docs name. + @MainActor + func testMaskedTextTheDeletesCannotReachFallsBackToTheCaretTap() throws { + app.launchArguments = [ + "--agent-device-text-entry-regression", + "--agent-device-text-entry-soft-keyboard", + "--agent-device-text-entry-masked-value", + "--agent-device-text-entry-prefilled", + ] + app.launch() + addTeardownBlock { [self] in + invalidateCachedTarget(reason: "unit_test_cleanup") + app.terminate() + } + let input = app.textFields["agent-device-hardware-keyboard-input"] + XCTAssertTrue(input.waitForFixtureExistence(timeout: appExistenceTimeout)) + let togglePresses = app.staticTexts["agent-device-masked-toggle-presses"] + XCTAssertTrue(togglePresses.waitForFixtureExistence(timeout: appExistenceTimeout)) + input.coordinate(withNormalizedOffset: CGVector(dx: 0.02, dy: 0.5)).tap() + + let response = try executeTypeCommand( + activeApp: app, + command: try fillCommandFixture(commandId: "fill-caret-at-start", text: "abc", at: input) + ) + + XCTAssertTrue(response.ok, String(describing: response.error)) + XCTAssertEqual(togglePresses.label, "presses=1") + } + // The issue's own case: its placeholder is eight bullets, which React Native reports as the value of // the empty field. @MainActor From 78ffd181cefc88f02c3f3142b3bd72761c61eeb7 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 11 Nov 2026 01:30:26 +0530 Subject: [PATCH 08/10] docs(fill): name the masked read-back limit Masked text the deletes cannot reach that shows as many bullets as the placeholder reads as cleared, so fill types the new text next to it. --- src/commands/schema/cli-help-workflows.ts | 2 +- website/docs/docs/commands.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/schema/cli-help-workflows.ts b/src/commands/schema/cli-help-workflows.ts index 3336cd68a8..29b7ab5114 100644 --- a/src/commands/schema/cli-help-workflows.ts +++ b/src/commands/schema/cli-help-workflows.ts @@ -186,7 +186,7 @@ Stabilizers: Re-enable settings you changed before finishing. Text-entry quirks: - Local iOS fill reuses focus when the current command identifies the target input and reads its keyboard focus. Readable focused inputs use select-all/delete with read-back before any fallback caret tap. Masked inputs, such as secure fields, that show nothing or a placeholder that is not a mask are not cleared; other masked inputs get deletes with read-back before any fallback caret tap. + Local iOS fill reuses focus when the current command identifies the target input and reads its keyboard focus. Readable focused inputs use select-all/delete with read-back before any fallback caret tap. Masked inputs, such as secure fields, that show nothing or a placeholder that is not a mask are not cleared; other masked inputs get deletes with read-back before any fallback caret tap. Masked text the deletes can't reach that shows as many bullets as the placeholder reads as cleared, so the new text is typed next to it. iOS Allow Paste cannot be exercised under XCUITest; prefill with clipboard write "some text" instead and test the system prompt manually. Android Gboard handwriting/stylus UI can capture text in an IME-owned input instead of the app field. If fill reports that input was captured by the keyboard/IME, use the diagnostic targetInput/actualInput details, inspect keyboard status/get if needed, and switch or disable handwriting outside the command plan before retrying. Do not keep retrying fill/type against the same field while the IME owns focus. If the exact target changes but app-owned formatting prevents raw equality, fill succeeds with verification: "unconfirmed" plus target-bound requested/before/after evidence; inspect that evidence instead of retrying the same mutation. iOS accessibility-driven fill types the replacement once and never clears and retypes a read-back mismatch. Exact settled text confirms the entry. Nonempty replacements wait until the confirmation deadline before reporting TEXT_ENTRY_MISMATCH. A value containing only characters in order from the post-clear value plus the request fails with TEXT_ENTRY_MISMATCH, including plain dropped characters and unchanged values; legitimate trimming or masks can also hit this limit ("5" into "$0.00" displaying "$0.05"). Other settled values return verification: "unconfirmed" with requested/before/after/target evidence, including grouping ("00 062 91 77" for "000629177"), currency ("$10.00" for "1000"), and OTP summaries. Missing, reordered, duplicated or stale text can also be unconfirmed, so assert the expected value with a value selector, get/is, or the resulting screen before continuing. For single-line fills ending in a submit key, any non-matching value observed on the same target succeeds unverified, including partial or cleared text; this exception skips dropped-character checks because the submit may change the field. Assert the resulting screen. Multiline fields compare newlines as content. Unreadable or removed fields remain unverified. The coordinate-driven fill route still requires an exact match. After TEXT_ENTRY_MISMATCH, inspect the field and retry fill only if it needs correction, using the --delay-ms value from the error hint. diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index 45112c91b4..7441151dd0 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -497,7 +497,7 @@ A `click` or `press` whose target the daemon resolves to a point (`@ref` or sele ### Text entry - `fill` replaces the field value. `type` appends to the focused field and accepts text only: use `fill @ref "text"` to target a field, or `press @ref` then `type "text"`. -- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. A masked input, such as a secure field, is not cleared when it shows nothing or a placeholder that is not a mask. Otherwise it gets deletes with read-back first, and the caret tap at the field's right edge, where a show/hide control often sits, runs only when the read-back shows neither an empty value nor a masked placeholder. +- iOS, including Limrun, `fill` avoids another focus tap when the current command identifies the target input and reads its keyboard focus. For readable focused inputs, clearing tries select-all/delete and reads the result before moving the caret for delete-burst fallback. Newly focused inputs retain caret preparation. A masked input, such as a secure field, is not cleared when it shows nothing or a placeholder that is not a mask. Otherwise it gets deletes with read-back first, and the caret tap at the field's right edge, where a show/hide control often sits, runs only when the read-back shows neither an empty value nor a masked placeholder. If the deletes can't reach the text, for example after the caret was moved off the end, and that text shows as many bullets as the placeholder, the read-back can't tell it from empty, so the new text is typed at the caret, next to the old text. - Use plain `fill` or `type` first. Add `--delay-ms` only when a debounced or search-as-you-type field misses characters, or the app must receive each incremental update; delayed typing enters characters one at a time instead of using a clipboard-style fallback. - `fill --text-stdin` reads the text from stdin so a secret never appears in process arguments. Pipe it with `printf %s`. It reads at most 64 KiB, removes one trailing newline, and refuses a terminal, empty input, invalid UTF-8, or an extra text argument. Output shows the value as `${VAR}` with `--record-as ` and as `[REDACTED]` otherwise, including in error messages and details, and in the `requested`, `before`, and `after` read-back of an unconfirmed fill, which can hold a reformatted form of the value. With `--settle`, the diff line text and tail labels are replaced whole, so text around the value in the field is not shown either; refs and counts stay. While script recording is armed, pass `--record-as ` or `--no-record`; passing neither is an error. Batch steps don't accept it. - The privacy controls for typed input (`--text-stdin` and `--record-as`) keep the literal out of agent-device's own responses, diagnostics, and recorded scripts. They do not rewrite what the platform records: on iOS, XCTest writes its own diagnostic logs and its `.xcresult` bundle, and typed text can appear in both, on a simulator or a physical device. Treat those as sensitive, and use test-only credentials when they may be kept or shared. See [Security and trust](/docs/security-trust). From 864ace9a783e5df1c05ef513316221b68115c2d2 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 11 Nov 2026 01:57:30 +0530 Subject: [PATCH 09/10] fix(ios): log the masked clear skip of an empty field The masked clear logged its route only after the deletes, so a skipped empty field left no line in runner.log. --- .../AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift index dd9728f126..fcf43a3409 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift @@ -431,6 +431,7 @@ extension RunnerTests { try reader.dispatch { try retapAt(read: input, app: app, element: input.element) } } if maskedTextShown(by: input) == .empty { + NSLog("AGENT_DEVICE_RUNNER_TEXT_ENTRY_CLEAR route=masked-skip shown=empty") return } let burst = Self.textClearBurst(valueLength: valueLength) From 569032096af8317a7b4d5a0b7e339ca957f7d5e2 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 11 Nov 2026 02:40:25 +0530 Subject: [PATCH 10/10] fix(ios): keep the caret-tap fallback when the masked read-back finds no input 939214c25 ended the clear there instead. No fixture stops answering in the middle of a clear, so that change had no test; this restores the behavior at fa2b299a8. Also drops a test comment that named the wrong limit. --- .../RunnerTests+TextEntry.swift | 15 +++++++-------- .../UnitTests/RunnerTests+TextTypingTests.swift | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift index fcf43a3409..f7d1e4b878 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift @@ -436,14 +436,13 @@ extension RunnerTests { } let burst = Self.textClearBurst(valueLength: valueLength) reader.dispatch { input.element.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: burst)) } - // An input that stops answering (#3060) has had its one burst, as below. - guard let cleared = try reader.input() else { - return - } - let shown = maskedTextShown(by: cleared) - NSLog("AGENT_DEVICE_RUNNER_TEXT_ENTRY_CLEAR route=masked-deletes shown=%@", String(describing: shown)) - if shown != .text { - return + // An input that stops answering (#3060) goes on to the caret tap and burst below. + if let cleared = try reader.input() { + let shown = maskedTextShown(by: cleared) + NSLog("AGENT_DEVICE_RUNNER_TEXT_ENTRY_CLEAR route=masked-deletes shown=%@", String(describing: shown)) + if shown != .text { + return + } } } #endif diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift index 507d299a9c..b5709a0428 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift @@ -639,7 +639,7 @@ extension RunnerTests { } // Deletes from a caret moved to the start reach none of the text, so the clear falls back to the caret - // tap at the right edge, which in this fixture lands on the toggle: the limit `fill`'s docs name. + // tap at the right edge, which in this fixture lands on the toggle. @MainActor func testMaskedTextTheDeletesCannotReachFallsBackToTheCaretTap() throws { app.launchArguments = [