Skip to content

feat(ui): Patterns library pilot on the shared design system (U5 B1)#437

Merged
OBenner merged 3 commits into
developfrom
claude/ui-b1-patterns
Jul 23, 2026
Merged

feat(ui): Patterns library pilot on the shared design system (U5 B1)#437
OBenner merged 3 commits into
developfrom
claude/ui-b1-patterns

Conversation

@OBenner

@OBenner OBenner commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

Fourth screen of the B1 "Code & review" batch, ported from desktop-patterns.html. This is the last of the four B1 code-review surfaces (Changelog, PRs, Issues, Patterns).

libs/ui (shared design system)

  • PatternLibrary: search + filter-chip toolbar (active chip count turns blue), two-column body with a 2-up pattern card grid beside an optional right meta rail. Each card: kind glyph (pattern/gotcha/decision/rule, the Rule glyph reusing the AA-safe purple pair), optional code prefix, title, lang chip, description, optional dark code snippet, tag pills, and dot-separated footer facts with red (failures) / green (wins) tones; loading/error/empty states; grid collapses to one column at 1280px, rail drops at 1180px.
  • New shared types: UiPattern / UiPatternKind / UiPatternFooterStat / UiPatternSnippet.

Electron

  • Pure patterns-ui mappers: backend Pattern → sparse card, cross-spec aggregation with case/whitespace-insensitive dedup (the same rule is re-learned across specs), client-side filtering — 7 tests.
  • PatternsPilotView: patterns are stored per spec, so the pilot aggregates over the project's known specs (from the task store) via the existing pattern.listPatterns IPC, tolerating per-spec failures. Read-only — the approve/override/delete flows stay on the legacy view. Mounted as "Patterns (new UI)".

i18n

  • patterns:patternsPilot.* (en+fr), navigation:items.patternsNext.
  • Fix: registers the previously-unregistered patterns namespace — the legacy Patterns view (useTranslation(['patterns'])) was rendering raw keys, the same latent bug found for kanban.

Scope note

The backend has no gotcha/decision/rule taxonomy and no snippet/tag/reuse data — a learned pattern is plain text + a coarse category + a confidence bucket. So the live adapter maps every item to a sparse pattern card (title + category chip + confidence footer); the rich card fields (kinds, snippet, tags, footer facts) exist for mockup fidelity and are exercised in Storybook. The legacy view's approve/override flows are intentionally not reimplemented here.

Verification

  • 7/7 mapper/aggregation tests; libs/ui + Electron tsc clean; Storybook rebuilt and the Library story verified against the mockup in light + dark (card grid, all four kind glyphs, snippets, tags, red/green footer facts, meta rail), responsive collapse checked at 900px.
  • Adversarial find→verify review runs next; anything it surfaces lands as a follow-up commit here.

B1 status

With this, all four B1 code-review screens are piloted. Next batch: B2 Analytics & usage.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a Patterns library pilot accessible from the sidebar.
    • Browse aggregated patterns with search, filtering, confidence labels, metadata, and responsive card layouts.
    • Added loading, empty, error, and retry states.
    • Added English and French localization for the Patterns experience.
  • Bug Fixes

    • Improved pattern handling by removing duplicate entries and gracefully handling unavailable pattern data.
  • Tests

    • Added coverage for pattern mapping, aggregation, deduplication, and search behavior.

Fourth B1 screen, ported from desktop-patterns.html:

- libs/ui: new PatternLibrary screen — search + filter-chip toolbar
  (active chip count turns blue), two-column body with a 2-up pattern
  card grid (kind glyph pattern/gotcha/decision/rule, code prefix,
  title, lang chip, description, optional code snippet, tag pills,
  dot-separated footer facts with red/green tones) beside an optional
  right meta rail; loading/error/empty states; grid collapses to one
  column at 1280px, rail drops at 1180px. New shared types:
  UiPattern/UiPatternKind/UiPatternFooterStat/UiPatternSnippet.
- Electron: pure patterns-ui mappers (backend Pattern → sparse card,
  cross-spec aggregation with case/space-insensitive dedup,
  client-side filtering; 7 tests) + PatternsPilotView. Patterns are
  stored per spec, so the pilot aggregates over the project's known
  specs (from the task store) via the existing pattern.listPatterns
  IPC, tolerating per-spec failures. Read-only — the approve/override
  flows stay on the legacy view. Mounted as "Patterns (new UI)".
- i18n: patterns:patternsPilot.* keys (en+fr), navigation.patternsNext;
  also registers the previously-unregistered patterns namespace so the
  legacy Patterns view stops rendering raw keys.

The backend has no gotcha/decision/rule taxonomy or snippet/tag data,
so the live adapter maps every learned item to a sparse 'pattern' card;
the rich card fields exist for the mockup fidelity shown in Storybook.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@OBenner, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 59f22df0-037a-4c63-8514-c1768922e95a

📥 Commits

Reviewing files that changed from the base of the PR and between e47ab7b and 0d32681.

📒 Files selected for processing (3)
  • apps/frontend/src/renderer/__tests__/patterns-ui.test.ts
  • apps/frontend/src/renderer/components/PatternsPilotView.tsx
  • libs/ui/src/screens/PatternLibrary.tsx
