Skip to content

Commit

Permalink
💄 style: improve display of set limited history messages, `randomne…
Browse files Browse the repository at this point in the history
…ss` and `voice input` (lobehub#2586)

* 💄 style: Modify the display effect of some content

* 💄 style: Modify the display effect of `voice input`

* 💄 style: Modify the display effect of `voice input`
  • Loading branch information
RubuJam committed May 28, 2024
1 parent 6a51975 commit 22c9b9c
Show file tree
Hide file tree
Showing 21 changed files with 56 additions and 16 deletions.
1 change: 1 addition & 0 deletions locales/ar/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "غير محدود",
"limited": "يحتوي فقط على {{number}} رسالة محادثة",
"setlimited": "تعيين عدد الرسائل التاريخية",
"title": "تحديد عدد الرسائل التاريخية",
"unlimited": "غير محدود"
},
Expand Down
1 change: 1 addition & 0 deletions locales/bg-BG/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Неограничен",
"limited": "Включете само {{number}} съобщения от разговора",
"setlimited": "Задайте ограничение за използване на брой исторически съобщения",
"title": "Ограничаване на броя на съобщенията в историята",
"unlimited": "Неограничен брой съобщения в историята"
},
Expand Down
1 change: 1 addition & 0 deletions locales/de-DE/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Unbegrenzt",
"limited": "Enthält nur {{number}} Gesprächsnachrichten",
"setlimited": "Setzen Sie die begrenzte Anzahl von Nachrichten",
"title": "Historiennachrichten begrenzen",
"unlimited": "Unbegrenzte Historiennachrichten"
},
Expand Down
1 change: 1 addition & 0 deletions locales/en-US/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Unlimited",
"limited": "Include only {{number}} conversation messages",
"setlimited": "Set limited history messages",
"title": "Limit History Message Count",
"unlimited": "Unlimited history message count"
},
Expand Down
1 change: 1 addition & 0 deletions locales/es-ES/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Sin límite",
"limited": "Incluye solo {{number}} mensajes de conversación",
"setlimited": "Establecer cantidad de mensajes históricos",
"title": "Limitar número de mensajes históricos",
"unlimited": "Sin límite de mensajes históricos"
},
Expand Down
1 change: 1 addition & 0 deletions locales/fr-FR/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Illimité",
"limited": "Inclure uniquement {{number}} messages de conversation",
"setlimited": "Définir le nombre de messages d'historique",
"title": "Limite du nombre de messages historiques",
"unlimited": "Aucune limite sur le nombre de messages historiques"
},
Expand Down
1 change: 1 addition & 0 deletions locales/it-IT/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Illimitato",
"limited": "Include solo {{number}} messaggi di conversazione",
"setlimited": "Imposta il numero di messaggi storici da utilizzare",
"title": "Limita il numero di messaggi storici",
"unlimited": "Numero illimitato di messaggi storici"
},
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "制限なし",
"limited": "{{number}}件の会話メッセージのみ含む",
"setlimited": "使用履歴メッセージ数",
"title": "過去メッセージ数を制限する",
"unlimited": "過去メッセージ数を制限しない"
},
Expand Down
1 change: 1 addition & 0 deletions locales/ko-KR/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "제한 없음",
"limited": "{{number}}개의 대화 메시지만 포함",
"setlimited": "사용할 메시지 수 설정",
"title": "이전 메시지 수 제한",
"unlimited": "이전 메시지 수 제한 없음"
},
Expand Down
1 change: 1 addition & 0 deletions locales/nl-NL/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Onbeperkt",
"limited": "Bevat alleen {{number}} berichten",
"setlimited": "Stel berichtengeschiedenis in",
"title": "Berichtgeschiedenis beperken",
"unlimited": "Onbeperkt aantal berichten in de geschiedenis"
},
Expand Down
1 change: 1 addition & 0 deletions locales/pl-PL/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Bez limitu",
"limited": "Zawiera tylko {{number}} wiadomości",
"setlimited": "Ustaw limit wiadomości historycznych",
"title": "Ograniczenie liczby wiadomości w historii",
"unlimited": "Bez limitu wiadomości w historii"
},
Expand Down
1 change: 1 addition & 0 deletions locales/pt-BR/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Sem limite",
"limited": "Incluir apenas {{number}} mensagens de conversa",
"setlimited": "Definir número de mensagens de histórico",
"title": "Limitar número de mensagens de histórico",
"unlimited": "Sem limite de mensagens de histórico"
},
Expand Down
1 change: 1 addition & 0 deletions locales/ru-RU/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Без ограничений",
"limited": "Содержит только {{number}} сообщений",
"setlimited": "Установить ограничение на количество использованных сообщений",
"title": "Ограничение истории сообщений",
"unlimited": "Без ограничения истории сообщений"
},
Expand Down
1 change: 1 addition & 0 deletions locales/tr-TR/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Sınırsız",
"limited": "Yalnızca {{number}} konuşma mesajını içerir",
"setlimited": "Kullanılan mesaj sayısı",
"title": "Geçmiş Mesaj Sayısı Sınırlama",
"unlimited": "Sınırsız geçmiş mesaj sayısı"
},
Expand Down
1 change: 1 addition & 0 deletions locales/vi-VN/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "Không giới hạn",
"limited": "Chỉ chứa {{number}} tin nhắn trò chuyện",
"setlimited": "Thiết lập số lượng tin nhắn lịch sử",
"title": "Giới hạn số lượng tin nhắn lịch sử",
"unlimited": "Không giới hạn số lượng tin nhắn lịch sử"
},
Expand Down
1 change: 1 addition & 0 deletions locales/zh-CN/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "不限制",
"limited": "只包含 {{number}} 条会话消息",
"setlimited": "使用历史消息数",
"title": "限制历史消息数",
"unlimited": "不限历史消息数"
},
Expand Down
1 change: 1 addition & 0 deletions locales/zh-TW/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"enableHistoryCount": {
"alias": "不限制",
"limited": "只包含 {{number}} 條對話訊息",
"setlimited": "設置限制",
"title": "限制歷史訊息數",
"unlimited": "不限歷史訊息數"
},
Expand Down
20 changes: 13 additions & 7 deletions src/features/ChatInput/ActionBar/History.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ActionIcon, SliderWithInput } from '@lobehub/ui';
import { Popover, Switch } from 'antd';
import { Timer, TimerOff } from 'lucide-react';
import { memo } from 'react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

