Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions desktop-app/storybook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
storybook-static
*.log
1 change: 1 addition & 0 deletions desktop-app/storybook/.storybook/launch-note.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run: npm run storybook (port 6106)
70 changes: 70 additions & 0 deletions desktop-app/storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import type { StorybookConfig } from '@storybook/react-vite';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
import type { Plugin } from 'vite';
import remarkGfm from 'remark-gfm';

const here = (path: string) => fileURLToPath(new URL(path, import.meta.url));

// Stories import the current app through `src/after/desktop-app/…`; that prefix is the live
// desktop app this Storybook lives in (no copy is kept). `src/before/` is a frozen snapshot of
// the base build the audit compared against.
const desktopApp = here('../..');
const afterPrefix = here('../src/after/desktop-app/');
const liveAfter: Plugin = {
name: 'darkbloom-live-after',
enforce: 'pre',
async resolveId(source, importer, options) {
if (!importer || !source.startsWith('.')) return null;
const target = path.resolve(path.dirname(importer.split('?')[0]), source);
if (!target.startsWith(afterPrefix)) return null;
return this.resolve(path.join(desktopApp, target.slice(afterPrefix.length)), importer, {
...options,
skipSelf: true,
});
},
};

// Each version's renderer reads its native bridge from its own useBackend module. Route those
// imports to small wrappers so Before and After each get a separate mock bridge and action log.
const beforeBackend = here('../src/before/desktop-app/src/renderer/useBackend.ts');
const afterBackend = path.join(desktopApp, 'src/renderer/useBackend.ts');
const versionBridges: Plugin = {
name: 'darkbloom-version-bridges',
enforce: 'pre',
async resolveId(source, importer, options) {
if (!importer || importer.includes('/stories/support/')) return null;
const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });
if (resolved?.id === beforeBackend) return here('../stories/support/useBackend.before.ts');
if (resolved?.id === afterBackend) return here('../stories/support/useBackend.after.ts');
return null;
},
};

const config: StorybookConfig = {
framework: { name: '@storybook/react-vite', options: {} },
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.tsx'],
addons: [
{
// GitHub-style tables in the Introduction.
name: '@storybook/addon-docs',
options: { mdxPluginOptions: { mdxCompileOptions: { remarkPlugins: [remarkGfm] } } },
},
],
staticDirs: ['../public'],
core: { disableTelemetry: true },
async viteFinal(config) {
config.plugins = [liveAfter, versionBridges, ...(config.plugins ?? [])];
config.resolve ??= {};
const alias = config.resolve.alias;
config.resolve.alias = [
...(Array.isArray(alias)
? alias
: Object.entries(alias ?? {}).map(([find, replacement]) => ({ find, replacement }))),
{ find: /^vitest$/, replacement: here('../stories/support/vitestShim.ts') },
];
config.resolve.dedupe = ['react', 'react-dom', 'lucide-react'];
return config;
},
};
export default config;
20 changes: 20 additions & 0 deletions desktop-app/storybook/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Preview } from '@storybook/react-vite';
import '../src/after/desktop-app/src/renderer/brand.css';
import '../src/after/desktop-app/src/renderer/styles.css';
import '../stories/support/compare.css';

document.documentElement.dataset.theme = 'dark';

const preview: Preview = {
parameters: {
layout: 'fullscreen',
controls: { disable: true },
actions: { disable: true },
options: {
storySort: {
order: ['Introduction', 'Install flow', 'Flows', ['Onboarding', 'Status checks', 'Model loading', 'Autopilot'], 'App shell', 'Fixes', ['Onboarding and launch', 'Desktop runtime', 'Stats and updates', 'Earnings and sign-in', 'Sign-in dialog', 'Models', 'Studio, Cooling and Leaderboard', 'My Macs', 'Home numbers'], 'Second pass', ['Theme and layout', 'Behavior', 'Keyboard and screen readers'], 'Third pass', 'Fourth pass', 'Fifth pass', 'Internal'],
},
},
},
};
export default preview;
32 changes: 32 additions & 0 deletions desktop-app/storybook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Darkbloom desktop review Storybook

Before/After stories and walkthroughs for the desktop UI audit (Layr-Labs/d-inference
#1452–#1508). Each comparison renders the real desktop components twice with the same fixtures:

- **After** is the live app in this repository (`desktop-app/src`, `desktop-app/tests` fixtures).
Stories import it as `src/after/desktop-app/…`; `.storybook/main.ts` maps that prefix to the
desktop app, so no copy is kept and the stories always show the current code.
- **Before** is `src/before/`, a frozen snapshot of `bfa75a2c` (the base the audit PRs targeted).

`stories/DistributionFlow.mdx` (*Install flow*) describes the end-to-end install flow (DMG →
Install the Darkbloom CLI → check → link → start). *App shell › Pages* renders the real `App` (with its
sidebar) at each page; stories open a page through the mocked bridge's `onNavigate`
(`bridges.after.navigate(route)`, or `<AtRoute>` in `stories/support/Shell.tsx`).

`brand.css` and `public/` are the app's generated assets (`desktop-app/scripts/assets.mjs`).
The native bridge is mocked per version (`stories/support/`); no runtime, account or production
endpoint is contacted. Its `system()` reports macOS 27.0 unless a story passes `macosVersion`
(`resetBridges({ macosVersion: '26.5' })`, `shellFixtures({ macosVersion })`); `openSoftwareUpdate()`
is only logged.

```bash
cd desktop-app
node scripts/assets.mjs # generates brand.css and the app icons the stories use
cd storybook
npm ci
npm run storybook # http://127.0.0.1:6106
npm run build-storybook # static site in storybook-static/
```

CSS-only fixes from the second pass are shown as headless-Chrome captures in `public/evidence/`
(global styles can't differ between two panes of one page); they are static images.
Loading
Loading