Skip to content

feat(web): add canonical theme preference - #371

Open
testikun wants to merge 1 commit into
openpi-dev:mainfrom
testikun:codex/issue-350-canonical-theme
Open

feat(web): add canonical theme preference#371
testikun wants to merge 1 commit into
openpi-dev:mainfrom
testikun:codex/issue-350-canonical-theme

Conversation

@testikun

@testikun testikun commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Problem

OpenPI Web had no package-owned theme preference. A browser-local choice would create a second source of truth and drift from the canonical /openpi-setup contract. This implements the canonical theme slice of #350 without overlapping PR #359's language/localStorage work.

Value

Users can choose system, light, or dark once through OpenPI setup, see that choice in no-argument setup status, and have every Web client render the same authoritative preference. The default follows the browser/OS color scheme.

Approach

  • Add ui.webTheme to MyPiSetupConfig, defaulting and failing closed to system.
  • Extend the episode-scoped typed setup writer with ui_web_theme, update status/prompt/docs/defaults, and register the field in the config drift guard.
  • Project the canonical preference in WebSnapshot; the browser resolves system with prefers-color-scheme and never persists a competing theme value.
  • Refactor Web colors into semantic light/dark tokens so interactive, code, menu, dialog, and composer states remain coherent.

Validation

  • bun run check — passed, including the 15-field configuration contract.
  • bun run test — passed: Node 1241 passed / 1 platform skip; Vitest 30 passed.
  • Focused setup/config/Web suites — 95 passed.
  • Runtime provenance: isolated pi list reported the single OpenPI source /tmp/openpi-issue-350, whose checkout was based on 72fbba52832841cfc78c2f7e7947eeb89efc73bc plus this PR commit.
  • Real local Workbench test: canonical ui.webTheme=dark produced preferences.theme=dark from /api/snapshot and rendered the final dark UI in an actual browser. No mock image was used. The 1280×720 screenshot is attached to the first feat(web): add persistent theme/language preferences and accessibility/mobile hardening #350 claim comment.

Impact

  • User-visible behavior: OpenPI Web gains canonical system/light/dark themes; default remains system-following.
  • Model-visible context/tools: the existing setup tool gains one bounded enum field only during setup episodes; no ordinary-turn tool is added.
  • Runtime/lifecycle: snapshots synchronously read the small canonical setup document; system mode reacts to browser color-scheme changes for the page lifetime.
  • Persisted config/data: adds optional canonical ui.webTheme; old or invalid documents read safely as system and are normalized on the next setup write.
  • Compatibility/risk: additive protocol field with protocol version unchanged; older clients ignore it, and the new client safely falls back to system if absent.

@github-actions github-actions Bot added documentation Improvements or additions to documentation area:setup OpenPI setup, configuration, or setup documentation labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:setup OpenPI setup, configuration, or setup documentation documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant