feat(mobile): Storybook + ember theme tooling (Sprint 1 / PR 1 of 7)

Closed
JU
4mo ago
+442-13

Summary

Foundation PR of the chat-mobile sprint-1 stack. Pure tooling: scaffolds Storybook RN, rewrites the mobile app's color tokens to the desktop ember palette (Path A), and lands the Storybook config tweaks needed to make stories prep without crashing.

Storybook scaffold (`apps/mobile/.rnstorybook/`)

  • `main.js` story globs, `preview.tsx` decorators, `index.tsx` UI shell
  • on-device controls + actions addons
  • Geist + Geist Mono fonts via `@expo-google-fonts/geist`

Ember theme tokens

  • `apps/mobile/global.css` and `apps/mobile/lib/theme.ts` rewritten to the ember warm palette (`#e07850` accent, warm-neutral surface ramp #151110 / #1a1716 / #201e1c / #2a2827)
  • `NAV_THEME` (expo-router) updated to mirror ember tokens
  • State palette (live / warning / danger / success / neutral) for chat-domain status indicators

Storybook config fixes

  • AsyncStorage adapter passed to `getStorybookUI`
  • Node `tty` module stubbed for Metro (Storybook 9 RN compatibility)
  • `screens/**/*.stories` excluded from the glob — they transitively import `useTheme` → `lib/theme.ts` → `expo-router/react-navigation` which crashes at prep time
  • Decorator wrapped in `` from `expo-router/react-navigation` (mitigation attempt) then re-doubled-down on the screens exclusion when wrap proved insufficient

Stack position — 1 of 5

This PR must merge first; PRs 2–5 build on it.

#BranchStatus
PR 1 (this)`chat-mobile-sprint-1-tooling`foundation — Storybook + ember tokens
PR 2`chat-mobile-sprint-1-ported`port vendor primitives + first-party app components to ember
PR 3`chat-mobile-sprint-1-atoms`10 chat-view atoms
PR 4`chat-mobile-sprint-1-molecules`19 chat-view molecules
PR 5`chat-mobile-sprint-1-organisms`10 chat-view organisms

Each downstream branch contains this PR's commits plus its own (cross-fork stacks can't set non-`main` bases). After this PR merges, downstream branches rebase onto fresh `main` and shrink to their phase-specific diff.

Test plan

  • `cd apps/mobile && bun storybook` — Storybook opens in Expo
  • No expo-router crash at prep time
  • Storybook UI shell renders with on-device controls + actions tabs
  • `bun run typecheck` passes (28/28)

Open in Stage

Summary by cubic

Added on-device Storybook for React Native, gated by EXPO_PUBLIC_STORYBOOK=true, to speed up mobile UI work. The app theme matches main (stock shadcn/ui zinc); token galleries and the HelloWorld scaffold were removed.

  • New Features

    • Storybook scaffold under apps/mobile/.rnstorybook; app boots Storybook when EXPO_PUBLIC_STORYBOOK=true.
    • Integrated @storybook/react-native via withStorybook in metro.config.js for env-gated builds.
    • Loaded Geist and Geist Mono via @expo-google-fonts/geist and @expo-google-fonts/geist-mono, with expo-splash-screen gating and error-safe hide.
  • Bug Fixes

    • Fixed persisted-selection crash by passing AsyncStorage to getStorybookUI.
    • Avoided expo-router context errors with a StorybookRouterProvider (sets PreviewRouteContext, LinkingContext, UnhandledLinkingContext) and removed a duplicate NavigationContainer so it passes SDK 56 checks.
    • Stubbed Node tty using a Storybook module mock; added a default Welcome story to prevent EmptyIndex crashes.
    • Ensured splash screen never stalls on font load errors.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Storybook integration for interactive component development and testing.
    • New npm scripts: storybook to launch the Storybook environment and storybook-generate for story generation.
  • Chores

    • Updated application configuration and build system to enable conditional Storybook environment loading.
    • Updated font handling dependencies.

Review Change Stack