Skip to content

Conversation

@maifeeulasad
Copy link
Contributor

closes #549

Copilot AI review requested due to automatic review settings January 9, 2026 12:36
@maifeeulasad
Copy link
Contributor Author

@DayuanJiang if you need some changes, please let me know.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a user preference setting to choose between Enter or Ctrl+Enter as the keyboard shortcut for sending messages in the chat interface, addressing issue #549.

Key changes:

  • Added a new storage key for the send shortcut preference
  • Implemented UI controls in the settings dialog to toggle between "Enter to send" and "Ctrl+Enter to send" modes
  • Updated the chat input keyboard handler to respect the user's preference
  • Added translations for the new setting in English, Chinese, and Japanese

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/storage.ts Adds sendShortcut storage key constant for persisting user preference
lib/i18n/dictionaries/en.json Adds English translations for the send shortcut setting UI
lib/i18n/dictionaries/zh.json Adds Chinese translations for the send shortcut setting UI
lib/i18n/dictionaries/ja.json Adds Japanese translations for the send shortcut setting UI
components/settings-dialog.tsx Implements select dropdown UI for choosing send shortcut preference
components/chat-input.tsx Updates keyboard handler to check preference and send message accordingly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Biki-dev and others added 2 commits January 9, 2026 19:14
… at 160px, it hide the letter “d” from the word “Send.”
Copilot AI review requested due to automatic review settings January 10, 2026 05:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Owner

@DayuanJiang DayuanJiang left a comment

Choose a reason for hiding this comment

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

@maifeeulasad Thanks, please check these 2 comment.

@maifeeulasad
Copy link
Contributor Author

@DayuanJiang care to take another look please?

Copy link
Owner

@DayuanJiang DayuanJiang left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, I found another minor issue, could you please also fix this?

Copilot AI review requested due to automatic review settings January 10, 2026 14:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

components/chat-input.tsx:232

  • The keyboard shortcut feature lacks test coverage. The repository has e2e tests for keyboard interactions (tests/e2e/keyboard.spec.ts), but there are no tests verifying:
  1. That Enter sends messages when "enter" mode is selected
  2. That Cmd/Ctrl+Enter sends messages when "ctrl-enter" mode is selected
  3. That Shift+Enter creates a new line in "enter" mode
  4. That the setting persists across page reloads

Consider adding test coverage for this feature to ensure it works correctly and prevent regressions.

    const handleKeyDown = (e: React.KeyboardEvent) => {
        const shouldSend =
            sendShortcut === "enter"
                ? e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.metaKey
                : (e.metaKey || e.ctrlKey) && e.key === "Enter"

        if (shouldSend) {
            e.preventDefault()
            const form = e.currentTarget.closest("form")
            if (form && input.trim() && !isDisabled) {
                form.requestSubmit()
            }
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 196 to 198
const [sendShortcut] = useState(() =>
localStorage.getItem(STORAGE_KEYS.sendShortcut) || "ctrl-enter",
)
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

There are two issues with the sendShortcut state initialization:

  1. Direct access to localStorage without checking if window is defined can cause SSR issues during hydration in Next.js, potentially resulting in "localStorage is not defined" errors or hydration mismatches.

  2. The state is initialized once on mount but won't react to changes made in the settings dialog. If a user changes the preference while the chat input is mounted, the change won't take effect until page reload.

Consider adding a typeof window check for SSR safety (similar to line 168 in settings-dialog.tsx), and implementing a mechanism to listen for localStorage changes. Note that the 'storage' event only fires for changes from other windows/tabs, so for same-window changes you may need a custom event or context-based solution to propagate the setting change from the settings dialog to the chat input component.

Copilot uses AI. Check for mistakes.
@DayuanJiang
Copy link
Owner

@maifeeulasad Thanks for the fix. I tested it locally and found it is better to make it work without refreshing the page to keep the setting behavior consistent. I fixed it myself. Merged.

@DayuanJiang DayuanJiang merged commit b7eaf46 into DayuanJiang:main Jan 11, 2026
6 of 7 checks passed
@maifeeulasad
Copy link
Contributor Author

@DayuanJiang really appreciate it. I was nice contributing to this open source project and working with this really collaborative team! 🥂

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.

[Feature] Add setting for Enter/Ctrl+Enter to send messages

3 participants