From e31faf2f5aefcea00c88b1b965292babe84f7513 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Mon, 20 Jul 2026 11:51:03 +0200 Subject: [PATCH] feat(settings): hide desktop section on tauri mobile and web Desktop settings only apply on tauri desktop (linux/macos/windows). Filter the section from the settings menu and profile menu, and redirect direct /settings/desktop routes to the index on other platforms. Mirrors the existing persona-section guard. --- .../hide-desktop-settings-tauri-mobile.md | 5 +++++ src/app/features/settings/Settings.tsx | 17 ++++++++++++++--- src/app/features/settings/SettingsRoute.tsx | 11 +++++++++-- src/app/pages/client/profile/Profile.tsx | 9 +++++++-- src/app/utils/platform.ts | 7 +++++++ 5 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 .changeset/hide-desktop-settings-tauri-mobile.md diff --git a/.changeset/hide-desktop-settings-tauri-mobile.md b/.changeset/hide-desktop-settings-tauri-mobile.md new file mode 100644 index 0000000000..4c95d16ef9 --- /dev/null +++ b/.changeset/hide-desktop-settings-tauri-mobile.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Hide the desktop settings section on Tauri mobile and web. diff --git a/src/app/features/settings/Settings.tsx b/src/app/features/settings/Settings.tsx index a66ce3fe64..514f4be9f7 100644 --- a/src/app/features/settings/Settings.tsx +++ b/src/app/features/settings/Settings.tsx @@ -62,6 +62,7 @@ import { useSettingsFocus } from './useSettingsFocus'; import { SettingsLinkProvider } from './SettingsLinkContext'; import { useSettingsLinkBaseUrl } from './useSettingsLinkBaseUrl'; import { Desktop } from './desktop'; +import { isDesktopTauri } from '$utils/platform'; export enum SettingsPages { GeneralPage, @@ -192,6 +193,7 @@ export function Settings({ : undefined; const [showPersona] = useSetting(settingsAtom, 'showPersonaSetting'); + const isDesktop = isDesktopTauri(); const settingsLinkBaseUrl = useSettingsLinkBaseUrl(); const screenSize = useScreenSizeContext(); const isControlled = activeSection !== undefined; @@ -200,6 +202,9 @@ export function Settings({ if (initialPage === SettingsPages.PerMessageProfilesPage && !showPersona) { return SettingsPages.GeneralPage; } + if (initialPage === SettingsPages.DesktopPage && !isDesktop) { + return SettingsPages.GeneralPage; + } if (initialPage) return initialPage; return screenSize === ScreenSize.Mobile ? undefined : SettingsPages.GeneralPage; }); @@ -215,18 +220,24 @@ export function Settings({ if (section === 'persona' && !showPersona) { return 'general'; } + if (section === 'desktop' && !isDesktop) { + return 'general'; + } return section; - }, [activeSection, isControlled, legacyActivePage, showPersona]); + }, [activeSection, isControlled, legacyActivePage, showPersona, isDesktop]); const menuItems = useMemo( () => settingsSections - .filter((section) => showPersona || section.id !== 'persona') + .filter( + (section) => + (showPersona || section.id !== 'persona') && (isDesktop || section.id !== 'desktop') + ) .map((section) => { const icon = settingsMenuIcons[section.id]; return { id: section.id, name: section.label, ...icon }; }), - [showPersona] + [showPersona, isDesktop] ); const handleSelectSection = (section: SettingsSectionId) => { diff --git a/src/app/features/settings/SettingsRoute.tsx b/src/app/features/settings/SettingsRoute.tsx index 33044d8337..d6349e807e 100644 --- a/src/app/features/settings/SettingsRoute.tsx +++ b/src/app/features/settings/SettingsRoute.tsx @@ -4,6 +4,7 @@ import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize'; import { getSettingsPath } from '$pages/pathUtils'; import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; +import { isDesktopTauri } from '$utils/platform'; import { trimTrailingSlash } from '$utils/common'; import { getSettingsCloseTarget, type SettingsRouteState } from './navigation'; import { Settings } from './Settings'; @@ -12,7 +13,8 @@ import { isSettingsSectionId, type SettingsSectionId } from './routes'; function resolveSettingsSection( section: string | undefined, screenSize: ScreenSize, - showPersona: boolean + showPersona: boolean, + showDesktop: boolean ): SettingsSectionId | null { if (section === undefined) { return screenSize === ScreenSize.Mobile ? null : 'general'; @@ -26,6 +28,10 @@ function resolveSettingsSection( return null; } + if (section === 'desktop' && !showDesktop) { + return null; + } + return section; } @@ -40,6 +46,7 @@ export function SettingsRoute({ routeSection }: SettingsRouteProps) { const location = useLocation(); const screenSize = useScreenSizeContext(); const [showPersona] = useSetting(settingsAtom, 'showPersonaSetting'); + const showDesktop = isDesktopTauri(); const routeState = location.state as SettingsRouteState | null; const shallowBackgroundState = screenSize !== ScreenSize.Mobile && Boolean(routeState?.backgroundLocation); @@ -55,7 +62,7 @@ export function SettingsRoute({ routeSection }: SettingsRouteProps) { (typeof browserHistoryIndex === 'number' && browserHistoryIndex > 0) || location.key !== 'default'; - const activeSection = resolveSettingsSection(section, screenSize, showPersona); + const activeSection = resolveSettingsSection(section, screenSize, showPersona, showDesktop); const shouldRedirectToGeneral = section === undefined && screenSize !== ScreenSize.Mobile; const shouldRedirectToIndex = section !== undefined && activeSection === null; diff --git a/src/app/pages/client/profile/Profile.tsx b/src/app/pages/client/profile/Profile.tsx index 2c40ac5ff4..cf265d0f4f 100644 --- a/src/app/pages/client/profile/Profile.tsx +++ b/src/app/pages/client/profile/Profile.tsx @@ -34,6 +34,7 @@ import { useUserPresence } from '$hooks/useUserPresence'; import { useUserProfile } from '$hooks/useUserProfile'; import type { SettingsMenuItem } from '$features/settings'; import { settingsMenuIcons, settingsSections, useOpenSettings } from '$features/settings'; +import { isDesktopTauri } from '$utils/platform'; import { UserQuickTools } from '../sidebar/UserQuickTools'; import { CaretDownIcon, @@ -82,15 +83,19 @@ export function ProfileMobile() { const hideText = curWidth <= 80 && !isMobile; const [showPersona] = useSetting(settingsAtom, 'showPersonaSetting'); + const isDesktop = isDesktopTauri(); const menuItems = useMemo( () => settingsSections - .filter((section) => showPersona || section.id !== 'persona') + .filter( + (section) => + (showPersona || section.id !== 'persona') && (isDesktop || section.id !== 'desktop') + ) .map((section) => { const icon = settingsMenuIcons[section.id]; return { id: section.id, name: section.label, ...icon }; }), - [showPersona] + [showPersona, isDesktop] ); return ( diff --git a/src/app/utils/platform.ts b/src/app/utils/platform.ts index d5bf964bb7..cfec9cbe25 100644 --- a/src/app/utils/platform.ts +++ b/src/app/utils/platform.ts @@ -1,10 +1,17 @@ import { isTauri } from '@tauri-apps/api/core'; +import { type as osType } from '@tauri-apps/plugin-os'; export function hasServiceWorker(): boolean { // Android WebViews (Tauri) do not support service workers. return 'serviceWorker' in navigator && !isTauri(); } +const DESKTOP_TAURI_OS = new Set(['linux', 'macos', 'windows']); + +export function isDesktopTauri(): boolean { + return isTauri() && DESKTOP_TAURI_OS.has(osType()); +} + export function hasControllingServiceWorker(): boolean { return hasServiceWorker() && navigator.serviceWorker.controller !== null; }