Skip to content

feat(settings): configurable send key (Enter or Ctrl+Enter) - #1001

Merged
agegr merged 7 commits into
agegr:mainfrom
vill-jiang:feat/enter-send-mode
Sep 30, 2026
Merged

agegr merged 7 commits into
agegr:mainfrom
vill-jiang:feat/enter-send-mode

Conversation

@vill-jiang

Copy link
Copy Markdown
Contributor

设置面板增加发送快捷键的选项,默认Enter发送,可以切换为Ctrl/Cmd-Enter发送。

展示效果
image

移动端不论设置都是Enter都是输入换行
image

villjiang and others added 7 commits September 30, 2026 10:06
Add a 'Send key' preference in Settings > General > Chat that lets
desktop users choose between Enter-to-send (default, current behavior)
and Ctrl+Enter-to-send.

- new useEnterSendMode hook (localStorage 'pi-enter-send-mode',
  useSyncExternalStore, same pattern as useChatAppearance)
- ChatInput sendShortcut branches on the preference; Shift+Enter always
  inserts a newline; mobile behavior unchanged (Ctrl/Cmd+Enter only)
- segmented control in SettingsPanel styled like the theme selector
- i18n strings for en / zh-CN / zh-TW
- update SettingsPanel.test.mjs chat-options assertions (4 -> 5)
- Slash, @ file and history menus accept plain Enter in either send mode on a
  desktop keyboard. They used the send shortcut, so in Ctrl+Enter mode Enter
  inserted a newline instead of picking the highlighted item. In that mode
  Enter completes an exact slash command rather than sending it.
- The IME composition-end guard also covers plain Enter, so Safari's Enter
  that confirms a candidate does not add a newline in Ctrl+Enter mode.
- Mobile keeps its existing behavior.
- Settings: one row like the other chat options, with single-line
  "Enter" / "Ctrl/Cmd+Enter" choices; the two-line labels wrapped into
  three lines in Chinese. Drop aria-checked from the labels, since the native
  radios already expose it.
- The handler reads enterSendMode directly; the tests provide it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@agegr

agegr commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Thanks @vill-jiang! A Ctrl/Cmd+Enter send option is small and genuinely useful, especially with IME input and long multi-line prompts. The store (useSyncExternalStore + localStorage with a safe server snapshot) is simple and fits the other appearance settings.

I pushed a few fixes:

  • Menus still take Enter in Ctrl+Enter mode. The slash, @ file, and history menus accepted sendShortcut, so in Ctrl+Enter mode pressing Enter on a highlighted item inserted a newline instead of picking it, even though the menu hint says "Tab / Enter". On a desktop keyboard the menus now accept plain Enter in either mode. In Ctrl+Enter mode, Enter on an exact slash command completes it instead of sending it, so Enter never sends in that mode. Mobile is unchanged.
  • IME guard. The composition-end grace check also covers plain Enter. Otherwise Safari's Enter that confirms a candidate would add a stray newline in Ctrl+Enter mode.
  • Settings row. It's now laid out like the other chat options (label left, control right), with single-line Enter / Ctrl/Cmd+Enter choices. The two-line labels wrapped into three lines in Chinese at 260px. I also dropped aria-checked from the <label>s, since the native radios already expose the state.
  • The handler reads enterSendMode directly instead of the typeof guard. ChatInput.test.mjs now provides it and covers the Ctrl+Enter mode cases (newline, Ctrl/Cmd+Enter send/steer, menus, slash completion, IME grace, mobile).
  • Merged main.

Checked in the browser: in Ctrl+Enter mode, Enter inserts a newline (list continuation still applies), and Enter in the slash menu completes /compact . tsc --noEmit, eslint, and the full unit suite pass (the one failure, worktree.test.mjs force removal, also fails on main in my macOS temp dir). LGTM 👍


Generated by Claude Code

@agegr
agegr merged commit 5df8278 into agegr:main Sep 30, 2026
Kano-u pushed a commit to Kano-u/pi-web that referenced this pull request Oct 2, 2026
解开 agegr#981 的 DirectoryPicker 冲突后,这一段(390e70f..f52fd84)实测 0 冲突:

- agegr#992 移动端输入框停在键盘上方并给打字更多空间
- agegr#997 限制每客户端 SSE 积压
- agegr#1001 可配置发送键(Enter / Ctrl+Enter)
- agegr#1006 从 pi 的 provider catalog 解析 discovery endpoint
- agegr#1017 空闲关闭被禁用时回收 Stop 无法解除的运行
- agegr#1016 Stop 结束输出被幸存进程持住的命令
- agegr#1015 保留用户消息里输入的换行
- agegr#1019 在 Safari / iOS 16.2 上可加载(新增 browserslist,无新依赖)
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
* feat(settings): configurable send key (Enter or Ctrl+Enter)

Add a 'Send key' preference in Settings > General > Chat that lets
desktop users choose between Enter-to-send (default, current behavior)
and Ctrl+Enter-to-send.

- new useEnterSendMode hook (localStorage 'pi-enter-send-mode',
  useSyncExternalStore, same pattern as useChatAppearance)
- ChatInput sendShortcut branches on the preference; Shift+Enter always
  inserts a newline; mobile behavior unchanged (Ctrl/Cmd+Enter only)
- segmented control in SettingsPanel styled like the theme selector
- i18n strings for en / zh-CN / zh-TW
- update SettingsPanel.test.mjs chat-options assertions (4 -> 5)

* refactor: drop comments, use Ctrl/Cmd-Enter wording for cross-platform clarity

* fix(settings): two-line send key labels for narrow segmented control

* chore: remove inline comment

* chore: remove send shortcut comments

* fix(chat): keep Enter for menus in Ctrl+Enter send mode

- Slash, @ file and history menus accept plain Enter in either send mode on a
  desktop keyboard. They used the send shortcut, so in Ctrl+Enter mode Enter
  inserted a newline instead of picking the highlighted item. In that mode
  Enter completes an exact slash command rather than sending it.
- The IME composition-end guard also covers plain Enter, so Safari's Enter
  that confirms a candidate does not add a newline in Ctrl+Enter mode.
- Mobile keeps its existing behavior.
- Settings: one row like the other chat options, with single-line
  "Enter" / "Ctrl/Cmd+Enter" choices; the two-line labels wrapped into
  three lines in Chinese. Drop aria-checked from the labels, since the native
  radios already expose it.
- The handler reads enterSendMode directly; the tests provide it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: villjiang <[email protected]>
Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
* feat(settings): configurable send key (Enter or Ctrl+Enter)

Add a 'Send key' preference in Settings > General > Chat that lets
desktop users choose between Enter-to-send (default, current behavior)
and Ctrl+Enter-to-send.

- new useEnterSendMode hook (localStorage 'pi-enter-send-mode',
  useSyncExternalStore, same pattern as useChatAppearance)
- ChatInput sendShortcut branches on the preference; Shift+Enter always
  inserts a newline; mobile behavior unchanged (Ctrl/Cmd+Enter only)
- segmented control in SettingsPanel styled like the theme selector
- i18n strings for en / zh-CN / zh-TW
- update SettingsPanel.test.mjs chat-options assertions (4 -> 5)

* refactor: drop comments, use Ctrl/Cmd-Enter wording for cross-platform clarity

* fix(settings): two-line send key labels for narrow segmented control

* chore: remove inline comment

* chore: remove send shortcut comments

* fix(chat): keep Enter for menus in Ctrl+Enter send mode

- Slash, @ file and history menus accept plain Enter in either send mode on a
  desktop keyboard. They used the send shortcut, so in Ctrl+Enter mode Enter
  inserted a newline instead of picking the highlighted item. In that mode
  Enter completes an exact slash command rather than sending it.
- The IME composition-end guard also covers plain Enter, so Safari's Enter
  that confirms a candidate does not add a newline in Ctrl+Enter mode.
- Mobile keeps its existing behavior.
- Settings: one row like the other chat options, with single-line
  "Enter" / "Ctrl/Cmd+Enter" choices; the two-line labels wrapped into
  three lines in Chinese. Drop aria-checked from the labels, since the native
  radios already expose it.
- The handler reads enterSendMode directly; the tests provide it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: villjiang <[email protected]>
Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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