📝 Walkthrough

Walkthrough

Adds a shared PatternLibrary screen, backend pattern mapping and filtering utilities, a project-scoped pilot view, sidebar and App routing, English/French localization, responsive styling, Storybook states, and Vitest coverage.

Changes

Patterns library pilot

Layer / File(s) Summary
PatternLibrary screen and card contract
libs/ui/src/client/types.ts, libs/ui/src/screens/PatternLibrary.tsx, libs/ui/src/screens/PatternLibrary.css, libs/ui/src/screens/PatternLibrary.stories.tsx, libs/ui/src/index.ts
Defines UI pattern types and renders searchable, filterable pattern cards with loading, error, empty, metadata rail, responsive layouts, and Storybook variants.
Pattern mapping and collection utilities
apps/frontend/src/renderer/lib/patterns-ui.ts, apps/frontend/src/renderer/__tests__/patterns-ui.test.ts
Maps backend patterns to UI cards, aggregates and deduplicates per-spec results, filters fields case-insensitively, and tests these behaviors.
Pilot loading, navigation, and localization
apps/frontend/src/renderer/components/PatternsPilotView.tsx, apps/frontend/src/renderer/App.tsx, apps/frontend/src/renderer/components/Sidebar.tsx, apps/frontend/src/shared/i18n/*
Loads patterns for project specs, handles partial and global failures, wires search and retry behavior, adds sidebar/App routing, and registers English/French labels and resources.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Sidebar
  participant App
  participant PatternsPilotView
  participant ElectronAPI
  participant PatternLibrary
  Sidebar->>App: select patterns-next
  App->>PatternsPilotView: render with projectId
  PatternsPilotView->>ElectronAPI: listPatterns for each spec
  ElectronAPI-->>PatternsPilotView: per-spec patterns
  PatternsPilotView->>PatternLibrary: aggregated and filtered UiPattern cards
Loading

Suggested labels: area/fullstack

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: a Patterns library pilot UI built on the shared design system.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/ui-b1-patterns

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Reading useTaskStore.getState() once inside the effect stranded the
empty state when a project's tasks arrived after mount (opening
Patterns before the board). Subscribe to the store and drive the
effect off a stable spec-id string key so patterns refetch when the
spec set changes, without refetching on unrelated task updates. Adds
an empty-aggregation test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/frontend/src/renderer/components/PatternsPilotView.tsx`:
- Around line 37-53: Update all translation lookups in PatternsPilotView,
including confidenceLabels and the additional referenced ranges, to use
namespace-qualified patterns: keys such as patterns:patternsPilot.... Preserve
the existing translation sections and behavior while ensuring every user-facing
lookup follows the required namespace:section.key format.
- Around line 63-70: Update the spec ID derivation in PatternsPilotView to
subscribe to task updates by selecting tasks from useTaskStore rather than
calling getState(). Derive the project-filtered, unique specIds with useMemo,
then include specIds in the effect dependencies so it reruns after loadTasks
populates tasks or the project changes.

In `@libs/ui/src/screens/PatternLibrary.tsx`:
- Around line 131-156: The loading and empty state messages in PatternLibrary
need live-region announcements like the existing error state. Update the
corresponding `<p>` elements in the PatternLibrary render to use an appropriate
`aria-live` setting, while preserving their current conditional rendering and
labels.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b5d9038f-8b0a-45b6-8692-73b594eb783f

📥 Commits

Reviewing files that changed from the base of the PR and between 4e1310a and e47ab7b.

📒 Files selected for processing (15)
  • apps/frontend/src/renderer/App.tsx
  • apps/frontend/src/renderer/__tests__/patterns-ui.test.ts
  • apps/frontend/src/renderer/components/PatternsPilotView.tsx
  • apps/frontend/src/renderer/components/Sidebar.tsx
  • apps/frontend/src/renderer/lib/patterns-ui.ts
  • apps/frontend/src/shared/i18n/index.ts
  • apps/frontend/src/shared/i18n/locales/en/navigation.json
  • apps/frontend/src/shared/i18n/locales/en/patterns.json
  • apps/frontend/src/shared/i18n/locales/fr/navigation.json
  • apps/frontend/src/shared/i18n/locales/fr/patterns.json
  • libs/ui/src/client/types.ts
  • libs/ui/src/index.ts
  • libs/ui/src/screens/PatternLibrary.css
  • libs/ui/src/screens/PatternLibrary.stories.tsx
  • libs/ui/src/screens/PatternLibrary.tsx

Comment thread apps/frontend/src/renderer/components/PatternsPilotView.tsx
Comment thread apps/frontend/src/renderer/components/PatternsPilotView.tsx Outdated
Comment thread libs/ui/src/screens/PatternLibrary.tsx
- Namespace-qualify every translation lookup in PatternsPilotView
  (patterns:patternsPilot.*) per the i18n house style.
- Add aria-live="polite" to PatternLibrary's loading/empty states so
  screen readers announce search/filter transitions (the error state
  already carries role="alert").

The task-store subscription finding was already fixed in 0170e5d
(the review ran against the earlier commit).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@OBenner
OBenner merged commit ba29c40 into develop Jul 23, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant