diff --git a/src/renderer/src/store/slices/ui.test.ts b/src/renderer/src/store/slices/ui.test.ts index 6ce09091872..70e4a70b166 100644 --- a/src/renderer/src/store/slices/ui.test.ts +++ b/src/renderer/src/store/slices/ui.test.ts @@ -10,6 +10,7 @@ import type { } from '../../../../shared/types' import { createUISlice } from './ui' import { createWorktreeNavHistorySlice } from './worktree-nav-history' +import { createSettingsSearchState } from './settings-search-state' import type { AppState } from '../types' import type { FeatureInteractionState } from '../../../../shared/feature-interactions' @@ -28,6 +29,7 @@ function createUIStore(): StoreApi { worktreesByRepo: {}, rightSidebarOpen: false, rightSidebarWidth: 280, + ...createSettingsSearchState(args[0]), ...createWorktreeNavHistorySlice(...(args as Parameters)), ...createUISlice(...(args as Parameters)) })) as unknown as StoreApi @@ -680,6 +682,17 @@ describe('createUISlice settings navigation', () => { expect(store.getState().activeView).toBe('tasks') }) + + it('clears transient settings search when opening settings', () => { + const store = createUIStore() + + store.setState({ settingsSearchInputQuery: 'terminal', settingsSearchQuery: 'terminal' }) + store.getState().openSettingsPage() + + expect(store.getState().activeView).toBe('settings') + expect(store.getState().settingsSearchInputQuery).toBe('') + expect(store.getState().settingsSearchQuery).toBe('') + }) }) describe('createUISlice page navigation history', () => { diff --git a/src/renderer/src/store/slices/ui.ts b/src/renderer/src/store/slices/ui.ts index 4f5953d9f92..8a36b48bd6b 100644 --- a/src/renderer/src/store/slices/ui.ts +++ b/src/renderer/src/store/slices/ui.ts @@ -894,7 +894,10 @@ export const createUISlice: StateCreator = (set, get) })), setNewWorkspaceDraft: (draft) => set({ newWorkspaceDraft: draft }), clearNewWorkspaceDraft: () => set({ newWorkspaceDraft: null }), - openSettingsPage: () => + openSettingsPage: () => { + // Why: settings search is a transient page filter; opening Settings + // should never inherit hidden sections from the previous visit. + get().setSettingsSearchQuery('') set((state) => ({ activeView: 'settings', // Why: Settings is a temporary detour from either terminal or the @@ -903,7 +906,8 @@ export const createUISlice: StateCreator = (set, get) // dumping the user into terminal. previousViewBeforeSettings: state.activeView === 'settings' ? state.previousViewBeforeSettings : state.activeView - })), + })) + }, closeSettingsPage: () => set((state) => { const previousView =