fix: solve #5263 — Enter submits the New Workspace prompt

Draft
GI
4mo ago
+133-8

Root cause

The active New Workspace modal (V2, DashboardNewWorkspaceModal) renders its prompt with MarkdownEditor (Tiptap). In that editor, plain Enter inserts a newline and submission only happened via a window-level keydown listener gated on isEnterSubmit(e, { requireMod: true }) — i.e. Cmd/Ctrl+Enter. This made the launcher the outlier: the in-workspace chat composer (TiptapPromptEditor) already submits on plain Enter and uses Shift+Enter for a newline.

Affected code:

  • apps/desktop/src/renderer/components/MarkdownEditor/MarkdownEditor.tsx — no plain-Enter submit path.
  • apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/PromptGroup.tsx — Cmd+Enter-only submit + ⌘↵ hint.

The fix

  1. resolveEnterAction helper (pure, co-located) encodes the submit policy: Enter → submit, Shift+Enter → newline, deferring to IME composition and open suggestion menus, and falling back to the editor default when no submit handler is wired. This keeps the policy unit-testable without a DOM.
  2. MarkdownEditor gains an opt-in onEnter prop. A high-priority keyboard-shortcut extension uses resolveEnterAction so plain Enter submits (before HardBreak can insert a line break) and Shift+Enter inserts a newline. When onEnter is omitted, behavior is unchanged (backward compatible).
  3. New Workspace prompt passes onEnter={handleSubmit} and the hint changes from ⌘↵ to ↵. Cmd/Ctrl+Enter still submits through the existing window-level listener (requireMod: true), so there is no double-fire and the power-user shortcut keeps working.

The second, legacy modal (NewWorkspaceModal, used when V2 cloud is disabled) already submits on plain Enter via PromptInputTextarea, so it needed no change.

Tests

  • apps/desktop/src/renderer/components/MarkdownEditor/resolveEnterAction.test.ts reproduces the reported expectation and pins the policy: plain Enter → submit, Shift+Enter → newline, no-handler → editor default, IME/suggestion-open → deferred. bun test passes; bun run lint and bun run typecheck are clean.

Notes

  • The issue also proposed a configurable Settings → Keyboard preference. That is intentionally not included here to keep the change minimal and low-risk; the editor now reads its submit policy through one helper, which is the natural seam for wiring a preference later.

Closes #5263


Open in Stage

Summary by cubic

Enter now submits the New Workspace prompt (V2 modal), with Shift+Enter for newline, matching the chat composer. Keeps Cmd/Ctrl+Enter and fixes #5263.

  • Bug Fixes
    • Added a pure resolveEnterAction helper and an opt-in onEnter to the editor; behavior is unchanged when onEnter is not provided.
    • Wired onEnter in the New Workspace form and updated the hint from ⌘↵ to ↵.
    • Kept the window-level Cmd/Ctrl+Enter path to avoid double-submit; added unit tests for the enter policy.