From 890f4d6bcb37b75dfe5a60fd04cd141e0960c27e Mon Sep 17 00:00:00 2001 From: lc6464 Date: Thu, 11 Jun 2026 15:44:45 +0800 Subject: [PATCH] feat: add shift-enter hint below chat composer --- .../src/components/chat/chat-composer.tsx | 233 ++++++++++-------- web/frontend/src/i18n/locales/bn-in.json | 1 + web/frontend/src/i18n/locales/cs.json | 1 + web/frontend/src/i18n/locales/en.json | 1 + web/frontend/src/i18n/locales/pt-br.json | 1 + web/frontend/src/i18n/locales/zh.json | 1 + 6 files changed, 129 insertions(+), 109 deletions(-) diff --git a/web/frontend/src/components/chat/chat-composer.tsx b/web/frontend/src/components/chat/chat-composer.tsx index cae4d2f6d..a06e53043 100644 --- a/web/frontend/src/components/chat/chat-composer.tsx +++ b/web/frontend/src/components/chat/chat-composer.tsx @@ -70,6 +70,7 @@ export function ChatComposer({ const { t } = useTranslation() const canInput = inputDisabledReason === null const composingRef = useRef(false) + const hasInput = input.trim().length > 0 const disabledMessage = inputDisabledReason === null ? null @@ -96,120 +97,134 @@ export function ChatComposer({ return (
-
- {isDragActive && ( -
-
- {t("chat.dropImagesActive")} +
+
+ {isDragActive && ( +
+
+ {t("chat.dropImagesActive")} +
+
+ )} + + {attachments.length > 0 && ( +
+ {attachments.map((attachment, index) => ( +
+ {attachment.filename + +
+ ))} +
+ )} + + onInputChange(e.target.value)} + onCompositionStart={() => { + composingRef.current = true + }} + onCompositionEnd={() => { + composingRef.current = false + }} + onPaste={onPaste} + onKeyDown={handleKeyDown} + placeholder={placeholder} + disabled={!canInput} + title={disabledMessage || undefined} + className={cn( + "placeholder:text-muted-foreground/50 max-h-[200px] min-h-[64px] resize-none border-0 bg-transparent px-2 py-1 text-[15px] shadow-none transition-colors focus-visible:ring-0 focus-visible:outline-none dark:bg-transparent", + !canInput && "cursor-not-allowed", + )} + minRows={1} + maxRows={8} + /> + +
+
+ +
+ +
+ {contextUsage && ( + + )} + {canInput ? ( + + + + + + + + {t("chat.sendHint")} + + + ) : null}
- )} +
- {attachments.length > 0 && ( -
- {attachments.map((attachment, index) => ( -
- {attachment.filename - -
- ))} -
- )} - - onInputChange(e.target.value)} - onCompositionStart={() => { - composingRef.current = true - }} - onCompositionEnd={() => { - composingRef.current = false - }} - onPaste={onPaste} - onKeyDown={handleKeyDown} - placeholder={placeholder} - disabled={!canInput} - title={disabledMessage || undefined} +
- -
-
- -
- -
- {contextUsage && ( - - )} - {canInput ? ( - - - - - - - - {t("chat.sendHint")} - - - ) : null} -
+ > + {t("chat.composeHint")}
diff --git a/web/frontend/src/i18n/locales/bn-in.json b/web/frontend/src/i18n/locales/bn-in.json index 2df6f8e48..4b485e247 100644 --- a/web/frontend/src/i18n/locales/bn-in.json +++ b/web/frontend/src/i18n/locales/bn-in.json @@ -94,6 +94,7 @@ }, "sendMessage": "বার্তা পাঠান", "sendHint": "পাঠাতে Enter চাপুন\nনতুন লাইনের জন্য Shift + Enter", + "composeHint": "পাঠাতে Enter চাপুন, নতুন লাইনের জন্য Shift + Enter", "contextTitle": "প্রসঙ্গ", "contextDetail": "বিস্তারিত দেখুন", "contextCompressAt": "Compress at", diff --git a/web/frontend/src/i18n/locales/cs.json b/web/frontend/src/i18n/locales/cs.json index 41a81648e..4b0f8df96 100644 --- a/web/frontend/src/i18n/locales/cs.json +++ b/web/frontend/src/i18n/locales/cs.json @@ -92,6 +92,7 @@ }, "sendMessage": "Odeslat zprávu", "sendHint": "Enter pro odeslání\nShift + Enter pro nový řádek", + "composeHint": "Enter pro odeslání, Shift + Enter pro nový řádek", "contextTitle": "Kontext", "contextDetail": "Zobrazit detail", "contextCompressAt": "Komprimovat při", diff --git a/web/frontend/src/i18n/locales/en.json b/web/frontend/src/i18n/locales/en.json index 8211163bf..9636c4812 100644 --- a/web/frontend/src/i18n/locales/en.json +++ b/web/frontend/src/i18n/locales/en.json @@ -94,6 +94,7 @@ }, "sendMessage": "Send message", "sendHint": "Press Enter to send\nShift + Enter for a new line", + "composeHint": "Press Enter to send, Shift + Enter for a new line", "contextTitle": "Context", "contextDetail": "View Details", "contextCompressAt": "Compress at", diff --git a/web/frontend/src/i18n/locales/pt-br.json b/web/frontend/src/i18n/locales/pt-br.json index 0a6da6d79..6e5b6eed0 100644 --- a/web/frontend/src/i18n/locales/pt-br.json +++ b/web/frontend/src/i18n/locales/pt-br.json @@ -94,6 +94,7 @@ }, "sendMessage": "Enviar mensagem", "sendHint": "Pressione Enter para enviar\nShift + Enter para nova linha", + "composeHint": "Pressione Enter para enviar, Shift + Enter para nova linha", "contextTitle": "Contexto", "contextDetail": "Ver Detalhes", "contextCompressAt": "Comprimir em", diff --git a/web/frontend/src/i18n/locales/zh.json b/web/frontend/src/i18n/locales/zh.json index 9e7d5359d..315928046 100644 --- a/web/frontend/src/i18n/locales/zh.json +++ b/web/frontend/src/i18n/locales/zh.json @@ -94,6 +94,7 @@ }, "sendMessage": "发送消息", "sendHint": "按 Enter 发送\nShift + Enter 换行", + "composeHint": "按 Enter 发送,Shift + Enter 换行", "contextTitle": "上下文", "contextDetail": "查看详情", "contextCompressAt": "压缩阈值",