Skip to content

Conversation

@batmn-dev
Copy link
Owner

@batmn-dev batmn-dev commented Jan 29, 2026

Summary

This PR represents a major overhaul of the Usage UI project, transforming it from a flat structure into a production-ready monorepo with a comprehensive documentation system.

Key Changes

  • Monorepo Migration: Migrated to pnpm workspaces + Turborepo architecture with apps/www (docs site) and packages/ui (component library)
  • Documentation System: Added new /docs route with MDX support, live component previews, syntax-highlighted code blocks, and API tables
  • Usage Meter Components: Added core usage-meter and usage-meter-base components to the registry
  • UI Theme Refresh: Updated typography and theme with OKLCH color space
  • AI Agent Context: Added structured .agents/ directory with skills, workflows, and context documentation
  • CI Pipeline: Added GitHub Actions workflow with Turborepo caching

Commits Included

  • feat(www): migrate component pages to /docs route with new documentation system
  • feat(www): add MDX support and documentation components infrastructure
  • feat(ui): add usage-meter components to registry
  • feat(www): refresh UI theme and typography
  • fix(www): pin shadcn CLI version for deterministic builds
  • chore: improve agent skills, fix brand-sidebar navigation, update build pipeline
  • fix(ci): remove duplicate pnpm version specification
  • docs: update documentation to reflect completed monorepo migration
  • chore: migrate to pnpm monorepo with Turborepo
  • docs: reorganize AI agent context into structured .agents/ directory
  • docs: update AI context files for monorepo structure and add agent skills
  • docs: add claude skills recommendations
  • docs: add AI agent context files and project documentation

Test plan

  • Run pnpm install and verify workspace resolution
  • Run pnpm build and verify all packages build successfully
  • Run pnpm dev and verify the docs site loads at localhost:3000
  • Visit /docs/usage-meter and verify component documentation renders
  • Test component installation: npx shadcn add https://usage-ui.vercel.app/r/usage-meter.json
  • Verify theme toggle works (light/dark mode)
  • Run pnpm lint and pnpm typecheck pass

Note

Medium Risk
Touches Next.js routing/build pipeline (MDX/SSG) and adds filesystem-based code/props extraction, which could cause build/runtime regressions if paths or parsing assumptions break; other changes are mostly docs and styling.

Overview
Replaces the legacy /registry/[name] component pages with a new statically-generated /docs/[slug] documentation route that includes examples, installation instructions, and API reference sections.

Adds an MDX/tooling-backed documentation stack: Next.js MDX support, Shiki syntax highlighting + copyable code blocks, build-time source extraction from the monorepo, and lightweight TypeScript/JSDoc-based props extraction feeding a new ApiTable.

Updates demos and registry outputs to include new usage-meter / usage-meter-base components, refreshes global theme/typography (fonts, colors, prose styles), and adds extensive ADR/workflow documentation while removing the obsolete MONOREPO-MIGRATION.md.

Written by Cursor Bugbot for commit 7f30734. This will update automatically on new commits. Configure here.


Summary by cubic

Overhauls the project with a new MDX-powered documentation site under /docs and adds two usage-meter components ready for shadcn installation. This improves the docs experience, streamlines distribution, and modernizes the UI theme.

  • New Features

    • MDX docs system with live previews, Shiki code highlighting, API tables, install tabs, and component navigation.
    • New /docs/[slug] pages for component docs with static generation.
    • UsageMeter (Radix) and UsageMeterBase components added to the registry and published as public JSON for shadcn install.
    • Utilities for code and prop extraction plus syntax highlighting to power docs.
  • Refactors

    • Replaced /registry/[name] with /docs/[slug]; removed the old route and updated all links.
    • Theme and typography refresh: Inter font, neutral palette, and improved readability.
    • Cleaned up legacy artifacts (removed MONOREPO-MIGRATION.md) and added structured .agents docs (ADRs, research, workflows).

Written for commit 7f30734. Summary will update on new commits.

