Skip to content

fix: archived tasks view crashes with infinite loop white screen#37

Merged
samzong merged 1 commit intomainfrom
fix/archived-tasks-infinite-loop
Mar 14, 2026
Merged

fix: archived tasks view crashes with infinite loop white screen#37
samzong merged 1 commit intomainfrom
fix/archived-tasks-infinite-loop

Conversation

@samzong
Copy link
Collaborator

@samzong samzong commented Mar 14, 2026

Summary

  • Bug: Opening the archived tasks view caused a white screen crash with getSnapshot should be cached and Maximum update depth exceeded errors
  • Root cause: Zustand selector in ArchivedTasks called .filter() inline, creating a new array reference on every snapshot check → infinite re-render loop
  • Fix: Move .filter() from selector to useMemo, selector now returns the stable s.tasks reference

Changes

packages/desktop/src/renderer/layouts/MainArea/index.tsx

  • Import useMemo from React
  • Selector: useTaskStore((s) => s.tasks) (stable reference)
  • Filter: useMemo(() => tasks.filter(...), [tasks]) (recomputes only when tasks change)

Consistent with the existing pattern in LeftNav (line 77-79).

Move .filter() out of Zustand selector into useMemo to prevent
getSnapshot returning a new array reference on every call, which
caused useSyncExternalStore to loop infinitely.
@github-actions
Copy link

Hi @samzong,
Thanks for your pull request!
If the PR is ready, use the /auto-cc command to assign Reviewer to Review.
We will review it shortly.

Details

Instructions for interacting with me using comments are available here.
If you have questions or suggestions related to my behavior, please file an issue against the gh-ci-bot repository.

@samzong samzong merged commit a0aa5c8 into main Mar 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant