Skip to content

Conversation

@Kitenite
Copy link
Contributor

@Kitenite Kitenite commented Oct 9, 2025

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes


Important

Refactor editor to separate insert operations using a new InsertMode enum, removing old insert modes from EditorMode.

  • Behavior:
    • Removed INSERT_DIV and INSERT_TEXT from TOOLBAR_ITEMS in index.tsx.
    • Updated BottomBar and GestureScreen to use InsertMode for insert operations.
    • HotkeysArea now sets insertMode instead of editorMode for insert hotkeys.
    • use-image-drag-drop.tsx uses InsertMode.INSERT_IMAGE for image drag operations.
    • LeftPanel visibility logic updated to include EditorMode.PAN.
    • ModeToggle refactored to use getXPosition() for animation.
  • State Management:
    • Added insertMode to StateManager in state/index.ts.
    • InsertManager refactored to use InsertMode for element insertion.
  • Models:
    • Introduced InsertMode enum in models/src/editor/index.ts.
  • Misc:
    • Removed unused imports and code comments related to old insert modes.

This description was created by Ellipsis for 982dee3. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • Bottom bar now remains visible in Design and Pan modes.
    • Design panel stays visible in Pan mode.
    • AI chat retains image context along with highlights for more consistent replies.
  • Refactor

    • Streamlined insert workflow for element and image insertion, improving consistency across drag/drop and hotkeys.
    • Simplified mode toggle animation logic without changing behavior.

@vercel
Copy link

vercel bot commented Oct 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs Building Building Preview Comment Oct 9, 2025 4:42am
web Building Building Preview Comment Oct 9, 2025 4:42am

@supabase
Copy link

supabase bot commented Oct 9, 2025

This pull request has been ignored for the connected project wowaemfasoptxrdjhilu because there are no changes detected in apps/backend/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a new InsertMode enum and state field, migrates insert-related logic from editorMode to insertMode across canvas gestures, hotkeys, and image drag/drop. Adjusts UI visibility: bottom bar and DesignPanel now show in DESIGN and PAN. Refactors mode toggle x-position calculation. Chat context merge now preserves image contexts.

Changes

Cohort / File(s) Summary of Changes
Insert mode: model and state
packages/models/src/editor/index.ts
Added exported enum InsertMode (INSERT_TEXT, INSERT_DIV, INSERT_IMAGE).
Insert mode: state manager
apps/web/client/src/components/store/editor/state/index.ts
Added public field insertMode: InsertMode | null = null.
Insert mode: insert manager API
apps/web/client/src/components/store/editor/insert/index.ts
getDefaultProperties now takes InsertMode (was EditorMode); updated mode checks and imports; removed sanitizeFilename re-export.
Insert mode: gesture and hotkeys
apps/web/client/src/app/project/[id]/_components/canvas/frame/gesture.tsx, apps/web/client/src/app/project/[id]/_components/canvas/hotkeys/index.tsx
Switched insert logic from editorMode to insertMode; hotkeys set insertMode; gesture handlers use insertMode for cursors, inserts, and reset insertMode after drop.
Insert mode: image drag/drop hook
apps/web/client/src/app/project/[id]/_components/left-panel/design-panel/image-tab/hooks/use-image-drag-drop.tsx
Image drag/mouse handlers now set/clear insertMode instead of editorMode; updated imports.
UI visibility updates
apps/web/client/src/app/project/[id]/_components/bottom-bar/index.tsx, apps/web/client/src/app/project/[id]/_components/left-panel/index.tsx
Bottom bar visibility/animation and DesignPanel visibility now true in DESIGN and PAN via shouldShow/editorMode checks.
Top bar refactor
apps/web/client/src/app/project/[id]/_components/top-bar/mode-toggle.tsx
Extracted x-position selection into getXPosition() for PREVIEW/CODE/else.
Chat context merge tweak
apps/web/client/src/components/store/editor/chat/context.ts
Removed editorMode from reaction inputs; merged context now also preserves allImages; reduced logging.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant HK as Hotkeys
  participant SM as StateManager
  participant GH as GestureHandler (Canvas)
  participant IM as InsertManager
  participant UI as UI Components

  U->>HK: Press "Insert Div/Text" hotkey
  HK->>SM: set insertMode = INSERT_DIV/INSERT_TEXT
  Note right of SM: editorMode unchanged

  U->>GH: Move/MouseDown on canvas
  GH->>SM: read insertMode
  alt insertMode active
    GH->>GH: Show crosshair/text cursor, measures
    GH->>IM: getDefaultProperties(insertMode)
    GH->>GH: Create element on drop
    GH->>SM: set insertMode = null
    GH->>SM: set editorMode = DESIGN
  else no insertMode
    GH->>GH: Normal move/hover behavior
  end

  U->>UI: Toggle PAN/DESIGN
  UI->>SM: update editorMode
  UI->>UI: Bottom bar + DesignPanel visible when DESIGN or PAN
Loading
sequenceDiagram
  autonumber
  participant U as User
  participant Img as Image Drag/Drop Hook
  participant SM as StateManager
  participant GH as GestureHandler

  U->>Img: Start dragging image
  Img->>SM: set insertMode = INSERT_IMAGE
  U->>GH: Drop on canvas
  GH->>SM: read insertMode INSERT_IMAGE
  GH->>GH: Handle image insert
  GH->>SM: set insertMode = null
  GH->>SM: set editorMode = DESIGN
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

A nibble of code, a hop to insert,
New modes sprout softly—no need to convert.
Pan or design, the bars reappear,
Canvas awaits as elements draw near.
With paws on hotkeys, I gladly compose—
InsertMode blooms, and the garden grows. 🐇✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/drag

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ee7959 and 982dee3.

📒 Files selected for processing (10)
  • apps/web/client/src/app/project/[id]/_components/bottom-bar/index.tsx (2 hunks)
  • apps/web/client/src/app/project/[id]/_components/canvas/frame/gesture.tsx (6 hunks)
  • apps/web/client/src/app/project/[id]/_components/canvas/hotkeys/index.tsx (2 hunks)
  • apps/web/client/src/app/project/[id]/_components/left-panel/design-panel/image-tab/hooks/use-image-drag-drop.tsx (3 hunks)
  • apps/web/client/src/app/project/[id]/_components/left-panel/index.tsx (1 hunks)
  • apps/web/client/src/app/project/[id]/_components/top-bar/mode-toggle.tsx (2 hunks)
  • apps/web/client/src/components/store/editor/chat/context.ts (1 hunks)
  • apps/web/client/src/components/store/editor/insert/index.ts (7 hunks)
  • apps/web/client/src/components/store/editor/state/index.ts (2 hunks)
  • packages/models/src/editor/index.ts (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Kitenite Kitenite merged commit fadafe1 into main Oct 9, 2025
4 of 7 checks passed
label: t(transKeys.editor.toolbar.tools.insertText.name),
tooltip: t(transKeys.editor.toolbar.tools.insertText.tooltip),
},
// {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented-out insert mode items if they are no longer needed.

}
if (mode === EditorMode.CODE) {
return '100%';
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typographical: Unnecessary semicolon after the closing brace for the if statement. Consider removing it for cleaner code style.

Suggested change
};
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants