UX: adds chat send shortcut user preference (#30473)

Users can now decide if they want to send a message on:
- <kbd>enter</kbd>
- <kbd>meta + enter</kbd>

If you choose <kbd>meta + enter</kbd>, <kbd>enter</kbd> will add a
linebreak.

<img width="192" alt="Screenshot 2025-01-21 at 12 57 48"
src="https://github.com/user-attachments/assets/abfd6f8b-83b3-4e6f-be67-8f63d536ca8a"
/>
This commit is contained in:
Joffrey JAFFEUX
2025-01-22 13:17:45 +01:00
committed by GitHub
parent a66e5ff728
commit 2cff8c82e3
13 changed files with 195 additions and 10 deletions

View File

@ -39,6 +39,10 @@ module Chat
@chat_separate_sidebar_mode ||= { default: 0, never: 1, always: 2, fullscreen: 3 }
end
def base.chat_send_shortcut
@chat_send_shortcut ||= { enter: 0, meta_enter: 1 }
end
# Avoid attempting to override when autoloading
if !base.method_defined?(:chat_separate_sidebar_mode_default?)
base.enum :chat_separate_sidebar_mode,
@ -46,6 +50,10 @@ module Chat
prefix: "chat_separate_sidebar_mode"
end
if !base.method_defined?(:chat_send_shortcut_default?)
base.enum :chat_send_shortcut, base.chat_send_shortcut, prefix: "chat_send_shortcut"
end
if !base.method_defined?(:show_thread_title_prompts?)
base.attribute :show_thread_title_prompts, :boolean, default: true
end