- Update color scheme from nature tones to neutral grayscale palette
- Replace Montserrat font with Inter for cleaner typography
- Change headings from font-bold to font-semibold throughout
- Add text-balance and improved line-height for better readability
- Update registry JSON files to reflect component changes
- Add UsageMeter (Radix) with full accessibility support
- Add UsageMeterBase (lightweight) without Radix dependency
- Update registry.json with both component entries
- Update branding: rename logo from "Registry" to "usage-ui"
- Add documentation strategy and redesign workflow
- Remove MONOREPO-MIGRATION.md (migration complete)
Set up foundation for component documentation pages with MDX, Shiki syntax
highlighting, and reusable documentation components including code previews,
API tables, installation tabs, and component navigation.
…ion system

- Add new /docs/[name] pages for component documentation
- Remove old /registry/[name] route in favor of /docs
- Update all sidebar and homepage links to use /docs route
- Add component-preview and preview-error-boundary components
- Update add-registry-component workflow with documentation step
- Add changeset for documentation system changes
The lockfile was out of sync with apps/www/package.json after adding
@mdx-js/loader, @mdx-js/react, and @next/mdx dependencies.
@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
usage-ui Ready Ready Preview, Comment Jan 29, 2026 11:47pm

Replace implicit types with explicit React.ReactNode annotations
for all MDX component overrides to improve type safety.
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

9 issues found across 51 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/ui/src/components/registry/usage-meter/usage-meter-base.tsx">

<violation number="1" location="packages/ui/src/components/registry/usage-meter/usage-meter-base.tsx:49">
P2: Guard against max being 0 or negative before dividing, otherwise the meter can render invalid widths/aria text (Infinity/NaN) when max is 0.</violation>
</file>

<file name="apps/www/src/components/docs/client-code-wrapper.tsx">

<violation number="1" location="apps/www/src/components/docs/client-code-wrapper.tsx:21">
P2: Handle clipboard write failures so a denied permission doesn’t throw an unhandled rejection and falsely flip the copied state.</violation>
</file>

<file name="apps/www/src/lib/extract-props.ts">

<violation number="1" location="apps/www/src/lib/extract-props.ts:301">
P3: Dead/incomplete code: `match` is captured but never used, and the block just returns the original `type` unchanged. The comment suggests this was meant to resolve actual values but was never implemented. Either complete the implementation or remove the unnecessary code.</violation>
</file>

<file name=".agents/context/decisions/005-component-documentation-strategy.md">

<violation number="1" location=".agents/context/decisions/005-component-documentation-strategy.md:265">
P3: This ADR records two conflicting “Selected” decisions for API documentation (manual MDX tables vs. auto-generated react-docgen-typescript). The document should reflect a single selected approach or explicitly mark one as a future/alternative, otherwise the decision record is ambiguous.</violation>
</file>

<file name="apps/www/src/app/docs/[slug]/page.tsx">

<violation number="1" location="apps/www/src/app/docs/[slug]/page.tsx:25">
P2: `ComponentDocPage` will throw for unknown slugs because `getRegistryItem` throws before the `notFound()` guard can run. Catch the error and call `notFound()` so invalid routes return 404s.</violation>
</file>

<file name="apps/www/src/components/registry/registry-sidebar.tsx">

<violation number="1" location="apps/www/src/components/registry/registry-sidebar.tsx:192">
P2: Active state no longer matches the new `/docs/...` routes, so sidebar items won't highlight. Update the active check to compare against the `/docs/${item.name}` path.</violation>
</file>

<file name="packages/ui/src/components/registry/usage-meter/usage-meter.tsx">

<violation number="1" location="packages/ui/src/components/registry/usage-meter/usage-meter.tsx:57">
P2: Guard against `max <= 0` to avoid division by zero and invalid progress state. Normalize `max` (and optionally clamp `value`) before computing percentage and before passing props to the Progress root.</violation>
</file>

