Files
metabuilder/MUI_ELIMINATION_PLAN.md
2025-12-30 13:52:50 +00:00

24 KiB

MUI Dependency Elimination Plan

Status: Planning Phase Created: 2025-12-30 Goal: Remove @mui/material dependency completely from the codebase


Executive Summary

Total Files Using MUI: 160+ Total MUI Imports: 24,273+ import statements Migration Strategy: 6 phases over 8 weeks Key Approach: Lua packages for editors, fakemui for basic UI


Phase Overview

Phase 1: Foundation (Weeks 1-2)          ✅ Complete
Phase 2: Atomic Components (Weeks 2-3)   🔜 Ready to start
Phase 3: Basic UI (Weeks 3-4)            ⏳ Pending
Phase 4: Complex UI (Weeks 4-6)          ⏳ Pending
Phase 5: Lua Packages (Weeks 6-8)        ⏳ Pending
Phase 6: Cleanup (Week 8+)               ⏳ Pending

Recent Progress (2025-12-30)

Completed:

  • Created fakemui icon system (27 icons - full Phase 2!)
  • Migrated LuaBlocksEditor to fakemui (8 files)
  • Enhanced fakemui CSS reset to replace CssBaseline
  • Documented all 160+ MUI files for migration
  • Created DEPENDENCY_CLEANUP.md plan
  • Audited package.json dependencies
  • Phase 1 fakemui foundation 100% complete - All atoms, feedback, navigation, and data display components implemented:
    • Slider, Toggle/Switch, Rating
    • Toast/Snackbar, Dialog, Progress
    • Menu, Pagination
    • Table, List, Chip

Additional Progress (Latest Session):

  • Expanded fakemui icons to 70+ icons including:
    • Media controls: Pause, Stop, Maximize, Minimize, Volume, VolumeOff
    • Media: Camera, Video, Screen, Broadcast, Image
    • Security: Lock, LockOpen, Key, Shield
    • Utility: Terminal, Cloud, Globe, Archive, Clipboard, Package, Layers, Tag, Bookmark
    • Communication: Chat, Send
    • Plus: Refresh, File, Grid, List
  • Added LuaCATS type annotations to packages:
    • dbal_demo (5 files with full types)
    • screenshot_analyzer, social_hub, stream_cast (already typed)
  • Verified lua_test and package_validator have comprehensive types
  • Verified all ui_* packages have comprehensive types

Additional Progress (Session 2 - 2025-12-30):

  • Added 11 more icons to fakemui:
    • DragIndicator, DragHandle (for sortable items)
    • Print, Schedule, Tune (utilities)
    • ThumbUp, ThumbDown (feedback)
    • Notifications, NotificationsOff (alerts)
    • ContentCopy, ContentPaste (clipboard operations)
  • Added missing fakemui input components:
    • ButtonGroup (grouped buttons with shared styling)
    • FormControl with useFormControl hook (form state context)
    • RadioGroup with useRadioGroup hook (grouped radios)
    • NativeSelect (browser-native select with styling)
  • Created SCSS styles for all new components:
    • ButtonGroup.module.scss
    • FormControl.module.scss
    • RadioGroup.module.scss
    • NativeSelect.module.scss
  • Created shared UI types package:
    • packages/shared/types/ui_types.lua (comprehensive type definitions)
    • UIComponent, ButtonProps, InputProps, CardProps, etc.
    • UserInfo, TenantInfo, RenderContext, ActionResult types
  • Added parameterized tests to ui_level3:
    • moderation.test.lua with permission level tests
    • moderation.cases.json with test data
  • Total fakemui icons now: 80+ (up from 70+)

Additional Progress (Session 3 - 2025-12-31):

  • @mui/icons-material completely eliminated from source code!
    • Migrated 40+ component files to fakemui icons
    • Created 50+ new fakemui icons including:
      • Component icons: Article, Checkbox, CropFree, CropPortrait, GridView, etc.
      • Navigation: FirstPage, LastPage, ViewColumn, ViewStream
      • Interaction: ToggleOn, TouchApp, FormatAlignLeft
      • Display: AccountCircle, Verified, LocalOffer, LooksOne, TextFields, TableChart, Minus
    • Updated atoms/display/Icon.tsx to use fakemui icons dynamically
    • Migrated get-component-icon.tsx to fakemui
    • Updated all test files (NavLink.test.tsx, NavItem.test.tsx, NavGroup.test.tsx)
  • Total fakemui icons now: 130+ (up from 80+)
  • Icon mappings complete for all common MUI icon names

