PictoPy icon indicating copy to clipboard operation
PictoPy copied to clipboard

Issues in `src/features` folder (Parent ID comparisons, onboarding loop timeouts, and type safety)

Open MayankSharma-ops opened this issue 4 months ago • 6 comments

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 selectFoldersByParentId and selectFolderHierarchy strictly compared parent IDs: folder.parent_folder_id === parentId.
  • Details: In FolderDetails, parent_folder_id is an optional string (string | undefined), while root queries pass parentId: string | null. Under strict equality, undefined === null evaluates to false.
  • Impact: Hierarchy generation (selectFolderHierarchy) and filtering root folders via selectFoldersByParentId(state, null) failed entirely (returned empty arrays).

2. Cascading Re-renders & Test Timeouts (onboardingSlice.ts)

  • Bug: The onboarding state initialized all step statuses to false regardless of existing local storage. Each step component mounted, read its completion from localStorage, and then dispatched markCompleted in a useEffect on 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 selectSelectedMemory selector was typed with a local state shape (state: { memories: MemoriesState }) instead of the standard RootState used 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.

MayankSharma-ops avatar Jul 15 '26 17:07 MayankSharma-ops

👋 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 :)

github-actions[bot] avatar Jul 15 '26 17:07 github-actions[bot]

Provide screenshots for the detected dead code, type inconsistencies, Re-renders & Test Timeouts, Parent ID Mismatch

rohan-pandeyy avatar Jul 16 '26 05:07 rohan-pandeyy

@MayankSharma-ops @rohan-pandeyy can you assign me this issue, if this issue needs a contributor, I would love to work on it!

Takitxt avatar Jul 16 '26 09:07 Takitxt

Image 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. Image 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. Image 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

MayankSharma-ops avatar Jul 16 '26 18:07 MayankSharma-ops

@rohan-pandeyy should i work on this?

MayankSharma-ops avatar Jul 21 '26 09:07 MayankSharma-ops

Hi, I’d like to work on the root-folder selector issue in this ticket. Could a maintainer please confirm it is available?

abhu-k avatar Aug 18 '26 12:08 abhu-k