<file name="apps/www/src/components/docs/component-code-preview.tsx">

<violation number="1" location="apps/www/src/components/docs/component-code-preview.tsx:66">
P2: The underline indicator will never become visible because the `data-[state=active]` selector is applied to the indicator element, which doesn’t receive `data-state`. The attribute is on the parent trigger, so the opacity class never toggles.</violation>
</file>

<file name=".agents/workflows/implement-documentation-redesign.md">

<violation number="1" location=".agents/workflows/implement-documentation-redesign.md:313">
P1: Missing `cn` import in code example. The `cn()` function is used but not imported, which will cause a `ReferenceError` when developers copy this code. Add `import { cn } from "@/lib/utils"` after the shiki import.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@batmn-dev
Copy link
Owner Author

@greptileai

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

15 issues found across 51 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/www/src/components/docs/client-code-wrapper.tsx">

<violation number="1" location="apps/www/src/components/docs/client-code-wrapper.tsx:22">
P2: Handle clipboard write failures to avoid unhandled promise rejections and inconsistent UI state when permissions are denied.</violation>
</file>

<file name="apps/www/src/components/docs/api-table.tsx">

<violation number="1" location="apps/www/src/components/docs/api-table.tsx:50">
P2: Use nullish coalescing so valid falsy defaults (e.g., empty string) are displayed instead of being replaced with "—".</violation>
</file>

<file name="apps/www/src/mdx-components.tsx">

<violation number="1" location="apps/www/src/mdx-components.tsx:55">
P2: Use horizontal overflow for table wrappers so wide tables can scroll instead of overflowing the layout.</violation>
</file>

<file name="packages/ui/src/components/registry/usage-meter/usage-meter-base.tsx">

<violation number="1" location="packages/ui/src/components/registry/usage-meter/usage-meter-base.tsx:49">
P2: Guard against max <= 0 to avoid NaN/Infinity percentages and invalid width styles when consumers pass max={0}.</violation>
</file>

<file name="apps/www/src/components/docs/component-nav.tsx">

<violation number="1" location="apps/www/src/components/docs/component-nav.tsx:16">
P2: Guard against currentName not found; otherwise next will incorrectly point to the first item when currentIndex is -1.</violation>
</file>

<file name="packages/ui/src/components/registry/usage-meter/usage-meter.tsx">

<violation number="1" location="packages/ui/src/components/registry/usage-meter/usage-meter.tsx:57">
P2: Guard against `max` being 0 (or negative) before dividing; otherwise the percentage becomes Infinity/NaN and the indicator transform breaks.</violation>
</file>

<file name="apps/www/src/lib/shiki.ts">

<violation number="1" location="apps/www/src/lib/shiki.ts:50">
P2: highlightCode allows any BundledLanguage even though the highlighter only loads a small subset. Passing an unloaded language will throw at runtime. Narrow the parameter to the supported language union or validate before calling codeToHtml.</violation>

<violation number="2" location="apps/www/src/lib/shiki.ts:71">
P2: highlightCodeToTokens allows any BundledLanguage even though the highlighter only loads a small subset. Passing an unloaded language will throw at runtime. Narrow the parameter to the supported language union or validate before calling codeToTokens.</violation>
</file>

<file name="apps/www/src/lib/extract-props.ts">

<violation number="1" location="apps/www/src/lib/extract-props.ts:139">
P3: Dead code: `propName.startsWith("...")` can never be true because the regex `[\w]+` capturing `propName` cannot match `.` characters.</violation>

<violation number="2" location="apps/www/src/lib/extract-props.ts:300">
P2: Unused variable: `match` is captured but never used. The comment suggests resolving values, but this just returns the original type. Either complete the implementation or remove the match extraction.</violation>
</file>

<file name="apps/www/src/components/docs/component-code-preview.tsx">

