Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(chat): keep the queued-message hint on the message row (#20287)

Arvin Xue6b4a1c97fe0
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 12a08a2e1d1..891a99ca410 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -1281,6 +1281,7 @@
"inputQueue.edit": "Edit",
"inputQueue.enqueueRejected": "Queue is full. Try again after the current run finishes.",
"inputQueue.queuedHint": "Sends when the current step finishes",
+ "inputQueue.queuedMergeHint": "Merged and sent when the current step finishes",
"inputQueue.sendNow": "Send now (interrupts current run)",
"intentUnderstanding.title": "Understanding your intent...",
"internalLink.agent.open": "Open agent",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 39aff427b69..766ab168349 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -1281,6 +1281,7 @@
"inputQueue.edit": "编辑",
"inputQueue.enqueueRejected": "队列已满。请在当前运行完成后再试。",
"inputQueue.queuedHint": "当前步骤完成后发送",
+ "inputQueue.queuedMergeHint": "当前步骤完成后合并发送",
"inputQueue.sendNow": "立即发送(中断当前运行)",
"intentUnderstanding.title": "正在理解你的意图…",
"internalLink.agent.open": "打开助理",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index c95bebe3f4c..1137c147cfb 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -792,6 +792,7 @@ export default {
'inputQueue.edit': 'Edit',
'inputQueue.enqueueRejected': 'Queue is full. Try again after the current run finishes.',
'inputQueue.queuedHint': 'Sends when the current step finishes',
+ 'inputQueue.queuedMergeHint': 'Merged and sent when the current step finishes',
'inputQueue.sendNow': 'Send now (interrupts current run)',
'intentUnderstanding.title': 'Understanding your intent...',
'inviteMembers': 'Invite members',
diff --git a/src/features/Conversation/ChatInput/QueueTray.tsx b/src/features/Conversation/ChatInput/QueueTray.tsx
index c7ddefda45c..8d1c0677bde 100644
--- a/src/features/Conversation/ChatInput/QueueTray.tsx
+++ b/src/features/Conversation/ChatInput/QueueTray.tsx
@@ -1,9 +1,9 @@
'use client';
-import { Flexbox, Icon, Image } from '@lobehub/ui';
+import { Flexbox, Icon, Image, Tooltip } from '@lobehub/ui';
import { ActionIcon } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
-import { ArrowUp, ListEnd, Pencil, Trash2 } from 'lucide-react';
+import { ArrowUp, Info, ListEnd, Pencil, Trash2 } from 'lucide-react';
import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -28,9 +28,12 @@ const PREVIEW_SIZE = 28;
const styles = createStaticStyles(({ css, cssVar }) => ({
container: css`
+ container-type: inline-size;
+
border: 1px solid ${cssVar.colorFillSecondary};
border-block-end: none;
border-radius: 12px 12px 0 0;
+
background: ${cssVar.colorBgElevated};
`,
fileChip: css`
@@ -53,11 +56,40 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
text-overflow: ellipsis;
`,
hint: css`
- padding-block: 0 6px;
- padding-inline: 34px 12px;
+ display: inline-flex;
+ flex: none;
+ gap: 4px;
+ align-items: center;
+
font-size: 12px;
color: ${cssVar.colorTextDescription};
`,
+ hintGlyph: css`
+ cursor: help;
+
+ display: none;
+
+ padding: 0;
+ border: none;
+ border-radius: 4px;
+
+ color: inherit;
+
+ background: none;
+
+ /* Too narrow to spare a sentence on the send timing: keep the meaning on the
+ glyph's tooltip instead of squeezing the message text. */
+ @container (max-width: 480px) {
+ display: inline-flex;
+ }
+ `,
+ hintText: css`
+ white-space: nowrap;
+
+ @container (max-width: 480px) {
+ display: none;
+ }
+ `,
icon: css`
flex-shrink: 0;
color: ${cssVar.colorTextDescription};
@@ -80,7 +112,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
}
`,
item: css`
- padding-block: 6px 4px;
+ padding-block: 6px;
padding-inline: 12px 8px;
`,
itemDivider: css`
@@ -89,6 +121,8 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
text: css`
overflow: hidden;
+ min-width: 0;
+
font-size: 13px;
line-height: 1.4;
text-overflow: ellipsis;
@@ -245,6 +279,12 @@ const QueueTray = memo(() => {
// "send now" then.
if (!canUseResource) return null;
+ // The queue drains as one take-all and is merged into a single send, so a
+ // multi-item queue has to say "merges" instead of "sends".
+ const hintText = t(
+ queuedMessages.length > 1 ? 'inputQueue.queuedMergeHint' : 'inputQueue.queuedHint',
+ );
+
return (
<Flexbox className={styles.container} gap={0}>
{queuedMessages.map((msg, index) => {
@@ -258,7 +298,13 @@ const QueueTray = memo(() => {
key={msg.id}
>
<Icon className={styles.icon} icon={ListEnd} size={14} />
- <Flexbox horizontal align={'center'} flex={1} gap={8} style={{ overflow: 'hidden' }}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={'0 1 auto'}
+ gap={8}
+ style={{ minWidth: 0, overflow: 'hidden' }}
+ >
{previews.length > 0 && (
<Flexbox horizontal flex={'none'} gap={4}>
{previews.map((file) => (
@@ -267,11 +313,27 @@ const QueueTray = memo(() => {
</Flexbox>
)}
{msg.content && (
- <Flexbox className={styles.text} flex={1}>
+ <Flexbox className={styles.text} flex={'0 1 auto'}>
{msg.content}
</Flexbox>
)}
</Flexbox>
+ {/* The send timing is this message's own caption, so it rides the
+ message row right after the content instead of taking a line.
+ Several queued messages are merged into a single send on drain,
+ so the wording changes with the queue size. */}
+ <span className={styles.hint}>
+ {/* Collapsed form. It is display:none while the sentence fits, so
+ it adds no tab stop there; when it shows it is a real
+ focusable control carrying the wording as its name. */}
+ <Tooltip title={hintText}>
+ <button aria-label={hintText} className={styles.hintGlyph} type={'button'}>
+ <Icon icon={Info} size={13} />
+ </button>
+ </Tooltip>
+ <span className={styles.hintText}>{hintText}</span>
+ </span>
+ <div style={{ flex: 1 }} />
<ActionIcon
aria-label={t('inputQueue.edit')}
icon={Pencil}
@@ -296,7 +358,6 @@ const QueueTray = memo(() => {
</Flexbox>
);
})}
- <div className={styles.hint}>{t('inputQueue.queuedHint')}</div>
</Flexbox>
);
});