diff --git a/apps/desktop/src/app/command-center/index.tsx b/apps/desktop/src/app/command-center/index.tsx index ab459599be7..14fe739f2f3 100644 --- a/apps/desktop/src/app/command-center/index.tsx +++ b/apps/desktop/src/app/command-center/index.tsx @@ -12,7 +12,6 @@ import type { ActionStatusResponse, AnalyticsResponse, StatusResponse } from '@/ import { useI18n } from '@/i18n' import { sessionTitle } from '@/lib/chat-runtime' import { compactNumber } from '@/lib/format' -import { useStoreSelector } from '@/lib/use-session-slice' import { Activity, AlertCircle, @@ -26,6 +25,7 @@ import { } from '@/lib/icons' import { exportSession } from '@/lib/session-export' import { fmtDateTime } from '@/lib/time' +import { useStoreSelector } from '@/lib/use-session-slice' import { cn } from '@/lib/utils' import { upsertDesktopActionTask } from '@/store/activity' import { $pinnedSessionIds, pinSession, unpinSession } from '@/store/layout' @@ -318,7 +318,7 @@ export function CommandCenterView({ initialSection, onClose, onDeleteSession, on label: cc.sections[value], onSelect: () => setSection(value) })), - [cc, section] + [cc, section, setSection] ) return ( diff --git a/apps/desktop/src/app/command-palette/index.tsx b/apps/desktop/src/app/command-palette/index.tsx index 8d22cf99aea..b9e9944685f 100644 --- a/apps/desktop/src/app/command-palette/index.tsx +++ b/apps/desktop/src/app/command-palette/index.tsx @@ -1,7 +1,7 @@ import { useStore } from '@nanostores/react' import { useQuery } from '@tanstack/react-query' import { Dialog as DialogPrimitive } from 'radix-ui' -import { useCallback, useEffect, useMemo, useRef, useState, memo } from 'react' +import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useNavigate } from 'react-router-dom' import { HUD_HEADING, HUD_ITEM, HUD_POSITION, HUD_SURFACE, HUD_TEXT } from '@/app/floating-hud' diff --git a/apps/desktop/src/app/settings/index.tsx b/apps/desktop/src/app/settings/index.tsx index 8204dc35836..3411a749d19 100644 --- a/apps/desktop/src/app/settings/index.tsx +++ b/apps/desktop/src/app/settings/index.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useRef } from 'react' +import { useCallback, useEffect, useMemo, useRef } from 'react' import { useLocation, useNavigate } from 'react-router-dom' import { codiconIcon } from '@/components/ui/codicon' @@ -85,22 +85,29 @@ export function SettingsView({ onClose, onConfigSaved, onMainModelChanged }: Set // Jump to a section + its sub-view in one navigate. Two sequential setters // would each read the same stale `search` and the second would clobber the // first's `tab` — so the sub-view never opened on narrow screens. - const openSubView = (tab: SettingsViewId, param: string, value: string, fallback: string) => { - const params = new URLSearchParams(search) - params.set('tab', tab) + const openSubView = useCallback( + (tab: SettingsViewId, param: string, value: string, fallback: string) => { + const params = new URLSearchParams(search) + params.set('tab', tab) - if (value === fallback) { - params.delete(param) - } else { - params.set(param, value) - } + if (value === fallback) { + params.delete(param) + } else { + params.set(param, value) + } - const qs = params.toString() - navigate({ hash, pathname, search: qs ? `?${qs}` : '' }, { replace: true }) - } + const qs = params.toString() + navigate({ hash, pathname, search: qs ? `?${qs}` : '' }, { replace: true }) + }, + [hash, navigate, pathname, search] + ) - const openProviderView = (view: ProviderView) => openSubView('providers', 'pview', view, 'accounts') - const openKeysView = (view: KeysView) => openSubView('keys', 'kview', view, 'tools') + const openProviderView = useCallback( + (view: ProviderView) => openSubView('providers', 'pview', view, 'accounts'), + [openSubView] + ) + + const openKeysView = useCallback((view: KeysView) => openSubView('keys', 'kview', view, 'tools'), [openSubView]) const importInputRef = useRef(null) @@ -251,7 +258,7 @@ export function SettingsView({ onClose, onConfigSaved, onMainModelChanged }: Set onSelect: () => setActiveView('about') } ] - , [activeView, keysView, providerView, t]) + , [activeView, keysView, providerView, t, setActiveView, openProviderView, openKeysView]) const navFooter = ( <> diff --git a/apps/desktop/src/app/skills/index.tsx b/apps/desktop/src/app/skills/index.tsx index 0c6e380d9d2..a05f762ae8c 100644 --- a/apps/desktop/src/app/skills/index.tsx +++ b/apps/desktop/src/app/skills/index.tsx @@ -16,17 +16,16 @@ import { getSkills, getToolsets, getUsageAnalytics, - type HermesGateway, toggleSkill, toggleToolset } from '@/hermes' import { useI18n } from '@/i18n' import { isDesktopToolsetVisible } from '@/lib/desktop-toolsets' import { compactNumber } from '@/lib/format' -import { useStoreSelector } from '@/lib/use-session-slice' import { queryClient, writeCache } from '@/lib/query-client' import { invalidateSlashCompletions } from '@/lib/slash-completion-cache' import { normalize } from '@/lib/text' +import { useStoreSelector } from '@/lib/use-session-slice' import { $gateway } from '@/store/gateway' import { notify, notifyError } from '@/store/notifications' import { $activeGatewayProfile, normalizeProfileKey } from '@/store/profile'