Expand All @@ -10,12 +10,20 @@ import { agentSelectors } from '@/store/agent/selectors';

const History = memo(() => {
const { t } = useTranslation('setting');
const [popoverOpen, setPopoverOpen] = useState(false);

const [historyCount, unlimited, updateAgentConfig] = useAgentStore((s) => {
const config = agentSelectors.currentAgentChatConfig(s);
return [config.historyCount, !config.enableHistoryCount, s.updateAgentChatConfig];
});

const title = t(
unlimited
? 'settingChat.enableHistoryCount.unlimited'
: 'settingChat.enableHistoryCount.limited',
{ number: historyCount || 0 },
);

return (
<Popover
arrow={false}
Expand Down Expand Up @@ -44,18 +52,16 @@ const History = memo(() => {
</Flexbox>
</Flexbox>
}
onOpenChange={setPopoverOpen}
open={popoverOpen}
placement={'top'}
title={t('settingChat.enableHistoryCount.setlimited')}
trigger={'click'}
>
<ActionIcon
icon={unlimited ? TimerOff : Timer}
placement={'bottom'}
title={t(
unlimited
? 'settingChat.enableHistoryCount.unlimited'
: 'settingChat.enableHistoryCount.limited',
{ number: historyCount || 0 },
)}
title={popoverOpen ? undefined : title}
/>
</Popover>
);
Expand Down
14 changes: 8 additions & 6 deletions src/features/ChatInput/ActionBar/Temperature.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { ActionIcon, SliderWithInput } from '@lobehub/ui';
import { Popover } from 'antd';
import { Thermometer } from 'lucide-react';
import { memo } from 'react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';

import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';

const Temperature = memo(() => {
const { t } = useTranslation('setting');
const [popoverOpen, setPopoverOpen] = useState(false);

const [temperature, updateAgentConfig] = useAgentStore((s) => {
const config = agentSelectors.currentAgentConfig(s);
return [config.params?.temperature, s.updateAgentConfig];
});

const title = t('settingModel.temperature.titleWithValue', { value: temperature });

return (
<Popover
arrow={false}
Expand All @@ -32,14 +35,13 @@ const Temperature = memo(() => {
value={temperature}
/>
}
onOpenChange={setPopoverOpen}
open={popoverOpen}
placement={'top'}
title={t('settingModel.temperature.title')}
trigger={'click'}
>
<ActionIcon
icon={Thermometer}
placement={'bottom'}
title={t('settingModel.temperature.titleWithValue', { value: temperature })}
/>
<ActionIcon icon={Thermometer} placement={'bottom'} title={popoverOpen ? undefined : title} />
</Popover>
);
});
Expand Down
20 changes: 17 additions & 3 deletions src/features/ChatInput/STT/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ActionIcon, Alert, Highlighter } from '@lobehub/ui';
import { Button, Dropdown } from 'antd';
import { createStyles } from 'antd-style';
import { Mic, MicOff } from 'lucide-react';
import { memo } from 'react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

Expand Down Expand Up @@ -43,6 +43,11 @@ const CommonSTT = memo<{
}) => {
const { t } = useTranslation('chat');
const { styles } = useStyles();
const [dropdownOpen, setDropdownOpen] = useState(false);

const handleDropdownVisibleChange = (open: boolean) => {
setDropdownOpen(open);
};

return (
<Dropdown
Expand Down Expand Up @@ -74,6 +79,14 @@ const CommonSTT = memo<{
menu={{
activeKey: 'time',
items: [
{
key: 'title',
label: (
<Flexbox>
<div style={{ fontWeight: 'bolder' }}>{t('stt.action')}</div>
</Flexbox>
),
},
{
key: 'time',
label: (
Expand All @@ -85,7 +98,8 @@ const CommonSTT = memo<{
},
],
}}
open={!!error || isRecording || isLoading}
onOpenChange={handleDropdownVisibleChange}
open={dropdownOpen || !!error || isRecording || isLoading}
placement={mobile ? 'topRight' : 'top'}
trigger={['click']}
>
Expand All @@ -96,7 +110,7 @@ const CommonSTT = memo<{
placement={'bottom'}
size={mobile ? { blockSize: 36, fontSize: 16 } : { fontSize: 22 }}
style={{ flex: 'none' }}
title={desc}
title={dropdownOpen ? '' : desc}
/>
</Dropdown>
);
Expand Down
1 change: 1 addition & 0 deletions src/locales/default/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export default {
enableHistoryCount: {
alias: '不限制',
limited: '只包含 {{number}} 条会话消息',
setlimited: '使用历史消息数',
title: '限制历史消息数',
unlimited: '不限历史消息数',
},
Expand Down

0 comments on commit 22c9b9c

Please sign in to comment.