Skip to content

refactor(ui): migrate sidebar visual properties to cva variants - #403

Merged
Astro-Han merged 3 commits into
mainfrom
opencode/390-sidebar-polish
Jul 1, 2026
Merged

refactor(ui): migrate sidebar visual properties to cva variants#403
Astro-Han merged 3 commits into
mainfrom
opencode/390-sidebar-polish

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrate sidebar SessionListPanel visual properties from hand-written .maka-* CSS to cva variants aligned with ui.tsx governance, and fix the collapsed Storybook story rendering.

Why

Closes #390. The sidebar carried ~180 lines of visual CSS (hover, active, focus, disabled, pending states for nav-row, settings, row-action) duplicating what cva variants already govern through buttonVariants in ui.tsx. Font sizes had drifted to seven tiers (9.5/10/10.5/11/12/13/14px) with no design intent. The collapsed story was blank because .agents-sidebar[data-collapsed="true"] { width: 0 } (correct in the app, where an outer resizable container sets width) collapsed the panel inside Storybook's 72px block container.

Scope

Changed:

  • packages/ui/src/session-list-panel.tsx — add 3 cva variants (navRowVariants, settingsButtonVariants, rowActionVariants); unify all sidebar UiButton to size="nav" + cva variant.
  • apps/desktop/src/renderer/styles/sidebar.css — remove ~180 lines of visual CSS; keep grid layout, -webkit-app-region, and stable class hooks only.
  • apps/desktop/src/renderer/styles/onboarding.css — converge font sizes to 11/13/14px; remove uppercase/letter-spacing from group label; fix .maka-list-group-toggle font: inherit bug (was resetting weight/size to parent values); add justify-content: flex-start to override UiButton's justify-center.
  • packages/ui/stories/session-list-panel.stories.tsx — collapsed story adds inline <style> overriding width: 0 so the 72px icon rail renders.
  • apps/desktop/src/main/__tests__/session-row-actions-fail-soft-contract.test.ts — check cva pending state instead of CSS rule.
  • apps/desktop/src/main/__tests__/search-modal-lifecycle-contract.test.ts — regex matches cn() className.

Not included:

  • primitives/sidebar.tsx (740 lines, shadcn-style) remains dead code — out of scope.
  • List-row container and list-row-main stay in CSS (single instance with state-coupled selectors, cva has no benefit).
  • Action overlay gradient leak at 176px narrow width (low priority, visibility: hidden already mitigates meta/unread).

Verification

  • npm run typecheck — all workspaces pass.
  • npm run pretest (check-console + check-a11y) — pass.
  • Sidebar contract tests (session-row-actions-fail-soft, search-modal-lifecycle) — 23/23 pass.
  • Storybook visual check across all 6 stories: before/after screenshots in notes/screenshots/compare/.
  • Collapsed story: 0 visible icons → 7 visible icons (search, toggle, 4 nav, settings).

User-facing impact

No behavioral change. Visual changes are within existing story contracts:

  • Font sizes converge to 3 tiers (11/13/14px), reducing visual noise.
  • Active-state hierarchy: nav active (0.09) > list active (0.07) > hover (0.06), clarifying which surface is primary.
  • Group labels use weight-based hierarchy instead of uppercase/letter-spacing (better for Chinese).
  • Radius unified to 8px (rounded-md); original 6px/8px mix had no design intent.
image

Reviewer notes

  • Rebased on latest main after shell-chrome refactor moved search/toggle from sidebar header to shell topbar; sidebarIconButtonVariants was removed as it no longer has consumers in the sidebar.
  • The collapsed story <style> override is a fixture fix, not a component change — in the real app the outer resizable grid column sets width, so width: 0 on .agents-sidebar[data-collapsed="true"] is correct.
  • size="nav" is an empty-string variant (no size utilities) that prevents buttonVariants from injecting conflicting size classes; visual properties come entirely from the cva variant.
  • Root font-size is 15px, so text-sm (0.875rem) = 13.125px, not the 14px a 16px root would give. list-row-name uses 0.875rem to match nav's text-sm.

Migrate sidebar visual properties from hand-written .maka-* CSS rules
to cva variants aligned with ui.tsx governance, and fix collapsed story
rendering.

- Add navRowVariants, settingsButtonVariants, rowActionVariants cva in
  session-list-panel.tsx (sidebarIconButtonVariants removed after main
  moved search/toggle to shell topbar)
- Unify all sidebar UiButton to size="nav" + cva variant
- Remove ~180 lines of visual CSS from sidebar.css (hover, active,
  focus, disabled, pending states for nav-row, settings, row-action)
- Converge font sizes: 9.5/10/10.5/11/12/13/14 seven tiers to 11/13/14
- Remove uppercase/letter-spacing from group label (ineffective for
  Chinese), use weight-based hierarchy
- Establish active-state hierarchy: nav 0.09 > list 0.07 > hover 0.06
- Fix collapsed story: .agents-sidebar[data-collapsed=true] width:0
  (correct in app, breaks in story) overridden via inline <style>
- Fix .maka-list-group-toggle: remove font:inherit (bug resetting
  weight/size to parent), add justify-content:flex-start to override
  UiButton justify-center
- Update 2 contract tests to check cva patterns instead of CSS rules

Closes #390
Astro-Han added 2 commits July 1, 2026 18:33
…test

- P2: add child selectors to navRowVariants for active icon
  (text-foreground), newTask icon (foreground-70), and count default
  color (foreground-40) — these were lost when CSS rules were deleted
- P3a: replace settingsButtonVariants cva (no variants) with a plain
  const string, keeping cva only for navRowVariants/rowActionVariants
  that have actual tone branches
- P3b: add assertion that SessionRow action buttons call
  rowActionVariants(), so removing the call now fails the test
  (verified by temporarily removing all 4 calls)
…en test

- P3: remove redundant tone.default text color (already in base class)
- P3: move count active background/color from CSS to navRowVariants cva
- P3: row action test uses matchAll to assert all 4 buttons call
  rowActionVariants, not just one
@Astro-Han
Astro-Han merged commit 3f1776f into main Jul 1, 2026
@Astro-Han
Astro-Han deleted the opencode/390-sidebar-polish branch July 14, 2026 05:05
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.

chore(ui): track Storybook-driven UI polish after file-boundary governance

1 participant