Merge pull request #271 from RugerMcCarthy/feat/send_preview_option

feat: add switch of send preview bubble
This commit is contained in:
Yifei Zhang 2023-04-02 20:08:35 +08:00 committed by GitHub
commit e248e9196a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 13 deletions

View File

@ -292,6 +292,8 @@ export function Chat(props: {
const latestMessageRef = useRef<HTMLDivElement>(null);
const [autoScroll, setAutoScroll] = useState(true);
const config = useChatStore((state) => state.config);
// preview messages
const messages = (session.messages as RenderMessage[])
.concat(
@ -305,15 +307,14 @@ export function Chat(props: {
},
]
: [],
)
.concat(
userInput.length > 0
).concat(
userInput.length > 0 && config.sendPreviewBubble
? [
{
role: "user",
content: userInput,
date: new Date().toLocaleString(),
preview: true,
preview: false,
},
]
: [],

View File

@ -278,6 +278,18 @@ export function Settings(props: { closeSettings: () => void }) {
}
></input>
</SettingItem>
<SettingItem title={Locale.Settings.SendPreviewBubble}>
<input
type="checkbox"
checked={config.sendPreviewBubble}
onChange={(e) =>
updateConfig(
(config) => (config.sendPreviewBubble = e.currentTarget.checked),
)
}
></input>
</SettingItem>
</List>
<List>
<SettingItem

View File

@ -77,6 +77,7 @@ const cn = {
SendKey: "发送键",
Theme: "主题",
TightBorder: "紧凑边框",
SendPreviewBubble: "发送预览气泡",
Prompt: {
Disable: {
Title: "禁用提示词自动补全",

View File

@ -78,6 +78,7 @@ const en: LocaleType = {
SendKey: "Send Key",
Theme: "Theme",
TightBorder: "Tight Border",
SendPreviewBubble: "Send Preview Bubble",
Prompt: {
Disable: {
Title: "Disable auto-completion",

View File

@ -77,6 +77,7 @@ const tw: LocaleType = {
SendKey: "發送鍵",
Theme: "主題",
TightBorder: "緊湊邊框",
SendPreviewBubble: "發送預覽氣泡",
Prompt: {
Disable: {
Title: "停用提示詞自動補全",

View File

@ -43,6 +43,7 @@ export interface ChatConfig {
fontSize: number;
theme: Theme;
tightBorder: boolean;
sendPreviewBubble: boolean;
disablePromptHint: boolean;
@ -132,6 +133,7 @@ const DEFAULT_CONFIG: ChatConfig = {
fontSize: 14,
theme: Theme.Auto as Theme,
tightBorder: false,
sendPreviewBubble: true,
disablePromptHint: false,