<violation number="1" location="apps/www/src/components/docs/component-code-preview.tsx:1">
P1: This component renders Radix UI tabs but isn’t marked as a client component. Without a "use client" directive, Next.js will treat this file as a server component and Radix UI will fail at build/runtime. Add the directive at the top of the file.</violation>

<violation number="2" location="apps/www/src/components/docs/component-code-preview.tsx:66">
P2: TabIndicator never becomes visible because the `data-[state=active]` variant is applied to the indicator itself, but `data-state` is set on `Tabs.Trigger`. Use a group or parent selector so the indicator reacts to the trigger’s active state.</violation>
</file>

<file name="apps/www/src/components/docs/code-renderer.tsx">

<violation number="1" location="apps/www/src/components/docs/code-renderer.tsx:7">
P2: `CodeRenderer` accepts any `BundledLanguage`, but the highlighter only loads a small subset of languages. Passing an un-loaded language will throw at runtime (“Language not loaded”), which will break docs rendering. Restrict the prop type to the supported list or add a fallback/validation before calling `highlightCode`.</violation>
</file>

<file name="apps/www/src/app/docs/[slug]/page.tsx">

<violation number="1" location="apps/www/src/app/docs/[slug]/page.tsx:25">
P2: Convert the registry lookup to call notFound() when the slug is missing. As written, getRegistryItem throws and the notFound branch never runs.</violation>
</file>

<file name="apps/www/src/app/(registry)/tokens/page.tsx">

<violation number="1" location="apps/www/src/app/(registry)/tokens/page.tsx:38">
P2: The arbitrary font class uses `family-name:` which isn’t valid Tailwind syntax for `font-family`, so this utility won’t apply the intended font. Use a standard arbitrary font-family value instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@greptile-apps
Copy link

greptile-apps bot commented Jan 29, 2026

Greptile Overview

Greptile Summary

This PR successfully transforms the project from a flat structure into a production-ready monorepo with a comprehensive documentation system. The migration adds MDX-powered component documentation under /docs/[slug], two new usage-meter components, and a refreshed neutral theme.

Key Changes:

  • Replaced /registry/[name] route with new /docs/[slug] static documentation pages featuring live previews, syntax-highlighted code blocks (via Shiki), API tables, and installation tabs
  • Added UsageMeter (Radix-based) and UsageMeterBase (HTML-only) components with proper accessibility, variants (success/warning/danger), and edge case handling
  • Implemented build-time code extraction using import.meta.url and React cache for efficient SSG
  • Refreshed theme to neutral OKLCH color space with Inter font and improved typography
  • Added MDX infrastructure with @next/mdx, Shiki for syntax highlighting, and new documentation UI primitives

Critical Issue:

  • usage-meter.json specifies incorrect dependency "radix-ui" - should be "@radix-ui/react-progress". This will cause installation failures when users run npx shadcn add.

Recommendations:

  • API table currently hardcodes generic props instead of extracting actual component props from TypeScript interfaces
  • Verify demo routes /demo/usage-meter and /demo/usage-meter-base render correctly with iframe integration
  • Consider implementing automatic prop extraction from component source files for better API documentation

Confidence Score: 3/5

  • This PR is safe to merge after fixing the critical Radix dependency issue in usage-meter.json
  • Score reflects one critical dependency bug that will break shadcn CLI installation, plus several documentation quality issues (hardcoded API props, demo route verification needed). The core architecture is sound but needs the dependency fix before users can successfully install components.
  • apps/www/public/r/usage-meter.json requires immediate fix for the radix-ui dependency name

Important Files Changed

Filename Overview
apps/www/src/app/docs/[slug]/page.tsx New documentation route with static generation, iframe previews, and component rendering - logic issue with conditional iframe rendering
packages/ui/src/components/registry/usage-meter/usage-meter.tsx New Radix-based usage meter component with proper accessibility, variants, and edge case handling
apps/www/src/lib/code.ts Build-time code extraction using path.join for cross-package file reading
apps/www/src/app/globals.css Complete theme refresh to neutral OKLCH palette with improved readability and documentation prose styles
apps/www/public/r/usage-meter.json Registry JSON for UsageMeter component - contains critical dependency error that will break shadcn CLI installation

