From 12ef6b05f4559f649b045ef9647c8f31b97275ed Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 20 Aug 2026 09:27:44 +0000 Subject: [PATCH 1/3] fix: restore console dashboard visibility on React hosts Mount React console pages in a real flex box instead of display:contents, which WebKit can omit from the box tree and hide every dashboard card. Keep card surfaces on explicit HSL tokens and add regression coverage for the host and admin dashboard. Co-authored-by: GeekMr --- Makefile | 2 + frontend/src/console/ReactPageHost.spec.ts | 61 ++++++++++ frontend/src/console/ReactPageHost.vue | 20 +++- .../src/console/react/DashboardPage.test.ts | 107 ++++++++++++++++++ frontend/src/console/react/DashboardPage.tsx | 24 ++-- .../src/console/react/ModelDistribution.ts | 2 +- .../src/console/react/TokenUsageTrend.tsx | 5 +- frontend/src/console/react/ui/card.tsx | 4 +- frontend/src/console/react/ui/sidebar.tsx | 2 +- frontend/src/console/react/ui/skeleton.tsx | 2 +- frontend/src/styles/ui-layout.css | 14 +++ .../styles/ui-modern-compat-parts/part-03.css | 12 ++ frontend/vitest.config.ts | 3 + 13 files changed, 235 insertions(+), 23 deletions(-) create mode 100644 frontend/src/console/ReactPageHost.spec.ts create mode 100644 frontend/src/console/react/DashboardPage.test.ts diff --git a/Makefile b/Makefile index e0900efba..8ddf51fa2 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,8 @@ FRONTEND_CRITICAL_VITEST := \ src/api/__tests__/admin.features.spec.ts \ src/api/admin/__tests__/backup.spec.ts \ src/views/admin/__tests__/FeatureRegistryView.spec.ts \ + src/console/ReactPageHost.spec.ts \ + src/console/react/DashboardPage.test.ts \ src/router/__tests__/progressive-routes.spec.ts \ src/components/ui/__tests__/primitives.spec.ts \ src/ui-platform/chartTheme.test.ts \ diff --git a/frontend/src/console/ReactPageHost.spec.ts b/frontend/src/console/ReactPageHost.spec.ts new file mode 100644 index 000000000..56347ecd7 --- /dev/null +++ b/frontend/src/console/ReactPageHost.spec.ts @@ -0,0 +1,61 @@ +import { readFileSync } from 'node:fs' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' + +import { act, createElement } from 'react' +import { flushPromises, mount } from '@vue/test-utils' +import { describe, expect, it } from 'vitest' + +import ReactPageHost from './ReactPageHost.vue' + +;(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true + +const src = resolve(dirname(fileURLToPath(import.meta.url))) +const hostSource = readFileSync(resolve(src, 'ReactPageHost.vue'), 'utf8') +const layoutSource = readFileSync(resolve(src, '../styles/ui-layout.css'), 'utf8') +const cardSource = readFileSync(resolve(src, 'react/ui/card.tsx'), 'utf8') + +function VisibleDashboardStub() { + return createElement( + 'div', + { 'data-slot': 'card', className: 'card bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))]' }, + 'API Keys', + ) +} + +describe('React console host visibility', () => { + it('mounts React pages in a real layout box instead of display:contents', () => { + expect(hostSource).not.toMatch(/class="contents"/) + expect(hostSource).toContain('data-console-runtime="react"') + expect(hostSource).toContain('console-runtime-host') + expect(hostSource).toContain('flex h-full min-h-0 min-w-0 w-full flex-1 flex-col') + expect(layoutSource).toContain("[data-console-runtime='react']") + expect(layoutSource).toContain('display: flex;') + expect(layoutSource).not.toMatch(/\[data-console-runtime='react'\][^{]*contents/) + expect(cardSource).toContain('bg-[hsl(var(--card))]') + expect(cardSource).toContain('text-[hsl(var(--card-foreground))]') + }) + + it('renders dashboard metric cards into the host so they stay in the box tree', async () => { + const wrapper = mount(ReactPageHost, { + props: { + load: async () => ({ default: VisibleDashboardStub }), + props: {}, + errorMessage: 'Failed to load console page', + }, + attachTo: document.body, + }) + + await act(async () => { + await flushPromises() + }) + + const host = wrapper.get('[data-console-runtime="react"]') + expect(host.classes()).toContain('console-runtime-host') + expect(host.classes()).not.toContain('contents') + expect(wrapper.text()).toContain('API Keys') + expect(wrapper.find('[data-slot="card"]').exists()).toBe(true) + + wrapper.unmount() + }) +}) diff --git a/frontend/src/console/ReactPageHost.vue b/frontend/src/console/ReactPageHost.vue index 4f60b6797..7e5d06458 100644 --- a/frontend/src/console/ReactPageHost.vue +++ b/frontend/src/console/ReactPageHost.vue @@ -1,5 +1,9 @@