Skip to content

Fix UI accessibility contrast, touch targets, and vitest storage on Node 24 - #61

Open
ruibaby wants to merge 1 commit into
mainfrom
fix/ui-a11y-tests
Open

ruibaby wants to merge 1 commit into
mainfrom
fix/ui-a11y-tests

Conversation

@ruibaby

@ruibaby ruibaby commented Nov 29, 2026

Copy link
Copy Markdown
Member

Problem

  1. Front-end tests fail on Node 24 without NODE_OPTIONS workarounds: 57 of 340 specs die with TypeError: Cannot read properties of undefined (reading 'setItem').
  2. Several surfaces break the accessibility floor documented in DESIGN.md: metadata uses text-gray-400 (#9ca3af, 2.6:1 on white), metadata text is 11px, mobile controls are 28–32px, and the canvas zoom control's accessible name never matches the percentage it shows.

Cause

Node 24 defines localStorage/sessionStorage accessors on globalThis that resolve to undefined unless --localstorage-file is passed. jsdom's populateGlobal only fills in globals that are absent, so the broken Node accessors shadow the real Storage instances on the jsdom window.

Changes

  • Add ui/vitest.setup.ts to re-point localStorage/sessionStorage at globalThis.jsdom.window, guarded so a missing jsdom window is a no-op. Register it from ui/vitest.config.ts and pin the jsdom URL so storage has a non-opaque origin.
  • Raise metadata and help text from gray-400 to gray-500 across page cards, preview placeholders, preset groups, import help, and the archive dropzone. The remaining gray-400 usages are decorative icons only.
  • Lift 11px metadata to 12px in PageCard.
  • Grow the canvas zoom controls and the composer send/stop buttons to 44px below the md breakpoint; desktop sizes are unchanged.
  • Include the current scale in the zoom control's accessible name, and match it by prefix in the canvas spec.

Reproduction

Node 24.22.3, NODE_OPTIONS unset:

pnpm --dir ui test:unit --run

Before: Test Files 3 failed | 28 passed (31), Tests 57 failed | 283 passed (340).
After: Test Files 31 passed (31), Tests 340 passed (340).

Validation

  • pnpm --dir ui type-check — no errors.
  • pnpm --dir ui test:unit --run — 340 passed, NODE_OPTIONS empty.
  • pnpm --dir ui build — succeeds, only the pre-existing chunk-size warning.
  • Isolated Halo instance (bash gradlew haloServer, plugin in dev mode), measured in the browser at 1440px and 375px: metadata renders at 12px #6b7280; zoom buttons are 28×28 at 1440px and 44×44 at 375px; send is 32×32 at 1440px and 44×44 at 375px; the zoom control's accessible name reads 适应画布,当前 27%.

Reviewer note

The run-status and theme-warning badges move from 11px to 12px. DESIGN.md allows 10–11px for badges specifically; this trades that exception for the 12px floor. Revert those two classes if the badge spec should win.

Screenshots

Captured from the isolated instance at 1440×900 and 375×812.

Page list, metadata in muted gray at 12px:

Page list

Create screen, preset group labels and the manual-create/import links:

Create screen

Workbench at 1440px, zoom control unchanged at 28px:

Workbench desktop

Canvas at 375px, zoom buttons at 44px with the scale in the accessible name:

Canvas mobile

Composer at 375px, send at 44px:

Composer mobile

The instance ships AI Foundation 1.0.0, below the 1.1.1 this plugin requires, so the composer and preset chips render in their disabled state and no generation flow is shown. Everything else above is the real packaged plugin UI.

Node 24 exposes localStorage/sessionStorage getters that resolve to
undefined without --localstorage-file, and jsdom's populateGlobal does not
override existing globals, so all Storage-based specs failed. Point the
globals at the jsdom window in a vitest setup file and pin the jsdom URL.

Raise metadata text from quiet gray to muted gray, lift the 11px metadata
to the 12px floor, grow mobile zoom and send/stop controls to 44px, and
include the current scale in the zoom control's accessible name.
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