Skip to content

Add container visualization for accessibility snapshots#278

Draft
RoyalPineapple wants to merge 6 commits intomainfrom
a11y-container-graph
Draft

Add container visualization for accessibility snapshots#278
RoyalPineapple wants to merge 6 commits intomainfrom
a11y-container-graph

Conversation

@RoyalPineapple
Copy link
Copy Markdown
Collaborator

@RoyalPineapple RoyalPineapple commented Dec 2, 2025

Supersedes previous container visualization attempts on this branch with a clean rebuild from main.

Summary

  • Fix overlay alignment by parsing accessibility hierarchy before rendering the snapshot image
  • Add container visualization for accessibility snapshot legends (showContainers configuration flag)
  • Record iOS 26.4 reference images for AccessibilitySnapshotPreviews tests

Details

Overlay alignment fix

drawHierarchy(afterScreenUpdates:true) can trigger safe area layout changes that shift UICollectionView-backed content. When parsing happened after rendering, the parser read frames from a different layout state than what the image captured. Fix: parse before rendering.

Container legend

When showContainers is enabled, the legend renders a hierarchical view that groups elements by their accessibility containers using dashed borders and container badges. The snapshot area (image + overlays) is identical regardless of showContainers — only the legend content changes.

New types:

  • HierarchyColorAssignment — assigns color indices to hierarchy nodes
  • ContainerLegendEntryView — dashed-border legend entry with badge
  • HierarchyLegendView — recursive hierarchical legend renderer

Demo includes SemanticGroupWrapper — a lightweight UIViewRepresentable that sets accessibilityContainerType = .semanticGroup since SwiftUI has no native equivalent.

Test plan

  • All existing snapshot tests pass
  • New container demo tests (with and without containers) produce aligned overlays
  • Container legend correctly groups elements by container with dashed borders
  • Overlay alignment verified with both drawHierarchyInRect and renderLayerInContext
  • iOS 26.4 reference images recorded

🤖 Generated with Claude Code

@RoyalPineapple RoyalPineapple changed the title Add accessibility container visualization with hierarchy support [WIP] Add accessibility container visualization with hierarchy support Dec 3, 2025
@RoyalPineapple RoyalPineapple force-pushed the a11y-container-graph branch 3 times, most recently from 3d8c515 to 3733a88 Compare December 3, 2025 16:40
@RoyalPineapple RoyalPineapple changed the title [WIP] Add accessibility container visualization with hierarchy support Add hierarchical accessibility parsing API Dec 4, 2025
@RoyalPineapple RoyalPineapple force-pushed the a11y-container-graph branch 7 times, most recently from 452d709 to b531faf Compare December 9, 2025 12:45
Copy link
Copy Markdown
Collaborator Author

@RoyalPineapple RoyalPineapple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still in progress

@RoyalPineapple RoyalPineapple force-pushed the a11y-container-graph branch 9 times, most recently from e2c65ec to bb6609f Compare January 28, 2026 17:21
@RoyalPineapple RoyalPineapple changed the title Add hierarchical accessibility parsing API Add container visualization for accessibility snapshots Jan 28, 2026
@RoyalPineapple RoyalPineapple changed the base branch from main to a11y-hierarchy-parsing January 28, 2026 17:22
@RoyalPineapple RoyalPineapple changed the base branch from a11y-hierarchy-parsing to main January 28, 2026 17:28
Conductor and others added 4 commits April 7, 2026 17:45
drawHierarchy(afterScreenUpdates:true) can trigger safe area layout
changes that shift UICollectionView-backed content (e.g. List cells).
When parsing happened after rendering, the parser read frames from
a different layout state than what the image captured.

Fix: parse the accessibility hierarchy before rendering the snapshot
image, so drawHierarchy captures the same layout state the parser read.

Also updates the test helper to accept a configuration parameter and
adds iOS 26.4 to tested device configs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When showContainers is enabled in the configuration, the legend
renders a hierarchical view that groups elements by their accessibility
containers using dashed borders and container badges.

New files:
- HierarchyColorAssignment: assigns color indices to hierarchy nodes
- ContainerLegendEntryView: dashed-border legend entry with badge
- HierarchyLegendView: recursive hierarchical legend renderer
- ContainerDemo: demo using SemanticGroupWrapper for real UIKit containers

Changes:
- AccessibilitySnapshotConfiguration: add showContainers flag
- ParsedAccessibilityData: add hierarchy tree (not just flat markers)
- SwiftUIAccessibilitySnapshotView: swap legend based on showContainers
- SwiftUIAccessibilitySnapshotContainerView: pass hierarchy through

The snapshot area (image + overlays) is identical regardless of
showContainers — only the legend content changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
drawHierarchyInRect renders content with safe area offsets applied,
causing a ~68pt misalignment between overlay positions and rendered
content. renderLayerInContext renders the layer tree directly without
safe area effects, producing correctly aligned overlays.

Also updates HierarchyColorAssignment to use traversal-order-based
element indexing so legend colors match overlay colors, and re-records
all iOS 26.4 reference images with the corrected rendering mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Container badges now display the container's label, type, or identifier
instead of just a number. Semantic groups show "label: value" when both
are present, or just the label/value/identifier individually. Other
container types show their type name (List, Landmark, Tab Bar, etc.).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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