From 1637d7de8f70d606487baa03b989b94a0401c688 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Wed, 1 Apr 2026 05:57:01 +0000 Subject: [PATCH] fix: preserve tab ownership filter across category and search changes in script library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setCategory and setSearch called loadTemplates() with no arguments, dropping the mine/shared filter set by the active tab — causing the list to show all templates instead of the current user's scripts after any filter interaction. Store now persists tabFilters whenever loadTemplates is called with explicit filters, and reuses them for subsequent no-arg calls from setCategory/setSearch. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/store/scriptGeneratorStore.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/store/scriptGeneratorStore.ts b/frontend/src/store/scriptGeneratorStore.ts index 4cee1aa5..5cb1cdab 100644 --- a/frontend/src/store/scriptGeneratorStore.ts +++ b/frontend/src/store/scriptGeneratorStore.ts @@ -14,6 +14,7 @@ interface ScriptGeneratorState { selectedTemplate: ScriptTemplateDetail | null searchQuery: string activeCategoryId: string | null // null = "All" + tabFilters: { mine?: boolean; shared?: boolean } // current tab's ownership filter isLoadingTemplates: boolean // drives skeleton in ScriptTemplateList isLoadingDetail: boolean // drives spinner in ScriptConfigurePane @@ -48,6 +49,7 @@ export const useScriptGeneratorStore = create()((set, get) selectedTemplate: null, searchQuery: '', activeCategoryId: null, + tabFilters: {}, isLoadingTemplates: false, isLoadingDetail: false, paramValues: {}, @@ -68,6 +70,10 @@ export const useScriptGeneratorStore = create()((set, get) }, loadTemplates: async (filters) => { + // When filters are provided (e.g. tab change), persist them so that + // subsequent setCategory/setSearch calls reuse the same ownership filter. + const resolvedFilters = filters !== undefined ? filters : get().tabFilters + if (filters !== undefined) set({ tabFilters: filters }) set({ isLoadingTemplates: true }) try { const { activeCategoryId, categories, searchQuery } = get() @@ -75,8 +81,8 @@ export const useScriptGeneratorStore = create()((set, get) const params: { category_slug?: string; search?: string; mine?: boolean; shared?: boolean } = {} if (category) params.category_slug = category.slug if (searchQuery) params.search = searchQuery - if (filters?.mine) params.mine = true - if (filters?.shared) params.shared = true + if (resolvedFilters.mine) params.mine = true + if (resolvedFilters.shared) params.shared = true const templates = await scriptsApi.getTemplates(params) set({ templates, isLoadingTemplates: false }) } catch {