Additional Progress (Session 4 - 2025-12-31):

  • Added 32 new fakemui icons for media center:
    • Media controls: FastForward, FastRewind, SkipPrevious, SkipNext, Shuffle, Repeat, RepeatOne
    • Video: FilmSlate, Tv, Fullscreen, FullscreenExit, AspectRatio, HighQuality, Subtitles, ClosedCaption
    • Audio: Headphones, Mic, MicOff, Radio, Volume, VolumeOff
    • Gaming: SportsEsports, Gamepad, Joystick
    • Utilities: Queue, Transform, PictureAsPdf, Article, MenuBook, People, ArrowUpDown, Timer, Speed, CameraAlt
  • Added new fakemui components:
    • CardTitle, CardDescription, CardFooter (Card subcomponents)
    • Heading (Typography alias for headings)
    • FormField (Form input wrapper with label/error)
    • Iframe (Embedded content)
    • Markdown (Markdown renderer)
    • Separator (Divider alias)
  • Created github_tools Lua package (Phase 5):
    • Full components.json with GitHubViewer, RunList, RunDetails, AnalysisPanel, RunFilters
    • Lua scripts: init.lua, fetch_runs.lua, analyze.lua, filter.lua, status.lua
    • Complete LuaCATS type annotations
    • Parameterized test suite with github_tools.test.lua
  • Added tests to media_center package:
    • helpers.test.lua with parameterized tests
    • helpers.cases.json with 30+ test cases
  • Total fakemui icons now: 162+ (up from 130+)

Additional Progress (Session 5 - 2025-12-31):

  • Added 12 new admin/storage/security icons:
    • Admin: AccountTree, AdminPanelSettings, ManageAccounts
    • Storage: Backup, Restore, Storage
    • Security: Domain, SecurityUpdate, VerifiedUser, VpnKey
    • Utility: Policy, Help
  • Added parameterized tests to 4 packages:
    • forum_forge: permissions.test.lua + permissions.cases.json (21 test cases)
      • can_post, can_moderate, flag_post, rank_thread functions
    • irc_webchat: chat.test.lua + chat.cases.json (20+ test cases)
      • help/users/clear/me commands, time formatting, message creation
    • arcade_lobby: arcade.test.lua + arcade.cases.json (15+ test cases)
      • matchmaking buckets, tournament permissions, queue metrics
    • notification_center: notifications.test.lua + notifications.cases.json (20+ test cases)
      • calculate_total, severity classes, toast variants, summary preparation
  • Created github_tools Lua package scaffold
  • Total fakemui icons now: 266+ (up from 162+)
  • Test coverage expanded to 8+ packages with parameterized tests

Additional Progress (Session 6 - 2025-12-30):

  • Added 22 new fakemui icons for rich text editing and UI:
    • Rich Text: FormatBold, FormatItalic, FormatUnderline, FormatStrikethrough
    • Lists: FormatListBulleted, FormatListNumbered, FormatQuote
    • Insert: InsertLink, InsertPhoto, AttachFile
    • Date/Time: DateRange, AccessTime
    • Color: ColorPicker
    • Devices: Smartphone, Tablet, Desktop
    • i18n: Language, QrCode
    • Image: RotateLeft, RotateRight
    • Theme: DarkMode, LightMode
  • Added 4 new fakemui input components:
    • DatePicker (HTML5 date/datetime/month/week inputs)
    • TimePicker (HTML5 time input with step support)
    • ColorPicker (with presets, alpha support, text input)
    • FileUpload (drag & drop, validation, preview)
  • Added SCSS styles: Pickers.module.scss for all new picker components
  • Added parameterized test cases to code_editor:
    • editor.cases.json with 50+ test cases for theme, color picker, JSON, Lua, editor modes
  • Updated code_editor metadata.json with all test files
  • Total fakemui icons now: 288+ (up from 266+)
  • Total fakemui input components now: 28 (up from 24)

