Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
feat(interface): add toggle for colored user message bubble
Akarshan Biswase6e5ca8e0326
diff --git a/web-app/src/containers/MessageItem.tsx b/web-app/src/containers/MessageItem.tsxindex 29dd3361f..66add92bb 100644--- a/web-app/src/containers/MessageItem.tsx+++ b/web-app/src/containers/MessageItem.tsx@@ -21,6 +21,7 @@ import {import { CopyButton } from './CopyButton'import { formatDate } from '@/utils/formatDate'import { useModelProvider } from '@/hooks/useModelProvider'+import { useInterfaceSettings } from '@/hooks/useInterfaceSettings'import { useMessageErrors } from '@/stores/message-errors'import {IconRefresh,@@ -87,6 +88,7 @@ export const MessageItem = memo(onDelete,}: MessageItemProps) => {const selectedModel = useModelProvider((state) => state.selectedModel)+ const coloredUserBubble = useInterfaceSettings((s) => s.coloredUserBubble)const metadata = message.metadata as Record<string, unknown> | undefinedconst messageError = useMessageErrors((s) => s.errors[message.id])const createdAt = (metadata?.createdAt as Date) ?? new Date()@@ -244,7 +246,14 @@ export const MessageItem = memo(<div key={`${message.id}-${partIndex}`} className="w-full">{message.role === 'user' ? (<div className="flex justify-end w-full h-full text-start wrap-break-word whitespace-normal">- <div className="bg-primary relative text-primary-foreground p-2 rounded-md inline-block max-w-[80%]">+ <div+ className={cn(+ 'relative p-2 rounded-md inline-block max-w-[80%]',+ coloredUserBubble+ ? 'bg-primary text-primary-foreground'+ : 'bg-secondary text-foreground'+ )}+ >{/* Show attached files if any */}{attachedFiles.length > 0 && (<div className="flex flex-wrap gap-2 mb-3">diff --git a/web-app/src/hooks/useInterfaceSettings.ts b/web-app/src/hooks/useInterfaceSettings.tsindex 92fddf685..f32ef4ce0 100644--- a/web-app/src/hooks/useInterfaceSettings.ts+++ b/web-app/src/hooks/useInterfaceSettings.ts@@ -109,10 +109,12 @@ interface InterfaceSettingsState {accentColor: AccentColorValuenotificationPosition: NotificationPositionshowTokenSpeed: boolean+ coloredUserBubble: booleansetFontSize: (size: FontSize) => voidsetAccentColor: (color: AccentColorValue) => voidsetNotificationPosition: (position: NotificationPosition) => voidsetShowTokenSpeed: (show: boolean) => void+ setColoredUserBubble: (colored: boolean) => voidresetInterface: () => void}@@ -123,6 +125,7 @@ type InterfaceSettingsPersistedSlice = Omit<| 'setAccentColor'| 'setNotificationPosition'| 'setShowTokenSpeed'+ | 'setColoredUserBubble'>export const fontSizeOptions = [@@ -141,6 +144,7 @@ const createDefaultInterfaceValues = (): InterfaceSettingsPersistedSlice => {accentColor: DEFAULT_ACCENT_COLOR,notificationPosition: getDefaultNotificationPosition(),showTokenSpeed: true,+ coloredUserBubble: true,}}@@ -177,6 +181,7 @@ export const useInterfaceSettings = create<InterfaceSettingsState>()(accentColor: DEFAULT_ACCENT_COLOR,notificationPosition: getDefaultNotificationPosition(),showTokenSpeed: true,+ coloredUserBubble: true,})},@@ -204,6 +209,10 @@ export const useInterfaceSettings = create<InterfaceSettingsState>()(setShowTokenSpeed: (show) => {set({ showTokenSpeed: show })},++ setColoredUserBubble: (colored) => {+ set({ coloredUserBubble: colored })+ },}},{@@ -214,6 +223,7 @@ export const useInterfaceSettings = create<InterfaceSettingsState>()(accentColor: state.accentColor,notificationPosition: state.notificationPosition,showTokenSpeed: state.showTokenSpeed,+ coloredUserBubble: state.coloredUserBubble,}),// Apply settings when hydrating from storageonRehydrateStorage: () => (state) => {@@ -246,6 +256,10 @@ export const useInterfaceSettings = create<InterfaceSettingsState>()(if (typeof state.showTokenSpeed !== 'boolean') {state.showTokenSpeed = true}++ if (typeof state.coloredUserBubble !== 'boolean') {+ state.coloredUserBubble = true+ }}// Return the state to be used for hydrationdiff --git a/web-app/src/locales/en/settings.json b/web-app/src/locales/en/settings.jsonindex db3776b23..4fde2def6 100644--- a/web-app/src/locales/en/settings.json+++ b/web-app/src/locales/en/settings.json@@ -96,6 +96,8 @@"notificationPositionBottomLeft": "Bottom left","showTokenSpeed": "Show token speed","showTokenSpeedDesc": "Display tokens/sec and token count inline below assistant messages. When off, a compact icon shows the details on click.",+ "coloredUserBubble": "Colored user message bubble",+ "coloredUserBubbleDesc": "Use the accent color as the background of your messages. When off, they match assistant messages with plain text on a neutral background.","windowBackground": "Window Background","windowBackgroundDesc": "Set the app window's background color.","appMainView": "App Main View",diff --git a/web-app/src/routes/settings/interface.tsx b/web-app/src/routes/settings/interface.tsxindex 0330b2d8c..330abdc23 100644--- a/web-app/src/routes/settings/interface.tsx+++ b/web-app/src/routes/settings/interface.tsx@@ -20,8 +20,13 @@ export const Route = createFileRoute(route.settings.interface as any)({function InterfaceSettings() {const { t } = useTranslation()- const { resetInterface, showTokenSpeed, setShowTokenSpeed } =- useInterfaceSettings()+ const {+ resetInterface,+ showTokenSpeed,+ setShowTokenSpeed,+ coloredUserBubble,+ setColoredUserBubble,+ } = useInterfaceSettings()return (<div className="flex flex-col h-svh w-full">@@ -67,6 +72,16 @@ function InterfaceSettings() {/>}/>+ <CardItem+ title={t('settings:interface.coloredUserBubble')}+ description={t('settings:interface.coloredUserBubbleDesc')}+ actions={+ <Switch+ checked={coloredUserBubble}+ onCheckedChange={setColoredUserBubble}+ />+ }+ /><CardItemtitle={t('settings:interface.resetToDefault')}description={t('settings:interface.resetToDefaultDesc')}