diff --git a/app/(main)/[locale]/settings/page.tsx b/app/(main)/[locale]/settings/page.tsx index a8168a35..8476e27f 100644 --- a/app/(main)/[locale]/settings/page.tsx +++ b/app/(main)/[locale]/settings/page.tsx @@ -336,6 +336,14 @@ const LEGACY_TAB_MAP: Record = { function readPersistedTab(): Tab { try { + // One-shot deep link from the sidebar section gears (Folders / Tags). + // Used only as the initial tab and intentionally NOT written to + // 'settings-active-tab', so a gear click never becomes the persisted + // default that the regular Settings button lands on. Cleared on mount. + const deepLink = sessionStorage.getItem('settings-deep-link-tab'); + if (deepLink) { + return (deepLink in LEGACY_TAB_MAP ? LEGACY_TAB_MAP[deepLink] : deepLink) as Tab; + } const saved = localStorage.getItem('settings-active-tab'); if (!saved) return 'appearance'; if (saved in LEGACY_TAB_MAP) { @@ -361,6 +369,11 @@ export default function SettingsPage() { const { stalwartFeaturesEnabled } = useConfig(); const { isFeatureEnabled } = usePolicyStore(); const [activeTab, setActiveTab] = useState(readPersistedTab); + // Consume the one-shot deep-link key so a section gear only steers this one + // open, never the persisted default for future Settings-button clicks. + useEffect(() => { + try { sessionStorage.removeItem('settings-deep-link-tab'); } catch { /* ignore */ } + }, []); const [mobileShowContent, setMobileShowContent] = useState(false); const [searchQuery, setSearchQuery] = useState(''); const [pendingHighlight, setPendingHighlight] = useState<{ tab: Tab; label: string; pluginId?: string } | null>(null); @@ -934,7 +947,7 @@ export default function SettingsPage() { return (