Fix sidebar state persistence - #826
Open
Creylay wants to merge 6 commits into
Open
Conversation
… add related tests
…lapsibleList components
…oks in multiple languages
…te management for open sections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two related bugs in the left sidebar across the Datasets, Models, and Generative modules: (1)
datasets/folderswere fetched and held independently by the Datasets and Models modules, so changes made in one wouldn't show up in the other without a full remount; (2) sidebar UI state (which session/task groups and which dataset folders were expanded) lived in leaf components that unmount on every route change, so it silently reset to closed/default every time the user navigated away and back. Both are fixed by lifting the shared data into oneDatasetsProvidermounted at the app root, mountingModelsProvider/GenerativeProviderat the root too, and making the group/folder list components controlled so their open/closed state lives in these persisted contexts instead of local component state.Type of Change
Check all that apply like this [x]:
Changes (by file)
src/contexts/DatasetsContext.jsx(new): sharedDatasetsProvider. The single source of truth fordatasets/folders(previously duplicated inModelsContextandDatasetsAndNotebooksContext), plus the new sharedopenFolderIdsmap that tracks which named folders are expanded.src/components/models/ModelsContext.jsx: consumes the sharedDatasetsProviderinstead of callinguseDatasets/useFoldersdirectly; re-exposesopenFolderIds/setOpenFolderIds; adds persistedopenSectionsstate for the sidebar's task-group open/closed map (previously local state inModelsLeftBar).src/components/custom/contexts/DatasetsAndNotebooksContext.jsx: same migration to the sharedDatasetsProvider; re-exposesopenFolderIds/setOpenFolderIds.src/components/generative/GenerativeContext.jsx: adds persistedopenSectionsstate for the sidebar's session-group open/closed map (previously local state inSessionBar).src/App.jsx: mountsDatasetsProvider>ModelsProvider>GenerativeProviderat the app root, above the router, so their state survives navigation instead of resetting every time/app/modelsor/app/generativeis left and re-entered.src/pages/models/Models.jsx,src/pages/generative/Generative.jsx: no longer wrap their own page-scoped Provider (moved toApp.jsx).src/components/threeSectionLayout/GroupedCollapsibleList.jsx: adds an optional controlled mode (openGroups/onOpenGroupsChange), backward-compatible with its existing uncontrolledinitialOpenGroupsusage.src/components/models/ModelsLeftBar.jsx,src/components/generative/SessionBar.jsx: read/write group open-state through their context instead of localuseState, and pass it intoGroupedCollapsibleListas a controlled prop;ModelsLeftBar's group-reset effect now merges (preserves already-open groups) instead of wiping all groups closed when a new task category appears, matchingSessionBar's existing behavior.src/components/threeSectionLayout/DatasetFolderList.jsx:FolderSectiongains an optional controlledopen/onToggleOpenmode; the bulk-select "open everything" behavior is now a derived render-time value instead of a write into the persisted folder-open map, so entering bulk-select mode no longer permanently overwrites the user's closed folders.src/components/notebooks/DatasetNotebookLeftBar.jsx: passes the sharedopenFolderIds/setOpenFolderIdsintoDatasetFolderList.Testing (optional)