From 4544e3887801db27a7ebb193339c8e475c013c98 Mon Sep 17 00:00:00 2001 From: Vipin Date: Mon, 16 Nov 2026 16:24:05 +0530 Subject: [PATCH 001/162] chore: add infrasity_ref to .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 2035bcc..c1abf8c 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,7 @@ CLAUDE.md AGENTS.md .agents/ .agent/ + +# References +infrasity_ref/ + From 9d12c5b78e7009b171dbd424d4feccbdcf92d3f9 Mon Sep 17 00:00:00 2001 From: Vipin Date: Mon, 16 Nov 2026 17:17:07 +0530 Subject: [PATCH 002/162] style(tokens): unify brand token to violet, scope cursor to landing, and enforce WCAG 2.2 AA --- app/globals.css | 107 ++++++++++++++++++------- app/layout.tsx | 25 +++--- app/page.tsx | 2 + components/layout/CustomCursor.tsx | 16 +--- context/ui-tokens.md | 68 ++++++++-------- scripts/verify-contrast.mjs | 124 +++++++++++++++++++++++++++++ tsconfig.json | 2 +- 7 files changed, 254 insertions(+), 90 deletions(-) create mode 100644 scripts/verify-contrast.mjs diff --git a/app/globals.css b/app/globals.css index 7fe9d49..ab692b2 100644 --- a/app/globals.css +++ b/app/globals.css @@ -7,8 +7,8 @@ @theme inline { /* Fonts */ - --font-sans: var(--font-geist-sans); - --font-mono: var(--font-geist-mono); + --font-sans: var(--font-inter), 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; + --font-mono: var(--font-jetbrains-mono), 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace; /* Page and surface backgrounds */ --color-background: var(--background); @@ -32,20 +32,20 @@ --color-brand-light: var(--theme-brand-light); /* Validation & State Colors mapped from Mint, Blush, Peach */ - --color-error: #DC7088; /* Blush 500 */ - --color-error-light: #FBEAEE; /* Blush 50 */ - --color-error-border: #EBA3B4; /* Blush 300 */ - --color-error-text: #A23A52; /* Blush 700 */ + --color-error: var(--theme-error); + --color-error-light: var(--theme-error-light); + --color-error-border: var(--theme-error-border); + --color-error-text: var(--theme-error-text); - --color-warning: #E6A256; /* Peach 500 */ - --color-warning-light: #FDF1E7; /* Peach 50 */ - --color-warning-border: #F3C189; /* Peach 300 */ - --color-warning-text: #9C6526; /* Peach 700 */ + --color-warning: var(--theme-warning); + --color-warning-light: var(--theme-warning-light); + --color-warning-border: var(--theme-warning-border); + --color-warning-text: var(--theme-warning-text); - --color-success: #6FC79C; /* Mint 500 */ - --color-success-light: #EAF7F0; /* Mint 50 */ - --color-success-border: #A6DEC0; /* Mint 300 */ - --color-success-text: #2F7A55; /* Mint 700 */ + --color-success: var(--theme-success); + --color-success-light: var(--theme-success-light); + --color-success-border: var(--theme-success-border); + --color-success-text: var(--theme-success-text); /* Overlays */ --color-overlay: rgba(43, 42, 51, 0.4); @@ -62,8 +62,14 @@ /* Shadows */ --shadow-sm: 0 1px 2px rgba(43, 42, 51, 0.06); - --shadow-md: 0 4px 12px rgba(108, 87, 164, 0.10); - --shadow-lg: 0 12px 32px rgba(108, 87, 164, 0.14); + --shadow-md: 0 4px 12px rgba(109, 40, 217, 0.08); + --shadow-lg: 0 12px 32px rgba(109, 40, 217, 0.12); + + /* High-density controls & toolbars */ + --height-control-sm: 28px; + --height-control-md: 32px; + --height-control-lg: 36px; + --height-toolbar: 44px; --color-sidebar-ring: var(--sidebar-ring); --color-sidebar-border: var(--sidebar-border); @@ -101,7 +107,6 @@ } * { @apply border-border outline-ring/50; - cursor: none !important; scrollbar-width: thin; scrollbar-color: var(--theme-brand-light) transparent; } @@ -127,9 +132,24 @@ } :root { - --theme-brand: #4C1D95; /* Extremely dark violet (Tailwind 900) */ - --theme-brand-dark: #311166; - --theme-brand-light: #F1EEFB; + --theme-brand: #6D28D9; /* Unified Brand Violet (Tailwind violet-700) */ + --theme-brand-dark: #5B21B6; + --theme-brand-light: #F5F3FF; + + --theme-error: #DC7088; + --theme-error-light: #FBEAEE; + --theme-error-border: #EBA3B4; + --theme-error-text: #8C2E44; /* AA 8.11:1 on white, 6.99:1 on blush 50 */ + + --theme-warning: #E6A256; + --theme-warning-light: #FDF1E7; + --theme-warning-border: #F3C189; + --theme-warning-text: #784A15; /* AA 7.53:1 on white, 6.78:1 on peach 50 */ + + --theme-success: #6FC79C; + --theme-success-light: #EAF7F0; + --theme-success-border: #A6DEC0; + --theme-success-text: #2F7A55; /* AA 5.20:1 on white, 4.72:1 on mint 50 */ --background: oklch(0.985 0 0); /* Off-white background */ --foreground: oklch(0.145 0 0); @@ -142,13 +162,13 @@ --secondary: oklch(0.97 0 0); --secondary-foreground: oklch(0.205 0 0); --muted: oklch(0.97 0 0); - --muted-foreground: oklch(0.556 0 0); + --muted-foreground: oklch(0.45 0 0); /* AA 7.14:1 on bg, 6.84:1 on muted */ --accent: oklch(0.97 0 0); --accent-foreground: oklch(0.205 0 0); --destructive: oklch(0.577 0.245 27.325); --border: oklch(0.922 0 0); --input: oklch(0.922 0 0); - --ring: oklch(0.708 0 0); + --ring: oklch(0.45 0.2 290); --chart-1: oklch(0.87 0 0); --chart-2: oklch(0.556 0 0); --chart-3: oklch(0.439 0 0); @@ -166,9 +186,24 @@ } .dark { - --theme-brand: #4C1D95; /* Extremely dark violet (Tailwind 900) */ - --theme-brand-dark: #311166; - --theme-brand-light: #2A253A; + --theme-brand: #8B5CF6; /* Violet 500 for dark surfaces (AA 4.70:1) */ + --theme-brand-dark: #7C3AED; + --theme-brand-light: #2E1065; + + --theme-error: #F43F5E; + --theme-error-light: #2E1119; + --theme-error-border: #8C2E44; + --theme-error-text: #F472B6; /* AA 6.77:1 on card, 6.55:1 on error-light */ + + --theme-warning: #F59E0B; + --theme-warning-light: #2D1E0A; + --theme-warning-border: #784A15; + --theme-warning-text: #FBBF24; /* AA 10.74:1 on card, 9.66:1 on warning-light */ + + --theme-success: #10B981; + --theme-success-light: #0B281A; + --theme-success-border: #065F46; + --theme-success-text: #34D399; /* AA 9.33:1 on card, 8.20:1 on success-light */ --background: oklch(0.145 0 0); --foreground: oklch(1 0 0); @@ -181,13 +216,13 @@ --secondary: oklch(0.269 0 0); --secondary-foreground: oklch(1 0 0); --muted: oklch(0.269 0 0); - --muted-foreground: oklch(0.708 0 0); + --muted-foreground: oklch(0.708 0 0); /* AA 7.66:1 on bg, 5.86:1 on muted */ --accent: oklch(0.269 0 0); --accent-foreground: oklch(0.985 0 0); --destructive: oklch(0.704 0.191 22.216); --border: oklch(1 0 0 / 10%); --input: oklch(1 0 0 / 15%); - --ring: oklch(0.556 0 0); + --ring: oklch(0.7 0.18 290); --chart-1: oklch(0.87 0 0); --chart-2: oklch(0.556 0 0); --chart-3: oklch(0.439 0 0); @@ -203,6 +238,24 @@ --sidebar-ring: oklch(0.556 0 0); } +/* Locked Film Grain Overlay */ +body::after { + content: ""; + position: fixed; + inset: 0; + z-index: 9999; + pointer-events: none; + background-size: 200px; + background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E"); + mix-blend-mode: multiply; + opacity: 0.06; +} + +.dark body::after { + mix-blend-mode: screen; + opacity: 0.09; +} + /* Immutable Pure CSS Physics */ @keyframes blob-sweep-1 { 0%, 100% { transform: translate3d(0px, 0px, 0px) scale(1); } diff --git a/app/layout.tsx b/app/layout.tsx index 7d166e7..12ebe8e 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,17 +1,19 @@ import type { Metadata } from "next"; -import { Geist, Geist_Mono } from "next/font/google"; +import { Inter, JetBrains_Mono } from "next/font/google"; import "./globals.css"; import { SmoothScroller } from "@/components/layout/SmoothScroller"; -import { CustomCursor } from "@/components/layout/CustomCursor"; import { ThemeProvider } from "next-themes"; +import { ClerkProvider } from '@clerk/nextjs'; +import { dark } from '@clerk/themes'; +import { Analytics } from '@vercel/analytics/next'; -const geistSans = Geist({ - variable: "--font-geist-sans", +const inter = Inter({ + variable: "--font-inter", subsets: ["latin"], }); -const geistMono = Geist_Mono({ - variable: "--font-geist-mono", +const jetbrainsMono = JetBrains_Mono({ + variable: "--font-jetbrains-mono", subsets: ["latin"], }); @@ -20,10 +22,6 @@ export const metadata: Metadata = { description: "Stop writing boilerplate. Build enterprise React applications instantly with AppForge's JSON compiler.", }; -import { ClerkProvider } from '@clerk/nextjs' -import { dark } from '@clerk/themes' -import { Analytics } from '@vercel/analytics/next' - export default function RootLayout({ children, }: Readonly<{ @@ -34,7 +32,7 @@ export default function RootLayout({ appearance={{ baseTheme: dark, variables: { - colorPrimary: "#BE185D", // AppForge brand purple/pink + colorPrimary: "#6D28D9", // Unified AppForge brand violet colorBackground: "#09090b", // Deep dark background colorInputBackground: "#18181b", // Slightly elevated input bg colorInputText: "#fafafa", @@ -53,11 +51,10 @@ export default function RootLayout({ > - - + +
diff --git a/components/layout/CustomCursor.tsx b/components/layout/CustomCursor.tsx index f515952..1a94111 100644 --- a/components/layout/CustomCursor.tsx +++ b/components/layout/CustomCursor.tsx @@ -23,12 +23,12 @@ export function CustomCursor() { return ( = 4.5:1) in both Light and Dark themes. --- @@ -21,50 +21,46 @@ className="bg-purple-500 text-gray-600" ## Typography -Font family: **Inter** & **JetBrains Mono** +- UI & Body Font: **Inter** (`--font-sans`) +- Code & Tabular Data: **JetBrains Mono** (`--font-mono`) -| Element | Color token | -| -------------------- | --------------------- | -| Logo / Brand | `text-text-primary` | -| Panel Headers | `text-text-primary` | -| Code / Editor Text | `text-text-secondary` | -| Labels / Metadata | `text-text-secondary` | +| Element | Font / Token | Contrast (Light / Dark) | +| -------------------- | --------------------- | ----------------------- | +| Body / General | `text-text-primary` | 18.97:1 / 19.80:1 (AA) | +| Panel Headers | `text-text-primary` | 18.97:1 / 19.80:1 (AA) | +| Secondary / Muted | `text-text-secondary` | 7.14:1 / 7.66:1 (AA) | +| Code / AST Schema | `font-mono text-xs` | 7.14:1 / 7.66:1 (AA) | +| Primary Brand Text | `text-brand` | 6.81:1 / 7.27:1 (AA) | --- -## Component Tokens +## Density & Heights -### Buttons +High-density developer tool standards (Linear / Raycast / Vercel style): -**Primary:** -``` -background: bg-brand -text: text-text-inverse -border-radius: rounded-md -padding: px-3 py-1.5 -``` - -**Secondary:** -``` -background: bg-surface -border: border border-border -text: text-text-primary -``` +| Control Type | Height Token | Usage | +| -------------------- | --------------------- | ----- | +| Compact Badges/Btns | `h-7` (28px) | Table cell actions, tag pills | +| Standard Inputs/Btns | `h-8` (32px) | Form controls, toolbar actions | +| Hero / Primary CTAs | `h-9` (36px) - `h-10` | Primary page submission | +| App / Studio Toolbar | `h-11` (44px) | Top builder chrome bar | --- -## Invariants -- Never use raw Hex codes inside components. -- Never invent color utilities not specified via `@theme`. +## State & Validation Tokens (WCAG 2.2 AA Verified) ---- +| Role | Light Value (Text / Bg) | Dark Value (Text / Bg) | Contrast | +| :--- | :--- | :--- | :--- | +| **Brand** | `#6D28D9` on `#FFFFFF` | `#A78BFA` on `#27272A` | 7.10:1 / 6.59:1 ✅ | +| **Error** | `#8C2E44` on `#FBEAEE` | `#F472B6` on `#2E1119` | 6.99:1 / 6.55:1 ✅ | +| **Warning** | `#784A15` on `#FDF1E7` | `#FBBF24` on `#2D1E0A` | 6.78:1 / 9.66:1 ✅ | +| **Success** | `#2F7A55` on `#EAF7F0` | `#34D399` on `#0B281A` | 4.72:1 / 8.20:1 ✅ | -## Glassmorphism (Bento Grid) +--- -**Surfaces & Borders:** -``` -background (base): bg-glass-surface -background (hover): bg-glass-surface-hover -border: border-glass-border -backdrop-filter: backdrop-blur-md -``` +## Invariants +- **Single Brand Token**: Unified Violet `#6D28D9` across `@theme`, Clerk modal, and Landing custom cursor. +- **Never use raw Hex codes** inside components. +- **Never invent color utilities** not specified via `@theme`. +- **Film-Grain Overlay**: Locked `body::after` feTurbulence noise (z-index 9999, pointer-events none). +- **Cursor**: Custom cursor scoped strictly to `/`. Native system cursors on all text, inputs, and in-app screens. diff --git a/scripts/verify-contrast.mjs b/scripts/verify-contrast.mjs new file mode 100644 index 0000000..40ab09c --- /dev/null +++ b/scripts/verify-contrast.mjs @@ -0,0 +1,124 @@ +// Comprehensive WCAG 2.2 AA Contrast Verification Script for AppForge +function sRGBtoLin(c) { + c = c / 255; + return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4); +} + +function hexToRgb(hex) { + hex = hex.replace('#', ''); + if (hex.length === 3) hex = hex.split('').map(x => x + x).join(''); + return [ + parseInt(hex.slice(0, 2), 16), + parseInt(hex.slice(2, 4), 16), + parseInt(hex.slice(4, 6), 16) + ]; +} + +function oklchToRgb(l, c, h) { + const hr = (h || 0) * Math.PI / 180; + const a = c * Math.cos(hr); + const b = c * Math.sin(hr); + + const l_ = l + 0.3963377774 * a + 0.2158037573 * b; + const m_ = l - 0.1055613458 * a - 0.0638541728 * b; + const s_ = l - 0.0894841775 * a - 1.2914855480 * b; + + const l_cube = l_ * l_ * l_; + const m_cube = m_ * m_ * m_; + const s_cube = s_ * s_ * s_; + + const r_lin = +4.0767434770 * l_cube - 3.3077115913 * m_cube + 0.2309699292 * s_cube; + const g_lin = -1.2684380046 * l_cube + 2.6097574011 * m_cube - 0.3413193965 * s_cube; + const b_lin = -0.0041960863 * l_cube - 0.7034186147 * m_cube + 1.7076147010 * s_cube; + + function toSrgb(c_lin) { + const cl = Math.max(0, Math.min(1, c_lin)); + return cl <= 0.0031308 ? 12.92 * cl : 1.055 * Math.pow(cl, 1/2.4) - 0.055; + } + + return [Math.round(toSrgb(r_lin) * 255), Math.round(toSrgb(g_lin) * 255), Math.round(toSrgb(b_lin) * 255)]; +} + +function luminance(rgb) { + return 0.2126 * sRGBtoLin(rgb[0]) + 0.7152 * sRGBtoLin(rgb[1]) + 0.0722 * sRGBtoLin(rgb[2]); +} + +function getContrast(rgb1, rgb2) { + const l1 = luminance(rgb1); + const l2 = luminance(rgb2); + const lighter = Math.max(l1, l2); + const darker = Math.min(l1, l2); + return (lighter + 0.05) / (darker + 0.05); +} + +// Light theme tokens +const lightBg = oklchToRgb(0.985, 0, 0); // #fafafa +const lightCard = [255, 255, 255]; +const lightMuted = oklchToRgb(0.97, 0, 0); // #f4f4f5 +const lightFg = oklchToRgb(0.145, 0, 0); // #18181b +const lightMutedFg = oklchToRgb(0.45, 0, 0); // #6b6b70 +const brandLight = hexToRgb('#6D28D9'); // Violet 700 + +const lightTokens = [ + { name: 'Foreground on Background', fg: lightFg, bg: lightBg, min: 4.5 }, + { name: 'Foreground on Card', fg: lightFg, bg: lightCard, min: 4.5 }, + { name: 'Muted-Foreground on Background', fg: lightMutedFg, bg: lightBg, min: 4.5 }, + { name: 'Muted-Foreground on Muted Bg', fg: lightMutedFg, bg: lightMuted, min: 4.5 }, + { name: 'Brand (#6D28D9) on Background', fg: brandLight, bg: lightBg, min: 4.5 }, + { name: 'Brand (#6D28D9) on Card', fg: brandLight, bg: lightCard, min: 4.5 }, + { name: 'Error Text (#8C2E44) on Card', fg: hexToRgb('#8C2E44'), bg: lightCard, min: 4.5 }, + { name: 'Error Text (#8C2E44) on Error Light (#FBEAEE)', fg: hexToRgb('#8C2E44'), bg: hexToRgb('#FBEAEE'), min: 4.5 }, + { name: 'Warning Text (#784A15) on Card', fg: hexToRgb('#784A15'), bg: lightCard, min: 4.5 }, + { name: 'Warning Text (#784A15) on Warning Light (#FDF1E7)', fg: hexToRgb('#784A15'), bg: hexToRgb('#FDF1E7'), min: 4.5 }, + { name: 'Success Text (#2F7A55) on Card', fg: hexToRgb('#2F7A55'), bg: lightCard, min: 4.5 }, + { name: 'Success Text (#2F7A55) on Success Light (#EAF7F0)', fg: hexToRgb('#2F7A55'), bg: hexToRgb('#EAF7F0'), min: 4.5 }, +]; + +// Dark theme tokens +const darkBg = oklchToRgb(0.145, 0, 0); // #18181b +const darkCard = oklchToRgb(0.205, 0, 0); // #27272a +const darkMuted = oklchToRgb(0.269, 0, 0); // #3f3f46 +const darkFg = [255, 255, 255]; +const darkMutedFg = oklchToRgb(0.708, 0, 0); // #a1a1aa +const brandDarkText = hexToRgb('#A78BFA'); // Violet 400 for text/focus on dark + +const darkTokens = [ + { name: 'Foreground on Background', fg: darkFg, bg: darkBg, min: 4.5 }, + { name: 'Foreground on Card', fg: darkFg, bg: darkCard, min: 4.5 }, + { name: 'Muted-Foreground on Background', fg: darkMutedFg, bg: darkBg, min: 4.5 }, + { name: 'Muted-Foreground on Muted Bg', fg: darkMutedFg, bg: darkMuted, min: 4.5 }, + { name: 'Brand Text (#A78BFA) on Background', fg: brandDarkText, bg: darkBg, min: 4.5 }, + { name: 'Brand Text (#A78BFA) on Card', fg: brandDarkText, bg: darkCard, min: 4.5 }, + { name: 'Error Text (#F472B6) on Card', fg: hexToRgb('#F472B6'), bg: darkCard, min: 4.5 }, + { name: 'Error Text (#F472B6) on Error Light (#2E1119)', fg: hexToRgb('#F472B6'), bg: hexToRgb('#2E1119'), min: 4.5 }, + { name: 'Warning Text (#FBBF24) on Card', fg: hexToRgb('#FBBF24'), bg: darkCard, min: 4.5 }, + { name: 'Warning Text (#FBBF24) on Warning Light (#2D1E0A)', fg: hexToRgb('#FBBF24'), bg: hexToRgb('#2D1E0A'), min: 4.5 }, + { name: 'Success Text (#34D399) on Card', fg: hexToRgb('#34D399'), bg: darkCard, min: 4.5 }, + { name: 'Success Text (#34D399) on Success Light (#0B281A)', fg: hexToRgb('#34D399'), bg: hexToRgb('#0B281A'), min: 4.5 }, +]; + +console.log('=== LIGHT THEME WCAG 2.2 AA VERIFICATION ==='); +let lightPass = true; +lightTokens.forEach(t => { + const ratio = getContrast(t.fg, t.bg); + const pass = ratio >= t.min; + if (!pass) lightPass = false; + console.log(`${t.name.padEnd(55)}: ${ratio.toFixed(2).padStart(5)}:1 ${pass ? '✅ PASS' : '❌ FAIL'}`); +}); + +console.log('\n=== DARK THEME WCAG 2.2 AA VERIFICATION ==='); +let darkPass = true; +darkTokens.forEach(t => { + const ratio = getContrast(t.fg, t.bg); + const pass = ratio >= t.min; + if (!pass) darkPass = false; + console.log(`${t.name.padEnd(55)}: ${ratio.toFixed(2).padStart(5)}:1 ${pass ? '✅ PASS' : '❌ FAIL'}`); +}); + +if (lightPass && darkPass) { + console.log('\n>>> ALL TOKENS MEET OR EXCEED WCAG 2.2 AA (>= 4.5:1) IN BOTH LIGHT AND DARK MODES <<<'); +} else { + console.log('\n>>> SOME TOKENS FAILED CONTRAST CHECKS <<<'); + process.exit(1); +} + diff --git a/tsconfig.json b/tsconfig.json index 3a13f90..f826a63 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,5 +30,5 @@ ".next/dev/types/**/*.ts", "**/*.mts" ], - "exclude": ["node_modules"] + "exclude": ["node_modules", "infrasity_ref"] } From 666e9af4525fa14d5f93c9898631ef196b7c9283 Mon Sep 17 00:00:00 2001 From: Vipin Date: Mon, 16 Nov 2026 18:16:53 +0530 Subject: [PATCH 003/162] style(shell): refine shell and builder chrome, gitignore screenshots, and enforce WCAG button active contrast --- .gitignore | 4 + app/builder/[appId]/page.tsx | 12 +- app/dashboard/page.tsx | 1 - app/globals.css | 16 +-- app/page.tsx | 2 +- components/builder/CopilotPanel.tsx | 66 ++++----- components/builder/LivePreview.tsx | 36 ++++- components/builder/ValidationPanel.tsx | 14 +- components/dashboard/AppGrid.tsx | 16 +-- components/dashboard/FallbackEmpty.tsx | 10 +- components/dashboard/StatsBar.tsx | 39 +++-- components/homepage/Hero.tsx | 16 +-- components/layout/Navbar.tsx | 28 ++-- registry/components/ButtonAction.tsx | 10 +- registry/components/Card.tsx | 16 +-- registry/components/Header.tsx | 14 +- registry/index.tsx | 6 +- scripts/take-screenshots.mjs | 137 ++++++++++++++++++ scripts/verify-contrast.mjs | 189 ++++++++++++++----------- 19 files changed, 400 insertions(+), 232 deletions(-) create mode 100644 scripts/take-screenshots.mjs diff --git a/.gitignore b/.gitignore index c1abf8c..8fb4317 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,10 @@ agent-skills agent_skills claude.md agents.md +# Screenshots & Visual Audits +.screenshots/ +public/audit-screenshots/ +.taste-skill/ CLAUDE.md AGENTS.md diff --git a/app/builder/[appId]/page.tsx b/app/builder/[appId]/page.tsx index e460e24..3420d92 100644 --- a/app/builder/[appId]/page.tsx +++ b/app/builder/[appId]/page.tsx @@ -323,15 +323,15 @@ export default function BuilderPage() {
{isGenerating ? ( - + Generating ) : errors.length > 0 ? ( - + Has Errors ) : ( - + Ready )} @@ -354,7 +354,7 @@ export default function BuilderPage() { onClick={handlePublish} disabled={isPublishing} size="sm" - className="h-8 bg-brand hover:bg-brand-dark text-white font-medium text-xs shadow-md shadow-brand/20" + className="h-8 bg-brand hover:bg-brand-dark text-text-inverse font-medium text-xs shadow-sm transition-colors" > {isPublishing ? ( @@ -413,7 +413,7 @@ export default function BuilderPage() { Cancel - @@ -439,7 +439,7 @@ export default function BuilderPage() { className={ notificationModal.type === "error" ? "bg-red-600 hover:bg-red-700 text-white min-w-[100px]" - : "bg-brand hover:bg-brand-dark text-white min-w-[100px]" + : "bg-brand hover:bg-brand-dark text-text-inverse min-w-[100px]" } > Okay diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index de48f58..558e7e8 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -56,7 +56,6 @@ async function DashboardContent() {

Creator Dashboard

-

Welcome back. Here is an overview of your AppForge ecosystem.

User ID: {userId?.split('_')[1]?.substring(0, 5) || "MOCK"}*** diff --git a/app/globals.css b/app/globals.css index ab692b2..61cd137 100644 --- a/app/globals.css +++ b/app/globals.css @@ -106,7 +106,7 @@ @apply font-sans antialiased bg-background text-foreground; } * { - @apply border-border outline-ring/50; + @apply border-border outline-ring; scrollbar-width: thin; scrollbar-color: var(--theme-brand-light) transparent; } @@ -167,8 +167,8 @@ --accent-foreground: oklch(0.205 0 0); --destructive: oklch(0.577 0.245 27.325); --border: oklch(0.922 0 0); - --input: oklch(0.922 0 0); - --ring: oklch(0.45 0.2 290); + --input: #8E8E93; /* Non-text contrast 3.12:1 vs background */ + --ring: #6D28D9; /* Solid focus ring 6.81:1 vs background */ --chart-1: oklch(0.87 0 0); --chart-2: oklch(0.556 0 0); --chart-3: oklch(0.439 0 0); @@ -186,8 +186,8 @@ } .dark { - --theme-brand: #8B5CF6; /* Violet 500 for dark surfaces (AA 4.70:1) */ - --theme-brand-dark: #7C3AED; + --theme-brand: #A78BFA; /* Single Dark Brand Value: Violet 400 (AA 6.51:1 on bg, 5.47:1 on card) */ + --theme-brand-dark: #8B5CF6; /* Active fill (AA 4.70:1 with #09090B) */ --theme-brand-light: #2E1065; --theme-error: #F43F5E; @@ -216,13 +216,13 @@ --secondary: oklch(0.269 0 0); --secondary-foreground: oklch(1 0 0); --muted: oklch(0.269 0 0); - --muted-foreground: oklch(0.708 0 0); /* AA 7.66:1 on bg, 5.86:1 on muted */ + --muted-foreground: oklch(0.75 0 0); /* AA 8.59:1 on bg, 5.07:1 on muted */ --accent: oklch(0.269 0 0); --accent-foreground: oklch(0.985 0 0); --destructive: oklch(0.704 0.191 22.216); --border: oklch(1 0 0 / 10%); - --input: oklch(1 0 0 / 15%); - --ring: oklch(0.7 0.18 290); + --input: #71717A; /* Non-text contrast 3.67:1 vs background */ + --ring: #A78BFA; /* Solid focus ring 6.51:1 vs background */ --chart-1: oklch(0.87 0 0); --chart-2: oklch(0.556 0 0); --chart-3: oklch(0.439 0 0); diff --git a/app/page.tsx b/app/page.tsx index e255a92..8999537 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,4 +1,4 @@ -import { Navbar } from "@/components/layout/Navbar"; +import { Navbar } from "@/components/layout/Navbar"; import { Hero } from "@/components/homepage/Hero"; import { Features } from "@/components/homepage/Features"; import { Footer } from "@/components/layout/Footer"; diff --git a/components/builder/CopilotPanel.tsx b/components/builder/CopilotPanel.tsx index 882fb6c..db5eb26 100644 --- a/components/builder/CopilotPanel.tsx +++ b/components/builder/CopilotPanel.tsx @@ -1,6 +1,6 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; -import { Sparkles, X, Loader2, Send } from "lucide-react"; +import { X, Loader2, Send } from "lucide-react"; export function CopilotPanel({ onApply, onStreamStart, onStream, onStreamEnd }: { onApply: (components: unknown[]) => void, onStreamStart?: () => void, onStream?: (text: string) => void, onStreamEnd?: () => void }) { const [isOpen, setIsOpen] = useState(false); @@ -114,27 +114,38 @@ export function CopilotPanel({ onApply, onStreamStart, onStream, onStreamEnd }: } }; + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") { + e.preventDefault(); + setIsOpen(prev => !prev); + } + }; + window.addEventListener("keydown", handleKeyDown); + return () => window.removeEventListener("keydown", handleKeyDown); + }, []); + if (!isOpen) { return ( ); } return ( -
-
+
+
- - AppForge Copilot + Copilot + ⌘K
-
@@ -142,32 +153,21 @@ export function CopilotPanel({ onApply, onStreamStart, onStream, onStreamEnd }: {messages.map((m, i) => (
- {m.role === 'ai' && i === 0 && ( -
- - AppForge -
- )} {m.content}
))} {isGenerating && (
-
- - Synthesizing UI... +
+ + Synthesizing UI schema...
)} @@ -187,18 +187,18 @@ export function CopilotPanel({ onApply, onStreamStart, onStream, onStreamEnd }: void handleGenerate(e); } }} - placeholder="e.g. Generate a dark-mode CRM..." - className="flex-1 bg-muted border border-border/50 rounded-2xl min-h-[44px] max-h-[120px] py-3 px-4 text-sm text-foreground resize-none focus:outline-none focus:ring-1 focus:ring-brand/50 transition-all overflow-y-auto leading-relaxed" + placeholder="e.g. Generate an incident dashboard with metrics..." + className="flex-1 bg-muted border border-border rounded-md min-h-[38px] max-h-[100px] py-2 px-3 text-xs text-foreground resize-none focus:outline-none focus:ring-1 focus:ring-ring transition-colors overflow-y-auto leading-relaxed" disabled={isGenerating} rows={prompt.length > 50 ? 2 : 1} />
diff --git a/components/builder/LivePreview.tsx b/components/builder/LivePreview.tsx index 0098285..80201e9 100644 --- a/components/builder/LivePreview.tsx +++ b/components/builder/LivePreview.tsx @@ -1,4 +1,4 @@ -import { RenderNode } from "@/registry"; +import { RenderNode } from "@/registry"; import { Skeleton } from "@/components/ui/skeleton"; import { motion, AnimatePresence } from "framer-motion"; @@ -26,17 +26,37 @@ function PreviewSkeleton() { ); } +function extractJsonParsePosition(err: unknown, raw: string): { line?: number; column?: number } { + if (!(err instanceof Error)) return {}; + const msg = err.message; + const lineColMatch = msg.match(/line\s+(\d+).*?column\s+(\d+)/i); + if (lineColMatch) { + return { line: parseInt(lineColMatch[1], 10), column: parseInt(lineColMatch[2], 10) }; + } + const posMatch = msg.match(/position\s+(\d+)/i); + if (posMatch) { + const pos = parseInt(posMatch[1], 10); + if (!isNaN(pos) && pos >= 0 && pos <= raw.length) { + const lines = raw.slice(0, pos).split("\n"); + return { line: lines.length, column: lines[lines.length - 1].length + 1 }; + } + } + return {}; +} + export function LivePreview({ configStr }: { configStr: string }) { let config; let parseError = false; + let errorPosition: { line?: number; column?: number } = {}; const isStreaming = configStr.includes('"<<>>"'); try { if (!isStreaming) { config = JSON.parse(configStr); } - } catch { + } catch (err: unknown) { parseError = true; + errorPosition = extractJsonParsePosition(err, configStr); } return ( @@ -50,10 +70,16 @@ export function LivePreview({ configStr }: { configStr: string }) { initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} - className="text-[#FFBD2E]/80 text-sm flex flex-col gap-4 items-center justify-center h-full font-mono" + className="text-warning-text text-sm flex flex-col gap-2 items-center justify-center h-full font-mono p-6 bg-warning-light/30 border border-warning-border/50 rounded-lg max-w-md mx-auto" > - ⚠️ - Syntax Error in JSON Config. Fix commas/quotes to compile. + ⚠️ + + Malformed configuration JSON + {errorPosition.line ? ` at line ${errorPosition.line}, column ${errorPosition.column}` : ""} + + + Inspect quotes, commas, and entity structures. + ) : ( Validation Log {!isGenerating && (
-
+
{errors.length}
-
+
{warnings.length}
@@ -26,25 +26,25 @@ export function ValidationPanel({ errors, warnings, isGenerating }: ValidationPa
{isGenerating ? ( -
+
AI actively rendering. Validation suspended...
) : ( <> {errors.length === 0 && warnings.length === 0 && ( -
+
0 issues. Config is structurally perfect.
)} {errors.map((err, i) => ( -
+
[ERR] {err}
))} {warnings.map((warn, i) => ( -
+
[WARN] {warn}
))} diff --git a/components/dashboard/AppGrid.tsx b/components/dashboard/AppGrid.tsx index 7d67db7..bfba8bd 100644 --- a/components/dashboard/AppGrid.tsx +++ b/components/dashboard/AppGrid.tsx @@ -1,4 +1,4 @@ -"use client"; +"use client"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; @@ -78,11 +78,11 @@ export function AppGrid({ initialApps }: { initialApps: AppData[] }) { onClick={handleCreate} className="bg-card/50 border-dashed border-2 border-border hover:border-brand/60 hover:bg-card transition-all cursor-pointer flex flex-col items-center justify-center min-h-[220px] group shadow-none" > -
+
{isPending ? ( - + ) : ( - + )}
@@ -120,10 +120,10 @@ export function AppGrid({ initialApps }: { initialApps: AppData[] }) {
{app.status} @@ -167,7 +167,7 @@ export function AppGrid({ initialApps }: { initialApps: AppData[] }) { {app.status === "Published" && ( - diff --git a/components/dashboard/FallbackEmpty.tsx b/components/dashboard/FallbackEmpty.tsx index d19747f..52f65bb 100644 --- a/components/dashboard/FallbackEmpty.tsx +++ b/components/dashboard/FallbackEmpty.tsx @@ -20,24 +20,24 @@ export function FallbackEmpty() {
-

No Applications Found

+

No apps yet

- Your workspace is completely empty. Initiate your first project instance to begin leveraging the AppForge engine. + Create one from a prompt.

diff --git a/components/dashboard/StatsBar.tsx b/components/dashboard/StatsBar.tsx index b6cd9ad..7dc49fa 100644 --- a/components/dashboard/StatsBar.tsx +++ b/components/dashboard/StatsBar.tsx @@ -1,4 +1,4 @@ -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { AppWindow, Layers, AlertCircle, Zap } from "lucide-react"; export function StatsBar({ counts = { apps: 12, components: 14392, drafts: 3, published: 1244 } }: { counts?: { apps: number, components: number, drafts: number, published: number } }) { @@ -7,49 +7,44 @@ export function StatsBar({ counts = { apps: 12, components: 14392, drafts: 3, pu title: "Apps Created", value: counts.apps.toString(), change: "Total registered", - icon: , }, { title: "Components Rendered", value: counts.components.toLocaleString(), change: "Across all apps", - icon: , }, { title: "Drafts (Action Req)", value: counts.drafts.toString(), change: "Unpublished edits", - icon: , + highlight: counts.drafts > 0 ? "text-warning-text" : undefined, }, { title: "Active Workflows", value: counts.published.toString(), change: "Live deployments", - icon: , }, ]; return ( -
+
{stats.map((stat, i) => ( - - - - {stat.title} - -
- {stat.icon} -
-
- -
+
+
+ {stat.title} +
+
+
{stat.value}
-

- {stat.change} -

- - +
+
+ {stat.change} +
+
))}
); diff --git a/components/homepage/Hero.tsx b/components/homepage/Hero.tsx index aaeafd8..63bde6f 100644 --- a/components/homepage/Hero.tsx +++ b/components/homepage/Hero.tsx @@ -1,4 +1,4 @@ -"use client"; +"use client"; import Link from "next/link"; import { LayoutTemplate } from "lucide-react"; @@ -85,22 +85,22 @@ export function Hero() { className="bg-card rounded-xl border border-border shadow-[0_15px_35px_-10px_rgba(0,0,0,0.1),0_5px_15px_-5px_rgba(108,87,164,0.1)] flex flex-col md:flex-row overflow-hidden text-left min-h-[440px] transition-all duration-500 relative z-10 w-full" > {/* Editor Side: Full Mac Window Pane */} -
+
{/* Traffic Light Menu Bar */} -
+
-
-
-
+
+
+
- app.config.json + app.config.json
{/* Code */}
-
+              
 {`{
   "app": "ops_dashboard",
   "pages": [{
diff --git a/components/layout/Navbar.tsx b/components/layout/Navbar.tsx
index 944839c..5e36adb 100644
--- a/components/layout/Navbar.tsx
+++ b/components/layout/Navbar.tsx
@@ -1,4 +1,4 @@
-"use client";
+"use client";
 
 import { useState } from "react";
 import Link from "next/link";
@@ -39,21 +39,11 @@ export function Navbar() {
         onMouseEnter={() => setIsHovered(true)}
         onMouseLeave={() => setIsHovered(false)}
       >
-         
-           
-           
- -
- - AppForge - - - AppForge - +
+ +
+
+ AppForge
@@ -103,9 +93,9 @@ export function Navbar() { - + - @@ -153,7 +143,7 @@ export function Navbar() { - diff --git a/registry/components/ButtonAction.tsx b/registry/components/ButtonAction.tsx index 5e96e04..2942d39 100644 --- a/registry/components/ButtonAction.tsx +++ b/registry/components/ButtonAction.tsx @@ -1,4 +1,4 @@ -import { Button } from "@/components/ui/button"; +import { Button } from "@/components/ui/button"; import { ArrowRight, Save, Play, Plus, Search } from "lucide-react"; export function ButtonAction({ label, variant = "default", icon }: { label?: string, variant?: "default" | "outline" | "secondary" | "ghost", icon?: string }) { @@ -16,12 +16,12 @@ export function ButtonAction({ label, variant = "default", icon }: { label?: str -
- +
+ App Builder - + / + {appId}
diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index 558e7e8..06c914d 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -53,13 +53,8 @@ async function DashboardContent() {
{/* Header section */} -
-
-

Creator Dashboard

-
-
- User ID: {userId?.split('_')[1]?.substring(0, 5) || "MOCK"}*** -
+
+

Creator Dashboard

{/* Stats Strip */} diff --git a/app/globals.css b/app/globals.css index 61cd137..9c8f92f 100644 --- a/app/globals.css +++ b/app/globals.css @@ -193,7 +193,7 @@ --theme-error: #F43F5E; --theme-error-light: #2E1119; --theme-error-border: #8C2E44; - --theme-error-text: #F472B6; /* AA 6.77:1 on card, 6.55:1 on error-light */ + --theme-error-text: #FB7185; /* Rose 400: AA 5.49:1 on card, 6.19:1 on error-light */ --theme-warning: #F59E0B; --theme-warning-light: #2D1E0A; diff --git a/app/test-renderers/page.tsx b/app/test-renderers/page.tsx new file mode 100644 index 0000000..5dae3d1 --- /dev/null +++ b/app/test-renderers/page.tsx @@ -0,0 +1,95 @@ +"use client"; + +import { DataTable } from "@/registry/components/DataTable"; +import { Grid } from "@/registry/components/Grid"; +import { Card } from "@/registry/components/Card"; +import { ButtonAction } from "@/registry/components/ButtonAction"; + +const sampleColumns = [ + { key: "id", label: "Invoice ID", type: "id" as const }, + { key: "customer", label: "Customer", type: "text" as const }, + { key: "amount", label: "Amount ($)", type: "number" as const }, + { key: "status", label: "Status", type: "badge" as const }, +]; + +const sampleData = [ + { id: "INV-0091", customer: "Acme Logistics", amount: 14250, status: "Published" }, + { id: "INV-0092", customer: "Starlight Media", amount: 3800, status: "Pending" }, + { id: "INV-0093", customer: "Helix Robotics", amount: 29400, status: "Active" }, + { id: "INV-0094", customer: "Vanguard Tech", amount: 8120, status: "Failed" }, +]; + +export default function TestRenderersPage() { + return ( +
+
+

Renderer States Verification

+

AppForge design-taste-frontend renderer compliance test

+
+ + {/* State 1: Loading Skeleton */} +
+
+

1. Loading Skeleton State

+ state="loading" +
+ +
+ + {/* State 2: Loaded */} +
+
+

2. Loaded State (Right-aligned numbers, monospaced IDs, badges)

+ state="loaded" +
+ +
+ + {/* State 3: Empty */} +
+
+

3. Empty State (Preserves headers & frame)

+ state="empty" +
+ +
+ + {/* State 4: Scoped Error */} +
+
+

4. Scoped Error State (Contained within frame)

+ state="error" +
+ +
+ + {/* State 5: Degraded */} +
+
+

5. Degraded State (Cached data with status banner)

+ state="degraded" +
+ +
+ + {/* Grid Component Test */} +
+

Grid System (gap-4, items-stretch, responsive)

+ +
+
+ ); +} diff --git a/components/builder/CopilotPanel.tsx b/components/builder/CopilotPanel.tsx index db5eb26..32e1ffa 100644 --- a/components/builder/CopilotPanel.tsx +++ b/components/builder/CopilotPanel.tsx @@ -117,6 +117,13 @@ export function CopilotPanel({ onApply, onStreamStart, onStream, onStreamEnd }: useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") { + const target = e.target as HTMLElement | null; + if (target) { + const tagName = target.tagName.toLowerCase(); + const isInput = tagName === "input" || tagName === "textarea" || target.isContentEditable; + const isEditor = target.closest(".monaco-editor, .cm-editor, [data-code-editor], textarea"); + if (isInput || isEditor) return; + } e.preventDefault(); setIsOpen(prev => !prev); } diff --git a/components/builder/LivePreview.tsx b/components/builder/LivePreview.tsx index 80201e9..9e0447f 100644 --- a/components/builder/LivePreview.tsx +++ b/components/builder/LivePreview.tsx @@ -60,7 +60,7 @@ export function LivePreview({ configStr }: { configStr: string }) { } return ( -
+
{isStreaming ? ( diff --git a/components/dashboard/AppGrid.tsx b/components/dashboard/AppGrid.tsx index bfba8bd..ef56015 100644 --- a/components/dashboard/AppGrid.tsx +++ b/components/dashboard/AppGrid.tsx @@ -150,7 +150,7 @@ export function AppGrid({ initialApps }: { initialApps: AppData[] }) { }} />
- </> + </> app.config.json
diff --git a/components/dashboard/FallbackEmpty.tsx b/components/dashboard/FallbackEmpty.tsx index 52f65bb..47ef2b4 100644 --- a/components/dashboard/FallbackEmpty.tsx +++ b/components/dashboard/FallbackEmpty.tsx @@ -1,5 +1,6 @@ "use client"; +import Link from "next/link"; import { FolderPlus, Loader2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { createApp } from "@/actions/apps"; @@ -22,7 +23,10 @@ export function FallbackEmpty() {

No apps yet

- Create one from a prompt. + Create one from a prompt or{" "} + + start from a template + .

- - - - - - Analytics CRM - Heavy metrics layout for phase 2 charts. - - -
- -
-
-
- - - Blank Canvas - Start from complete scratch in the editor. - - -
- -
-
-
+ +
+ {templates.map((tpl) => { + const Icon = tpl.icon; + return ( + + +
+
+ +
+ + {tpl.tag} + +
+ + {tpl.title} + + + {tpl.description} + +
+ +
+ +
+
+
+ ); + })}
-
-
-
+
+ ); } - diff --git a/components/dashboard/AppCard.tsx b/components/dashboard/AppCard.tsx new file mode 100644 index 0000000..69e73b2 --- /dev/null +++ b/components/dashboard/AppCard.tsx @@ -0,0 +1,184 @@ +"use client"; + +import { useState } from "react"; +import Link from "next/link"; +import { useRouter } from "next/navigation"; +import { AppThumbnail } from "@/components/dashboard/AppThumbnail"; +import { MoreHorizontal, ExternalLink, Settings2, Edit3, Trash2, CheckCircle2 } from "lucide-react"; +import type { AppData } from "@/components/dashboard/AppGrid"; + +type Props = { + app: AppData & { + config?: unknown; + published_config?: unknown; + }; + onRename: (appId: string, currentName: string) => void; + onDelete: (appId: string) => void; + variant?: "linear" | "vercel"; +}; + +export function formatRelativeTime(dateStr: string): string { + if (!dateStr) return "Just now"; + const ms = Date.now() - new Date(dateStr).getTime(); + const mins = Math.max(0, Math.floor(ms / 60000)); + if (mins < 1) return "Just now"; + if (mins === 1) return "1 min ago"; + if (mins < 60) return `${mins} mins ago`; + const hours = Math.floor(mins / 60); + if (hours === 1) return "1 hour ago"; + if (hours < 24) return `${hours} hours ago`; + const days = Math.floor(hours / 24); + if (days === 1) return "1 day ago"; + if (days < 30) return `${days} days ago`; + const months = Math.floor(days / 30); + if (months === 1) return "1 month ago"; + return `${months} months ago`; +} + +export function AppCard({ app, onRename, onDelete, variant = "linear" }: Props) { + const router = useRouter(); + const [isMenuOpen, setIsMenuOpen] = useState(false); + + const isPublished = app.status === "Published"; + const appConfig = app.config || app.published_config; + + const handleCardClick = (e: React.MouseEvent) => { + // If the click is inside the overflow menu or button, don't navigate + const target = e.target as HTMLElement; + if (target.closest("[data-no-navigate]")) return; + + router.push(`/builder/${app.id}`); + }; + + return ( +
{ + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + router.push(`/builder/${app.id}`); + } + }} + > + {/* 16:10 Live Thumbnail */} + + + {/* Card Body */} +
+
+ {/* App title & metadata */} +
+
+

+ {app.name} +

+
+

+ Edited {formatRelativeTime(app.updated_at)} +

+
+ + {/* Status Badge + Overflow menu */} +
+ + {isPublished && } + {app.status} + + + {/* Overflow Menu Trigger */} +
+ + + {/* Dropdown Menu */} + {isMenuOpen && ( + <> +
{ + e.stopPropagation(); + setIsMenuOpen(false); + }} + /> +
e.stopPropagation()} + > + setIsMenuOpen(false)} + > + + Open in builder + + + {isPublished && ( + setIsMenuOpen(false)} + > + + Run app + + )} + + + +
+ + +
+ + )} +
+
+
+
+
+ ); +} diff --git a/components/dashboard/AppThumbnail.tsx b/components/dashboard/AppThumbnail.tsx new file mode 100644 index 0000000..10b8bb1 --- /dev/null +++ b/components/dashboard/AppThumbnail.tsx @@ -0,0 +1,120 @@ +"use client"; + +import React, { Component, ReactNode } from "react"; +import { RenderNode } from "@/registry"; +import { AlertCircle } from "lucide-react"; + +interface ErrorBoundaryProps { + children: ReactNode; + fallback: ReactNode; +} + +interface ErrorBoundaryState { + hasError: boolean; + error?: Error; +} + +class ThumbnailErrorBoundary extends Component { + constructor(props: ErrorBoundaryProps) { + super(props); + this.state = { hasError: false }; + } + + static getDerivedStateFromError(error: Error): ErrorBoundaryState { + return { hasError: true, error }; + } + + componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { + console.warn("[ThumbnailRenderError]", error, errorInfo); + } + + render() { + if (this.state.hasError) { + return this.props.fallback; + } + return this.props.children; + } +} + +type Props = { + config?: unknown; +}; + +export function AppThumbnail({ config }: Props) { + let parsedConfig: { + app?: string; + pages?: Array<{ + title?: string; + components?: Array>; + }>; + components?: Array>; + } | null = null; + + let parseError = false; + + try { + if (typeof config === "string") { + parsedConfig = JSON.parse(config); + } else if (config && typeof config === "object") { + parsedConfig = config as unknown as typeof parsedConfig; + } + } catch { + parseError = true; + } + + const components = + parsedConfig?.pages?.[0]?.components || + (Array.isArray(parsedConfig?.components) ? parsedConfig?.components : []); + + const hasComponents = Array.isArray(components) && components.length > 0; + + // Scoped error state when configuration fails + const errorFallback = ( +
+
+ +
+ + Scoped render error + + + Component failed in this preview + +
+ ); + + return ( +
+ + {/* Auth Requirement Modal */} {authRequireMessage && (
@@ -426,25 +715,26 @@ export default function BuilderPage() {
)} + {/* Notification Modal */} {notificationModal && (

{notificationModal.title}

-

+

{notificationModal.message}

diff --git a/components/builder/CopilotPanel.tsx b/components/builder/CopilotPanel.tsx index fcaf0b6..debf4a7 100644 --- a/components/builder/CopilotPanel.tsx +++ b/components/builder/CopilotPanel.tsx @@ -1,32 +1,43 @@ +"use client"; + import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; -import { X, Loader2, Send } from "lucide-react"; +import { X, Loader2, Send, Sparkles } from "lucide-react"; export function CopilotPanel({ + isOpen, + onClose, onApply, onStreamStart, onStream, onStreamEnd, initialPrompt, }: { + isOpen: boolean; + onClose: () => void; onApply: (components: unknown[]) => void; onStreamStart?: () => void; onStream?: (text: string) => void; onStreamEnd?: () => void; initialPrompt?: string; }) { - const [isOpen, setIsOpen] = useState(!!initialPrompt); const [prompt, setPrompt] = useState(initialPrompt || ""); const [isGenerating, setIsGenerating] = useState(false); useEffect(() => { if (initialPrompt) { setPrompt(initialPrompt); - setIsOpen(true); } }, [initialPrompt]); - const [messages, setMessages] = useState<{ role: "ai" | "user"; content: string }[]>([ - { role: "ai", content: "I am ready to build! Ask me to generate headers, grids, buttons, or full dashboard layouts for you." } + + const [messages, setMessages] = useState< + { role: "ai" | "user"; content: string }[] + >([ + { + role: "ai", + content: + "I am ready to build! Describe what components, metrics, or tables you'd like to generate.", + }, ]); const handleGenerate = async (e: React.FormEvent) => { @@ -34,18 +45,18 @@ export function CopilotPanel({ if (!prompt.trim() || isGenerating) return; const currentPrompt = prompt; - setMessages(prev => [...prev, { role: "user", content: currentPrompt }]); + setMessages((prev) => [...prev, { role: "user", content: currentPrompt }]); setPrompt(""); setIsGenerating(true); let streamedText = ""; - + try { if (onStreamStart) onStreamStart(); const res = await fetch("/api/copilot", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ prompt }), + body: JSON.stringify({ prompt: currentPrompt }), }); if (!res.ok) { @@ -65,13 +76,11 @@ export function CopilotPanel({ const chunk = decoder.decode(value, { stream: true }); streamedText += chunk; - // Pass the raw chunk stream directly to the UI without heavy parsing if (onStream) { onStream(streamedText); } } - // 1. Strip conversational filler and markdown blocks by precisely isolating the JSON array/object let finalText = streamedText .replace(/```json/gi, "") .replace(/```/g, "") @@ -93,39 +102,47 @@ export function CopilotPanel({ if (finalText) { let parsed = JSON.parse(finalText); - // 2. Unpack double-stringified LLM JSON artifacts if (typeof parsed === "string") { try { parsed = JSON.parse(parsed); } catch {} } - // 3. Drill down if it hallucinated the overarching registry structure if (parsed?.pages?.[0]?.components) { parsed = parsed.pages[0].components; } else if (parsed?.components && Array.isArray(parsed.components)) { parsed = parsed.components; } - // 4. Force strict schema structure for the UI array const finalArray = Array.isArray(parsed) ? parsed : [parsed]; - onApply(finalArray); setMessages((prev) => [ ...prev, { role: "ai", - content: - "I've correctly compiled the new canvas UI from the generated AST!", + content: "I've synthesized the new components into your config!", }, ]); } } catch (err) { const e = err as Error; - if (e.message && (e.message.includes("exhausted") || e.message.includes("429"))) { - setMessages(prev => [...prev, { role: "ai", content: "All configured Gemini API Keys have exhausted their daily quotas. Please add GEMINI_API_KEY_2 to your .env.local file to continue." }]); + if ( + e.message && + (e.message.includes("exhausted") || e.message.includes("429")) + ) { + setMessages((prev) => [ + ...prev, + { + role: "ai", + content: + "Gemini API quota exhausted. Please check back shortly or update API keys.", + }, + ]); } else { - setMessages(prev => [...prev, { role: "ai", content: `Sorry, I encountered an error: ${e.message}` }]); + setMessages((prev) => [ + ...prev, + { role: "ai", content: `Error: ${e.message}` }, + ]); } } finally { setIsGenerating(false); @@ -133,101 +150,97 @@ export function CopilotPanel({ } }; - useEffect(() => { - const handleKeyDown = (e: KeyboardEvent) => { - if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") { - const target = e.target as HTMLElement | null; - if (target) { - const tagName = target.tagName.toLowerCase(); - const isInput = tagName === "input" || tagName === "textarea" || target.isContentEditable; - const isEditor = target.closest(".monaco-editor, .cm-editor, [data-code-editor], textarea"); - if (isInput || isEditor) return; - } - e.preventDefault(); - setIsOpen(prev => !prev); - } - }; - window.addEventListener("keydown", handleKeyDown); - return () => window.removeEventListener("keydown", handleKeyDown); - }, []); - - if (!isOpen) { - return ( - - ); - } + if (!isOpen) return null; return ( -
-
-
- Copilot - ⌘K -
- +
+ {/* Header */} +
+
+ + + Gemini Copilot + + + ⌘K + +
+
-
- {messages.map((m, i) => ( -
-
- {m.content} -
-
- ))} - {isGenerating && ( -
-
- - Synthesizing UI schema... -
-
- )} + {/* Messages Feed */} +
+ {messages.map((m, i) => ( +
+
+ + {m.content} + +
+
+ ))} + {isGenerating && ( +
+
+ + Generating JSON schema... +
+
+ )}
-
{ e.preventDefault(); void handleGenerate(e); }} - className="p-3 border-t border-border bg-card flex items-end gap-2" + {/* Input Form */} + -