Milimo frontend state manager

From mainza-ai/milimovideo · View interactive version

Milimo frontend state manager is an AI agent skill from the GitHub repository mainza-ai/milimovideo. Strict guidelines for the Milimo Video React 18/TypeScript frontend, specifically regarding the 7-slice Zustand God Store architecture, the SSE listener loops, and the "Magnetic V1" CSS-based timeline rendering logic. Use this when building UI features, modifying state synchronization, or addressing

How to use this skill

Skill file

Milimo Frontend State Manager Skill

As the Milimo Frontend State Manager, your primary responsibility is maintaining the integrity, performance, and synchronization of the React 18 UI.

1. The Zustand "God Store" (`timelineStore.ts`)

Milimo uses a single timelineStore.ts built from 7 distinct slices to prevent context re-render thrashing:

RULES:

2. Magnetic V1 & Free Placement (Timeline Layout)

The timeline UI is entirely DOM/CSS-based absolute positioning (no HTML5 <canvas>).

3. Browser Quirks & Engine Workarounds

Safari is notoriously difficult for media web apps. The frontend must strictly adhere to these workarounds:

A. Safari Audio Fix (`GlobalAudioManager.ts`)

Safari blocks <audio> autoplay and suffers from aggressive media desync when syncing HTML5 video to separate audio tags.

  1. The Playback Loop: PlaybackEngine.tsx uses a headless requestAnimationFrame to advance currentTime via Date.now() deltas.
  2. Audio Decoding: GlobalAudioManager.ts pre-fetches .mp3 files via HTTP Range requests and uses decodeAudioData into an in-memory AudioBufferSourceNode.
  3. Mute Control: Audio nodes remain playing but are muted (gain.value = 0) instead of being stopped, circumventing Safari user-gesture policies on re-start.
  4. Drift Tolerance: The frontend hardcodes a 250ms drift tolerance. If the video <video> tag current time deviates from the PlaybackEngine time by more than 250ms, it forces a .fastSeek().

B. Safari Draggable Hover Bug

Elements with draggable={true} in Safari WebKit silently swallow CSS pointer events, completely neutralizing Tailwind's group-hover and standard :hover pseudo-classes intended for child overlay UI.

4. SSE & React Hooks

Backend task updates flow exclusively through Server-Sent Events.

5. UI Layout Components

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.