Skip to content

docs: design notes for a live-UI box model - #11

Merged
woladi merged 1 commit into
mainfrom
docs/box-model
Aug 24, 2026
Merged

woladi merged 1 commit into
mainfrom
docs/box-model

Conversation

@woladi

@woladi woladi commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Analysis only — no implementation, no code touched.

Answers the question "can we give an agent a JSON box model of a live layout, with colours and borders?" and decides where that work belongs. Everything is measured on an M1 Pro rather than assumed.

What the probes found

  • AX coverage is much better than earlier notes here guessed. Finder returns geometry for 100% of elements, the Electron-based Claude app 99% across 25 levels, Safari 99% including the full web-content tree.
  • No styling in AX — verified by enumerating every attribute name across four apps — with one exception: AXAttributedStringForRange carries real AXFont family/name/size and alignment, so typography is fact, not an estimate from OCR box heights.
  • The AX walk is the bottleneck, not pixels. Every attribute read is a synchronous IPC round trip: 4001 elements cost 1.57 s in Safari but 11.34 s in Finder, batched. Colours cost 90 ms to decode the capture once, then 0.009 ms per element.

Conclusion

Implement here, not in macos-vision-mcp: the tree walk needs a compiled Swift helper and this package owns the native-helper pipeline — the same reason ui-helper moved here. Follows the existing inferLayout / buildPageAnalysis split, with composition here and tool shaping in the MCP server.

The doc states the limits up front: this is not the CSS box model, padding and border width are inferred rather than measured, occluded elements have untrustworthy colours, and for web pages the DevTools protocol already returns the real thing.

Merging this unblocks an implementation agent working from docs/BOX-MODEL.md.

🤖 Generated with Claude Code

Analysis only, no implementation. Records what macOS can actually give
an LLM about an on-screen layout — element boxes, hierarchy, colours,
typography — and where that work belongs.

Measured rather than assumed, on an M1 Pro:

- AX coverage is much better than earlier notes in this project guessed.
  Finder returns geometry for 100% of elements, the Electron-based Claude
  app 99% across 25 levels, Safari 99% including full web content.
- AX exposes no styling attributes at all — verified by enumerating every
  attribute name across four apps — with one exception:
  AXAttributedStringForRange carries real AXFont family/name/size and
  alignment, so typography need not be estimated from OCR box heights.
- The bottleneck is the AX walk, not pixels: every attribute read is a
  synchronous IPC round trip. 4001 elements cost 1.57s in Safari but
  11.34s in Finder, batched. Colours cost 90ms to decode the capture once
  and 0.009ms per element after that.

Concludes that this belongs here rather than in macos-vision-mcp: the
tree walk needs a compiled Swift helper, and this package owns the
native-helper pipeline — the same reason ui-helper moved here. Follows
the existing inferLayout/buildPageAnalysis split, with composition here
and tool shaping in the MCP server.

States the limits up front: this is not the CSS box model, padding and
border width are inferred rather than measured, occluded elements have
untrustworthy colours, and for web pages the DevTools protocol already
returns the real thing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@woladi
woladi merged commit c9d814e into main Aug 24, 2026
1 check passed
@woladi
woladi deleted the docs/box-model branch August 24, 2026 16:00
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.

1 participant