diff --git a/frontend/src/components/ui/data-table.tsx b/frontend/src/components/ui/data-table.tsx index 6a9e0caa..c4c77a0f 100644 --- a/frontend/src/components/ui/data-table.tsx +++ b/frontend/src/components/ui/data-table.tsx @@ -111,6 +111,16 @@ interface DataTableProps { * one DataTable. Pages that mount multiple DataTables on the same route * (e.g. `/settings/prompts`) must pass distinct keys per instance, or * their persisted state will alias and overwrite each other. + * + * Recommended composition for multi-table routes — take the route base + * through `usePageStorageKeys` and append a per-table suffix instead of + * hard-coding the `table_4_` prefix: + * + * ```tsx + * const { table: base } = usePageStorageKeys(); + * + * + * ``` */ storageKey?: string; } diff --git a/frontend/src/pages/settings/settings-prompts.tsx b/frontend/src/pages/settings/settings-prompts.tsx index 5e2dcbdf..508d2871 100644 --- a/frontend/src/pages/settings/settings-prompts.tsx +++ b/frontend/src/pages/settings/settings-prompts.tsx @@ -35,6 +35,7 @@ import { } from '@/components/ui/dropdown-menu'; import { StatusCard } from '@/components/ui/status-card'; import { useDeletePromptMutation, useSettingsPromptsQuery } from '@/graphql/types'; +import { usePageStorageKeys } from '@/hooks/use-page-storage-keys'; // Types for table data type AgentPromptTableData = { displayName: string; // Formatted display name @@ -69,6 +70,10 @@ const SettingsPrompts = () => { const { data, error, loading: isLoading } = useSettingsPromptsQuery(); const [deletePrompt, { loading: isDeleteLoading }] = useDeletePromptMutation(); const navigate = useNavigate(); + // Shared base key for the route; each DataTable appends its own suffix so + // sorting / column visibility / search-column narrowing live in distinct + // slots even though the page mounts two tables. + const { table: tableStorageBase } = usePageStorageKeys(); // Reset dialog states const [resetDialogOpen, setResetDialogOpen] = useState(false); @@ -860,7 +865,7 @@ const SettingsPrompts = () => { initialPageSize={1000} renderRowContextMenu={renderAgentRowContextMenu} renderSubComponent={renderAgentSubComponent} - storageKey="table_4_/settings/prompts:agents" + storageKey={`${tableStorageBase}:agents`} /> )} @@ -881,7 +886,7 @@ const SettingsPrompts = () => { initialPageSize={1000} renderRowContextMenu={renderToolRowContextMenu} renderSubComponent={renderToolSubComponent} - storageKey="table_4_/settings/prompts:tools" + storageKey={`${tableStorageBase}:tools`} /> )}