Issues in `src/features` folder (Parent ID comparisons, onboarding loop timeouts, and type safety)
Bug Report: Issues in src/features folder (Parent ID comparisons, onboarding loop timeouts, and type safety)
Description
A series of bugs and technical debt items were identified in the Redux slices and selectors inside frontend/src/features. These issues caused strict comparison bugs (e.g. failing to render/resolve root folders in hierarchy selectors), cascading state updates during initialization leading to Jest timeouts/warnings, and type inconsistency.
Identified Issues & Impact
1. Root Folders Ignored due to Parent ID Mismatch (folderSelectors.ts)
- Bug: The selectors
selectFoldersByParentIdandselectFolderHierarchystrictly compared parent IDs:folder.parent_folder_id === parentId. - Details: In
FolderDetails,parent_folder_idis an optional string (string | undefined), while root queries passparentId: string | null. Under strict equality,undefined === nullevaluates tofalse. - Impact: Hierarchy generation (
selectFolderHierarchy) and filtering root folders viaselectFoldersByParentId(state, null)failed entirely (returned empty arrays).
2. Cascading Re-renders & Test Timeouts (onboardingSlice.ts)
- Bug: The onboarding state initialized all step statuses to
falseregardless of existing local storage. Each step component mounted, read its completion fromlocalStorage, and then dispatchedmarkCompletedin auseEffecton mount. - Impact: On initial app load/mounting, components repeatedly dispatched state updates in a chain, causing React state update console warnings (
not wrapped in act(...)) and causing Jest tests to exceed the default 5000ms timeout.
3. Type Inconsistency in Memories Selector (memoriesSlice.ts)
- Bug: The
selectSelectedMemoryselector was typed with a local state shape(state: { memories: MemoriesState })instead of the standardRootStateused by all other selectors in the project.
4. Dead Code (folderThunks.ts)
- Issue: An empty
folderThunks.ts(0 bytes) existed in the directory but was never used or imported.
👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)
Provide screenshots for the detected dead code, type inconsistencies, Re-renders & Test Timeouts, Parent ID Mismatch
@MayankSharma-ops @rohan-pandeyy can you assign me this issue, if this issue needs a contributor, I would love to work on it!
Problem: folder.parent_folder_id is optional (string | undefined) but parentId is string | null for root. Checking undefined === null is false, filtering out root folders.
Problem: The default parentId is null but root folders have undefined parent IDs. The strict check undefined === null is false, returning an empty array [] for hierarchy.
Problem: Direct use of localStorage without a check can crash in environments like server-side rendering or node testing.
Problem: Initializing step status to all false forces the application to sequentially mount each completed step, execute their useEffect hooks, and dispatch markCompleted on load. This triggers multiple cascading re-renders and Jest timeouts.
folderThunks.ts This file is completely empty (0 bytes) and is unused dead code in the repository
@rohan-pandeyy should i work on this?
Hi, I’d like to work on the root-folder selector issue in this ticket. Could a maintainer please confirm it is available?