Skip to content

Commit ce6bbbc

Browse files
committed
🤖 add emotion styled compatibility shim
_Generated with `cmux`_
1 parent a6c2ff0 commit ce6bbbc

38 files changed

+374
-65
lines changed

CHROMATIC_ISSUE_SUMMARY.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Chromatic Build Issue Summary
22

33
## Problem
4+
45
Storybook builds locally but fails in Chromatic with error:
6+
57
```
68
TypeError: a is not a function
79
at https://68e30fca49979473fc9abc73-...chromatic.com/assets/AssistantMessage.stories-...js:6:11
@@ -10,60 +12,71 @@ at https://68e30fca49979473fc9abc73-...chromatic.com/assets/AssistantMessage.sto
1012
This is the minified version of `styled is not a function` - @emotion/styled's default export isn't being resolved correctly in Chromatic's build environment.
1113

1214
## Root Cause
15+
1316
Almost every component in the project uses `@emotion/styled` (25+ files). The issue appears to be a module resolution problem specific to Chromatic's infrastructure where the default export from @emotion/styled becomes undefined in the production build.
1417

1518
## Attempted Solutions
19+
1620
1. ✅ Converted 2 tool components (BashToolCall, FileReadToolCall) to CSS modules
17-
2. ✅ Added dedupe config for emotion packages
18-
3. ❌ CommonJS inclusion config (broke build)
19-
4. ❌ Explicit emotion/styled alias (broke build)
20-
5. ❌ Various Babel/Vite configurations
21+
2. ✅ Added dedupe config for emotion packages
22+
3. ✅ Introduced `src/styles/styled.ts` compatibility shim that normalizes default export resolution and re-exported `styled` for all components
23+
4. ❌ CommonJS inclusion config (broke build)
24+
5. ❌ Explicit emotion/styled alias (broke build)
25+
6. ❌ Various Babel/Vite configurations
2126

2227
## Current Status
28+
2329
- Local Storybook build: ✅ Works
2430
- Chromatic build: ❌ Fails with "a is not a function"
2531
- Partially converted: 2/4 tool components, but 25+ other components still use styled
2632

2733
## Options Going Forward
2834

2935
### Option 1: Complete CSS Modules Conversion (High Effort)
36+
3037
- Convert all 25+ components from @emotion/styled to CSS modules
3138
- Pros: Eliminates dependency on emotion/styled entirely
3239
- Cons: 10-20 hours of work, risky refactor, may break styling
3340

3441
### Option 2: Debug Chromatic Bundle (Medium Effort)
42+
3543
- Deep dive into Chromatic's Vite build process
3644
- Compare local vs Chromatic bundle outputs
3745
- May require Chromatic support ticket
3846
- Pros: Fixes root cause
3947
- Cons: May be Chromatic infrastructure issue outside our control
4048

4149
### Option 3: Skip Chromatic for Now (Low Effort)
50+
4251
- Disable Chromatic workflow temporarily
4352
- Use local Storybook for development
4453
- Revisit when Chromatic updates or when we have more time
4554
- Pros: Unblocks current work
4655
- Cons: Loses visual regression testing
4756

4857
### Option 4: Simplify Storybook Scope (Medium Effort)
58+
4959
- Only include stories for components that don't use styled
5060
- Or create simplified versions of components for Storybook only
5161
- Pros: Gets some stories working in Chromatic
5262
- Cons: Limited coverage
5363

5464
## Recommendation
65+
5566
**Option 3** (Skip Chromatic for now) + document the issue for later investigation.
5667

5768
The emotion/styled issue appears to be environmental (Chromatic-specific) rather than a code problem. Local Storybook works fine for development. Visual regression testing can be added back once the root cause is identified.
5869

5970
## Files Modified
71+
6072
- `.storybook/main.ts` - Added dedupe config
6173
- `src/components/tools/BashToolCall.tsx` - Converted to CSS modules
6274
- `src/components/tools/FileReadToolCall.tsx` - Converted to CSS modules
6375
- `src/components/tools/shared/ToolPrimitives.tsx` - Converted to CSS modules
6476
- Created corresponding `.module.css` files
6577

6678
## Components Still Using @emotion/styled
79+
6780
- AssistantMessage, UserMessage, MessageWindow, MarkdownRenderer
6881
- TypewriterMarkdown, TypewriterText, StreamErrorMessage
6982
- ReasoningMessage, TerminalOutput, ChatBarrier
@@ -72,4 +85,3 @@ The emotion/styled issue appears to be environmental (Chromatic-specific) rather
7285
- ToggleGroup, Tooltip, ThinkingSlider, TipsCarousel
7386
- NewWorkspaceModal, ChatMetaSidebar (and tabs)
7487
- ProposePlanToolCall, FileEditToolCall
75-

PR38_STATUS.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,52 @@
11
# PR #38 Status Report
22

33
## Current State
4+
45
- **Branch**: `storybook-tool-messages`
56
- **PR**: https://github.com/coder/cmux/pull/38
67
- **Status**: BLOCKED - Chromatic build failing
78

89
## What Works ✅
10+
911
- ✅ Storybook builds locally
1012
- ✅ All 13 tool message stories render correctly
1113
- ✅ FileReadToolCall custom component working
1214
- ✅ TypeScript/ESLint passing
1315
- ✅ No code quality issues
1416

1517
## What's Blocked ❌
18+
1619
- ❌ Chromatic visual regression testing
1720
- Reason: `@emotion/styled` module resolution failure in Chromatic environment
1821
- Error: `TypeError: a is not a function` (styled is not a function)
1922

2023
## Investigation Summary
24+
2125
Spent significant time investigating the Chromatic build failure:
26+
2227
- Converted 2 components to CSS modules (BashToolCall, FileReadToolCall)
2328
- Tried multiple Vite/Babel configurations
2429
- Added dedupe config for emotion packages
25-
- None resolved the Chromatic-specific issue
30+
- Added compatibility shim `src/styles/styled.ts` to normalize default export usage across the app
31+
- None resolved the Chromatic-specific issue yet (pending new Chromatic run with shim)
2632

2733
## Root Cause
34+
2835
The `@emotion/styled` default export becomes undefined in Chromatic's production build environment. This affects 25+ components across the codebase, not just the new Storybook stories.
2936

3037
## Decision Needed
38+
3139
See `CHROMATIC_ISSUE_SUMMARY.md` for detailed options analysis.
3240

3341
**Quick options:**
42+
3443
1. **Merge as-is** - Storybook works locally, accept Chromatic failure for now
3544
2. **Disable Chromatic** - Remove workflow temporarily, re-enable after fix
3645
3. **Continue conversion** - Convert all 25+ components to CSS modules (10-20 hours)
3746
4. **Open support ticket** - Contact Chromatic team for help
3847

3948
## Recommendation
49+
4050
**Option 1 or 2** - The Storybook feature is complete and working. The Chromatic issue is environmental and affects the entire codebase, not specific to this PR. It should be addressed separately.
4151

4252
The stories provide value for local development even without Chromatic visual regression testing.

0 commit comments

Comments
 (0)