Skip to content

Add an HTML design system gallery with native component captures - #1121

Open
ivanfenenko wants to merge 4 commits into
mainfrom
feature/component-gallery
Open

ivanfenenko wants to merge 4 commits into
mainfrom
feature/component-gallery

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds an internal design system tool: an HTML replica of every Component Gallery entry on both platforms, with real simulator and emulator captures of each state next to it.

HTML gallery (scripts/component-gallery/)

  • Replicates all 82 gallery components (78 Android entries plus 4 iOS-only) in plain HTML, CSS, and JavaScript, with no framework or bundler.
  • iOS and Android phone frames, including iPhone Duo poses from docs/devices/iphone-duo/geometry.json.
  • The five theme presets in light and dark, resolved with a port of ThemeResolver, plus text size.
  • Every variant and state on one screen, a Playground for single instances, an element inspector, and Spec, Tokens, Parity, and Native tabs.
  • Themes, icons, file-type icons, specs, and the component list are read from the repo by build.mjs.
  • npm run gallery builds and serves it with live reload. npm run gallery:check fails when a native gallery entry has no HTML component.

Native captures

  • iOS: a debug-only capture registry and host next to the Component Gallery, a UI test that captures every state in one app launch, and scripts/component-gallery/capture-ios.sh. A full run takes about 5 minutes.
  • Android: a debug-only capture registry, an instrumented Compose test, and scripts/component-gallery/capture-android.sh. A full run takes about 3 minutes.
  • Both refuse to run on a simulator or AVD that is not a dedicated capture device (Component Capture… / component_capture…), so a personal device is never erased or reconfigured.
  • Both read captures/contract.json, exported from the HTML gallery so state ids match across HTML, iOS, and Android. States a platform cannot draw are recorded as skipped with a reason; approximations carry a note.
  • npm run gallery:html-captures renders the HTML side at the native width and scale, for a swipe comparison in the Native tab.
  • Captures and generated data are git-ignored.

App code touched outside the gallery

  • Gallery sample data moved into shared fixtures or made internal, so captures reuse it.
  • iOS pressed preview (OpenCodePressedPreview.swift): an environment value the press styles of Button, Floating Chrome, Floating Pill Chrome, Action Tile, List Item, and Hunk Navigation Pill read next to isPressed. It compiles into Release but never matches there, so it cannot change the app.
  • iOS Debug-only: keyboard focus for the focus-ring capture, an inline Bottom Sheet preview, and a launch argument in OpenCode_MobileApp.swift. Dialog and Modal cards are internal.
  • AppearanceSettingsView.swift and AppearanceSettingsScreen.kt: the syntax sample is internal.

Skill

  • .agents/skills/component-captures/ explains how to recapture after changing a component, and how to add captures for a new component or state.

Checks

  • iOS and Android both covered
  • Screenshots for UI changes: no user-facing app UI change; the app changes are debug-only capture hooks and gallery fixtures. The tool runs locally with npm run gallery.
  • Tests run
    • Android: :app:compileDebugKotlin, :app:compileReleaseKotlin, :app:compileDebugAndroidTestKotlin, and componentgallery unit tests pass after rebasing on main.
    • iOS: Debug, Release, and build-for-testing succeed after rebasing on main. Unit tests for touched components passed before the rebase.
    • Full capture runs on both platforms after the review fixes: iOS 1072 tiles, Android 1048 tiles, no missing states. The capture scripts refuse non-capture devices and the gallery server returns 400 for malformed URLs (checked by hand).
    • Full capture runs on both platforms report no missing states. npm run gallery:check passes (82 of 82).

Risks / Follow-ups

  • SwiftLint and ktlint were not run locally.
  • iOS/Android differences found while building the replicas stay local: the Parity tab reads them from the git-ignored scripts/component-gallery/divergences/ folder when present. None are committed, since they are unverified.
  • HTML replicas approximate Liquid Glass, Material elevation, and spring motion.

scripts/component-gallery replicates every design-system component in HTML with iOS and Android phone frames, themes, states, specs, and a Native tab that shows simulator and emulator captures of each state. npm run gallery serves it, gallery:check checks coverage, and gallery:html-captures renders the HTML side for the swipe comparison. Adds the component-captures skill.
…llery

Adds a debug-only capture registry and host next to the Component Gallery, a UI test that saves one PNG per component state in light and dark, and scripts/component-gallery/capture-ios.sh. Gallery sample data moves into shared fixtures so the captures reuse it.
… gallery

Adds a debug-only capture registry, an instrumented test that saves one PNG per component state in light and dark, and scripts/component-gallery/capture-android.sh. Gallery sample builders become internal so the captures reuse them.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review: no finding that 2+ of 3 passes agreed on.

8 finding(s) from a single pass, not posted
  • scripts/component-gallery/capture-android.sh:210 high: Android capture never fails on missing tiles (muse-spark-1.3-contributor)
  • scripts/component-gallery/check.mjs:18 high: Gallery check ignores per-state coverage (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/Components/Input/OpenCodeKeyboardFocusable.swift:277 medium: Delayed capture focus not cancelled on disappear (muse-spark-1.3-contributor)
  • android/app/src/androidTest/java/dev/opencode/mobile/ui/componentgallery/capture/ComponentCaptureTest.kt:259 medium: Overlay crop can go out of screenshot bounds (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/ComponentGallery/Capture/ComponentCaptureHost.swift:143 medium: Stale tile frame reported for next step (muse-spark-1.3-contributor)
  • scripts/component-gallery/render-html.html:14 medium: Center-aligned components render left-aligned in HTML captures (deepseek-v4.1-flash)
  • scripts/component-gallery/shell.js:108 low: Unvalidated theme id from the URL hash crashes the gallery (deepseek-v4.1-flash)
  • scripts/component-gallery/native-tab.js:14 low: Skipped captures recorded with state "*" are shown as merely missing (deepseek-v4.1-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.136

…evices

Divergence notes now load at build time from the git-ignored divergences/ folder instead of living in the component files. The capture scripts refuse simulators and AVDs that are not dedicated capture devices, clean up their staging folder, write one log per run, and pick a phone system image for the host CPU. The gallery server returns 400 for malformed URLs. iOS capture focus hooks compile only in Debug and the pressed preview never matches in Release. Gallery sample paths use /Users/example.

This branch has not been deployed

No deployments
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