Improve task UI responsiveness and optimistic task updates#1
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8a638e12a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const next = prev.map((task) => | ||
| task.id === tempId ? { ...createdTask, starred: false } : task | ||
| ); | ||
| saveTasksCache(currentListId, next); | ||
| return next; |
There was a problem hiding this comment.
Avoid caching another list after async adds
When a user submits a task in list A and switches to another list before insertTask resolves, the prev passed to this updater can now be the new list's tasks while currentListId is still the old list captured by the submit handler. This saves the other list into list A's cache and leaves the temp task unreplaced until a later network refresh; only write the cache when the temp id is still present, or update a per-list snapshot instead of the shared tasks state.
Useful? React with 👍 / 👎.
| counts[list.id] = (allTasksByList[list.id] || []).filter( | ||
| (task) => task.status !== "completed" | ||
| ).length; |
There was a problem hiding this comment.
Keep sidebar counts in sync with list edits
These badges now depend only on allTasksByList, but list-view add/complete/delete handlers update the separate tasks state and do not update allTasksByList. After a user edits tasks while viewing a list, the sidebar count for that list stays based on the last board fetch until returning to board or refreshing, so the displayed count is stale; include the active list state in this derivation or keep allTasksByList updated with the same optimistic changes.
Useful? React with 👍 / 👎.
Motivation
Description
visibleTasks,completedTasks,listTaskCounts, andcurrentTaskListusinguseMemoinsrc/pages/AppPage.jsxto avoid rebuilding trees on unrelated renders.src/components/TaskBoard.jsxto precomputeboardDatawithuseMemoand exportedTaskBoardwithReact.memoto cut unnecessary recalculation and rerenders.refand afocusAddTaskInputcallback (requestAnimationFrame) insrc/pages/AppPage.jsx, and wired that into sidebar/board actions and keyboard shortcuts.getTasksreload), addedsaveTasksCachehelper to persist optimistic state, and exportedDesktopTaskItemwithReact.memoto further reduce rerenders (src/pages/AppPage.jsx,src/components/TaskBoard.jsx,src/components/DesktopTaskItem.jsx).Testing
npm run build— succeeded and produced a production build.npm test -- --watchAll=false— failed early due to the CRA/Jest environment not resolvingreact-router-dominsrc/App.jsx(pre-existing resolver issue), so unit tests did not run to completion.Codex Task