Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] add option to hide initial message for new chats #1777

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/renderer/components/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import SmartToyIcon from '@mui/icons-material/SmartToy'
import SettingsIcon from '@mui/icons-material/Settings'
import { useTranslation } from 'react-i18next'
import { Message, SessionType } from '../../shared/types'
import { useAtomValue, useSetAtom } from 'jotai'
import { useAtom, useAtomValue, useSetAtom } from 'jotai'
import {
showMessageTimestampAtom,
showModelNameAtom,
showTokenCountAtom,
showWordCountAtom,
openSettingDialogAtom,
enableMarkdownRenderingAtom,
settingsAtom,
} from '../stores/atoms'
import { currsentSessionPicUrlAtom, showTokenUsedAtom } from '../stores/atoms'
import * as scrollActions from '../stores/scrollActions'
Expand All @@ -44,6 +45,7 @@ export interface Props {
export default function Message(props: Props) {
const { t } = useTranslation()
const theme = useTheme()


const showMessageTimestamp = useAtomValue(showMessageTimestampAtom)
const showModelName = useAtomValue(showModelNameAtom)
Expand Down Expand Up @@ -102,6 +104,11 @@ export default function Message(props: Props) {
}
}, [msg.content])

const hideInitMsg = () => {
const [settings, _1] = useAtom(settingsAtom);
return settings.hideInitialMessage;
}

let content = msg.content
if (typeof msg.content !== 'string') {
content = JSON.stringify(msg.content)
Expand Down Expand Up @@ -146,6 +153,7 @@ export default function Message(props: Props) {
[theme.breakpoints.down('sm')]: {
paddingX: '0.3rem',
},
display: msg?.role === 'system' && hideInitMsg() ? "none" : "initial"
}}
>
<Grid container wrap="nowrap" spacing={1.5}>
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"theme": "Thema",
"show message word count": "Wortanzahl anzeigen",
"show message token count": "Tokenanzahl anzeigen",
"hide initial message": "Anfangsgespräch verstecken",
"show message token usage": "Token-Nutzung anzeigen",
"show model name": "Modellname anzeigen",
"show message timestamp": "Zeitstempel anzeigen",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"show message word count": "Show message word count",
"show message token count": "Show message token count",
"show message token usage": "Show message token usage",
"hide initial message": "Hide initial message",
"show model name": "Show model name",
"show message timestamp": "Show message timestamp",
"proxy": "Proxy",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"show message word count": "Afficher le nombre de mots du message",
"show message token count": "Afficher le nombre de jetons du message",
"show message token usage": "Afficher l'utilisation des jetons du message",
"hide initial message": "Masquer le message initial",
"show model name": "Afficher le nom du modèle",
"show message timestamp": "Afficher l'horodatage du message",
"proxy": "Proxy",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"show message word count": "メッセージの単語数を表示",
"show message token count": "メッセージのトークン数を表示",
"show message token usage": "メッセージのトークン使用状況を表示",
"hide initial message": "初期メッセージを非表示にする",
"show model name": "モデル名を表示",
"show message timestamp": "メッセージのタイムスタンプを表示",
"proxy": "プロキシ",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/locales/ko/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"show message word count": "메시지 단어 수 표시",
"show message token count": "메시지 토큰 수 표시",
"show message token usage": "메시지 토큰 사용량 표시",
"hide initial message": "초기 대화 프롬프트 숨기기",
"show model name": "모델 이름 표시",
"show message timestamp": "메시지 타임스탬프 표시",
"proxy": "프록시",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"show message word count": "Показать количество слов в сообщении",
"show message token count": "Показать количество токенов в сообщении",
"show message token usage": "Показать использование токенов в сообщении",
"hide initial message": "Скрыть начальное сообщение",
"show model name": "Показать название модели",
"show message timestamp": "Показать временную метку сообщения",
"proxy": "Прокси",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/locales/zh-Hans/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"theme": "主题",
"show message word count": "显示消息的字数统计",
"show message token count": "显示消息的 token 数量",
"hide initial message": "隐藏初始对话提示",
"show message token usage": "显示消息的 token 消耗",
"show model name": "显示模型名称",
"show message timestamp": "显示消息的时间戳",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/i18n/locales/zh-Hant/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"show message word count": "顯示消息的字數",
"show message token count": "顯示消息的 token 數量",
"show message token usage": "顯示消息的 token 消耗",
"hide initial message": "隱藏初始對話提示",
"show model name": "顯示模型名稱",
"show message timestamp": "顯示消息的時間戳",
"proxy": "代理",
Expand Down
11 changes: 11 additions & 0 deletions src/renderer/pages/SettingDialog/DisplaySettingTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ export default function DisplaySettingTab(props: {
})
}
/>
<FormControlLabel
control={<Switch />}
label={t('hide initial message')}
checked={settingsEdit.hideInitialMessage}
onChange={(e, checked) =>
setSettingsEdit({
...settingsEdit,
hideInitialMessage: checked,
})
}
/>
</FormGroup>
</Box>
)
Expand Down
1 change: 1 addition & 0 deletions src/shared/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function settings(): Settings {
showTokenUsed: true,
showModelName: true,
showMessageTimestamp: false,
hideInitialMessage: false,
userAvatarKey: '',
theme: Theme.FollowSystem,
language: 'en',
Expand Down
1 change: 1 addition & 0 deletions src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export interface Settings extends ModelSettings {
showTokenUsed?: boolean
showModelName?: boolean
showMessageTimestamp?: boolean
hideInitialMessage?: boolean

theme: Theme
language: Language
Expand Down