2025-02-10 16:49:47 +11:00
import React , {
ChangeEventHandler ,
2026-09-12 20:28:41 -04:00
FocusEventHandler ,
2025-07-27 15:13:00 +03:00
FormEventHandler ,
2025-02-10 16:49:47 +11:00
KeyboardEventHandler ,
MouseEventHandler ,
2026-10-25 02:07:23 -04:00
ReactNode ,
2026-05-15 15:38:02 -04:00
useCallback ,
2025-07-27 15:13:00 +03:00
useEffect ,
2026-07-01 09:07:03 -04:00
useMemo ,
2026-05-15 15:38:02 -04:00
useRef ,
2025-02-10 16:49:47 +11:00
useState ,
} from 'react' ;
2025-07-27 15:13:00 +03:00
import dayjs from 'dayjs' ;
2025-02-10 16:49:47 +11:00
import {
as ,
Box ,
Button ,
Chip ,
2026-06-01 21:30:27 -04:00
color ,
2025-02-10 16:49:47 +11:00
config ,
2025-07-27 15:13:00 +03:00
Header ,
2025-02-10 16:49:47 +11:00
Icon ,
IconButton ,
Icons ,
Input ,
Menu ,
MenuItem ,
PopOut ,
RectCords ,
Scroll ,
2026-06-10 20:31:35 -04:00
Spinner ,
2025-02-10 16:49:47 +11:00
Switch ,
Text ,
toRem ,
2026-10-25 12:16:14 -04:00
RadioButton ,
2025-02-10 16:49:47 +11:00
} from 'folds' ;
import { isKeyHotkey } from 'is-hotkey' ;
2026-06-19 20:54:32 -04:00
import { HexColorPicker } from 'react-colorful' ;
2025-02-10 16:49:47 +11:00
import FocusTrap from 'focus-trap-react' ;
2026-07-01 09:07:03 -04:00
import {
draggable ,
dropTargetForElements ,
monitorForElements ,
} from '@atlaskit/pragmatic-drag-and-drop/element/adapter' ;
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine' ;
import { reorder } from '@atlaskit/pragmatic-drag-and-drop/reorder' ;
import {
attachClosestEdge ,
extractClosestEdge ,
Edge ,
} from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge' ;
import { useAtom } from 'jotai' ;
2026-09-25 15:50:22 -04:00
import { useClientConfig } from '../../../hooks/useClientConfig' ;
2026-06-19 20:54:32 -04:00
import { HexColorPickerPopOut } from '../../../components/HexColorPickerPopOut' ;
2026-06-19 21:01:57 -04:00
import { BgSwatch as BgSwatchStyle } from './BgSwatch.css' ;
2025-02-10 16:49:47 +11:00
import { Page , PageContent , PageHeader } from '../../../components/page' ;
import { SequenceCard } from '../../../components/sequence-card' ;
2026-06-16 01:04:23 -04:00
import {
DENOISE_MODELS ,
isMLDenoiseSupported ,
ML_DENOISE_REQUIREMENTS ,
} from '../../../utils/lotusDenoiseUtils' ;
2025-02-10 16:49:47 +11:00
import { useSetting } from '../../../state/hooks/settings' ;
2026-09-17 01:56:06 -04:00
import { useSettingsSyncActions } from '../../../hooks/useSettingsSync' ;
2026-10-25 01:08:28 -04:00
import { YourDataSection } from './YourData' ;
2026-05-21 20:49:33 -04:00
import {
2026-06-30 22:34:17 -04:00
CallAudioBitrate ,
2026-05-21 20:49:33 -04:00
ChatBackground ,
2026-07-01 09:07:03 -04:00
ComposerToolbarButtonKey ,
2026-06-10 13:20:29 -04:00
ComposerToolbarSettings ,
2026-05-21 20:49:33 -04:00
DateFormat ,
2026-06-16 01:40:37 -04:00
DenoiseModelId ,
2026-05-21 20:49:33 -04:00
MessageLayout ,
MessageSpacing ,
2026-06-15 20:29:59 -04:00
NoiseSuppressionMode ,
2026-07-01 09:07:03 -04:00
normalizeComposerToolbarOrder ,
2026-06-24 17:25:32 -04:00
RingtoneId ,
2026-06-30 22:34:17 -04:00
ScreenshareBitrate ,
ScreenshareFramerate ,
2026-06-15 01:14:56 -04:00
Settings ,
2026-05-21 20:49:33 -04:00
settingsAtom ,
} from '../../../state/settings' ;
2026-06-30 22:34:17 -04:00
import {
AUDIO_BITRATE_OPTIONS ,
SCREENSHARE_BITRATE_OPTIONS ,
SCREENSHARE_FRAMERATE_OPTIONS ,
} from '../../../utils/callQuality' ;
2026-06-15 20:29:59 -04:00
import { SeasonalPreview , SeasonTheme } from '../../../components/seasonal/SeasonalEffect' ;
2026-06-30 19:28:28 -04:00
import { SEASON_DATE_RANGES } from '../../../components/seasonal/seasonSchedule' ;
2025-02-10 16:49:47 +11:00
import { SettingTile } from '../../../components/setting-tile' ;
import { KeySymbol } from '../../../utils/key-symbol' ;
import { isMacOS } from '../../../utils/user-agent' ;
import {
DarkTheme ,
LightTheme ,
Theme ,
ThemeKind ,
useSystemThemeKind ,
2026-05-13 21:51:19 -04:00
useTheme ,
2025-02-10 16:49:47 +11:00
useThemeNames ,
useThemes ,
} from '../../../hooks/useTheme' ;
import { stopPropagation } from '../../../utils/keyboard' ;
2026-07-10 16:05:56 -04:00
import { pickerInputStyle } from '../../../utils/datetimeInput' ;
2026-05-13 21:51:19 -04:00
import { BG_OPTIONS , getChatBg } from '../../lotus/chatBackground' ;
2026-05-13 22:44:34 -04:00
import { resetBootSequence , runLotusBootSequence } from '../../../../lotus-boot' ;
2025-02-10 16:49:47 +11:00
import { useMessageLayoutItems } from '../../../hooks/useMessageLayout' ;
import { useMessageSpacingItems } from '../../../hooks/useMessageSpacing' ;
2026-07-18 16:08:40 -04:00
import {
TRANSLATE_TARGET_LANGUAGES ,
normalizeLang ,
isSupportedTargetLang ,
2026-10-18 00:19:48 -04:00
translationUnavailableText ,
2026-07-18 16:08:40 -04:00
} from '../../../utils/translation/langUtils' ;
import { chromeTranslationEngine } from '../../../utils/translation/chromeEngine' ;
2026-10-19 15:06:20 -04:00
import { SequenceCardStyle , SettingTileGroup } from '../styles.css' ;
import { ScreenSize , useScreenSize } from '../../../hooks/useScreenSize' ;
2026-09-23 20:52:16 -04:00
import { UpdateProgress , useTauriUpdater } from '../../../hooks/useTauriUpdater' ;
2026-09-30 19:00:10 -04:00
import {
describeUpdateError ,
isPackageManagedError ,
manualDownloadUrl ,
packageUpdateHelp ,
} from '../../../utils/updateErrors' ;
import { copyToClipboard } from '../../../utils/dom' ;
2026-07-02 13:31:09 -04:00
import { isTauri as isTauriEnv , invokeTauri , tauriInvoke } from '../../../hooks/useTauri' ;
2026-09-29 00:24:46 -04:00
import { useKeychainMirrorStatus } from '../../../state/keychainMirror' ;
2026-09-18 23:15:00 -04:00
import { isSafeGlobalToggleKey } from '../../../hooks/useCallHotkeys' ;
2026-07-01 09:07:03 -04:00
import { customWindowChromeAtom } from '../../../state/customWindowChrome' ;
2026-06-16 01:40:37 -04:00
import { useDateFormatItems } from '../../../hooks/useDateFormat' ;
2026-07-02 21:40:07 -04:00
import { useReducedMotion } from '../../../hooks/useReducedMotion' ;
2026-06-16 01:40:37 -04:00
import { playCallJoinSound } from '../../../utils/callSounds' ;
2026-06-24 17:25:32 -04:00
import { previewRingtone , RINGTONE_OPTIONS } from '../../../utils/ringtones' ;
2026-06-16 17:53:57 -04:00
import { DenoiseTester } from './DenoiseTester' ;
2026-06-28 22:43:18 -04:00
import { SettingsSelect } from '../../../components/settings-select/SettingsSelect' ;
2026-09-12 14:48:34 -04:00
import { isBindableCallKey } from '../../../utils/callKeybind' ;
2026-09-20 14:53:42 -04:00
import { StorageUsage } from './StorageUsage' ;
2026-09-20 15:15:04 -04:00
import { hapticsSupported } from '../../../utils/haptics' ;
2025-02-10 16:49:47 +11:00
2026-07-01 09:07:03 -04:00
/**
* P5-47 — opt-in TDS window chrome toggle (desktop only). Renders nothing in the
* browser. Backed by the standalone `customWindowChromeAtom`; `useTauriWindowChrome`
* (mounted in App.tsx) applies `set_decorations` when this flips.
*/
function DesktopChromeSetting() {
const [ customChrome , setCustomChrome ] = useAtom ( customWindowChromeAtom );
if ( ! isTauriEnv ()) return null ;
2026-07-02 16:16:52 -04:00
// Persist the flag, then reload so the window layout is rebuilt from scratch.
// Toggling live reflows the whole app while the room timeline is mounted, which
// resizes its virtualized scroll container and triggers runaway back-pagination
// (the "screen expands + auto-scrolls into the past" bug). A reload applies the
// chrome cleanly against a fresh, correct layout.
const handleToggle = ( value : boolean ) => {
setCustomChrome ( value );
window . location . reload ();
};
2026-07-01 09:07:03 -04:00
return (
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Custom window chrome (beta)"
2026-07-02 16:16:52 -04:00
description = "Replace the system title bar with a Lotus-styled one. Desktop only — reloads to apply."
after = {< Switch variant = "Primary" value = { customChrome } onChange = { handleToggle } />}
2026-07-01 09:07:03 -04:00
/>
</ SequenceCard >
);
}
2026-07-02 13:31:09 -04:00
/**
* P6-1 — "Launch on login" toggle (desktop only). Renders nothing in the
* browser. Reads the current state from the `autostart` plugin on mount and
* enables/disables it via the plugin commands when flipped. Not backed by an
* atom — the OS registration is the source of truth, mirrored into local state.
*/
function AutostartSetting() {
const [ enabled , setEnabled ] = useState ( false );
2026-09-23 22:46:10 -04:00
// [cinny-desktop #3] null until the native side answers (older builds don't
// have the command, so the switch just stays hidden there).
const [ startMinimized , setStartMinimized ] = useState < boolean | null >( null );
2026-09-24 12:51:18 -04:00
// [cinny-desktop #5] "ask" | "tray" | "quit"; null on builds without it.
const [ closeBehavior , setCloseBehavior ] = useState < string | null >( null );
2026-07-02 13:31:09 -04:00
useEffect (() => {
tauriInvoke () ? .( 'plugin:autostart|is_enabled' )
. then (( value ) => setEnabled ( value === true ))
. catch (() => undefined );
2026-09-24 12:51:18 -04:00
tauriInvoke () ? .( 'get_close_behavior' )
. then (( value ) => {
if ( typeof value === 'string' ) setCloseBehavior ( value );
})
. catch (() => undefined );
2026-09-23 22:46:10 -04:00
tauriInvoke () ? .( 'get_start_minimized' )
. then (( value ) => {
if ( typeof value === 'boolean' ) setStartMinimized ( value );
})
. catch (() => undefined );
2026-07-02 13:31:09 -04:00
}, []);
const handleChange = ( value : boolean ) => {
invokeTauri ( value ? 'plugin:autostart|enable' : 'plugin:autostart|disable' );
setEnabled ( value );
};
2026-09-24 12:51:18 -04:00
const handleCloseBehavior = ( value : string ) => {
invokeTauri ( 'set_close_behavior' , { value });
setCloseBehavior ( value );
};
2026-09-23 22:46:10 -04:00
const handleStartMinimized = ( value : boolean ) => {
invokeTauri ( 'set_start_minimized' , { value });
setStartMinimized ( value );
};
2026-07-02 13:31:09 -04:00
if ( ! isTauriEnv ()) return null ;
return (
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Launch on login"
description = "Start Lotus Chat automatically when you sign in to your computer."
after = {< Switch variant = "Primary" value = { enabled } onChange = { handleChange } />}
/>
2026-09-24 12:51:18 -04:00
{ closeBehavior !== null && (
< SettingTile
title = "When I close the window"
description = "Keep Lotus Chat running in the system tray (messages, notifications and calls keep arriving), or quit it. During a call, closing always keeps it running."
after = {
< SettingsSelect
value = { closeBehavior }
onChange = { handleCloseBehavior }
aria-label = "When I close the window"
options = {[
{ value : 'tray' , label : 'Keep running in the tray' },
{ value : 'quit' , label : 'Quit Lotus Chat' },
{ value : 'ask' , label : 'Ask me' },
]}
/>
}
/>
)}
2026-09-23 22:46:10 -04:00
{ enabled && startMinimized !== null && (
< SettingTile
title = "Start minimized"
description = "When it starts at login, keep Lotus Chat in the system tray instead of opening the window. Notifications still arrive; click the tray icon to open it."
after = {
< Switch variant = "Primary" value = { startMinimized } onChange = { handleStartMinimized } />
}
/>
)}
2026-07-02 13:31:09 -04:00
</ SequenceCard >
);
}
2026-09-29 00:24:46 -04:00
// [Gitea #105] Desktop: whether the login is also kept in the OS keychain.
function KeychainMirrorSetting() {
const status = useKeychainMirrorStatus ();
if ( ! isTauriEnv () || status . state === 'idle' || status . state === 'cleared' ) return null ;
let description : string ;
if ( status . state === 'ok' ) {
description =
"A copy of your login is kept in the system keychain (Windows Credential Manager). A later update will keep it only there, out of the app's data folder." ;
} else if ( status . state === 'unsupported' ) {
description =
"Not available on this system yet. Your login is saved in the app's data folder, as before." ;
} else {
description = `Couldn't save a copy to the system keychain ( ${ status . error } ). You stay logged in; your login is saved in the app's data folder, as before.` ;
}
return (
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
2026-10-25 01:37:37 -04:00
< SettingTile title = "Keep your sign-in in the system keychain" description = { description } />
2026-09-29 00:24:46 -04:00
</ SequenceCard >
);
}
2025-02-10 16:49:47 +11:00
type ThemeSelectorProps = {
themeNames : Record < string , string >;
themes : Theme [];
selected : Theme ;
onSelect : ( theme : Theme ) => void ;
};
const ThemeSelector = as < 'div' , ThemeSelectorProps > (
({ themeNames , themes , selected , onSelect , ... props }, ref ) => (
< Menu { ...props } ref = { ref }>
2025-08-04 20:29:12 +05:30
< Box direction = "Column" gap = "100" style = {{ padding : config.space.S100 }}>
2025-02-10 16:49:47 +11:00
{ themes . map (( theme ) => (
< MenuItem
key = { theme . id }
size = "300"
variant = { theme . id === selected . id ? 'Primary' : 'Surface' }
radii = "300"
onClick = {() => onSelect ( theme )}
>
< Text size = "T300" >{ themeNames [ theme . id ] ?? theme . id }</ Text >
</ MenuItem >
))}
</ Box >
</ Menu >
2026-05-21 23:30:50 -04:00
),
2025-02-10 16:49:47 +11:00
);
2026-10-25 01:37:37 -04:00
function SelectTheme ({ disabled , kind } : { disabled? : boolean ; kind? : ThemeKind }) {
const allThemes = useThemes ();
const themes = kind ? allThemes . filter (( theme ) => theme . kind === kind ) : allThemes ;
2025-02-10 16:49:47 +11:00
const themeNames = useThemeNames ();
const [ themeId , setThemeId ] = useSetting ( settingsAtom , 'themeId' );
2026-10-25 01:37:37 -04:00
const [, setLightThemeId ] = useSetting ( settingsAtom , 'lightThemeId' );
const [, setDarkThemeId ] = useSetting ( settingsAtom , 'darkThemeId' );
2025-02-10 16:49:47 +11:00
const [ menuCords , setMenuCords ] = useState < RectCords >();
2026-10-25 01:37:37 -04:00
const selectedTheme =
themes . find (( theme ) => theme . id === themeId ) ??
themes [ 0 ] ??
( kind === ThemeKind . Dark ? DarkTheme : LightTheme );
2025-02-10 16:49:47 +11:00
const handleThemeMenu : MouseEventHandler < HTMLButtonElement > = ( evt ) => {
setMenuCords ( evt . currentTarget . getBoundingClientRect ());
};
const handleThemeSelect = ( theme : Theme ) => {
setThemeId ( theme . id );
2026-10-25 01:37:37 -04:00
// [Gitea #455] Also remember it as this kind's variant, so switching to
// System later keeps the user's pick.
if ( theme . kind === ThemeKind . Light ) setLightThemeId ( theme . id );
else setDarkThemeId ( theme . id );
2025-02-10 16:49:47 +11:00
setMenuCords ( undefined );
};
return (
<>
< Button
size = "300"
2026-06-19 00:15:35 -04:00
variant = "Secondary"
2025-02-10 16:49:47 +11:00
outlined
fill = "Soft"
radii = "300"
after = {< Icon size = "300" src = { Icons . ChevronBottom } />}
onClick = { disabled ? undefined : handleThemeMenu }
aria-disabled = { disabled }
>
< Text size = "T300" >{ themeNames [ selectedTheme . id ] ?? selectedTheme . id }</ Text >
</ Button >
< PopOut
anchor = { menuCords }
offset = { 5 }
position = "Bottom"
align = "End"
content = {
< FocusTrap
focusTrapOptions = {{
initialFocus : false ,
onDeactivate : () => setMenuCords ( undefined ),
clickOutsideDeactivates : true ,
isKeyForward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowDown' || evt . key === 'ArrowRight' ,
isKeyBackward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowUp' || evt . key === 'ArrowLeft' ,
escapeDeactivates : stopPropagation ,
}}
>
< ThemeSelector
themeNames = { themeNames }
themes = { themes }
selected = { selectedTheme }
onSelect = { handleThemeSelect }
/>
</ FocusTrap >
}
/>
2026-06-14 12:20:47 -04:00
</>
);
}
2025-02-10 16:49:47 +11:00
function SystemThemePreferences() {
const themeKind = useSystemThemeKind ();
const themeNames = useThemeNames ();
const themes = useThemes ();
const [ lightThemeId , setLightThemeId ] = useSetting ( settingsAtom , 'lightThemeId' );
const [ darkThemeId , setDarkThemeId ] = useSetting ( settingsAtom , 'darkThemeId' );
const lightThemes = themes . filter (( theme ) => theme . kind === ThemeKind . Light );
const darkThemes = themes . filter (( theme ) => theme . kind === ThemeKind . Dark );
const selectedLightTheme = lightThemes . find (( theme ) => theme . id === lightThemeId ) ?? LightTheme ;
const selectedDarkTheme = darkThemes . find (( theme ) => theme . id === darkThemeId ) ?? DarkTheme ;
const [ ltCords , setLTCords ] = useState < RectCords >();
const [ dtCords , setDTCords ] = useState < RectCords >();
const handleLightThemeMenu : MouseEventHandler < HTMLButtonElement > = ( evt ) => {
setLTCords ( evt . currentTarget . getBoundingClientRect ());
};
const handleDarkThemeMenu : MouseEventHandler < HTMLButtonElement > = ( evt ) => {
setDTCords ( evt . currentTarget . getBoundingClientRect ());
};
const handleLightThemeSelect = ( theme : Theme ) => {
setLightThemeId ( theme . id );
setLTCords ( undefined );
};
const handleDarkThemeSelect = ( theme : Theme ) => {
setDarkThemeId ( theme . id );
setDTCords ( undefined );
};
return (
< Box wrap = "Wrap" gap = "400" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Light theme:"
2025-02-10 16:49:47 +11:00
after = {
< Chip
variant = { themeKind === ThemeKind . Light ? 'Primary' : 'Secondary' }
outlined = { themeKind === ThemeKind . Light }
radii = "Pill"
after = {< Icon size = "200" src = { Icons . ChevronBottom } />}
onClick = { handleLightThemeMenu }
>
< Text size = "B300" >{ themeNames [ selectedLightTheme . id ] ?? selectedLightTheme . id }</ Text >
</ Chip >
}
/>
< PopOut
anchor = { ltCords }
offset = { 5 }
position = "Bottom"
align = "End"
content = {
< FocusTrap
focusTrapOptions = {{
initialFocus : false ,
onDeactivate : () => setLTCords ( undefined ),
clickOutsideDeactivates : true ,
isKeyForward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowDown' || evt . key === 'ArrowRight' ,
isKeyBackward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowUp' || evt . key === 'ArrowLeft' ,
escapeDeactivates : stopPropagation ,
}}
>
< ThemeSelector
themeNames = { themeNames }
themes = { lightThemes }
selected = { selectedLightTheme }
onSelect = { handleLightThemeSelect }
/>
</ FocusTrap >
}
/>
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Dark theme:"
2025-02-10 16:49:47 +11:00
after = {
< Chip
variant = { themeKind === ThemeKind . Dark ? 'Primary' : 'Secondary' }
outlined = { themeKind === ThemeKind . Dark }
radii = "Pill"
after = {< Icon size = "200" src = { Icons . ChevronBottom } />}
onClick = { handleDarkThemeMenu }
>
< Text size = "B300" >{ themeNames [ selectedDarkTheme . id ] ?? selectedDarkTheme . id }</ Text >
</ Chip >
}
/>
< PopOut
anchor = { dtCords }
offset = { 5 }
position = "Bottom"
align = "End"
content = {
< FocusTrap
focusTrapOptions = {{
initialFocus : false ,
onDeactivate : () => setDTCords ( undefined ),
clickOutsideDeactivates : true ,
isKeyForward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowDown' || evt . key === 'ArrowRight' ,
isKeyBackward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowUp' || evt . key === 'ArrowLeft' ,
escapeDeactivates : stopPropagation ,
}}
>
< ThemeSelector
themeNames = { themeNames }
themes = { darkThemes }
selected = { selectedDarkTheme }
onSelect = { handleDarkThemeSelect }
/>
</ FocusTrap >
}
/>
</ Box >
);
}
function PageZoomInput() {
const [ pageZoom , setPageZoom ] = useSetting ( settingsAtom , 'pageZoom' );
const [ currentZoom , setCurrentZoom ] = useState ( ` ${ pageZoom } ` );
const handleZoomChange : ChangeEventHandler < HTMLInputElement > = ( evt ) => {
setCurrentZoom ( evt . target . value );
};
2026-09-12 20:28:41 -04:00
// Shared by Enter and blur so a typed-but-unconfirmed value is never
// silently dropped when the input loses focus.
const commitZoom = ( value : string ) => {
const newZoom = parseInt ( value , 10 );
if ( Number . isNaN ( newZoom )) return ;
const safeZoom = Math . max ( Math . min ( newZoom , 150 ), 75 );
setPageZoom ( safeZoom );
setCurrentZoom ( safeZoom . toString ());
};
2025-02-10 16:49:47 +11:00
const handleZoomEnter : KeyboardEventHandler < HTMLInputElement > = ( evt ) => {
if ( isKeyHotkey ( 'escape' , evt )) {
evt . stopPropagation ();
setCurrentZoom ( pageZoom . toString ());
}
if (
isKeyHotkey ( 'enter' , evt ) &&
'value' in evt . target &&
typeof evt . target . value === 'string'
) {
2026-09-12 20:28:41 -04:00
commitZoom ( evt . target . value );
2025-02-10 16:49:47 +11:00
}
};
2026-09-12 20:28:41 -04:00
const handleZoomBlur : FocusEventHandler < HTMLInputElement > = ( evt ) => {
commitZoom ( evt . target . value );
};
2025-02-10 16:49:47 +11:00
return (
< Input
style = {{ width : toRem ( 100 ) }}
2026-05-21 12:03:26 -04:00
aria-label = "Page zoom percentage"
2025-02-10 16:49:47 +11:00
variant = { pageZoom === parseInt ( currentZoom , 10 ) ? 'Secondary' : 'Success' }
size = "300"
radii = "300"
type = "number"
min = "75"
max = "150"
value = { currentZoom }
onChange = { handleZoomChange }
onKeyDown = { handleZoomEnter }
2026-09-12 20:28:41 -04:00
onBlur = { handleZoomBlur }
2025-02-10 16:49:47 +11:00
after = {< Text size = "T300" > % </ Text >}
outlined
/>
);
}
2026-10-25 02:07:23 -04:00
export function Appearance() {
2025-02-10 16:49:47 +11:00
const [ systemTheme , setSystemTheme ] = useSetting ( settingsAtom , 'useSystemTheme' );
2026-10-25 01:37:37 -04:00
const allThemes = useThemes ();
const [ themeId , setThemeId ] = useSetting ( settingsAtom , 'themeId' );
const [ lightThemeId ] = useSetting ( settingsAtom , 'lightThemeId' );
const [ darkThemeId ] = useSetting ( settingsAtom , 'darkThemeId' );
const currentKind = allThemes . find (( t ) => t . id === themeId ) ? . kind ?? ThemeKind . Light ;
let themeMode : 'system' | 'light' | 'dark' = 'system' ;
if ( ! systemTheme ) themeMode = currentKind === ThemeKind . Dark ? 'dark' : 'light' ;
const chooseThemeMode = ( mode : 'system' | 'light' | 'dark' ) => {
if ( mode === 'system' ) {
setSystemTheme ( true );
return ;
}
setSystemTheme ( false );
// Use the variant already chosen for that kind (or the default one).
const kind = mode === 'dark' ? ThemeKind.Dark : ThemeKind.Light ;
if ( allThemes . find (( t ) => t . id === themeId ) ? . kind === kind ) return ;
const preferred = mode === 'dark' ? darkThemeId : lightThemeId ;
const fallback = mode === 'dark' ? DarkTheme.id : LightTheme.id ;
setThemeId ( allThemes . find (( t ) => t . id === preferred && t . kind === kind ) ? . id ?? fallback );
};
2025-08-25 18:49:14 +05:30
const [ monochromeMode , setMonochromeMode ] = useSetting ( settingsAtom , 'monochromeMode' );
2025-02-10 16:49:47 +11:00
const [ twitterEmoji , setTwitterEmoji ] = useSetting ( settingsAtom , 'twitterEmoji' );
2026-05-21 20:49:33 -04:00
const [ perMessageProfiles , setPerMessageProfiles ] = useSetting (
settingsAtom ,
2026-05-21 23:30:50 -04:00
'perMessageProfiles' ,
2026-05-21 20:49:33 -04:00
);
2026-05-13 22:22:06 -04:00
const [ lotusTerminal , setLotusTerminal ] = useSetting ( settingsAtom , 'lotusTerminal' );
2026-06-02 15:36:45 -04:00
const [ nightLightEnabled , setNightLightEnabled ] = useSetting ( settingsAtom , 'nightLightEnabled' );
const [ nightLightOpacity , setNightLightOpacity ] = useSetting ( settingsAtom , 'nightLightOpacity' );
2026-07-10 16:05:56 -04:00
const [ nightLightSchedule , setNightLightSchedule ] = useSetting (
settingsAtom ,
'nightLightSchedule' ,
);
const [ nightLightStart , setNightLightStart ] = useSetting ( settingsAtom , 'nightLightStart' );
const [ nightLightEnd , setNightLightEnd ] = useSetting ( settingsAtom , 'nightLightEnd' );
2026-06-04 22:02:18 -04:00
const [ glassmorphismSidebar , setGlassmorphismSidebar ] = useSetting (
settingsAtom ,
'glassmorphismSidebar' ,
);
2026-06-05 11:46:16 -04:00
const [ pauseAnimations , setPauseAnimations ] = useSetting ( settingsAtom , 'pauseAnimations' );
2026-06-10 15:39:35 -04:00
const [ mentionHighlightColor , setMentionHighlightColor ] = useSetting (
settingsAtom ,
'mentionHighlightColor' ,
);
2026-06-28 14:22:08 -04:00
const [ customAccentColor , setCustomAccentColor ] = useSetting ( settingsAtom , 'customAccentColor' );
2026-06-10 15:39:35 -04:00
const [ fontFamily , setFontFamily ] = useSetting ( settingsAtom , 'fontFamily' );
2026-06-14 00:33:04 -04:00
const [ seasonalThemeOverride , setSeasonalThemeOverride ] = useSetting (
settingsAtom ,
'seasonalThemeOverride' ,
);
2026-10-25 02:07:23 -04:00
const [ chatBackground , setChatBackground ] = useSetting ( settingsAtom , 'chatBackground' );
2025-02-10 16:49:47 +11:00
return (
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Appearance </ Text >
< SequenceCard
className = { SequenceCardStyle }
variant = "SurfaceVariant"
direction = "Column"
gap = "400"
>
2026-10-25 01:37:37 -04:00
{ /* [Gitea #455] One control instead of a System switch plus a Theme
dropdown that was greyed out whenever the switch was on. */ }
2025-02-10 16:49:47 +11:00
< SettingTile
title = "Theme"
2026-10-25 01:37:37 -04:00
description = {
themeMode === 'system'
? "Follows your device's light or dark setting."
: 'Always use this theme, whatever your device is set to.'
}
after = {
< Box gap = "100" role = "radiogroup" aria-label = "Theme" shrink = "No" wrap = "Wrap" >
{(
[
[ 'system' , 'System' ],
[ 'light' , 'Light' ],
[ 'dark' , 'Dark' ],
] as const
). map (([ mode , label ]) => (
< Chip
key = { mode }
role = "radio"
aria-checked = { themeMode === mode }
variant = { themeMode === mode ? 'Primary' : 'Secondary' }
outlined = { themeMode === mode }
radii = "Pill"
onClick = {() => chooseThemeMode ( mode )}
>
< Text size = "B300" >{ label }</ Text >
</ Chip >
))}
</ Box >
}
2025-02-10 16:49:47 +11:00
/>
2026-10-25 01:37:37 -04:00
{ themeMode === 'system' && < SystemThemePreferences />}
{ themeMode !== 'system' && (
< SettingTile
title = { themeMode === 'light' ? 'Light theme:' : 'Dark theme:' }
after = {< SelectTheme kind = { themeMode === 'light' ? ThemeKind.Light : ThemeKind.Dark } />}
/>
)}
2025-02-10 16:49:47 +11:00
</ SequenceCard >
2025-08-25 18:49:14 +05:30
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Monochrome mode"
2025-08-25 18:49:14 +05:30
after = {< Switch variant = "Primary" value = { monochromeMode } onChange = { setMonochromeMode } />}
/>
</ SequenceCard >
2025-02-10 16:49:47 +11:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Emoji style: Twemoji"
2025-02-10 16:49:47 +11:00
after = {< Switch variant = "Primary" value = { twitterEmoji } onChange = { setTwitterEmoji } />}
/>
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
2026-10-25 01:37:37 -04:00
< SettingTile title = "Page zoom" after = {< PageZoomInput />} />
2025-02-10 16:49:47 +11:00
</ SequenceCard >
2026-05-13 21:17:59 -04:00
2026-05-21 20:49:33 -04:00
< SequenceCard
className = { SequenceCardStyle }
variant = "SurfaceVariant"
direction = "Column"
gap = "200"
>
2026-10-25 02:07:23 -04:00
< CollapsiblePicker
2026-10-25 01:37:37 -04:00
title = "Chat background"
2026-05-13 21:17:59 -04:00
description = "Pattern applied behind the message timeline."
2026-10-25 02:07:23 -04:00
current = { BG_OPTIONS . find (( o ) => o . value === chatBackground ) ? . label ?? 'None' }
>
2026-05-13 21:51:19 -04:00
< ChatBgGrid />
2026-10-25 02:07:23 -04:00
</ CollapsiblePicker >
2026-05-13 21:17:59 -04:00
</ SequenceCard >
2026-06-05 11:46:16 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Pause background animations"
2026-06-05 11:46:16 -04:00
description = "Stop background animation to reduce motion or improve performance."
after = {< Switch variant = "Primary" value = { pauseAnimations } onChange = { setPauseAnimations } />}
/>
</ SequenceCard >
2026-06-15 01:14:56 -04:00
< SequenceCard
className = { SequenceCardStyle }
variant = "SurfaceVariant"
direction = "Column"
gap = "200"
>
2026-10-25 02:07:23 -04:00
< CollapsiblePicker
2026-10-25 01:37:37 -04:00
title = "Seasonal theme"
2026-10-25 02:07:23 -04:00
description = "Decorative overlays for holidays and events. Auto follows the calendar."
current = {
SEASONAL_OPTIONS . find (( o ) => o . value === ( seasonalThemeOverride ?? 'auto' )) ? . label ??
'Auto'
}
>
2026-06-15 01:14:56 -04:00
< SeasonalBgGrid
value = { seasonalThemeOverride ?? 'auto' }
2026-06-18 10:37:44 -04:00
onChange = {( v ) => {
setSeasonalThemeOverride ( v );
2026-07-24 17:34:51 -04:00
// Any active seasonal mode (incl. "auto") is mutually exclusive
// with a chat background — else picking it is a silent no-op, since
// SeasonalEffect suppresses the overlay while a background is set.
// Only "off" leaves the background alone.
if ( v !== 'off' ) setChatBackground ( 'none' );
2026-06-18 10:37:44 -04:00
}}
2026-06-15 01:14:56 -04:00
/>
2026-10-25 02:07:23 -04:00
</ CollapsiblePicker >
2026-06-14 00:33:04 -04:00
</ SequenceCard >
2026-05-13 21:17:59 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Show name and avatar on every message"
2026-05-13 21:17:59 -04:00
description = "Display avatar and name on each message instead of grouping consecutive messages."
2026-05-21 20:49:33 -04:00
after = {
< Switch variant = "Primary" value = { perMessageProfiles } onChange = { setPerMessageProfiles } />
}
2026-05-13 21:17:59 -04:00
/>
</ SequenceCard >
2026-06-02 15:36:45 -04:00
< SequenceCard
className = { SequenceCardStyle }
variant = "SurfaceVariant"
direction = "Column"
gap = "200"
>
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Night light"
2026-06-02 15:36:45 -04:00
description = "Reduce blue light with a warm orange tint overlay."
after = {
< Switch variant = "Primary" value = { nightLightEnabled } onChange = { setNightLightEnabled } />
}
/>
{ nightLightEnabled && (
< Box
direction = "Column"
2026-07-10 16:05:56 -04:00
gap = "300"
2026-06-02 15:36:45 -04:00
style = {{ padding : `0 ${ config . space . S400 } ${ config . space . S300 } ` }}
>
2026-07-10 16:05:56 -04:00
< Box direction = "Column" gap = "100" >
< Text size = "T200" priority = "300" >
Intensity : { nightLightOpacity } %
</ Text >
< input
aria-label = "Night light intensity"
type = "range"
min = { 5 }
max = { 80 }
value = { nightLightOpacity }
onChange = {( e : React.ChangeEvent < HTMLInputElement >) =>
setNightLightOpacity ( parseInt ( e . target . value , 10 ))
}
style = {{ width : '100%' , accentColor : color.Primary.Main }}
/>
</ Box >
< Box alignItems = "Center" justifyContent = "SpaceBetween" gap = "200" >
< Box direction = "Column" >
< Text size = "T300" > Schedule </ Text >
< Text size = "T200" priority = "300" >
Only tint during the hours below
</ Text >
</ Box >
< Switch
variant = "Primary"
value = { nightLightSchedule }
onChange = { setNightLightSchedule }
/>
</ Box >
{ nightLightSchedule && (
< Box gap = "200" >
< Box direction = "Column" gap = "100" style = {{ flex : 1 }}>
< Text as = "label" htmlFor = "night-light-start" size = "T200" priority = "400" >
From
</ Text >
< input
id = "night-light-start"
type = "time"
value = { nightLightStart }
onChange = {( e ) => setNightLightStart ( e . target . value )}
style = { pickerInputStyle ( color , config )}
/>
</ Box >
< Box direction = "Column" gap = "100" style = {{ flex : 1 }}>
< Text as = "label" htmlFor = "night-light-end" size = "T200" priority = "400" >
To
</ Text >
< input
id = "night-light-end"
type = "time"
value = { nightLightEnd }
onChange = {( e ) => setNightLightEnd ( e . target . value )}
style = { pickerInputStyle ( color , config )}
/>
</ Box >
</ Box >
)}
2026-07-10 16:09:33 -04:00
{ nightLightSchedule && nightLightStart === nightLightEnd && (
< Text size = "T200" style = {{ color : color.Critical.Main }}>
Start and end times are the same , so the tint never turns on . Set different times .
</ Text >
)}
2026-06-02 15:36:45 -04:00
</ Box >
)}
</ SequenceCard >
2026-06-04 22:02:18 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Glass sidebar"
2026-06-04 22:02:18 -04:00
description = "Semi-transparent sidebar with frosted glass effect. Works best with custom chat backgrounds."
after = {
< Switch
variant = "Primary"
value = { glassmorphismSidebar }
onChange = { setGlassmorphismSidebar }
/>
}
/>
</ SequenceCard >
2026-05-13 22:22:06 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Lotus Terminal mode"
description = "A retro terminal look: orange and cyan on a dot grid, CRT scanlines and a boot animation (press Esc to skip)."
2026-05-13 22:44:34 -04:00
after = {
2026-05-15 15:38:02 -04:00
< Box direction = "Row" gap = "200" alignItems = "Center" >
2026-05-13 22:44:34 -04:00
{ lotusTerminal && (
< button
type = "button"
2026-05-21 20:49:33 -04:00
onClick = {() => {
resetBootSequence ();
runLotusBootSequence ( true );
}}
2026-05-13 22:44:34 -04:00
title = "Replay boot sequence"
style = {{
background : 'transparent' ,
2026-06-01 21:30:27 -04:00
border : '1px solid var(--accent-orange-border)' ,
color : 'var(--accent-orange)' ,
2026-05-13 22:44:34 -04:00
fontSize : '0.65rem' ,
padding : '0.2rem 0.6rem' ,
cursor : 'pointer' ,
fontFamily : 'inherit' ,
letterSpacing : '0.1em' ,
textTransform : 'uppercase' ,
whiteSpace : 'nowrap' ,
}}
>
▶ Boot
</ button >
)}
< Switch variant = "Primary" value = { lotusTerminal } onChange = { setLotusTerminal } />
</ Box >
}
2026-05-13 22:22:06 -04:00
/>
</ SequenceCard >
2026-06-10 15:39:35 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Interface font"
2026-06-10 15:39:35 -04:00
description = "Font used throughout the interface."
after = {
2026-06-14 12:20:47 -04:00
< SettingsSelect
2026-06-10 15:39:35 -04:00
value = { fontFamily ?? 'inter' }
2026-06-14 12:20:47 -04:00
onChange = {( v ) =>
setFontFamily ( v as 'system' | 'inter' | 'jetbrains-mono' | 'fira-code' )
2026-06-10 15:39:35 -04:00
}
2026-06-14 12:20:47 -04:00
options = {[
{ value : 'system' , label : 'System Default' },
{ value : 'inter' , label : 'Inter (default)' },
{ value : 'jetbrains-mono' , label : 'JetBrains Mono' },
{ value : 'fira-code' , label : 'Fira Code' },
]}
/>
2026-06-10 15:39:35 -04:00
}
/>
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "@mention highlight colour"
2026-06-10 15:39:35 -04:00
description = "Color used to highlight messages that mention you. Leave empty to use the theme default."
after = {
2026-06-19 20:54:32 -04:00
< HexColorPickerPopOut
picker = {
< HexColorPicker
color = { mentionHighlightColor || '#4caf50' }
onChange = { setMentionHighlightColor }
/>
}
onRemove = { mentionHighlightColor ? () => setMentionHighlightColor ( '' ) : undefined }
>
{( openPicker , opened ) => (
2026-06-19 00:15:35 -04:00
< Button
2026-06-10 15:39:35 -04:00
type = "button"
2026-06-19 20:54:32 -04:00
aria-pressed = { opened }
onClick = { openPicker }
2026-06-19 00:15:35 -04:00
size = "300"
variant = "Secondary"
fill = "Soft"
radii = "300"
2026-06-19 20:54:32 -04:00
before = {
< span
style = {{
width : toRem ( 16 ),
height : toRem ( 16 ),
borderRadius : config.radii.R300 ,
background : mentionHighlightColor || color . Primary . Main ,
border : ` ${ config . borderWidth . B300 } solid ${ color . SurfaceVariant . ContainerLine } ` ,
display : 'inline-block' ,
flexShrink : 0 ,
}}
/>
}
2026-06-10 15:39:35 -04:00
>
2026-06-19 20:54:32 -04:00
< Text size = "B300" >{ mentionHighlightColor ? 'Change' : 'Pick' }</ Text >
2026-06-19 00:15:35 -04:00
</ Button >
2026-06-10 15:39:35 -04:00
)}
2026-06-19 20:54:32 -04:00
</ HexColorPickerPopOut >
2026-06-10 15:39:35 -04:00
}
/>
</ SequenceCard >
2026-06-28 14:22:08 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Custom accent colour"
2026-06-28 14:22:08 -04:00
description = {
lotusTerminal
? 'Only applies to non-TDS themes. Disable Lotus Terminal Mode to use a custom accent.'
: 'Recolors the app accent (buttons, active states, links, selected states). Leave empty to use the theme default.'
}
after = {
< HexColorPickerPopOut
picker = {
< HexColorPicker
color = { customAccentColor || color . Primary . Main }
onChange = { setCustomAccentColor }
/>
}
onRemove = { customAccentColor ? () => setCustomAccentColor ( '' ) : undefined }
>
{( openPicker , opened ) => (
< Button
type = "button"
aria-pressed = { opened }
onClick = { openPicker }
disabled = { lotusTerminal }
size = "300"
variant = "Secondary"
fill = "Soft"
radii = "300"
before = {
< span
style = {{
width : toRem ( 16 ),
height : toRem ( 16 ),
borderRadius : config.radii.R300 ,
background : customAccentColor || color . Primary . Main ,
border : ` ${ config . borderWidth . B300 } solid ${ color . SurfaceVariant . ContainerLine } ` ,
display : 'inline-block' ,
flexShrink : 0 ,
}}
/>
}
>
< Text size = "B300" >{ customAccentColor ? 'Change' : 'Pick' }</ Text >
</ Button >
)}
</ HexColorPickerPopOut >
}
/>
</ SequenceCard >
2025-02-10 16:49:47 +11:00
</ Box >
);
}
2025-07-27 15:13:00 +03:00
type DateHintProps = {
hasChanges : boolean ;
handleReset : () => void ;
};
function DateHint ({ hasChanges , handleReset } : DateHintProps ) {
const [ anchor , setAnchor ] = useState < RectCords >();
const categoryPadding = { padding : config.space.S200 , paddingTop : 0 };
const handleOpenMenu : MouseEventHandler < HTMLElement > = ( evt ) => {
setAnchor ( evt . currentTarget . getBoundingClientRect ());
};
return (
< PopOut
anchor = { anchor }
position = "Top"
align = "End"
content = {
< FocusTrap
focusTrapOptions = {{
initialFocus : false ,
onDeactivate : () => setAnchor ( undefined ),
clickOutsideDeactivates : true ,
escapeDeactivates : stopPropagation ,
}}
>
< Menu style = {{ maxHeight : '85vh' , overflowY : 'auto' }}>
< Header size = "300" style = {{ padding : `0 ${ config . space . S200 } ` }}>
< Text size = "L400" > Formatting </ Text >
</ Header >
< Box direction = "Column" >
< Box style = { categoryPadding } direction = "Column" >
< Header size = "300" >
< Text size = "L400" > Year </ Text >
</ Header >
< Box direction = "Column" tabIndex = { 0 } gap = "100" >
< Text size = "T300" >
YY
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' }
Two - digit year
</ Text >{ ' ' }
</ Text >
< Text size = "T300" >
YYYY
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } Four - digit year
</ Text >
</ Text >
</ Box >
</ Box >
< Box style = { categoryPadding } direction = "Column" >
< Header size = "300" >
< Text size = "L400" > Month </ Text >
</ Header >
< Box direction = "Column" tabIndex = { 0 } gap = "100" >
< Text size = "T300" >
M
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } The month
</ Text >
</ Text >
< Text size = "T300" >
MM
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } Two - digit month
</ Text >{ ' ' }
</ Text >
< Text size = "T300" >
MMM
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } Short month name
</ Text >
</ Text >
< Text size = "T300" >
MMMM
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } Full month name
</ Text >
</ Text >
</ Box >
</ Box >
< Box style = { categoryPadding } direction = "Column" >
< Header size = "300" >
< Text size = "L400" > Day of the Month </ Text >
</ Header >
< Box direction = "Column" tabIndex = { 0 } gap = "100" >
< Text size = "T300" >
D
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } Day of the month
</ Text >
</ Text >
< Text size = "T300" >
DD
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } Two - digit day of the month
</ Text >
</ Text >
</ Box >
</ Box >
< Box style = { categoryPadding } direction = "Column" >
< Header size = "300" >
< Text size = "L400" > Day of the Week </ Text >
</ Header >
< Box direction = "Column" tabIndex = { 0 } gap = "100" >
< Text size = "T300" >
d
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } Day of the week ( Sunday = 0 )
</ Text >
</ Text >
< Text size = "T300" >
dd
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } Two - letter day name
</ Text >
</ Text >
< Text size = "T300" >
ddd
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } Short day name
</ Text >
</ Text >
< Text size = "T300" >
dddd
< Text as = "span" size = "Inherit" priority = "300" >
{ ': ' } Full day name
</ Text >
</ Text >
</ Box >
</ Box >
</ Box >
</ Menu >
</ FocusTrap >
}
>
{ hasChanges ? (
< IconButton
onClick = { handleReset }
type = "reset"
variant = "Secondary"
size = "300"
radii = "300"
2026-05-20 21:47:20 -04:00
aria-label = "Reset to default"
2025-07-27 15:13:00 +03:00
>
< Icon src = { Icons . Cross } size = "100" />
</ IconButton >
) : (
< IconButton
onClick = { handleOpenMenu }
type = "button"
variant = "Secondary"
size = "300"
radii = "300"
2026-05-20 21:47:20 -04:00
aria-label = "Setting info"
2025-07-27 15:13:00 +03:00
aria-pressed = { !! anchor }
>
< Icon style = {{ opacity : config.opacity.P300 }} size = "100" src = { Icons . Info } />
</ IconButton >
)}
</ PopOut >
);
}
type CustomDateFormatProps = {
value : string ;
onChange : ( format : string ) => void ;
};
function CustomDateFormat ({ value , onChange } : CustomDateFormatProps ) {
const [ dateFormatCustom , setDateFormatCustom ] = useState ( value );
useEffect (() => {
setDateFormatCustom ( value );
}, [ value ]);
const handleChange : ChangeEventHandler < HTMLInputElement > = ( evt ) => {
const format = evt . currentTarget . value ;
setDateFormatCustom ( format );
};
const handleReset = () => {
setDateFormatCustom ( value );
};
const handleSubmit : FormEventHandler < HTMLFormElement > = ( evt ) => {
evt . preventDefault ();
const target = evt . target as HTMLFormElement | undefined ;
const customDateFormatInput = target ? . customDateFormatInput as HTMLInputElement | undefined ;
const format = customDateFormatInput ? . value ;
if ( ! format ) return ;
onChange ( format );
};
const hasChanges = dateFormatCustom !== value ;
return (
< SettingTile >
< Box as = "form" onSubmit = { handleSubmit } gap = "200" >
< Box grow = "Yes" direction = "Column" >
< Input
required
name = "customDateFormatInput"
2026-05-21 12:03:26 -04:00
aria-label = "Custom date format"
2025-07-27 15:13:00 +03:00
value = { dateFormatCustom }
onChange = { handleChange }
maxLength = { 16 }
autoComplete = "off"
variant = "Secondary"
radii = "300"
style = {{ paddingRight : config.space.S200 }}
after = {< DateHint hasChanges = { hasChanges } handleReset = { handleReset } />}
/>
</ Box >
< Button
size = "400"
variant = { hasChanges ? 'Success' : 'Secondary' }
fill = { hasChanges ? 'Solid' : 'Soft' }
outlined
radii = "300"
disabled = { ! hasChanges }
type = "submit"
>
< Text size = "B400" > Save </ Text >
</ Button >
</ Box >
</ SettingTile >
);
}
type PresetDateFormatProps = {
value : string ;
onChange : ( format : string ) => void ;
};
function PresetDateFormat ({ value , onChange } : PresetDateFormatProps ) {
const [ menuCords , setMenuCords ] = useState < RectCords >();
const dateFormatItems = useDateFormatItems ();
const getDisplayDate = ( format : string ) : string =>
format !== '' ? dayjs (). format ( format ) : 'Custom' ;
const handleMenu : MouseEventHandler < HTMLButtonElement > = ( evt ) => {
setMenuCords ( evt . currentTarget . getBoundingClientRect ());
};
const handleSelect = ( format : DateFormat ) => {
onChange ( format );
setMenuCords ( undefined );
};
return (
<>
< Button
size = "300"
variant = "Secondary"
outlined
fill = "Soft"
radii = "300"
after = {< Icon size = "300" src = { Icons . ChevronBottom } />}
onClick = { handleMenu }
>
< Text size = "T300" >
{ getDisplayDate ( dateFormatItems . find (( i ) => i . format === value ) ? . format ?? value )}
</ Text >
</ Button >
< PopOut
anchor = { menuCords }
offset = { 5 }
position = "Bottom"
align = "End"
content = {
< FocusTrap
focusTrapOptions = {{
initialFocus : false ,
onDeactivate : () => setMenuCords ( undefined ),
clickOutsideDeactivates : true ,
isKeyForward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowDown' || evt . key === 'ArrowRight' ,
isKeyBackward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowUp' || evt . key === 'ArrowLeft' ,
escapeDeactivates : stopPropagation ,
}}
>
< Menu >
< Box direction = "Column" gap = "100" style = {{ padding : config.space.S100 }}>
{ dateFormatItems . map (( item ) => (
< MenuItem
key = { item . format }
size = "300"
variant = { value === item . format ? 'Primary' : 'Surface' }
radii = "300"
onClick = {() => handleSelect ( item . format )}
>
< Text size = "T300" >{ getDisplayDate ( item . format )}</ Text >
</ MenuItem >
))}
</ Box >
</ Menu >
</ FocusTrap >
}
/>
</>
);
}
function SelectDateFormat() {
const [ dateFormatString , setDateFormatString ] = useSetting ( settingsAtom , 'dateFormatString' );
const [ selectedDateFormat , setSelectedDateFormat ] = useState ( dateFormatString );
const customDateFormat = selectedDateFormat === '' ;
const handlePresetChange = ( format : string ) => {
setSelectedDateFormat ( format );
if ( format !== '' ) {
setDateFormatString ( format );
}
};
return (
<>
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Date format"
2025-07-27 15:13:00 +03:00
description = { customDateFormat ? dayjs (). format ( dateFormatString ) : '' }
after = {< PresetDateFormat value = { selectedDateFormat } onChange = { handlePresetChange } />}
/>
{ customDateFormat && (
< CustomDateFormat value = { dateFormatString } onChange = { setDateFormatString } />
)}
</>
);
}
2026-10-25 02:07:23 -04:00
export function DateAndTime() {
2025-07-27 15:13:00 +03:00
const [ hour24Clock , setHour24Clock ] = useSetting ( settingsAtom , 'hour24Clock' );
return (
< Box direction = "Column" gap = "100" >
2026-10-25 01:37:37 -04:00
< Text size = "L400" > Date and time </ Text >
2025-07-27 15:13:00 +03:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "24-hour time"
2025-07-27 15:13:00 +03:00
after = {< Switch variant = "Primary" value = { hour24Clock } onChange = { setHour24Clock } />}
/>
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SelectDateFormat />
</ SequenceCard >
</ Box >
);
}
2026-07-01 09:07:03 -04:00
const COMPOSER_TOOLBAR_LABELS : Record < ComposerToolbarButtonKey , string > = {
showFormat : 'Format' ,
showEmoji : 'Emoji' ,
showSticker : 'Sticker' ,
showGif : 'GIF' ,
showLocation : 'Location' ,
showPoll : 'Poll' ,
showVoice : 'Voice' ,
showSchedule : 'Schedule' ,
};
const COMPOSER_TOOLBAR_DRAG_TYPE = 'composer-toolbar-button' ;
type ComposerToolbarButtonRowProps = {
buttonKey : ComposerToolbarButtonKey ;
index : number ;
active : boolean ;
onToggle : ( key : ComposerToolbarButtonKey ) => void ;
};
function ComposerToolbarButtonRow ({
buttonKey ,
index ,
active ,
onToggle ,
} : ComposerToolbarButtonRowProps ) {
const rowRef = useRef < HTMLDivElement >( null );
const handleRef = useRef < HTMLButtonElement >( null );
const [ dragging , setDragging ] = useState ( false );
const [ closestEdge , setClosestEdge ] = useState < Edge | null >( null );
useEffect (() => {
const element = rowRef . current ;
const dragHandle = handleRef . current ;
if ( ! element || ! dragHandle ) return undefined ;
return combine (
draggable ({
element ,
dragHandle ,
getInitialData : () => ({ type : COMPOSER_TOOLBAR_DRAG_TYPE , buttonKey , index }),
onDragStart : () => setDragging ( true ),
onDrop : () => setDragging ( false ),
}),
dropTargetForElements ({
element ,
canDrop : ({ source }) => source . data . type === COMPOSER_TOOLBAR_DRAG_TYPE ,
getData : ({ input }) =>
attachClosestEdge (
{ type : COMPOSER_TOOLBAR_DRAG_TYPE , buttonKey , index },
{ element , input , allowedEdges : [ 'top' , 'bottom' ] },
),
getIsSticky : () => true ,
onDrag : ({ self , source }) => {
if ( source . data . buttonKey === buttonKey ) {
setClosestEdge ( null );
return ;
}
setClosestEdge ( extractClosestEdge ( self . data ));
},
onDragLeave : () => setClosestEdge ( null ),
onDrop : () => setClosestEdge ( null ),
}),
);
}, [ buttonKey , index ]);
let boxShadow : string | undefined ;
if ( closestEdge === 'top' ) boxShadow = `inset 0 2px 0 0 ${ color . Primary . Main } ` ;
else if ( closestEdge === 'bottom' ) boxShadow = `inset 0 -2px 0 0 ${ color . Primary . Main } ` ;
return (
< Box
ref = { rowRef }
alignItems = "Center"
gap = "200"
style = {{
padding : ` ${ config . space . S200 } ${ config . space . S400 } ` ,
opacity : dragging ? 0.5 : undefined ,
boxShadow ,
}}
>
< IconButton
ref = { handleRef }
size = "300"
radii = "300"
variant = "SurfaceVariant"
style = {{ cursor : 'grab' }}
aria-label = { `Reorder ${ COMPOSER_TOOLBAR_LABELS [ buttonKey ] } ` }
>
< Icon size = "100" src = { Icons . VerticalDots } />
</ IconButton >
< Text style = {{ flexGrow : 1 }} size = "T300" >
{ COMPOSER_TOOLBAR_LABELS [ buttonKey ]}
</ Text >
< Chip
variant = { active ? 'Primary' : 'Secondary' }
outlined = { active }
radii = "Pill"
onClick = {() => onToggle ( buttonKey )}
aria-pressed = { active }
>
< Text size = "T200" >{ active ? 'Shown' : 'Hidden' }</ Text >
</ Chip >
</ Box >
);
}
type ComposerToolbarReorderProps = {
order : ComposerToolbarButtonKey [];
buttons : ComposerToolbarSettings ;
onReorder : ( startIndex : number , finishIndex : number ) => void ;
onToggle : ( key : ComposerToolbarButtonKey ) => void ;
};
function ComposerToolbarReorder ({
order ,
buttons ,
onReorder ,
onToggle ,
} : ComposerToolbarReorderProps ) {
useEffect (
() =>
monitorForElements ({
canMonitor : ({ source }) => source . data . type === COMPOSER_TOOLBAR_DRAG_TYPE ,
onDrop : ({ location , source }) => {
const target = location . current . dropTargets [ 0 ];
if ( ! target ) return ;
const startIndex = source . data . index ;
const indexOfTarget = target . data . index ;
if ( typeof startIndex !== 'number' || typeof indexOfTarget !== 'number' ) return ;
const closestEdgeOfTarget = extractClosestEdge ( target . data );
// Insert relative to the target row, then compensate for the source
// row being removed from its original position.
let finishIndex = closestEdgeOfTarget === 'bottom' ? indexOfTarget + 1 : indexOfTarget ;
if ( startIndex < finishIndex ) finishIndex -= 1 ;
if ( finishIndex === startIndex ) return ;
onReorder ( startIndex , finishIndex );
},
}),
[ onReorder ],
);
return (
< Box direction = "Column" >
{ order . map (( key , index ) => (
< ComposerToolbarButtonRow
key = { key }
buttonKey = { key }
index = { index }
active = { buttons [ key ]}
onToggle = { onToggle }
/>
))}
</ Box >
);
}
2026-10-25 02:07:23 -04:00
export function Editor() {
2025-02-10 16:49:47 +11:00
const [ enterForNewline , setEnterForNewline ] = useSetting ( settingsAtom , 'enterForNewline' );
const [ isMarkdown , setIsMarkdown ] = useSetting ( settingsAtom , 'isMarkdown' );
2026-09-25 11:05:49 -04:00
const [ offerCodePaste , setOfferCodePaste ] = useSetting ( settingsAtom , 'offerCodePaste' );
2026-05-13 23:03:14 -04:00
const [ editorToolbar , setEditorToolbar ] = useSetting ( settingsAtom , 'editorToolbar' );
2026-06-10 13:20:29 -04:00
const [ composerToolbarButtons , setComposerToolbarButtons ] = useSetting (
settingsAtom ,
'composerToolbarButtons' ,
);
2026-07-01 09:07:03 -04:00
const composerToolbarOrder = useMemo (
() => normalizeComposerToolbarOrder ( composerToolbarButtons ? . order ),
[ composerToolbarButtons ? . order ],
);
const toggleToolbarButton = useCallback (
( key : ComposerToolbarButtonKey ) => {
setComposerToolbarButtons (( current ) => ({ ... current , [ key ] : ! current [ key ] }));
},
[ setComposerToolbarButtons ],
);
2025-02-10 16:49:47 +11:00
2026-07-01 09:07:03 -04:00
const reorderToolbarButtons = useCallback (
( startIndex : number , finishIndex : number ) => {
setComposerToolbarButtons (( current ) => ({
... current ,
order : reorder ({
list : normalizeComposerToolbarOrder ( current . order ),
startIndex ,
finishIndex ,
}),
}));
},
[ setComposerToolbarButtons ],
);
2026-06-10 17:15:34 -04:00
2025-02-10 16:49:47 +11:00
return (
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Editor </ Text >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Enter for a new line"
2025-02-10 16:49:47 +11:00
description = { `Use ${
isMacOS () ? KeySymbol . Command : 'Ctrl'
} + ENTER to send message and ENTER for newline.` }
after = {< Switch variant = "Primary" value = { enterForNewline } onChange = { setEnterForNewline } />}
/>
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Markdown formatting"
2025-02-10 16:49:47 +11:00
after = {< Switch variant = "Primary" value = { isMarkdown } onChange = { setIsMarkdown } />}
/>
</ SequenceCard >
2026-09-25 11:05:49 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Offer to format pasted code"
2026-09-25 11:05:49 -04:00
description = "When something you paste looks like code, offer to turn it into a code block. Nothing changes unless you accept."
after = {< Switch variant = "Primary" value = { offerCodePaste } onChange = { setOfferCodePaste } />}
/>
</ SequenceCard >
2026-05-13 23:03:14 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Formatting toolbar"
2026-05-13 23:03:14 -04:00
description = "Show bold, italic, code and other formatting buttons above the message input."
after = {< Switch variant = "Primary" value = { editorToolbar } onChange = { setEditorToolbar } />}
/>
</ SequenceCard >
2026-06-10 22:55:32 -04:00
< SequenceCard
className = { SequenceCardStyle }
variant = "SurfaceVariant"
direction = "Column"
gap = "300"
>
2026-06-10 13:20:29 -04:00
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Composer toolbar"
2026-07-01 09:07:03 -04:00
description = "Drag to reorder buttons, and tap a button to show or hide it in the message composer."
2026-06-10 13:20:29 -04:00
/>
2026-07-01 09:07:03 -04:00
< Box direction = "Column" style = {{ paddingBottom : config.space.S200 }}>
< ComposerToolbarReorder
order = { composerToolbarOrder }
buttons = { composerToolbarButtons }
onReorder = { reorderToolbarButtons }
onToggle = { toggleToolbarButton }
/>
2026-06-10 17:15:34 -04:00
</ Box >
2026-06-10 13:20:29 -04:00
</ SequenceCard >
2026-05-28 19:31:36 -04:00
</ Box >
);
}
2026-10-25 02:07:23 -04:00
export function Privacy() {
2026-05-28 19:31:36 -04:00
const [ hideActivity , setHideActivity ] = useSetting ( settingsAtom , 'hideActivity' );
const [ hidePresence , setHidePresence ] = useSetting ( settingsAtom , 'hidePresence' );
2026-06-02 19:31:30 -04:00
const [ privateReadReceipts , setPrivateReadReceipts ] = useSetting (
settingsAtom ,
'privateReadReceipts' ,
);
2026-06-03 22:13:22 -04:00
const [ warnOnUnverifiedDevices , setWarnOnUnverifiedDevices ] = useSetting (
settingsAtom ,
'warnOnUnverifiedDevices' ,
);
2026-10-25 11:51:02 -04:00
const [ urlPreview , setUrlPreview ] = useSetting ( settingsAtom , 'urlPreview' );
const [ encUrlPreview , setEncUrlPreview ] = useSetting ( settingsAtom , 'encUrlPreview' );
2026-09-17 01:46:21 -04:00
const [ stripTracking , setStripTracking ] = useSetting ( settingsAtom , 'stripTrackingParams' );
2026-10-25 11:51:02 -04:00
// [Gitea #461] One choice instead of two overlapping switches. Maps onto the
// existing settings, so every old combination keeps its behaviour:
// hideActivity also hides typing and other people's receipts from you.
let activity : 'everyone' | 'private' | 'hidden' = 'everyone' ;
if ( hideActivity ) activity = 'hidden' ;
else if ( privateReadReceipts ) activity = 'private' ;
const chooseActivity = ( next : typeof activity ) => {
setHideActivity ( next === 'hidden' );
setPrivateReadReceipts ( next !== 'everyone' );
};
2026-09-20 14:22:34 -04:00
const [ stripImageMeta , setStripImageMeta ] = useSetting ( settingsAtom , 'stripImageMetadata' );
2026-05-28 19:31:36 -04:00
return (
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Privacy </ Text >
2026-09-17 01:46:21 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Strip tracking parameters from links"
2026-09-17 01:46:21 -04:00
description = "Remove utm_, fbclid, YouTube si= and other ad/analytics identifiers from links you paste or send, and from links shown in chat. Runs entirely on this device."
after = {< Switch variant = "Primary" value = { stripTracking } onChange = { setStripTracking } />}
/>
</ SequenceCard >
2026-09-20 14:22:34 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Remove photo metadata before sending"
2026-09-20 14:22:34 -04:00
description = "Strip location, camera model and timestamp (EXIF/XMP) from JPEG, PNG and WebP images you send or set as an avatar. Pixels are untouched; the rotation is kept. Videos and GIFs are not covered."
after = {< Switch variant = "Primary" value = { stripImageMeta } onChange = { setStripImageMeta } />}
/>
</ SequenceCard >
2025-02-26 21:44:53 +11:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 11:51:02 -04:00
title = "Link previews"
description = "Your homeserver fetches and caches link previews. It will see the URLs of all links you preview."
after = {< Switch variant = "Primary" value = { urlPreview } onChange = { setUrlPreview } />}
2025-02-26 21:44:53 +11:00
/>
</ SequenceCard >
2026-06-02 19:31:30 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 11:51:02 -04:00
title = "Link previews in encrypted rooms"
description = {
< Box direction = "Column" gap = "100" >
< Text size = "T200" priority = "300" >
Your homeserver fetches link previews on your behalf . It cannot decrypt your
messages , but will see every URL you preview in encrypted rooms , potentially
revealing conversation topics .
</ Text >
< Chip
variant = "Warning"
fill = "Soft"
radii = "300"
size = "400"
style = {{ alignSelf : 'flex-start' }}
>
< Text size = "T200" > Privacy risk — enabled by default </ Text >
</ Chip >
</ Box >
2026-06-02 19:31:30 -04:00
}
2026-10-25 11:51:02 -04:00
after = {< Switch variant = "Primary" value = { encUrlPreview } onChange = { setEncUrlPreview } />}
2026-06-02 19:31:30 -04:00
/>
</ SequenceCard >
2026-10-25 11:51:02 -04:00
< SequenceCard
className = { SequenceCardStyle }
variant = "SurfaceVariant"
direction = "Column"
gap = "300"
>
< SettingTile
title = "Read receipts and typing"
description = "Who can see that you've read a message or are typing."
/>
< Box
direction = "Column"
gap = "200"
role = "radiogroup"
aria-label = "Read receipts and typing"
style = {{ padding : `0 ${ config . space . S400 } ${ config . space . S300 } ` }}
>
{(
[
[ 'everyone' , 'Everyone' , "Others see what you've read and when you're typing." ],
[
'private' ,
'Private read receipts' ,
"Others don't see what you've read (only you and your server do). Typing still shows." ,
],
[
'hidden' ,
'Hide my activity' ,
"No typing indicator and private read receipts. You also won't see other people's read receipts." ,
],
] as const
). map (([ value , label , help ]) => (
< label
key = { value }
style = {{ display : 'flex' , gap : config.space.S200 , cursor : 'pointer' }}
>
2026-10-25 12:16:14 -04:00
< RadioButton
2026-10-25 11:51:02 -04:00
name = "activity-privacy"
2026-10-25 12:16:14 -04:00
variant = "Primary"
size = "300"
2026-10-25 11:51:02 -04:00
checked = { activity === value }
2026-10-25 12:16:14 -04:00
onClick = {() => chooseActivity ( value )}
2026-10-25 11:51:02 -04:00
/>
< Box direction = "Column" >
< Text size = "T300" >{ label }</ Text >
< Text size = "T200" priority = "300" >
{ help }
</ Text >
</ Box >
</ label >
))}
</ Box >
</ SequenceCard >
2026-05-28 19:28:52 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Hide online status"
2026-05-28 19:28:52 -04:00
description = "Appear offline to everyone while still using the app. Disables online, away, and idle indicators."
after = {< Switch variant = "Primary" value = { hidePresence } onChange = { setHidePresence } />}
/>
</ SequenceCard >
2026-06-03 22:13:22 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Warn before sending to unverified devices"
description = "Show a warning in the composer when sending to a room with unverified devices."
after = {
< Switch
variant = "Primary"
value = { warnOnUnverifiedDevices }
onChange = { setWarnOnUnverifiedDevices }
/>
}
/>
</ SequenceCard >
2025-02-10 16:49:47 +11:00
</ Box >
);
}
2026-09-17 01:56:06 -04:00
// [Gitea #104] Sync toggle + the two manual actions. The toggle is itself
// device-local (never synced) so switching it off here sticks.
2026-10-25 02:07:23 -04:00
export function SettingsSyncSection() {
2026-10-19 15:06:20 -04:00
const isMobile = useScreenSize () === ScreenSize . Mobile ;
2026-09-17 01:56:06 -04:00
const [ settingsSync , setSettingsSync ] = useSetting ( settingsAtom , 'settingsSync' );
const { pushNow , clearRemote } = useSettingsSyncActions ();
const [ busy , setBusy ] = useState < 'push' | 'clear' | null > ( null );
const [ note , setNote ] = useState < string | null >( null );
const run = async ( action : 'push' | 'clear' ) => {
setBusy ( action );
setNote ( null );
try {
if ( action === 'push' ) {
await pushNow ();
setNote ( 'Pushed — other devices will pick these settings up on their next sync.' );
} else {
await clearRemote ();
setNote ( 'Cleared — devices keep their current settings until one pushes again.' );
}
} catch {
setNote ( 'Failed — check your connection and try again.' );
} finally {
setBusy ( null );
}
};
2026-10-19 15:06:20 -04:00
const syncButtons = (
< Box gap = "200" >
< Button
size = "300"
variant = "Secondary"
fill = "Soft"
outlined
radii = "300"
disabled = { busy !== null }
before = { busy === 'push' ? < Spinner size = "100" variant = "Secondary" /> : undefined }
onClick = {() => run ( 'push' )}
>
< Text size = "B300" > Push now </ Text >
</ Button >
< Button
size = "300"
variant = "Critical"
fill = "None"
radii = "300"
disabled = { busy !== null }
before = { busy === 'clear' ? < Spinner size = "100" variant = "Critical" /> : undefined }
onClick = {() => run ( 'clear' )}
>
< Text size = "B300" > Clear synced copy </ Text >
</ Button >
</ Box >
);
2026-09-17 01:56:06 -04:00
return (
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Sync </ Text >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Sync settings across devices"
2026-09-17 01:56:06 -04:00
description = "Keep your preferences (theme, composer toolbar, notifications, quiet hours, call keys…) the same on every device, stored as account data on your own homeserver. Device-specific settings such as zoom, media auto-load, noise suppression and volumes stay local."
after = {< Switch variant = "Primary" value = { settingsSync } onChange = { setSettingsSync } />}
/>
</ SequenceCard >
{ settingsSync && (
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Use this device's settings everywhere"
2026-09-17 01:56:06 -04:00
description = "Push this device's current preferences so every other device adopts them, even ones that changed something more recently."
2026-10-19 15:06:20 -04:00
// [Gitea #273] On phones the two buttons squeezed the text into a
// narrow column; put them under the description there.
after = { isMobile ? undefined : syncButtons }
>
{ isMobile && < Box style = {{ paddingTop : config.space.S100 }}>{ syncButtons }</ Box >}
</ SettingTile >
2026-09-17 01:56:06 -04:00
{ note && (
< Text
size = "T200"
priority = "300"
style = {{ padding : `0 ${ config . space . S300 } ${ config . space . S300 } ` }}
>
{ note }
</ Text >
)}
</ SequenceCard >
)}
</ Box >
);
}
2026-09-12 14:48:34 -04:00
// [Gitea #23] Denylist navigation-critical/modifier codes and reject a code that
// collides with the other call key (`otherKey`), so a rebind can never trap
// keyboard focus in-call or silently double-bind PTT and deafen to the same key.
function useKeyBind ( setter : ( code : string ) => void , otherKey? : string ) {
2026-06-03 00:45:43 -04:00
const [ listening , setListening ] = useState ( false );
2026-09-12 14:48:34 -04:00
const [ error , setError ] = useState < string | null >( null );
2026-06-03 00:45:43 -04:00
const listenerRef = useRef < (( e : KeyboardEvent ) => void ) | null > ( null );
2026-05-15 15:38:02 -04:00
useEffect (
() => () => {
2026-06-03 00:45:43 -04:00
if ( listenerRef . current ) window . removeEventListener ( 'keydown' , listenerRef . current , true );
2026-05-15 15:38:02 -04:00
},
2026-05-21 23:30:50 -04:00
[],
2026-05-15 15:38:02 -04:00
);
2026-05-14 11:07:10 -04:00
2026-06-03 00:45:43 -04:00
const startListening = useCallback (() => {
if ( listening ) return ;
2026-09-12 14:48:34 -04:00
setError ( null );
2026-06-03 00:45:43 -04:00
setListening ( true );
2026-05-14 11:07:10 -04:00
const onKey = ( e : KeyboardEvent ) => {
e . preventDefault ();
2026-09-12 14:48:34 -04:00
if ( e . code === 'Escape' ) {
// Escape always cancels the rebind without changing the key.
} else if ( ! isBindableCallKey ( e . code )) {
setError ( 'That key can’ t be bound — it’ s needed for keyboard navigation.' );
} else if ( otherKey && e . code === otherKey ) {
setError ( 'That key is already bound to the other call shortcut.' );
} else {
setter ( e . code );
}
2026-06-03 00:45:43 -04:00
setListening ( false );
2026-05-14 11:07:10 -04:00
window . removeEventListener ( 'keydown' , onKey , true );
2026-06-03 00:45:43 -04:00
listenerRef . current = null ;
2026-05-14 11:07:10 -04:00
};
2026-06-03 00:45:43 -04:00
listenerRef . current = onKey ;
2026-05-14 11:07:10 -04:00
window . addEventListener ( 'keydown' , onKey , true );
2026-09-12 14:48:34 -04:00
}, [ listening , setter , otherKey ]);
2026-06-03 00:45:43 -04:00
2026-09-12 14:48:34 -04:00
return { listening , startListening , error };
2026-06-03 00:45:43 -04:00
}
2026-05-14 11:07:10 -04:00
2026-06-03 00:45:43 -04:00
const keyLabel = ( code : string ) =>
code === 'Space' ? 'Space' : code . replace ( 'Key' , '' ). replace ( 'Digit' , '' );
2026-10-25 02:07:23 -04:00
export function Calls() {
2026-06-03 00:45:43 -04:00
const [ cameraOnJoin , setCameraOnJoin ] = useSetting ( settingsAtom , 'cameraOnJoin' );
const [ callNoiseSuppression , setCallNoiseSuppression ] = useSetting (
settingsAtom ,
'callNoiseSuppression' ,
);
2026-06-16 00:50:12 -04:00
const [ callDenoiseModel , setCallDenoiseModel ] = useSetting ( settingsAtom , 'callDenoiseModel' );
const [ callDenoiseNativeNS , setCallDenoiseNativeNS ] = useSetting (
settingsAtom ,
'callDenoiseNativeNS' ,
);
const [ callDenoiseGate , setCallDenoiseGate ] = useSetting ( settingsAtom , 'callDenoiseGate' );
const [ callDenoiseGateThreshold , setCallDenoiseGateThreshold ] = useSetting (
settingsAtom ,
'callDenoiseGateThreshold' ,
);
2026-06-03 00:45:43 -04:00
const [ pttMode , setPttMode ] = useSetting ( settingsAtom , 'pttMode' );
2026-10-20 19:45:11 -04:00
const [ callSummaryToast , setCallSummaryToast ] = useSetting ( settingsAtom , 'callSummaryToast' );
2026-09-20 14:50:28 -04:00
const [ callRejoin , setCallRejoin ] = useSetting ( settingsAtom , 'callRejoinAfterRestart' );
2026-09-20 15:15:04 -04:00
const [ haptics , setHaptics ] = useSetting ( settingsAtom , 'hapticFeedback' );
2026-06-03 00:45:43 -04:00
const [ pttKey , setPttKey ] = useSetting ( settingsAtom , 'pttKey' );
const [ deafenKey , setDeafenKey ] = useSetting ( settingsAtom , 'deafenKey' );
2026-09-18 23:15:00 -04:00
const [ deafenHotkey , setDeafenHotkey ] = useSetting ( settingsAtom , 'deafenHotkey' );
2026-09-17 13:39:51 -04:00
const [ globalCallHotkeys , setGlobalCallHotkeys ] = useSetting ( settingsAtom , 'globalCallHotkeys' );
2026-06-12 19:53:19 -04:00
const [ afkAutoMute , setAfkAutoMute ] = useSetting ( settingsAtom , 'afkAutoMute' );
2026-09-19 22:50:32 -04:00
const [ mutedTalkWarning , setMutedTalkWarning ] = useSetting ( settingsAtom , 'mutedTalkWarning' );
2026-06-12 19:53:19 -04:00
const [ afkTimeoutMinutes , setAfkTimeoutMinutes ] = useSetting ( settingsAtom , 'afkTimeoutMinutes' );
2026-06-12 22:20:22 -04:00
const [ callJoinLeaveSound , setCallJoinLeaveSound ] = useSetting (
settingsAtom ,
'callJoinLeaveSound' ,
);
2026-06-18 18:56:04 -04:00
const [ ringtoneVolume , setRingtoneVolume ] = useSetting ( settingsAtom , 'ringtoneVolume' );
2026-06-24 17:25:32 -04:00
const [ ringtoneId , setRingtoneId ] = useSetting ( settingsAtom , 'ringtoneId' );
2026-06-12 22:20:22 -04:00
2026-06-30 22:34:17 -04:00
const [ callAudioBitrate , setCallAudioBitrate ] = useSetting ( settingsAtom , 'callAudioBitrate' );
const [ screenshareBitrate , setScreenshareBitrate ] = useSetting (
settingsAtom ,
'screenshareBitrate' ,
);
const [ screenshareFramerate , setScreenshareFramerate ] = useSetting (
settingsAtom ,
'screenshareFramerate' ,
);
const [ soundboardEnabled , setSoundboardEnabled ] = useSetting ( settingsAtom , 'soundboardEnabled' );
const [ soundboardVolume , setSoundboardVolume ] = useSetting ( settingsAtom , 'soundboardVolume' );
2026-06-12 22:20:22 -04:00
const handleJoinLeaveSoundChange = ( value : 'off' | 'chime' | 'soft' | 'retro' ) => {
setCallJoinLeaveSound ( value );
if ( value !== 'off' ) playCallJoinSound ( value );
};
2026-06-03 00:45:43 -04:00
2026-06-24 17:25:32 -04:00
const handleRingtoneChange = ( value : RingtoneId ) => {
setRingtoneId ( value );
previewRingtone ( value , Math . max ( 0 , Math . min ( 1 , ringtoneVolume / 100 )));
};
2026-09-12 14:48:34 -04:00
const pttBind = useKeyBind ( setPttKey , deafenKey );
const deafenBind = useKeyBind ( setDeafenKey , pttKey );
2026-05-14 11:07:10 -04:00
2026-06-16 00:50:12 -04:00
const mlSupported = isMLDenoiseSupported ();
2026-06-17 20:02:16 -04:00
const selectedDenoiseModel = DENOISE_MODELS . find (( m ) => m . id === callDenoiseModel );
2026-06-16 00:50:12 -04:00
2026-05-14 11:07:10 -04:00
return (
2026-10-25 11:51:02 -04:00
// [Gitea #462] Fixed groups in every mode (it was one flat list).
< Box direction = "Column" gap = "700" >
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Joining </ Text >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Join with camera on"
description = "Enable camera automatically when joining a voice or video call. Camera is off by default."
after = {< Switch variant = "Primary" value = { cameraOnJoin } onChange = { setCameraOnJoin } />}
/>
</ SequenceCard >
< SequenceCard
className = { ` ${ SequenceCardStyle } ${ SettingTileGroup } ` }
variant = "SurfaceVariant"
direction = "Column"
gap = "400"
>
< SettingTile
title = "Rejoin calls after a restart"
description = "If Lotus crashes, reloads or restarts for an update while you are in a voice room, put you back in."
after = {
< SettingsSelect < 'ask' | 'auto' | 'off' >
value = { callRejoin }
onChange = { setCallRejoin }
options = {[
{ value : 'ask' , label : 'Ask' },
{ value : 'auto' , label : 'Rejoin automatically' },
{ value : 'off' , label : 'Do nothing' },
]}
2026-06-17 20:02:16 -04:00
/>
2026-10-25 11:51:02 -04:00
}
/>
< SettingTile
title = "Summary after calls"
description = "When a call ends, show how long it was and how the connection held up, with a Details button for who was there, network numbers and your own talk/mute time."
after = {
< Switch variant = "Primary" value = { callSummaryToast } onChange = { setCallSummaryToast } />
}
/>
</ SequenceCard >
</ Box >
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Microphone and noise </ Text >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Noise suppression"
description = {
< Box direction = "Column" gap = "200" >
{ /* [Gitea #271] T200 like every other setting description. */ }
< Text size = "T200" >
Filter background noise from your mic during calls . Browser - native uses the
built - in WebRTC suppressor ( Google NSNet2 ). ML runs a dedicated model for stronger
removal .
</ Text >
{ ! mlSupported && (
< Box direction = "Column" gap = "100" >
< Text size = "T200" priority = "400" >
ML options are not supported in this browser .
</ Text >
< Box as = "ul" style = {{ paddingLeft : '20px' , margin : 0 }}>
{ ML_DENOISE_REQUIREMENTS . map (( req ) => (
< Text as = "li" key = { req } size = "T200" >
{ req }
2026-06-17 20:02:16 -04:00
</ Text >
2026-10-25 11:51:02 -04:00
))}
</ Box >
2026-06-17 20:02:16 -04:00
</ Box >
2026-10-25 11:51:02 -04:00
)}
</ Box >
}
after = {
< SettingsSelect < NoiseSuppressionMode >
value = { callNoiseSuppression }
onChange = { setCallNoiseSuppression }
options = {[
{ value : 'off' , label : 'Off' },
{ value : 'browser' , label : 'Browser-native' },
{
value : 'ml' ,
label : 'ML (Advanced)' ,
disabled : ! mlSupported ,
},
]}
/>
}
/>
2026-06-16 00:50:12 -04:00
2026-10-25 11:51:02 -04:00
{ callNoiseSuppression === 'ml' && (
< Box
direction = "Column"
gap = "400"
style = {{
padding : '16px' ,
marginTop : '8px' ,
borderTop : ` ${ config . borderWidth . B300 } solid ${ color . Surface . ContainerLine } ` ,
background : color.Surface.Container ,
}}
>
{ /* ── Model selection ───────────────────────────────────────── */ }
< Box direction = "Column" gap = "200" >
< Text size = "L400" > Model </ Text >
< SettingTile
title = "ML model"
description = "Choose the machine learning model used for noise removal. Heavier models clean more aggressively at a higher CPU cost."
after = {
< SettingsSelect < DenoiseModelId >
value = { callDenoiseModel }
onChange = { setCallDenoiseModel }
options = { DENOISE_MODELS . map (( m ) => ({ value : m.id , label : m.name }))}
/>
}
/>
{ selectedDenoiseModel && (
2026-06-17 20:02:16 -04:00
< Box
2026-10-25 11:51:02 -04:00
direction = "Column"
gap = "200"
2026-06-17 20:02:16 -04:00
style = {{
2026-10-25 11:51:02 -04:00
padding : '12px' ,
borderRadius : '8px' ,
border : ` ${ config . borderWidth . B300 } solid ${ color . Surface . ContainerLine } ` ,
background : color.SurfaceVariant.Container ,
2026-06-17 20:02:16 -04:00
}}
>
2026-10-25 11:51:02 -04:00
< Text size = "T300" >{ selectedDenoiseModel . name }</ Text >
< Text size = "T200" priority = "300" >
{ selectedDenoiseModel . description }
</ Text >
< Box direction = "Row" gap = "400" wrap = "Wrap" >
{(
[
{ label : 'CPU' , value : selectedDenoiseModel.cpuUsage },
{ label : 'Voice quality' , value : selectedDenoiseModel.voiceQuality },
{ label : 'Transients' , value : selectedDenoiseModel.transients },
{ label : 'Download' , value : selectedDenoiseModel.binarySize },
] as const
). map (( stat ) => (
< Box key = { stat . label } direction = "Column" gap = "100" >
< Text size = "T200" priority = "300" >
{ stat . label }
</ Text >
< Text size = "T300" >{ stat . value }</ Text >
</ Box >
))}
2026-06-17 20:02:16 -04:00
</ Box >
</ Box >
2026-10-25 11:51:02 -04:00
)}
< details >
< summary style = {{ cursor : 'pointer' }}>
< Text as = "span" size = "T200" priority = "300" >
Compare all models
</ Text >
</ summary >
< Box direction = "Column" gap = "100" style = {{ overflowX : 'auto' , marginTop : '8px' }}>
< Box
direction = "Row"
gap = "100"
style = {{
borderBottom : ` ${ config . borderWidth . B300 } solid ${ color . Surface . ContainerLine } ` ,
paddingBottom : '4px' ,
}}
>
2026-06-17 20:02:16 -04:00
< Box style = {{ width : '160px' }}>
2026-10-25 11:51:02 -04:00
< Text size = "T200" priority = "300" >
Model
</ Text >
2026-06-17 20:02:16 -04:00
</ Box >
< Box style = {{ width : '80px' }}>
2026-10-25 11:51:02 -04:00
< Text size = "T200" priority = "300" >
CPU
</ Text >
2026-06-17 20:02:16 -04:00
</ Box >
< Box style = {{ width : '90px' }}>
2026-10-25 11:51:02 -04:00
< Text size = "T200" priority = "300" >
Quality
</ Text >
2026-06-17 20:02:16 -04:00
</ Box >
< Box grow = "Yes" >
2026-10-25 11:51:02 -04:00
< Text size = "T200" priority = "300" >
Transients
</ Text >
2026-06-17 20:02:16 -04:00
</ Box >
</ Box >
2026-10-25 11:51:02 -04:00
{ DENOISE_MODELS . map (( model ) => (
< Box key = { model . id } direction = "Row" gap = "100" >
< Box style = {{ width : '160px' }}>
< Text size = "T200" >{ model . name }</ Text >
</ Box >
< Box style = {{ width : '80px' }}>
< Text size = "T200" >{ model . cpuUsage }</ Text >
</ Box >
< Box style = {{ width : '90px' }}>
< Text size = "T200" >{ model . voiceQuality }</ Text >
</ Box >
< Box grow = "Yes" >
< Text size = "T200" >{ model . transients }</ Text >
</ Box >
</ Box >
))}
</ Box >
</ details >
2026-06-16 00:50:12 -04:00
2026-10-25 11:51:02 -04:00
< Text size = "T200" priority = "400" >
Note : Applying changes requires rejoining the call .
</ Text >
</ Box >
2026-06-17 20:02:16 -04:00
2026-10-25 11:51:02 -04:00
{ /* ── Enhancement toggles ───────────────────────────────────── */ }
< Box
direction = "Column"
gap = "300"
style = {{
paddingTop : '12px' ,
borderTop : ` ${ config . borderWidth . B300 } solid ${ color . Surface . ContainerLine } ` ,
}}
>
< Text size = "L400" > Enhancements </ Text >
< SettingTile
title = "Also use the browser's noise suppression"
description = "Run the browser's native stationary noise filter before the ML model. Recommended for eliminating fan hum."
after = {
< Switch
variant = "Primary"
value = { callDenoiseNativeNS }
onChange = { setCallDenoiseNativeNS }
/>
}
/>
2026-06-17 20:02:16 -04:00
2026-10-25 11:51:02 -04:00
< SettingTile
title = "Noise gate"
description = "Hard-cut audio when you aren't speaking to ensure absolute silence between sentences."
after = {
< Switch
variant = "Primary"
value = { callDenoiseGate }
onChange = { setCallDenoiseGate }
/>
}
/>
2026-06-16 00:50:12 -04:00
2026-10-25 11:51:02 -04:00
{ callDenoiseGate && (
< Box direction = "Column" gap = "100" >
< Box direction = "Row" justifyContent = "SpaceBetween" >
< Text size = "T200" > Gate Threshold </ Text >
< Text size = "T200" >{ callDenoiseGateThreshold } dB </ Text >
</ Box >
< input
aria-label = "Noise gate threshold"
type = "range"
min = "-100"
max = "0"
step = "1"
value = { callDenoiseGateThreshold }
onChange = {( e ) => setCallDenoiseGateThreshold ( parseInt ( e . target . value , 10 ))}
style = {{ width : '100%' , accentColor : color.Primary.Main }}
/>
2026-06-17 20:02:16 -04:00
</ Box >
2026-10-25 11:51:02 -04:00
)}
</ Box >
2026-06-16 17:53:57 -04:00
2026-10-25 11:51:02 -04:00
{ /* ── Test & calibrate ──────────────────────────────────────── */ }
< Box
direction = "Column"
gap = "200"
style = {{
paddingTop : '12px' ,
borderTop : ` ${ config . borderWidth . B300 } solid ${ color . Surface . ContainerLine } ` ,
}}
>
< Text size = "L400" > Test and calibrate </ Text >
< Text size = "T200" priority = "300" >
Audition the selected model and tune the gate without joining a call . Changes to
the settings above apply the next time you start a monitor or play a clip .
</ Text >
< DenoiseTester
model = { callDenoiseModel }
useGate = { callDenoiseGate }
gateThreshold = { callDenoiseGateThreshold }
nativeNS = { callDenoiseNativeNS }
/>
</ Box >
2026-06-16 17:53:57 -04:00
</ Box >
2026-10-25 11:51:02 -04:00
)}
</ SequenceCard >
< SequenceCard
className = { ` ${ SequenceCardStyle } ${ SettingTileGroup } ` }
variant = "SurfaceVariant"
direction = "Column"
gap = "400"
>
2026-05-14 11:07:10 -04:00
< SettingTile
2026-10-25 11:51:02 -04:00
title = "Warn me when I talk while muted"
description = "Shows a one-time 'You're muted' nudge with an Unmute button when the mic hears you but is muted. Never while Push to Talk is on."
2026-05-14 11:07:10 -04:00
after = {
2026-10-25 11:51:02 -04:00
< Switch variant = "Primary" value = { mutedTalkWarning } onChange = { setMutedTalkWarning } />
2026-05-14 11:07:10 -04:00
}
/>
2026-10-25 11:51:02 -04:00
< SettingTile
title = "AFK auto-mute"
description = "Automatically mute your microphone when you have been silent in a call."
after = {< Switch variant = "Primary" value = { afkAutoMute } onChange = { setAfkAutoMute } />}
/>
{ afkAutoMute && (
< SettingTile
title = "Idle timeout"
description = "How long to wait before auto-muting."
after = {
< SettingsSelect
value = { String ( afkTimeoutMinutes ?? 10 )}
onChange = {( v ) => setAfkTimeoutMinutes ( Number ( v ))}
options = {[
{ value : '1' , label : '1 minute' },
{ value : '5' , label : '5 minutes' },
{ value : '10' , label : '10 minutes' },
{ value : '20' , label : '20 minutes' },
{ value : '30' , label : '30 minutes' },
]}
/>
}
/>
)}
</ SequenceCard >
</ Box >
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Push to talk and hotkeys </ Text >
< SequenceCard
className = { ` ${ SequenceCardStyle } ${ SettingTileGroup } ` }
variant = "SurfaceVariant"
direction = "Column"
gap = "400"
>
< SettingTile
title = "Push to talk"
description = "Mute your microphone by default. Hold the PTT key to speak."
after = {< Switch variant = "Primary" value = { pttMode } onChange = { setPttMode } />}
/>
{ pttMode && (
< SettingTile
title = "Push-to-talk key"
description = { pttBind . error ?? 'Press a key to bind it as your push-to-talk key.' }
after = {
2026-09-18 23:15:00 -04:00
< Button
size = "300"
2026-10-25 11:51:02 -04:00
variant = { pttBind . listening ? 'Warning' : 'Secondary' }
fill = { pttBind . listening ? 'Solid' : 'Soft' }
2026-09-18 23:15:00 -04:00
radii = "300"
outlined
2026-10-25 11:51:02 -04:00
onClick = { pttBind . startListening }
2026-09-18 23:15:00 -04:00
style = {{ minWidth : '90px' }}
>
2026-10-25 11:51:02 -04:00
< Text size = "B300" >{ pttBind . listening ? 'Press a key…' : keyLabel ( pttKey )}</ Text >
2026-09-18 23:15:00 -04:00
</ Button >
2026-10-25 11:51:02 -04:00
}
/>
)}
2026-09-17 13:39:51 -04:00
< SettingTile
2026-10-25 11:51:02 -04:00
title = "Push to deafen"
description = {
deafenBind . error ??
( deafenHotkey
? ` ${
// [Gitea #279] The Escape hint only applies while rebinding.
deafenBind . listening
? 'Press a key to bind it, or Escape to cancel.'
: `Press ${ keyLabel ( deafenKey ) } during a call to mute your speakers.`
}${
! isSafeGlobalToggleKey ( deafenKey )
? ` A letter, digit or Space only works in the call view — on a chat screen typing takes priority ${
isTauriEnv () && globalCallHotkeys
? ' and other apps are never watched'
: ''
} . Bind an F-key or Numpad key to make it work everywhere.`
: ''
} `
: 'Off — no key toggles deafen. Use the headphone button in the call bar.' )
}
2026-09-17 13:39:51 -04:00
after = {
2026-10-25 11:51:02 -04:00
< Box alignItems = "Center" gap = "200" >
< Switch variant = "Primary" value = { deafenHotkey } onChange = { setDeafenHotkey } />
{ deafenHotkey && (
< Button
size = "300"
variant = { deafenBind . listening ? 'Warning' : 'Secondary' }
fill = { deafenBind . listening ? 'Solid' : 'Soft' }
radii = "300"
outlined
onClick = { deafenBind . startListening }
style = {{ minWidth : '90px' }}
>
< Text size = "B300" >
{ deafenBind . listening ? 'Press a key…' : keyLabel ( deafenKey )}
</ Text >
</ Button >
)}
</ Box >
2026-09-17 13:39:51 -04:00
}
/>
2026-10-25 11:51:02 -04:00
{ isTauriEnv () && (
< SettingTile
title = "Hotkeys work outside the window"
description = "Keep Push to Talk and Push to Deafen working while a game or another app has focus. The keys are only watched during a call and are never blocked from other apps. Windows only; some anti-cheat systems may prevent it."
after = {
< Switch
variant = "Primary"
value = { globalCallHotkeys }
onChange = { setGlobalCallHotkeys }
/>
}
/>
)}
{ hapticsSupported () && (
< SettingTile
title = "Haptic feedback"
description = "A short vibration when push-to-talk engages or releases and when you send a reaction. Off automatically when your system prefers reduced motion."
after = {< Switch variant = "Primary" value = { haptics } onChange = { setHaptics } />}
/>
)}
</ SequenceCard >
</ Box >
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Sounds </ Text >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Ringtone"
description = "Sound played for incoming calls. Selecting an option plays a preview."
after = {
< SettingsSelect
value = { ringtoneId }
onChange = {( v ) => handleRingtoneChange ( v as RingtoneId )}
options = { RINGTONE_OPTIONS }
/>
}
/>
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Ringtone volume"
description = "Volume of the incoming call ringtone."
/>
< Box
direction = "Row"
alignItems = "Center"
gap = "200"
style = {{ padding : `0 ${ config . space . S400 } ${ config . space . S300 } ` }}
>
< input
type = "range"
min = "0"
max = "100"
step = "5"
value = { ringtoneVolume }
onChange = {( e ) => setRingtoneVolume ( parseInt ( e . target . value , 10 ))}
aria-label = "Ringtone volume"
style = {{ flex : 1 , accentColor : color.Primary.Main }}
/>
< Text size = "T200" style = {{ minWidth : '32px' , textAlign : 'right' }}>
{ ringtoneVolume } %
</ Text >
</ Box >
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
2026-06-12 19:53:19 -04:00
< SettingTile
2026-10-25 11:51:02 -04:00
title = "Join and leave sounds"
description = "Play a sound when someone joins or leaves a call you are in. Selecting an option plays a preview."
2026-06-12 19:53:19 -04:00
after = {
2026-06-14 12:20:47 -04:00
< SettingsSelect
2026-10-25 11:51:02 -04:00
value = { callJoinLeaveSound }
onChange = {( v ) =>
handleJoinLeaveSoundChange ( v as 'off' | 'chime' | 'soft' | 'retro' )
}
2026-06-14 12:20:47 -04:00
options = {[
2026-10-25 11:51:02 -04:00
{ value : 'off' , label : 'Off' },
{ value : 'chime' , label : 'Chime' },
{ value : 'soft' , label : 'Soft' },
{ value : 'retro' , label : 'Retro' },
2026-06-14 12:20:47 -04:00
]}
/>
2026-06-12 19:53:19 -04:00
}
/>
2026-10-25 11:51:02 -04:00
</ SequenceCard >
</ Box >
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Quality </ Text >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Microphone bitrate"
description = "Cap the audio bitrate your mic sends in calls. Lower saves bandwidth; higher is clearer. Auto lets Element Call decide."
after = {
< SettingsSelect < CallAudioBitrate >
value = { callAudioBitrate }
onChange = { setCallAudioBitrate }
options = { AUDIO_BITRATE_OPTIONS }
/>
}
2026-07-18 22:38:01 -04:00
/>
2026-10-25 11:51:02 -04:00
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Screen share bitrate"
description = "Cap the bitrate used when you share your screen. Lower is smoother on poor connections; higher is sharper."
after = {
< SettingsSelect < ScreenshareBitrate >
value = { screenshareBitrate }
onChange = { setScreenshareBitrate }
options = { SCREENSHARE_BITRATE_OPTIONS }
2026-07-18 22:38:01 -04:00
/>
2026-10-25 11:51:02 -04:00
}
/>
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Screen share frame rate"
description = "Cap the frames-per-second of your screenshare. 60 fps suits motion/gaming; 15 fps suits slides and saves bandwidth."
after = {
< SettingsSelect < ScreenshareFramerate >
value = { screenshareFramerate }
onChange = { setScreenshareFramerate }
options = { SCREENSHARE_FRAMERATE_OPTIONS }
/>
}
/>
</ SequenceCard >
</ Box >
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Soundboard </ Text >
< SequenceCard
className = { ` ${ SequenceCardStyle } ${ SettingTileGroup } ` }
variant = "SurfaceVariant"
direction = "Column"
>
< SettingTile
title = "Soundboard"
description = "Show a soundboard button in the call bar. Upload short audio clips (like custom emojis) to play them into the call. Clips sync across your devices."
after = {
< Switch variant = "Primary" value = { soundboardEnabled } onChange = { setSoundboardEnabled } />
}
/>
{ soundboardEnabled && (
<>
< SettingTile title = "Soundboard volume" />
< Box
alignItems = "Center"
gap = "200"
style = {{ padding : `0 ${ config . space . S400 } ${ config . space . S300 } ` }}
>
< input
type = "range"
min = { 0 }
max = { 100 }
step = { 5 }
value = { soundboardVolume }
onChange = {( e ) => setSoundboardVolume ( parseInt ( e . target . value , 10 ))}
style = {{ flexGrow : 1 }}
aria-label = "Soundboard volume"
/>
< Text size = "T200" style = {{ minWidth : toRem ( 36 ), textAlign : 'right' }}>
{ soundboardVolume } %
</ Text >
</ Box >
</>
)}
</ SequenceCard >
</ Box >
2026-05-14 11:07:10 -04:00
</ Box >
);
}
2026-06-15 20:29:59 -04:00
const SEASONAL_OPTIONS : {
value : Settings [ 'seasonalThemeOverride' ];
label : string ;
emoji : string ;
}[] = [
{ value : 'auto' , label : 'Auto' , emoji : '🗓' },
{ value : 'off' , label : 'Off' , emoji : '× ' },
{ value : 'newyear' , label : 'New Year' , emoji : '🎆' },
{ value : 'lunar' , label : 'Lunar New Year' , emoji : '🏮' },
{ value : 'valentines' , label : "Valentine's" , emoji : '💖' },
{ value : 'stpatricks' , label : "St. Patrick's" , emoji : '🍀' },
{ value : 'aprilfools' , label : 'April Fools' , emoji : '?' },
{ value : 'earthday' , label : 'Earth Day' , emoji : '🌱' },
{ value : 'autumn' , label : 'Autumn' , emoji : '🍂' },
{ value : 'halloween' , label : 'Halloween' , emoji : '🎃' },
{ value : 'christmas' , label : 'Christmas' , emoji : '❄️' },
{ value : 'arcade' , label : 'Arcade Day' , emoji : '👾' },
{ value : 'deepspace' , label : 'Deep Space' , emoji : '🚀' },
];
2026-06-15 01:14:56 -04:00
2026-10-25 02:07:23 -04:00
/**
* [Gitea #460] A picker grid behind one row: the current choice and a Change
* button. The big grids (27 backgrounds, 13 seasonal themes) used to be always
* open and made Appearance about 2.5 screens long. Closes after a choice.
*/
export function CollapsiblePicker ({
title ,
description ,
current ,
children ,
} : {
title : string ;
description? : ReactNode ;
current : string ;
children : ReactNode ;
}) {
const [ open , setOpen ] = useState ( false );
const [ openedWith , setOpenedWith ] = useState ( current );
useEffect (() => {
if ( open && current !== openedWith ) setOpen ( false );
}, [ open , current , openedWith ]);
const id = `picker- ${ title . replace ( /[^a-z0-9]+/gi , '-' ). toLowerCase () } ` ;
return (
<>
< SettingTile
title = { title }
description = { description }
after = {
< Box alignItems = "Center" gap = "200" shrink = "No" >
< Text size = "T300" priority = "300" >
{ current }
</ Text >
< Button
size = "300"
variant = "Secondary"
fill = "Soft"
radii = "300"
outlined
aria-expanded = { open }
aria-controls = { id }
onClick = {() => {
setOpenedWith ( current );
setOpen (( o ) => ! o );
}}
>
< Text size = "B300" >{ open ? 'Done' : 'Change' }</ Text >
</ Button >
</ Box >
}
/>
{ open && (
< Box id = { id } style = {{ padding : `0 ${ config . space . S400 } ${ config . space . S300 } ` }}>
{ children }
</ Box >
)}
</>
);
}
2026-06-15 01:14:56 -04:00
function SeasonalBgGrid ({
value ,
onChange ,
} : {
value : Settings [ 'seasonalThemeOverride' ];
onChange : ( v : Settings [ 'seasonalThemeOverride' ]) => void ;
}) {
return (
2026-06-26 16:21:33 -04:00
< Box
2026-06-27 21:30:21 -04:00
grow = "Yes"
2026-06-26 16:21:33 -04:00
style = {{
display : 'grid' ,
gridTemplateColumns : `repeat(auto-fill, minmax( ${ toRem ( 76 ) } , 1fr))` ,
gap : config.space.S200 ,
}}
>
2026-06-15 01:14:56 -04:00
{ SEASONAL_OPTIONS . map (( opt ) => {
const selected = value === opt . value ;
const isSpecial = opt . value === 'auto' || opt . value === 'off' ;
return (
< Box key = { opt . value } direction = "Column" gap = "100" style = {{ alignItems : 'center' }}>
< button
type = "button"
aria-label = { opt . label }
aria-pressed = { selected }
2026-06-19 21:01:57 -04:00
data-selected = { selected }
className = { BgSwatchStyle }
2026-06-15 01:14:56 -04:00
onClick = {() => onChange ( opt . value )}
style = {{
position : 'relative' ,
width : toRem ( 76 ),
height : toRem ( 56 ),
backgroundColor : '#030508' ,
}}
>
{ ! isSpecial && < SeasonalPreview theme = { opt . value as SeasonTheme } />}
< div
style = {{
position : 'absolute' ,
inset : 0 ,
display : 'flex' ,
alignItems : 'center' ,
justifyContent : 'center' ,
backgroundImage :
opt.value === 'auto'
? 'linear-gradient(135deg, rgba(255,100,0,0.2), rgba(255,200,0,0.2), rgba(0,200,100,0.2), rgba(0,100,255,0.2))'
: undefined ,
pointerEvents : 'none' ,
}}
>
{ isSpecial && (
< span style = {{ fontSize : '22px' , opacity : opt.value === 'off' ? 0.4 : 1 }}>
{ opt . emoji }
</ span >
)}
</ div >
</ button >
2026-06-18 22:46:19 -04:00
< Text size = "T200" style = { selected ? { color : color.Primary.Main } : undefined }>
2026-06-15 01:14:56 -04:00
{ opt . label }
</ Text >
2026-06-30 19:28:28 -04:00
{( opt . value === 'auto' || ! isSpecial ) && (
< Text size = "T200" style = {{ opacity : 0.6 , textAlign : 'center' }}>
{ opt . value === 'auto'
? 'By calendar'
: SEASON_DATE_RANGES [ opt . value as SeasonTheme ]}
</ Text >
)}
2026-06-15 01:14:56 -04:00
</ Box >
);
})}
</ Box >
);
}
2026-05-13 21:51:19 -04:00
function ChatBgGrid() {
2026-05-13 21:17:59 -04:00
const [ chatBackground , setChatBackground ] = useSetting ( settingsAtom , 'chatBackground' );
2026-06-18 10:37:44 -04:00
const [, setSeasonalThemeOverride ] = useSetting ( settingsAtom , 'seasonalThemeOverride' );
2026-06-05 11:46:16 -04:00
const [ pauseAnimations ] = useSetting ( settingsAtom , 'pauseAnimations' );
2026-05-13 21:51:19 -04:00
const theme = useTheme ();
const isDark = theme . kind === ThemeKind . Dark ;
2026-07-02 21:40:07 -04:00
const reduced = useReducedMotion ();
2026-05-13 21:17:59 -04:00
return (
2026-06-26 16:21:33 -04:00
< Box
2026-06-27 21:30:21 -04:00
grow = "Yes"
2026-06-26 16:21:33 -04:00
style = {{
display : 'grid' ,
gridTemplateColumns : `repeat(auto-fill, minmax( ${ toRem ( 76 ) } , 1fr))` ,
gap : config.space.S200 ,
}}
>
2026-05-13 21:51:19 -04:00
{ BG_OPTIONS . map (( opt ) => (
< Box key = { opt . value } direction = "Column" gap = "100" style = {{ alignItems : 'center' }}>
< button
type = "button"
aria-label = { opt . label }
aria-pressed = { chatBackground === opt . value }
2026-06-19 21:01:57 -04:00
data-selected = { chatBackground === opt . value }
className = { BgSwatchStyle }
2026-06-18 10:37:44 -04:00
onClick = {() => {
setChatBackground ( opt . value as ChatBackground );
if ( opt . value !== 'none' ) setSeasonalThemeOverride ( 'off' );
}}
2026-05-13 21:51:19 -04:00
style = {{
width : toRem ( 76 ),
height : toRem ( 50 ),
2026-07-02 21:40:07 -04:00
... getChatBg ( opt . value as ChatBackground , isDark , pauseAnimations || reduced ),
2026-05-13 21:17:59 -04:00
}}
2026-05-13 21:51:19 -04:00
/>
2026-06-01 21:38:35 -04:00
< Text
size = "T200"
2026-06-18 22:46:19 -04:00
style = { chatBackground === opt . value ? { color : color.Primary.Main } : undefined }
2026-06-01 21:38:35 -04:00
>
2026-05-13 21:51:19 -04:00
{ opt . label }
</ Text >
</ Box >
))}
</ Box >
2026-05-13 21:17:59 -04:00
);
}
2025-02-10 16:49:47 +11:00
function SelectMessageLayout() {
const [ menuCords , setMenuCords ] = useState < RectCords >();
const [ messageLayout , setMessageLayout ] = useSetting ( settingsAtom , 'messageLayout' );
const messageLayoutItems = useMessageLayoutItems ();
const handleMenu : MouseEventHandler < HTMLButtonElement > = ( evt ) => {
setMenuCords ( evt . currentTarget . getBoundingClientRect ());
};
const handleSelect = ( layout : MessageLayout ) => {
setMessageLayout ( layout );
setMenuCords ( undefined );
};
return (
<>
< Button
size = "300"
variant = "Secondary"
outlined
fill = "Soft"
radii = "300"
after = {< Icon size = "300" src = { Icons . ChevronBottom } />}
onClick = { handleMenu }
>
< Text size = "T300" >
{ messageLayoutItems . find (( i ) => i . layout === messageLayout ) ? . name ?? messageLayout }
</ Text >
</ Button >
< PopOut
anchor = { menuCords }
offset = { 5 }
position = "Bottom"
align = "End"
content = {
< FocusTrap
focusTrapOptions = {{
initialFocus : false ,
onDeactivate : () => setMenuCords ( undefined ),
clickOutsideDeactivates : true ,
isKeyForward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowDown' || evt . key === 'ArrowRight' ,
isKeyBackward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowUp' || evt . key === 'ArrowLeft' ,
escapeDeactivates : stopPropagation ,
}}
>
< Menu >
2025-08-04 20:29:12 +05:30
< Box direction = "Column" gap = "100" style = {{ padding : config.space.S100 }}>
2025-02-10 16:49:47 +11:00
{ messageLayoutItems . map (( item ) => (
< MenuItem
key = { item . layout }
size = "300"
variant = { messageLayout === item . layout ? 'Primary' : 'Surface' }
radii = "300"
onClick = {() => handleSelect ( item . layout )}
>
< Text size = "T300" >{ item . name }</ Text >
</ MenuItem >
))}
</ Box >
</ Menu >
</ FocusTrap >
}
/>
</>
);
}
function SelectMessageSpacing() {
const [ menuCords , setMenuCords ] = useState < RectCords >();
const [ messageSpacing , setMessageSpacing ] = useSetting ( settingsAtom , 'messageSpacing' );
const messageSpacingItems = useMessageSpacingItems ();
const handleMenu : MouseEventHandler < HTMLButtonElement > = ( evt ) => {
setMenuCords ( evt . currentTarget . getBoundingClientRect ());
};
const handleSelect = ( layout : MessageSpacing ) => {
setMessageSpacing ( layout );
setMenuCords ( undefined );
};
return (
<>
< Button
size = "300"
variant = "Secondary"
outlined
fill = "Soft"
radii = "300"
after = {< Icon size = "300" src = { Icons . ChevronBottom } />}
onClick = { handleMenu }
>
< Text size = "T300" >
{ messageSpacingItems . find (( i ) => i . spacing === messageSpacing ) ? . name ?? messageSpacing }
</ Text >
</ Button >
< PopOut
anchor = { menuCords }
offset = { 5 }
position = "Bottom"
align = "End"
content = {
< FocusTrap
focusTrapOptions = {{
initialFocus : false ,
onDeactivate : () => setMenuCords ( undefined ),
clickOutsideDeactivates : true ,
isKeyForward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowDown' || evt . key === 'ArrowRight' ,
isKeyBackward : ( evt : KeyboardEvent ) =>
evt . key === 'ArrowUp' || evt . key === 'ArrowLeft' ,
escapeDeactivates : stopPropagation ,
}}
>
< Menu >
2025-08-04 20:29:12 +05:30
< Box direction = "Column" gap = "100" style = {{ padding : config.space.S100 }}>
2025-02-10 16:49:47 +11:00
{ messageSpacingItems . map (( item ) => (
< MenuItem
key = { item . spacing }
size = "300"
variant = { messageSpacing === item . spacing ? 'Primary' : 'Surface' }
radii = "300"
onClick = {() => handleSelect ( item . spacing )}
>
< Text size = "T300" >{ item . name }</ Text >
</ MenuItem >
))}
</ Box >
</ Menu >
</ FocusTrap >
}
/>
</>
);
}
2026-10-25 02:07:23 -04:00
export function Messages() {
2025-02-10 16:49:47 +11:00
const [ hideMembershipEvents , setHideMembershipEvents ] = useSetting (
settingsAtom ,
2026-05-21 23:30:50 -04:00
'hideMembershipEvents' ,
2025-02-10 16:49:47 +11:00
);
const [ hideNickAvatarEvents , setHideNickAvatarEvents ] = useSetting (
settingsAtom ,
2026-05-21 23:30:50 -04:00
'hideNickAvatarEvents' ,
2025-02-10 16:49:47 +11:00
);
const [ mediaAutoLoad , setMediaAutoLoad ] = useSetting ( settingsAtom , 'mediaAutoLoad' );
2026-07-06 19:48:12 -04:00
const [ inlineMediaEmbeds , setInlineMediaEmbeds ] = useSetting ( settingsAtom , 'inlineMediaEmbeds' );
2026-07-03 11:23:14 -04:00
const [ enforceRetentionLocally , setEnforceRetentionLocally ] = useSetting (
settingsAtom ,
'enforceRetentionLocally' ,
);
2026-07-18 16:08:40 -04:00
const [ translateTargetLang , setTranslateTargetLang ] = useSetting (
settingsAtom ,
'translateTargetLang' ,
);
const [ autoTranslate , setAutoTranslate ] = useSetting ( settingsAtom , 'autoTranslate' );
2026-09-12 20:28:41 -04:00
const [ gifPickerEnabled , setGifPickerEnabled ] = useSetting ( settingsAtom , 'gifPickerEnabled' );
2026-09-25 15:50:22 -04:00
// No Giphy key in this build's config: the switch can't show a GIF button.
const gifAvailable = !! useClientConfig (). gifApiKey ;
2026-07-18 16:08:40 -04:00
const translationSupported = chromeTranslationEngine . isSupported ();
const selectedTargetLang = isSupportedTargetLang ( translateTargetLang )
? normalizeLang ( translateTargetLang )
: 'en' ;
2025-02-10 16:49:47 +11:00
return (
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Messages </ Text >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
2026-10-25 01:37:37 -04:00
< SettingTile title = "Message layout" after = {< SelectMessageLayout />} />
2025-02-10 16:49:47 +11:00
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
2026-10-25 01:37:37 -04:00
< SettingTile title = "Message spacing" after = {< SelectMessageSpacing />} />
2025-02-10 16:49:47 +11:00
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Hide joins and leaves"
2025-02-10 16:49:47 +11:00
after = {
< Switch
variant = "Primary"
value = { hideMembershipEvents }
onChange = { setHideMembershipEvents }
/>
}
/>
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Hide name and avatar changes"
2025-02-10 16:49:47 +11:00
after = {
< Switch
variant = "Primary"
value = { hideNickAvatarEvents }
onChange = { setHideNickAvatarEvents }
/>
}
/>
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Don't load media automatically"
2025-02-26 21:44:53 +11:00
after = {
< Switch
variant = "Primary"
value = { ! mediaAutoLoad }
onChange = {( v ) => setMediaAutoLoad ( ! v )}
/>
}
2025-02-10 16:49:47 +11:00
/>
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Inline media players"
2026-07-06 20:01:05 -04:00
description = "Play YouTube, Vimeo, TikTok, Twitch, Spotify and more right in the chat. Nothing loads from the third-party site until you press play."
2026-07-06 19:48:12 -04:00
after = {
< Switch variant = "Primary" value = { inlineMediaEmbeds } onChange = { setInlineMediaEmbeds } />
}
/>
</ SequenceCard >
2026-10-25 01:37:37 -04:00
{ /* [Gitea #457] Only where this build has a GIF key: a disabled switch
with a paragraph about missing configuration helps nobody. */ }
{ gifAvailable && (
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "GIF picker"
description = "Every search term (and your IP address) is sent directly to Giphy, not through your homeserver. Off by default."
after = {
< Switch variant = "Primary" value = { gifPickerEnabled } onChange = { setGifPickerEnabled } />
}
/>
</ SequenceCard >
)}
2026-07-03 11:23:14 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Enforce message retention"
2026-07-03 11:23:14 -04:00
description = "Permanently delete your own messages once a room's retention window (Room Settings → Message Retention) has passed. Off by default; only affects your own messages."
after = {
< Switch
variant = "Primary"
value = { enforceRetentionLocally }
onChange = { setEnforceRetentionLocally }
/>
}
/>
</ SequenceCard >
2026-10-19 15:06:20 -04:00
< SequenceCard
className = { ` ${ SequenceCardStyle } ${ SettingTileGroup } ` }
variant = "SurfaceVariant"
direction = "Column"
>
2026-07-18 16:08:40 -04:00
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Translate messages into"
2026-07-18 16:08:40 -04:00
description = {
translationSupported
? 'Translate messages written in other languages into this one. Runs entirely on your device — message text never leaves your computer or touches a cloud service.'
2026-10-18 00:19:48 -04:00
: translationUnavailableText ( isTauriEnv ())
2026-07-18 16:08:40 -04:00
}
after = {
2026-07-18 22:38:01 -04:00
< SettingsSelect
2026-07-18 16:08:40 -04:00
value = { selectedTargetLang }
2026-07-18 22:38:01 -04:00
onChange = {( v ) => setTranslateTargetLang ( v )}
disabled = { ! translationSupported }
aria-label = "Translate messages into"
options = { TRANSLATE_TARGET_LANGUAGES . map (( l ) => ({ value : l.code , label : l.name }))}
/>
2026-07-18 16:08:40 -04:00
}
/>
{ translationSupported && (
< SettingTile
2026-10-25 01:37:37 -04:00
title = "Auto-translate incoming messages"
2026-07-18 16:08:40 -04:00
description = "Automatically translate messages that aren’ t already in your language. When off, translate individual messages from their menu. The first time a language is used, its model downloads once (a few MB)."
after = {< Switch variant = "Primary" value = { autoTranslate } onChange = { setAutoTranslate } />}
/>
)}
</ SequenceCard >
2025-02-10 16:49:47 +11:00
</ Box >
);
}
2026-09-23 20:52:16 -04:00
const formatMb = ( bytes : number ) : string => ` ${ ( bytes / 1 _048_576 ). toFixed ( 1 ) } MB` ;
function updateProgressText ( progress : UpdateProgress | undefined ) : string {
if ( ! progress ) return 'Checking for the update…' ;
if ( progress . phase === 'installing' ) return 'Installing — Lotus Chat will restart in a moment…' ;
if ( progress . phase === 'retrying' ) {
return `The update server didn’ t respond. Trying again in ${ progress . waitSecs } s (attempt ${ progress . attempt + 1 } of ${ progress . maxAttempts } )…` ;
}
const attempt =
progress . attempt > 1 ? ` (attempt ${ progress . attempt } of ${ progress . maxAttempts } )` : '' ;
const { downloaded , total } = progress ;
if ( ! total ) return `Downloading update… ${ formatMb ( downloaded ) }${ attempt } ` ;
const pct = Math . min ( 100 , Math . floor (( downloaded / total ) * 100 ));
return `Downloading update… ${ pct } % ( ${ formatMb ( downloaded ) } of ${ formatMb ( total ) } ) ${ attempt } ` ;
}
2026-09-30 19:00:10 -04:00
/**
* A Linux package install is updated with its package manager (the in-app
* updater can't write to /usr/bin): the command, Copy and a download link.
*/
function PackageUpdate ({ help } : { help : NonNullable < ReturnType < typeof packageUpdateHelp >> }) {
const [ copied , setCopied ] = useState < 'no' | 'yes' | 'failed' > ( 'no' );
const copy = () => {
const text = help . command ?? '' ;
if ( ! navigator . clipboard ) {
copyToClipboard ( text );
setCopied ( 'yes' );
return ;
}
navigator . clipboard . writeText ( text ). then (
() => setCopied ( 'yes' ),
() => setCopied ( 'failed' ),
);
};
let copyLabel = 'Copy command' ;
if ( copied === 'yes' ) copyLabel = 'Copied' ;
else if ( copied === 'failed' ) copyLabel = 'Copy failed: select it above' ;
return (
< Box direction = "Column" gap = "200" >
< Text size = "T200" >
Lotus Chat was installed as a system package , so update it the same way
{ help . command ? ' (your chats and settings are kept):' : '.' }
</ Text >
{ help . command && (
< Text
size = "T200"
style = {{ fontFamily : 'monospace' , wordBreak : 'break-all' , userSelect : 'all' }}
>
{ help . command }
</ Text >
)}
< Box gap = "200" wrap = "Wrap" >
{ help . command && (
< Button size = "300" radii = "300" variant = "Secondary" onClick = { copy }>
< Text size = "B300" >{ copyLabel }</ Text >
</ Button >
)}
< Button
size = "300"
radii = "300"
variant = "Secondary"
fill = "None"
outlined
onClick = {() => window . open ( help . url , '_blank' )}
>
< Text size = "B300" >{ help . download }</ Text >
</ Button >
</ Box >
</ Box >
);
}
2026-10-18 00:28:12 -04:00
/**
* [Gitea #290] Desktop-only settings in their own section (they used to sit
* inside Appearance, between Monochrome Mode and Twitter Emoji). Renders
* nothing outside the desktop app.
*/
2026-10-25 02:07:23 -04:00
export function DesktopSettings() {
2026-10-18 00:28:12 -04:00
if ( ! isTauriEnv ()) return null ;
return (
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Desktop </ Text >
< AutostartSetting />
< KeychainMirrorSetting />
< DesktopChromeSetting />
</ Box >
);
}
2026-10-25 02:07:23 -04:00
export function AppUpdates() {
2026-09-30 19:00:10 -04:00
const { isTauri , status , check , install , installKind } = useTauriUpdater ();
2026-06-10 20:31:35 -04:00
if ( ! isTauri ) return null ;
2026-09-30 19:00:10 -04:00
const packageHelp = packageUpdateHelp ( installKind );
const packageUpdate =
!! packageHelp &&
( status . state === 'available' ||
( status . state === 'error' && isPackageManagedError ( status . message )));
const description = packageUpdate
? status . state === 'available'
? `Update available: v ${ status . version } `
: 'An update is available.'
: status . state === 'checking'
2026-06-10 20:31:35 -04:00
? 'Checking for updates...'
: status . state === 'up-to-date'
? 'Lotus Chat is up to date.'
: status . state === 'available'
? `Update available: v ${ status . version } `
: status . state === 'installing'
2026-09-23 20:52:16 -04:00
? updateProgressText ( status . progress )
2026-06-10 20:31:35 -04:00
: status . state === 'error'
2026-09-23 20:52:16 -04:00
? describeUpdateError ( status . phase , status . message )
2026-06-10 20:31:35 -04:00
: 'Check for a new version of Lotus Chat.' ;
2026-09-23 20:52:16 -04:00
const retry = () => {
if ( status . state === 'error' && status . phase !== 'check' ) install ();
else check ();
};
2026-09-30 19:00:10 -04:00
const after = packageUpdate ? undefined : status . state === 'available' ? (
< Button size = "300" radii = "300" onClick = {() => install ()}>
< Text size = "B300" > Install & amp ; Restart </ Text >
</ Button >
) : status . state === 'checking' || status . state === 'installing' ? (
< Spinner variant = "Secondary" size = "200" />
) : status . state === 'error' ? (
< Box gap = "200" wrap = "Wrap" justifyContent = "End" >
< Button size = "300" radii = "300" variant = "Secondary" onClick = { retry }>
< Text size = "B300" > Try again </ Text >
2026-06-10 20:31:35 -04:00
</ Button >
2026-09-30 19:00:10 -04:00
{ status . phase !== 'check' && (
< Button
size = "300"
radii = "300"
variant = "Secondary"
fill = "None"
outlined
onClick = {() => window . open ( manualDownloadUrl ( navigator . userAgent ), '_blank' )}
>
< Text size = "B300" > Download installer </ Text >
2026-09-23 20:52:16 -04:00
</ Button >
2026-09-30 19:00:10 -04:00
)}
</ Box >
) : (
< Button size = "300" radii = "300" variant = "Secondary" onClick = { check }>
< Text size = "B300" > Check </ Text >
</ Button >
);
2026-06-10 20:31:35 -04:00
return (
< Box direction = "Column" gap = "100" >
2026-10-25 01:37:37 -04:00
< Text size = "L400" > App updates </ Text >
2026-06-10 20:31:35 -04:00
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
2026-10-25 01:37:37 -04:00
< SettingTile title = "Check for updates" description = { description } after = { after } />
2026-09-30 19:00:10 -04:00
{ packageUpdate && packageHelp && < PackageUpdate help = { packageHelp } />}
{ status . state === 'error' && ! packageUpdate && (
2026-09-23 20:52:16 -04:00
< Text size = "T200" priority = "300" style = {{ wordBreak : 'break-word' }}>
Details : { status . message }
</ Text >
)}
2026-06-10 20:31:35 -04:00
</ SequenceCard >
</ Box >
);
}
2025-02-10 16:49:47 +11:00
type GeneralProps = {
requestClose : () => void ;
};
2026-10-25 02:07:23 -04:00
/** [Gitea #459] Display options for people who want to see the plumbing. */
export function AdvancedDisplayOptions() {
const [ legacyUsernameColor , setLegacyUsernameColor ] = useSetting (
settingsAtom ,
'legacyUsernameColor' ,
);
const [ showHiddenEvents , setShowHiddenEvents ] = useSetting ( settingsAtom , 'showHiddenEvents' );
return (
< Box direction = "Column" gap = "100" >
< Text size = "L400" > Display </ Text >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Legacy username colour"
after = {
< Switch
variant = "Primary"
value = { legacyUsernameColor }
onChange = { setLegacyUsernameColor }
/>
}
/>
</ SequenceCard >
< SequenceCard className = { SequenceCardStyle } variant = "SurfaceVariant" direction = "Column" >
< SettingTile
title = "Show hidden events"
after = {
< Switch variant = "Primary" value = { showHiddenEvents } onChange = { setShowHiddenEvents } />
}
/>
</ SequenceCard >
</ Box >
);
}
/**
* [Gitea #459] General used to hold 76 of the ~110 settings (11 screens). Its
* sections now live on pages named for what people come to do; Privacy goes
* to Privacy & security (devices/Devices.tsx) and the display plumbing to
* Advanced (developer-tools).
*/
function SectionPage ({
title ,
requestClose ,
children ,
} : GeneralProps & { title : string ; children : ReactNode }) {
2025-02-10 16:49:47 +11:00
return (
< Page >
< PageHeader outlined = { false }>
< Box grow = "Yes" gap = "200" >
< Box grow = "Yes" alignItems = "Center" gap = "200" >
< Text size = "H3" truncate >
2026-10-25 02:07:23 -04:00
{ title }
2025-02-10 16:49:47 +11:00
</ Text >
</ Box >
< Box shrink = "No" >
2026-05-20 21:54:33 -04:00
< IconButton onClick = { requestClose } variant = "Surface" aria-label = "Close" >
2025-02-10 16:49:47 +11:00
< Icon src = { Icons . Cross } />
</ IconButton >
</ Box >
</ Box >
</ PageHeader >
< Box grow = "Yes" >
< Scroll hideTrack visibility = "Hover" >
< PageContent >
< Box direction = "Column" gap = "700" >
2026-10-25 02:07:23 -04:00
{ children }
2025-02-10 16:49:47 +11:00
</ Box >
</ PageContent >
</ Scroll >
</ Box >
</ Page >
);
}
2026-10-25 02:07:23 -04:00
export function AppearancePage ({ requestClose } : GeneralProps ) {
return (
< SectionPage title = "Appearance" requestClose = { requestClose }>
< Appearance />
</ SectionPage >
);
}
export function MessagesPage ({ requestClose } : GeneralProps ) {
return (
< SectionPage title = "Messages" requestClose = { requestClose }>
< Messages />
< Editor />
< DateAndTime />
</ SectionPage >
);
}
export function CallsPage ({ requestClose } : GeneralProps ) {
return (
< SectionPage title = "Calls & audio" requestClose = { requestClose }>
< Calls />
</ SectionPage >
);
}
export function DataStoragePage ({ requestClose } : GeneralProps ) {
return (
< SectionPage title = "Data & storage" requestClose = { requestClose }>
< StorageUsage />
< SettingsSyncSection />
< YourDataSection />
</ SectionPage >
);
}
/** Desktop app only (the menu hides it elsewhere). */
export function DesktopPage ({ requestClose } : GeneralProps ) {
return (
< SectionPage title = "Desktop" requestClose = { requestClose }>
< DesktopSettings />
< AppUpdates />
</ SectionPage >
);
}