Sequence Diagram

sequenceDiagram
    participant User
    participant Browser
    participant DocsPage as /docs/[slug]
    participant Registry as registry.json
    participant CodeExtractor as lib/code.ts
    participant Shiki as lib/shiki.ts
    participant Demo as /demo/[name]

    User->>Browser: Navigate to /docs/usage-meter
    Browser->>DocsPage: Request page (SSG)
    DocsPage->>Registry: getRegistryItem(slug)
    Registry-->>DocsPage: Component metadata
    DocsPage->>CodeExtractor: getComponentSource(slug)
    CodeExtractor->>Registry: Read registry.json
    CodeExtractor-->>DocsPage: Source code string
    DocsPage->>Shiki: highlightCode(source, "tsx")
    Shiki-->>DocsPage: Syntax-highlighted HTML
    DocsPage->>DocsPage: Render ComponentCodePreview
    DocsPage->>DocsPage: Check demos[slug] exists
    alt Demo exists
        DocsPage->>Browser: Render iframe to /demo/slug
        Browser->>Demo: Load demo preview
        Demo-->>Browser: Render component variants
    else No demo
        DocsPage->>Browser: Show "Preview not available"
    end
    DocsPage-->>Browser: Complete page with tabs, API table, install instructions
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

6 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

- Fix sidebar active state to match /docs/:slug route pattern
- Fix table overflow direction (use overflow-x-auto for horizontal scroll)
- Fix API table default value check using nullish coalescing
- Fix component-nav next button bounds check to handle missing items
- Add division-by-zero guard in usage-meter components
- Add error handling for clipboard API in code copy functionality
- Add "use client" directive to ComponentCodePreview
- Use SupportedLanguage type instead of BundledLanguage for consistency
- Add dynamicParams=false and try-catch for proper 404 handling
- Fix tab indicator styling with group-data-[state=active]
- Update ADR to clarify Decision 6 supersedes Decision 4
- Fix font class name in tokens page (font-inter)
- Fix hydration issues in sidebar and mcp-tabs by deferring Radix component rendering until after mount
- Add guards against division by zero in usage-meter components when max <= 0
- Fix code.ts path resolution using __dirname for reliable monorepo paths
- Update registry.json to focus on usage-meter components
- Add demo components for usage-meter and usage-meter-base
- Pre-render code syntax highlighting on server to avoid client-side mismatch
- Fix conditional iframe rendering to check if demo exists
Use a filled Circle icon for a cleaner, more abstract logo appearance.
@batmn-dev
Copy link
Owner Author

@greptileai

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

…riables

- Replace custom meter CSS variables with standard shadcn tokens:
  - success: chart-2, warning: chart-4, danger: destructive, track: secondary
- Remove custom --meter-* CSS variable definitions from globals.css
- Update favicon from emoji to minimal circle SVG
- Improve code.ts to support dual registry lookup (packages/ui + apps/www)
- Add dynamic prop extraction for API documentation tables
- Update registry.json entries for usage-meter components
@batmn-dev batmn-dev merged commit a7b0171 into main Jan 29, 2026
5 checks passed
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

}

const sourceCode = getComponentSource(slug);
const codeHtml = await highlightCode(sourceCode, "tsx");
Copy link

Choose a reason for hiding this comment

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

Legacy components display layout file instead of source code

Medium Severity

The new docs page calls getComponentSource(slug) for all registry items to populate the "Code" tab. For legacy shadcn components (accordion, button, alert, etc.) in apps/www/src/registry.json, the files[0].path points to src/layouts/minimal-layout.tsx rather than actual component source files (these components use registryDependencies to reference shadcn's registry). This causes the "Code" tab to display the layout file content instead of relevant component code for approximately 20+ UI primitives.

Fix in Cursor Fix in Web

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