📋 Ready to Execute:

  • Icon strategy: Full fakemui custom icons (no Phosphor) - 288+ icons!
  • Phase 1: Complete - all foundation components ready
  • Phase 2: ButtonGroup, FormControl, RadioGroup, NativeSelect, DatePicker, TimePicker, ColorPicker, FileUpload added
  • @mui/icons-material: ELIMINATED from source code
  • Phase 5: github_tools package created
  • Parameterized tests added to forum_forge, irc_webchat, arcade_lobby, notification_center, code_editor
  • Phase 3: Continue MUI core component elimination

Category Breakdown

🎯 Category 1: Lua Packages (12 files)

Components that should become dedicated Lua packages

1.1 Workflow Editor Suite (8 files)

  • Path: frontends/nextjs/src/components/workflow/
  • Package Name: @packages/workflow_editor
  • Files:
    • WorkflowEditor.tsx
    • WorkflowRunCard.tsx
    • WorkflowRunStatus.tsx
    • editor/WorkflowNodeCard.tsx
    • editor/WorkflowSidebar.tsx
    • editor/WorkflowTester.tsx
    • editor/WorkflowNodesPanel.tsx
    • editor/constants.tsx

Complexity: Medium-High MUI Usage: Icons (PlayArrow, CheckCircle, Delete), Layout (Card, Stack, Box) Recommendation: Convert to Lua package with JSON-based node system

