feat(ai): add enterToSubmit prop to ChatComposer#4
Conversation
Lets consumers opt into modifier-based send (Enter for newline, Cmd/Ctrl/Alt+Enter to send) instead of Enter-to-send. Defaults to true so existing usage is unchanged. Also guards against IME composition events.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe ChangesEnter Key Submission Control
🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/ai/src/ChatComposer.tsx`:
- Around line 74-85: In handleKeyDown, avoid calling onSend when sending is
disabled by respecting the existing canSend guard (so keyboard behavior matches
the Send button); before calling onSend() (both in the enterToSubmit branch and
the modifier-keys branch) check if canSend is true (or compute same guard:
!isSending && draft.trim().length > 0) and return early if not, and only call
event.preventDefault() when you will actually invoke onSend; locate
handleKeyDown and apply the guard there.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3233877e-567a-48e6-b223-1d2b977b7feb
📒 Files selected for processing (1)
packages/ai/src/ChatComposer.tsx
Match the Send button's enabled state: keyboard-triggered send is now suppressed when the draft is empty or isSending=true. In Enter-to-send mode, Enter still preventDefaults so it never inserts a newline; in modifier-to-send mode, we only preventDefault when we'll actually send. Addresses CodeRabbit review on spacedriveapp#4.
Summary
enterToSubmitprop (defaulttrue) to<ChatComposer>in@spacedrive/ai.true: Enter sends, Shift+Enter inserts a newline (current behavior — backward compatible).false: Enter inserts a newline; ⌘/Ctrl/Alt+Enter sends.event.nativeEvent.isComposing) so dead-keys / CJK composition no longer accidentally submit.Motivation
Some users frequently send multi-line messages and want Enter to insert newlines, with a modifier+Enter to send. Exposing this as a prop lets consumers (spacebot, etc.) wire it to a user preference.
Companion PR
Consumed by spacedriveapp/spacebot#600 (closes spacedriveapp/spacebot#599).
This PR must merge and a new
@spacedrive/airelease be published before that one can land.Test plan
enterToSubmit={false}→ Enter inserts newline, ⌘/Ctrl/Alt+Enter sends