mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
## Summary - **Fix blank screen crash** during video recreate flow: typing text, adjusting time slider, typing again, then clicking the text box caused an uncaught DOM exception in MentionTextarea's contentEditable caret operations, which unmounted the entire React tree (no error boundaries existed) - **Fix text selection disappearing** on mouse release in MentionTextarea: click handler and sync useEffect were destroying active selections by rewriting innerHTML and restoring only a collapsed caret - **Add React Error Boundary** around PromptBoxVideo as a safety net ## Changes ### MentionTextarea.tsx - Wrap `getCaretOffset`, `setCaretOffset`, `scrollCaretIntoView`, `handleInput`, sync `useEffect`, and `getOffsetRect` in try/catch to prevent uncaught DOMExceptions - Add null guard for `childNodes` iteration and `parentNode` access - Skip `detectMention` in `handleClick` when user has active text selection - Skip innerHTML rewrite in sync useEffect when editor has selected text ### PromptBoxVideo.tsx - Stabilize `characterNames` with `useMemo` to prevent `mentionColorMap` from rebuilding every render - Move empty characters array to module-level constant for stable reference - Add cleanup `useEffect` for `durationTimerRef` to prevent stale timer after unmount ### New: PromptBoxErrorBoundary.tsx - React Error Boundary with "Try again" recovery button ### ImageToVideo.tsx - Wrap `<PromptBoxVideo>` with `<PromptBoxErrorBoundary>` ## Reproduction steps (original bug) 1. Click "Recreate" on a video 2. Type text into the prompt box 3. Adjust the time slider 4. Type text again 5. Adjust the time slider and click the text box → **UI goes blank** ## Test plan - [x] Reproduced blank screen bug on Mac before fix - [x] Verified fix: repeated recreation flow no longer causes blank screen - [x] Verified text selection persists after mouse release - [x] Video generation with @mentions, reference images, and duration changes works correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>