BrowserOS icon indicating copy to clipboard operation
BrowserOS copied to clipboard

Snapshot never shows checkbox/radio state on real Chrome: tristate AX values are strings, the renderer compares booleans

Open WindriseAI opened this issue 4 weeks ago • 0 comments

Problem

The accessibility snapshot is supposed to serialize form-control state (checked, selected, expanded, ...), but on real Chrome no checkbox or radio ever shows a state bit: a checked checkbox and an unchecked one render identical lines, and act check reports success with no change since last snapshot even though the state did change.

Root cause

checked is a CDP tristate property. Real Chrome sends it as a string:

{ "name": "checked", "value": { "type": "tristate", "value": "true" } }

(You can see this in the repo's own captured fixture: packages/browseros-agent/crates/browseros-core/tests/data/captured/form/get-full-ax-tree.json.) But both renderers only compare against JavaScript booleans:

  • packages/browseros-agent/packages/browser-core/src/core/snapshot/render.ts → formatStates(): if (v === true) states.push('checked'), else if (v === 'mixed') ...
  • packages/browseros-agent/crates/browseros-core/src/snapshot/render.rs → format_states(): value == Some(&Value::Bool(true)), Value::String("mixed")

So "true"/"false" strings match neither branch and the state is silently dropped on real devices. Only the unit-test fixtures (which use real booleans) make it look like it works. Note selected/disabled/expanded are plain boolean/booleanOrUndefined and do render — only the tristate checked is affected.

Steps to reproduce

  1. Open https://the-internet.herokuapp.com/checkboxes.
  2. Snapshot; check the first checkbox via act { kind: "check" }.
  3. Snapshot again and read the diff.

Expected: the line gains a checked state (ideally checked/unchecked so "unchecked" is distinguishable from "no checked semantics"). Actual: identical lines, diff says no change.

Suggested fix

  • Accept both shapes in formatStates/format_states: booleans and "true"/"false"/"mixed" strings.
  • While here: report unchecked explicitly (the AX property is always present for checkbox/radio/switch), and let strVal/str_val fall back to numeric values so spinbutton/number inputs don't lose their value (typeof value === 'string' currently drops them).

I have a small patch series that does exactly this (both renderers, plus tests) and would be happy to send a PR.

WindriseAI avatar Nov 05 '26 19:11 WindriseAI