[Bug]: macOS `get_window_state` reports a text field's placeholder as its `value` when the field is empty or whitespace
Primary area
Cua Driver
Summary
On macOS the AX walk substitutes AXPlaceholderValue into value whenever AXValue is empty or whitespace-only, and trims what it keeps. An empty text field therefore reports its placeholder as its content, the caller cannot tell an empty field from one whose real content equals its placeholder, a verify_state predicate on value == "" can never be satisfied, and a set_value to "" cannot be read back.
Reproduction
- Launch the AppKit harness fixture (
libs/cua-driver/tests/fixtures/apps/macos/appkit, built bytests/fixtures/build/macos.sh); itstxt-inputfield has the placeholderType here…. AnyNSTextFieldwith a placeholder behaves the same. get_window_stateon the fixture window; note theelement_indexof thetxt-inputrow.set_valueon that element with"value": "", then"\n", then" \tΩ café\n", snapshotting after each.
Expected behavior
elements[].value is the raw AXValue after each write ("", "\n", " \tΩ café\n"); the placeholder, if reported at all, is a separate field.
Actual behavior
cua-driver 0.28.0, mcp --direct, same fixture:
set_value |
elements[].value reads back |
tree_markdown row |
|---|---|---|
"hello" |
"hello" |
AXTextField = "hello" |
"" |
"Type here…" |
AXTextField = "Type here…" |
"\n" |
"Type here…" |
AXTextField = "Type here…" |
" \tΩ café\n" |
"Ω café" |
AXTextField = "Ω café" |
Nothing in the result says which rows are placeholders. Whitespace is also trimmed from a non-empty value, so a value containing a newline is rewritten as well.
Environment
Cua component and version/commit: cua-driver 0.28.0 (cua-driver-rs-v0.28.0, e7e141ae)
Operating system and architecture: macOS 26.1, arm64
Application/browser/window system/image: AppKit harness fixture (NSTextField with placeholderString); any AppKit text field with a placeholder
Evidence
platform-macos/src/ax/tree.rs::walk_element: let value = value.filter(|v| !v.trim().is_empty()).or_else(|| copy_string_attr(element, "AXPlaceholderValue")); with the comment "AXPlaceholderValue as fallback for empty text fields", followed by visible_value = value.trim() feeding both AXNode.value and the structured element. Apple documents AXPlaceholderValue as a hint, never the control's current value.
Workaround and additional context
None that is reliable from the tool result: distinguishing a placeholder from content requires reading AX directly. Related but distinct: #2958 (AXStaticText values invisible to verify_state).
Submission checks
- [x] I searched for duplicate issues and active pull requests.
- [x] This issue describes a single problem.
- [x] I removed credentials, private data, sensitive screenshots, and vulnerability details from this public report.
I'd like to take this. Plan: in ax/tree.rs, keep value as the raw AXValue and drop the AXPlaceholderValue fallback. The placeholder moves to its own placeholder field on the node and in the get_window_state output, so an empty field reads as empty and agents still see the hint. That adds a field and removes nothing.
Evidence: a unit test for an empty field with a placeholder set, plus a before/after on a real text field.
#3787 covered this before it was closed as stale, so credit to @will-bogusz. #5921 rewrites the same lines; I'll keep this change small so whichever lands second has an easy rebase.