Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(marketing): style sample workspace before client scripts load (#8147)
Jacob Beckermanbbdbea9978af
diff --git a/apps/marketing/README.md b/apps/marketing/README.mdindex 6dae8e3ebd..7b330d60a5 100644--- a/apps/marketing/README.md+++ b/apps/marketing/README.md@@ -9,7 +9,8 @@ The public site, product pages, blog, sample workspace, and signup introductionfollow the visitor's system color scheme. `?theme=cream` and `?theme=dark` pin apalette. `features/setup/cream-preview.css` owns the light palette; the sharedrouter applies it across navigation, and each HTML entry applies it before-first paint. Check both palettes when changing a shared demo or surface.+first paint. Sample workspace styles read that HTML palette before route code+runs. Check both palettes when changing a shared demo or surface.## Ownership and dependency boundary@@ -128,9 +129,13 @@ Before the first prerender build, install Chromium withRun `git lfs pull` when migrated video files have not been fetched. The buildwrites the public artifact to `apps/marketing/dist/`, verifies the standaloneboundary, prerenders public pages, and finishes with the SEO migration gate.-The homepage uses Solid SSR and hydration. Build verification checks that its-first-painted heading retains its DOM node and geometry on desktop and mobile,-and exercises navigation and the deferred email demo.+The homepage uses Solid SSR and hydration. Both Vite builds compile Tailwind so+prerendered demos include their UI utilities before the client bundle loads.+Build verification checks sample workspace controls, icons, avatars, and layout+with the client bundle blocked in dark and cream palettes on desktop and mobile.+It also checks that the homepage's first-painted heading retains its DOM node and+geometry, then exercises navigation, the embedded workspace, and the deferred+email demo.Architecture regression tests create real temporary source graphs, CSS files,assets, and package symlinks. They verify that valid website references pass@@ -253,7 +258,11 @@ Interacting with the frame settles the entrance permanently for that mount.Embedded mode hides the demo banner; the normal `/demo` route keeps it. Verifynavigation and the mobile sidebar inside the frame, forward/backward scrolling,and interaction during the reveal. The desktop iframe renders at 85% scale inside-the same frame. The iframe uses native lazy loading.+the same frame. An IntersectionObserver sets the iframe's source as it nears the+viewport. Do not use native `loading="lazy"` for the sample workspace: Safari+can ignore the router's history updates in lazy frames and fail to boot. Verify+the embedded workspace in native Safari as well as Chromium after a production+build; a correctly styled standalone `/demo` does not prove the iframe boots.A benefit carousel fades the live preview into slab-serif headlines. The firsthighlight opens an email inside Home’s mixed activity feed; subsequent highlightsdiff --git a/apps/marketing/scripts/verifyDemo.ts b/apps/marketing/scripts/verifyDemo.tsnew file mode 100644index 0000000000..13d58b0b04--- /dev/null+++ b/apps/marketing/scripts/verifyDemo.ts@@ -0,0 +1,101 @@+import { type Browser, expect } from '@playwright/test';++/** The sample workspace must be styled even before its application JS loads. */+export async function verifyDemo(+ browser: Browser,+ origin: string+): Promise<void> {+ for (const viewport of [+ { width: 1440, height: 1000 },+ { width: 390, height: 844 },+ ]) {+ for (const theme of ['dark', 'cream'] as const) {+ const label = `${viewport.width}×${viewport.height} ${theme}`;+ const page = await browser.newPage({+ viewport,+ colorScheme: theme === 'cream' ? 'light' : 'dark',+ isMobile: viewport.width < 768,+ reducedMotion: 'reduce',+ });+ try {+ // Leave the small inline palette bootstrap enabled, but never load the+ // client bundle: it would replace the SSR styles and hide this bug.+ await page.route('**/*', async (route) => {+ if (+ new URL(route.request().url()).origin !== origin ||+ route.request().resourceType() === 'script'+ ) {+ await route.abort();+ return;+ }+ await route.continue();+ });+ await page.goto(`${origin}/demo?theme=${theme}`, {+ waitUntil: 'load',+ });+ const workspace = page.locator('.dummy-workspace');+ await expect(+ workspace,+ `Workspace background matches the palette before JS (${label})`+ ).toHaveCSS(+ 'background-color',+ theme === 'cream' ? 'rgb(245, 241, 232)' : 'oklch(0.17 0 0)'+ );+ await expect(workspace).toHaveCSS(+ 'color',+ theme === 'cream' ? 'oklch(0.2 0.004 70)' : 'oklch(1 0 21)'+ );+ await expect(+ page.getByRole('heading', {+ name: 'What should we work on?',+ exact: true,+ })+ ).toHaveCSS(+ 'color',+ theme === 'cream' ? 'rgb(0, 0, 0)' : 'oklch(1 0 21)'+ );+ const rail = page.locator('[data-ui="sidebar-rail"]');+ await expect(+ rail,+ `Workspace rail is styled before JS (${label})`+ ).toHaveCSS('display', 'flex');+ await expect(rail).toHaveCSS('flex-direction', 'column');+ const home = rail.getByRole('button', { name: 'Home', exact: true });+ await expect(home).toHaveCSS('display', 'flex');+ await expect(home).toHaveCSS(+ 'width',+ viewport.width < 650 ? '36px' : '40px'+ );+ await expect(home).toHaveCSS('height', '40px');+ await expect(+ rail+ .getByRole('button', { name: 'Create in workspace', exact: true })+ .locator('svg')+ ).toHaveCSS('width', '20px');+ const avatar = rail.getByRole('img', { name: 'Jacob', exact: true });+ await expect(avatar).toHaveCSS('width', '32px');+ await expect(avatar).toHaveCSS('height', '32px');+ const avatarRadius = await avatar.evaluate((element) =>+ parseFloat(getComputedStyle(element).borderTopLeftRadius)+ );+ expect(avatarRadius).toBeGreaterThanOrEqual(16);+ await expect(page.locator('.dummy-sidebar')).toHaveCSS(+ 'display',+ viewport.width < 650 ? 'none' : 'block'+ );+ const overflow = await page.evaluate(+ () => document.documentElement.scrollWidth > window.innerWidth+ );+ expect(+ overflow,+ `Workspace does not overflow horizontally (${label})`+ ).toBe(false);+ console.log(+ `[prerender] Sample workspace ${label}: palette, navigation, controls, icons, avatars, and responsive layout styled before JS`+ );+ } finally {+ await page.close();+ }+ }+ }+}diff --git a/apps/marketing/scripts/verifyHomepage.ts b/apps/marketing/scripts/verifyHomepage.tsindex edac6fd56f..9f40564526 100644--- a/apps/marketing/scripts/verifyHomepage.ts+++ b/apps/marketing/scripts/verifyHomepage.ts@@ -1,5 +1,6 @@import path from 'node:path';-import { chromium } from '@playwright/test';+import { chromium, expect } from '@playwright/test';+import { verifyDemo } from './verifyDemo';/** Verify the prerendered homepage keeps its first paint while becoming interactive. */export async function verifyHomepage(directory: string): Promise<void> {@@ -8,12 +9,13 @@ export async function verifyHomepage(directory: string): Promise<void> {port: 0,async fetch(request) {const pathname = decodeURIComponent(new URL(request.url).pathname);- const filename = path.resolve(+ let filename = path.resolve(directory,`.${pathname === '/' ? '/index.html' : pathname}`);if (!filename.startsWith(`${directory}/`))return new Response(null, { status: 404 });+ if (!path.extname(filename)) filename = path.join(filename, 'index.html');const file = Bun.file(filename);return (await file.exists())? new Response(file)@@ -24,6 +26,7 @@ export async function verifyHomepage(directory: string): Promise<void> {try {browser = await chromium.launch();const origin = `http://127.0.0.1:${server.port}`;+ await verifyDemo(browser, origin);// Light mode renders the cream palette (src/features/setup/sitePalette.ts).for (const [viewport, colorScheme] of [[{ width: 1440, height: 1000 }, 'dark'],@@ -122,6 +125,28 @@ export async function verifyHomepage(directory: string): Promise<void> {await page.getByRole('button', { name: 'Close navigation', exact: true }).click();+ if (viewport.width >= 800) {+ await page.locator('#interactive-demo').scrollIntoViewIfNeeded();+ const workspace = page.frameLocator(+ 'iframe[title="Embedded Macro sample workspace"]'+ );+ const chat = workspace+ .getByRole('navigation', { name: 'Workspace navigation' })+ .getByRole('button', { name: 'Chat', exact: true });+ await chat.click();+ await expect(chat).toHaveAttribute('aria-current', 'page');+ await expect(+ workspace.getByRole('complementary', { name: 'Chat navigation' })+ ).toBeVisible();+ await page+ .getByRole('button', { name: 'Show Docs highlight', exact: true })+ .click();+ await expect(+ workspace+ .getByRole('navigation', { name: 'Workspace navigation' })+ .getByRole('button', { name: 'Drive', exact: true })+ ).toHaveAttribute('aria-current', 'page');+ }await page.locator('#email').scrollIntoViewIfNeeded();await page.locator('[data-email-demo-body]')@@ -131,7 +156,7 @@ export async function verifyHomepage(directory: string): Promise<void> {`Homepage demo failed (${label}): ${errors.join('; ')}`);console.log(- `[prerender] Homepage ${label}: SSR heading identity and layout, hydration, navigation, and email demo verified`+ `[prerender] Homepage ${label}: SSR heading identity and layout, hydration, navigation, sample workspace, and email demo verified`);} finally {releaseScripts();diff --git a/apps/marketing/src/features/setup/cream-preview.css b/apps/marketing/src/features/setup/cream-preview.cssindex b168cec567..1d4703c95a 100644--- a/apps/marketing/src/features/setup/cream-preview.css+++ b/apps/marketing/src/features/setup/cream-preview.css@@ -119,8 +119,8 @@ html[data-palette='cream'] .homepage-embedded-stage::after { background: linear-html[data-palette='cream'] .homepage-demo-slide-copy h2 { color: #1d1c1a; }/* ---- Sample workspace (/demo, embedded on the homepage) ----------------- RouteDemo injects the dark palette on .dummy-route via @scope; outrank it. */-.dummy-route[data-palette='cream'] {+ Match the HTML bootstrap before RouteDemo's client code runs. */+html[data-palette='cream'] .dummy-route {--color-surface-0: #f5f1e8;--color-surface-1: #faf8f3;--color-surface-2: #fcfbf8;@@ -369,7 +369,7 @@ html[data-palette='cream'] .downloads-release a:hover { color: var(--color-ink);html[data-palette='cream'],html[data-palette='cream'] .feature-page,html[data-palette='cream'] .workspace-demo,-.dummy-route[data-palette='cream'] {+html[data-palette='cream'] .dummy-route {--color-accent: oklch(0.2 0.004 70deg);--color-content-3: #72706c;--color-content-4: #72706c;diff --git a/apps/marketing/vite.prerender.config.ts b/apps/marketing/vite.prerender.config.tsindex 94b0025451..73f87e175d 100644--- a/apps/marketing/vite.prerender.config.ts+++ b/apps/marketing/vite.prerender.config.ts@@ -2,6 +2,7 @@// Kept separate from vite.config.ts so the main client build is untouched.import path from 'node:path';+import tailwind from '@tailwindcss/vite';import { defineConfig } from 'vite';import solidPlugin from 'vite-plugin-solid';import solidSvg from 'vite-plugin-solid-svg';@@ -13,6 +14,7 @@ export default defineConfig({root: import.meta.dirname,plugins: [standaloneBoundary(),+ tailwind(),tsconfigPaths({ projects: ['./tsconfig.json'] }),solidPlugin({ ssr: true, solid: { hydratable: true } }),solidSvg(solidSvgOptions),