diff --git a/ROADMAP.md b/ROADMAP.md index 620fc85c..913a06ca 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -401,6 +401,17 @@ ObjectUI is a universal Server-Driven UI (SDUI) engine built on React + Tailwind - [x] Updated SchemaRenderer mock to forward `className` and include interactive child button for more realistic testing - [x] Add 9 new Vitest tests: pointer-events-none presence/absence, overlay presence/absence, relative positioning, click-to-select on Card-based widgets +**Phase 10 — Debug / Diagnostic Mode:** +- [x] Add `debug?: boolean` field to `DashboardSchema` type definition +- [x] Add `'dashboard'` to core `DebugCategory` type for `debugLog()` integration +- [x] Implement `DashboardDebugOverlay` — collapsible diagnostic panel rendered at dashboard top when `schema.debug: true` or `SchemaRendererProvider debug` context is enabled +- [x] Per-widget diagnostics: type, resolved component type, data presence, `provider:object` status, `objectName`, aggregate config +- [x] Color-coded status: green border for widgets with data/provider, red border for missing data +- [x] Console logging via `debugLog('dashboard', ...)` when `OBJECTUI_DEBUG` is globally enabled +- [x] Integrate debug mode into both `DashboardRenderer` and `DashboardGridLayout` +- [x] Export `DashboardDebugOverlay` and `WidgetDebugInfo` from `@object-ui/plugin-dashboard` +- [x] Add 7 Vitest tests (overlay render, toggle expand, per-widget diagnostics, provider:object identification, debugLog emission) + ### P1.11 Console — Schema-Driven View Config Panel Migration > Migrated the Console ViewConfigPanel from imperative implementation (~1655 lines) to Schema-Driven architecture using `ConfigPanelRenderer` + `useConfigDraft` + `ConfigPanelSchema`, reducing to ~170 lines declarative wrapper + schema factory. diff --git a/packages/core/src/utils/debug.ts b/packages/core/src/utils/debug.ts index 38a4eeda..dd22d66e 100644 --- a/packages/core/src/utils/debug.ts +++ b/packages/core/src/utils/debug.ts @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. */ -type DebugCategory = 'schema' | 'registry' | 'expression' | 'action' | 'plugin' | 'render'; +type DebugCategory = 'schema' | 'registry' | 'expression' | 'action' | 'plugin' | 'render' | 'dashboard'; function isDebugEnabled(): boolean { try { diff --git a/packages/plugin-dashboard/src/DashboardDebugOverlay.tsx b/packages/plugin-dashboard/src/DashboardDebugOverlay.tsx new file mode 100644 index 00000000..96abffed --- /dev/null +++ b/packages/plugin-dashboard/src/DashboardDebugOverlay.tsx @@ -0,0 +1,110 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import { useState } from 'react'; +import { cn } from '@object-ui/components'; +import { Bug, ChevronDown, ChevronUp } from 'lucide-react'; + +/** Per-widget diagnostic information surfaced by the debug overlay. */ +export interface WidgetDebugInfo { + id: string; + title?: string; + type?: string; + resolvedType?: string; + hasData: boolean; + isObjectProvider: boolean; + objectName?: string; + hasAggregate: boolean; + dataSnapshot?: unknown; +} + +export interface DashboardDebugOverlayProps { + dashboardTitle?: string; + widgetCount: number; + hasDataSource: boolean; + dataSourceKeys?: string[]; + widgets: WidgetDebugInfo[]; +} + +/** + * Visual debug overlay rendered at the top of a Dashboard when `debug: true`. + * Shows data-chain diagnostics for every widget so developers can quickly + * locate broken dataSource/context injection, missing objectName, or + * absent aggregate configs. + */ +export function DashboardDebugOverlay({ + dashboardTitle, + widgetCount, + hasDataSource, + dataSourceKeys, + widgets, +}: DashboardDebugOverlayProps) { + const [expanded, setExpanded] = useState(false); + + return ( +