1.2 GitHub Actions Viewer (10 files)

  • Path: frontends/nextjs/src/components/misc/github/
  • Package Name: @packages/github_actions_viewer
  • Files:
    • GitHubActionsFetcher.tsx
    • views/AnalysisPanel.tsx
    • views/RunList.tsx
    • views/RunDetails.tsx
    • views/run-list/* (6 files)

Complexity: Medium MUI Usage: Tables, Chips, Alerts, Typography Recommendation: Convert to Lua package with data table component


🔧 Category 2: Fakemui Migration (66 files)

Basic UI components that should migrate to fakemui

2.1 Atomic Components (20 files)

Path: frontends/nextjs/src/components/atoms/

Controls (7 files):

  • Button.tsx → fakemui/inputs/Button
  • Checkbox.tsx → fakemui/inputs/Checkbox
  • Radio.tsx → fakemui/inputs/Radio
  • Switch.tsx → fakemui/inputs/Switch
  • Slider.tsx → fakemui/inputs/Slider
  • Toggle.tsx → fakemui/inputs/ToggleButton

Display (8 files):

  • Avatar.tsx → fakemui/data-display/Avatar
  • Badge.tsx → fakemui/data-display/Badge
  • Icon.tsx → fakemui/icons/* (custom system)
  • IconButton.tsx → fakemui/inputs/IconButton
  • Label.tsx → fakemui/atoms/Label
  • Link.tsx → fakemui/navigation/Link
  • Text.tsx → fakemui/atoms/Text

Feedback (5 files):

  • ErrorBoundary.tsx → Keep as-is (React boundary)
  • Separator.tsx → fakemui/data-display/Divider
  • Skeleton.tsx → fakemui/feedback/Skeleton
  • ScrollArea.tsx → Custom CSS implementation
  • Tooltip.tsx → fakemui/data-display/Tooltip
  • Spinner.tsx → fakemui/feedback/CircularProgress
  • Progress.tsx → fakemui/feedback/LinearProgress

Inputs (3 files):

  • Input.tsx → fakemui/inputs/Input
  • TextArea.tsx → fakemui/inputs/Textarea
  • Select.tsx → fakemui/inputs/Select

2.2 UI Molecules (15+ files)

Path: frontends/nextjs/src/components/ui/molecules/

Display:

  • Accordion.tsx → fakemui/surfaces/Accordion
  • Alert.tsx → fakemui/feedback/Alert
  • Card.tsx → fakemui/surfaces/Card

Navigation:

  • Breadcrumb.tsx → fakemui/navigation/Breadcrumbs
  • NavGroup.tsx → Custom with fakemui primitives
  • NavItem.tsx → fakemui/navigation/ListItem
  • NavLink.tsx → fakemui/navigation/Link

Overlay:

  • Dialog.tsx → fakemui/utils/Dialog
  • DropdownMenu.tsx → fakemui/navigation/Menu
  • Popover.tsx → fakemui/utils/Popover
  • Tooltip.tsx → fakemui/data-display/Tooltip

Selection:

  • RadioGroup.tsx → fakemui/inputs/Radio with FormGroup
  • Select.tsx → fakemui/inputs/Select
  • ToggleGroup.tsx → fakemui/inputs/ToggleButtonGroup

Tabs:

  • Tabs.tsx → fakemui/navigation/Tabs
  • TabsContent.tsx → fakemui/navigation/Tab (panel)
  • TabsList.tsx → fakemui/navigation/Tabs (container)
  • TabsTrigger.tsx → fakemui/navigation/Tab (trigger)

2.3 UI Organisms (15+ files)

Path: frontends/nextjs/src/components/ui/organisms/

Dialogs:

  • AlertDialog → fakemui/utils/Dialog with Alert
  • Command → Custom with fakemui primitives
  • Sheet → fakemui/surfaces/Drawer

Navigation:

  • Navigation.tsx → Custom with fakemui/surfaces/AppBar
  • Sidebar → Custom with fakemui/surfaces/Drawer
  • Pagination → fakemui/navigation/Pagination

Data:

  • Form → Custom with fakemui/inputs
  • Table → fakemui/data-display/Table

🎨 Category 3: Theme & Providers (19 files)

Configuration files to be cleaned up after migration

3.1 Theme Files

Path: frontends/nextjs/src/theme/

Files to Remove:

  • components.ts (MUI component overrides)
  • light-theme.ts (MUI theme)
  • dark-theme.ts (MUI theme)
  • mui-theme.ts (theme creation)
  • modes/light-theme.ts
  • modes/dark-theme.ts
  • modes/components.ts

Files to Keep/Convert:

  • colors.ts → CSS variables
  • fonts.ts → CSS font definitions
  • typography.ts → CSS typography scale
  • layout.ts → CSS layout tokens
  • tokens.ts → CSS custom properties

3.2 Provider Files

Path: frontends/nextjs/src/app/providers/

Updates Needed:

  • providers-component.tsx
    • Remove: MuiThemeProvider, CssBaseline
    • Keep: ThemeContext for dark/light mode
    • Add: CSS variables injection

🧪 Category 4: Test Files (3 files)

Update alongside component migrations

  • NavLink.test.tsx
  • NavItem.test.tsx
  • NavGroup.test.tsx

Detailed Phase Plan

Phase 1: Foundation (Weeks 1-2)

Status: Partially Complete

Completed:

  • Created fakemui icon system (Plus, Trash, Copy, Arrows, etc.)
  • Migrated LuaBlocksEditor to fakemui
  • Created fakemui barrel export

Remaining:

  1. Choose icon library (Recommendation: Lucide React)
  2. Create CSS reset (replace CssBaseline)
  3. Create CSS variable theme system
  4. Update providers to use new theme

Deliverables:

  • Icon system decision + implementation
  • fakemui basic structure
  • CSS reset file
  • Theme CSS variables
  • Updated provider component

Phase 2: Atomic Components (Weeks 2-3)

Priority: High - Foundation for everything else

Week 2: Controls & Inputs

Files: 10 files

  1. Day 1-2: Button Components

    • atoms/controls/Button.tsx
    • atoms/display/IconButton.tsx
    • Reference: fakemui/inputs/Button.tsx
  2. Day 3-4: Form Inputs

    • atoms/inputs/Input.tsx
    • atoms/inputs/TextArea.tsx
    • atoms/inputs/Select.tsx
    • Reference: fakemui/inputs/Input.tsx, Textarea.tsx, Select.tsx
  3. Day 5: Form Controls

    • atoms/controls/Checkbox.tsx
    • atoms/controls/Radio.tsx
    • atoms/controls/Switch.tsx
    • Reference: fakemui/inputs/Checkbox.tsx, Radio.tsx, Switch.tsx

Week 3: Display & Feedback

Files: 13 files

  1. Day 1-2: Display Components

    • atoms/display/Avatar.tsx
    • atoms/display/Badge.tsx
    • atoms/display/Icon.tsx (critical - replaces all MUI icons)
    • atoms/display/Label.tsx
    • atoms/display/Link.tsx
    • atoms/display/Text.tsx
  2. Day 3-4: Feedback Components

    • atoms/feedback/Skeleton.tsx
    • atoms/feedback/Spinner.tsx
    • atoms/feedback/Progress.tsx
    • atoms/feedback/Tooltip.tsx
    • atoms/feedback/Separator.tsx
  3. Day 5: Testing & Verification

    • Update all atom tests
    • Visual regression testing
    • Component demo page

Deliverables:

  • 20 atom components migrated to fakemui
  • Icon replacement complete
  • All atom tests passing
  • Component showcase page

Phase 3: Basic UI Components (Weeks 3-4)

Priority: High - User-facing components

Week 3: Display & Navigation Molecules

Files: 10 files

  1. Day 1-2: Display Components

    • molecules/display/Card.tsx
    • molecules/display/Alert.tsx
    • molecules/display/Accordion.tsx
  2. Day 3-4: Navigation Components

    • molecules/navigation/Breadcrumb.tsx
    • molecules/navigation/NavGroup.tsx
    • molecules/navigation/NavItem.tsx
    • molecules/navigation/NavLink.tsx
  3. Day 5: Tabs

    • molecules/tabs/Tabs.tsx
    • molecules/tabs/TabsContent.tsx
    • molecules/tabs/TabsList.tsx
    • molecules/tabs/TabsTrigger.tsx

Week 4: Overlay & Selection

Files: 8 files

  1. Day 1-2: Overlay Components

    • molecules/overlay/Dialog.tsx
    • molecules/overlay/DropdownMenu.tsx
    • molecules/overlay/Popover.tsx
    • molecules/overlay/Tooltip.tsx
  2. Day 3-4: Selection Components

    • molecules/selection/RadioGroup.tsx
    • molecules/selection/Select.tsx
    • molecules/selection/ToggleGroup.tsx
  3. Day 5: Testing

    • Update molecule tests
    • Integration testing

Deliverables:

  • 18 molecule components migrated
  • Navigation components working
  • All overlay components functional
  • Tests passing

Phase 4: Complex UI Components (Weeks 4-6)

Priority: Medium - Advanced features

Week 5: Navigation Organisms

Files: 12 files

  1. Day 1-3: Main Navigation

    • organisms/navigation/Navigation.tsx
    • organisms/navigation/NavigationMenuItems.tsx
    • organisms/navigation/NavigationResponsive.tsx
    • organisms/navigation/Sidebar (6 files)
  2. Day 4-5: Pagination

    • organisms/navigation/pagination/* (5 files)

Week 6: Dialogs & Data

Files: 10 files

  1. Day 1-2: Dialog System

    • organisms/dialogs/AlertDialog
    • organisms/dialogs/Command
    • organisms/dialogs/Sheet
  2. Day 3-4: Data Components

    • organisms/data/Form.tsx
    • organisms/data/Table.tsx
    • data/table/* (Body, Header, EmptyState)
  3. Day 5: Testing & Polish

    • Full UI testing
    • Responsive testing

Deliverables:

  • 22 organism components migrated
  • Navigation system complete
  • Data components functional
  • Full regression testing

Phase 5: Lua Packages (Weeks 6-8)

Priority: Medium - Specialized editors

Week 7: Workflow Editor Package

Package: @packages/workflow_editor Files: 8 files

  1. Day 1-2: Package Structure

    • Create package directory structure
    • Create components.json
    • Define metadata schema
  2. Day 3-4: Component Migration

    • Migrate WorkflowEditor components
    • Replace MUI with fakemui
    • Implement node system with JSON
  3. Day 5: Testing

    • Package integration tests
    • Visual workflow testing

Week 8: GitHub Viewer Package

Package: @packages/github_actions_viewer Files: 10 files

  1. Day 1-2: Package Structure

    • Create package structure
    • Define data schemas
  2. Day 3-4: Component Migration

    • Migrate GitHub viewer components
    • Implement custom table with fakemui
    • Replace MUI icons
  3. Day 5: Integration

    • Package testing
    • Integration with main app

Deliverables:

  • workflow_editor package created
  • github_actions_viewer package created
  • Both packages tested and documented

Phase 6: Final Cleanup (Week 8+)

Priority: High - Complete removal

Cleanup Tasks

  1. Theme System Removal

    • Remove theme/components.ts
    • Remove theme/*-theme.ts files
    • Remove MUI theme imports
  2. Provider Updates

    • Remove MuiThemeProvider from providers
    • Remove CssBaseline import
    • Update theme context to use CSS variables
  3. Package.json

    • Remove @mui/material
    • Remove @mui/icons-material
    • Remove @mui/system
    • Verify no residual MUI dependencies
  4. Testing

    • Full application smoke test
    • Visual regression testing
    • Performance benchmarking
    • Bundle size analysis
  5. Documentation

    • Update component documentation
    • Create migration guide for future devs
    • Document new icon system
    • Document theme CSS variables

Deliverables:

  • Zero MUI imports remaining
  • All tests passing
  • Bundle size reduced by 15-25%
  • Documentation complete

Icon System Migration

Current System

  • atoms/display/Icon.tsx dynamically imports from @mui/icons-material
  • Used across entire codebase
  • Supports 100+ icon names

Replacement Options

Option Icons Size Pros Cons
Lucide React 1000+ ~50KB Tree-shakeable, modern, well-maintained Learning curve
Feather Icons 286 ~30KB Minimal, beautiful Limited selection
Custom SVG Custom ~5KB Full control, zero deps Manual maintenance
Radix Icons 300+ ~25KB Radix-aligned Smaller set

DECISION: Custom SVG System (fakemui/icons)

  • Why: Full control, zero dependencies, already started
  • Approach: Add icons as needed from Heroicons/Lucide/Phosphor
  • Benefit: Zero dependencies, full control, tiny bundle (~1KB per icon)
  • Process: Copy SVG paths when needed, create TSX components
  • Status: APPROVED - Moving forward with this approach

Migration Metrics

Success Criteria

  • Zero imports from @mui/material
  • Zero imports from @mui/icons-material
  • Zero imports from @mui/system
  • All theme tests passing
  • All UI component tests passing
  • No visual regressions
  • Bundle size reduced 15-25%
  • Performance improvements

Current Progress

  • Phase 1: 40% complete (icon system started, LuaBlocksEditor migrated)
  • Phase 2: 0% complete
  • Phase 3: 0% complete
  • Phase 4: 0% complete
  • Phase 5: 0% complete
  • Phase 6: 0% complete

Overall: ~7% complete (11/160 files migrated)


Key Files Reference

Fakemui Examples

Migration Examples


Risk Assessment

Low Risk

  • Atomic component migration (well-isolated)
  • Icon system replacement (centralized)
  • CSS variable theme (progressive enhancement)

Medium Risk

  • Complex organism components (navigation, dialogs)
  • Form components (validation, error handling)
  • Table components (sorting, filtering)

High Risk

  • Workflow editor (complex state, D&D)
  • Package creation (new architecture)
  • Provider changes (affects entire app)

Mitigation Strategies

  1. Parallel Development: Keep MUI versions until replacement tested
  2. Feature Flags: Toggle between old/new components
  3. Incremental Rollout: Migrate page-by-page if needed
  4. Testing: Comprehensive visual regression testing
  5. Rollback Plan: Git branches for easy reversion

Next Steps

Immediate (This Week)

  1. Complete MUI elimination plan
  2. Choose icon replacement strategy
  3. Create CSS reset file
  4. Start Phase 2: Migrate Button component

Short Term (Next 2 Weeks)

  1. Complete Phase 2: All atomic components
  2. Start Phase 3: Molecule components
  3. Set up visual regression testing

Medium Term (Weeks 3-6)

  1. Complete Phase 3 & 4: All UI components
  2. Begin Lua package creation
  3. Theme cleanup

Long Term (Weeks 6-8)

  1. Complete Lua packages
  2. Final MUI removal
  3. Documentation and cleanup

Questions & Decisions Needed

  1. Icon System: Custom SVG vs Lucide React?

    • Recommendation: Custom SVG (already started)
  2. CSS Framework: Pure CSS vs Tailwind utilities?

    • Current: Mix of SCSS modules and Tailwind
    • Recommendation: Keep current approach
  3. Component Library: Continue fakemui or use Radix?

    • Current: Fakemui + Radix for complex interactions
    • Recommendation: Use both (fakemui for display, Radix for behavior)
  4. Lua Packages: Which components become packages?

    • Confirmed: Workflow editor, GitHub viewer
    • TBD: Nerd mode IDE, other specialized editors

Last Updated: 2025-12-30 Next Review: After Phase 2 completion