Fix archived tasks visibility and real-time updates #1130
Fix archived tasks visibility and real-time updates #1130arnestrickmann merged 6 commits intogeneralaction:mainfrom
Conversation
|
@thisisharsh7 is attempting to deploy a commit to the General Action Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR refactors how archived tasks are fetched and displayed in the UI. The changes introduce Key changes:
Issues found:
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| src/renderer/components/ProjectMainView.tsx | Refactored archived tasks fetching logic and improved UI visibility controls, but introduced race condition and performance inefficiencies |
Last reviewed commit: cf07fcc
| const refetchArchivedTasks = useCallback(() => { | ||
| setTimeout(async () => { | ||
| try { | ||
| const result = await window.electronAPI.getArchivedTasks(project.id); | ||
| if (!cancelled && Array.isArray(result)) { | ||
| if (Array.isArray(result)) { | ||
| setArchivedTasks(result); | ||
| } | ||
| } catch { | ||
| // silently ignore | ||
| } | ||
| } | ||
| void fetchArchived(); | ||
| return () => { | ||
| cancelled = true; | ||
| }; | ||
| }, [showFilter, project.id]); | ||
| }, 100); | ||
| }, [project.id]); |
There was a problem hiding this comment.
missing cancellation mechanism in setTimeout can cause race conditions
The previous implementation had a cancelled flag to prevent stale updates. Without it:
- If the component unmounts during the 100ms delay,
setArchivedTaskswill be called on an unmounted component - If multiple rapid refetch calls occur, race conditions could cause stale data to override newer data
| const refetchArchivedTasks = useCallback(() => { | |
| setTimeout(async () => { | |
| try { | |
| const result = await window.electronAPI.getArchivedTasks(project.id); | |
| if (!cancelled && Array.isArray(result)) { | |
| if (Array.isArray(result)) { | |
| setArchivedTasks(result); | |
| } | |
| } catch { | |
| // silently ignore | |
| } | |
| } | |
| void fetchArchived(); | |
| return () => { | |
| cancelled = true; | |
| }; | |
| }, [showFilter, project.id]); | |
| }, 100); | |
| }, [project.id]); | |
| const refetchArchivedTasks = useCallback(() => { | |
| const timeoutId = setTimeout(async () => { | |
| try { | |
| const result = await window.electronAPI.getArchivedTasks(project.id); | |
| if (Array.isArray(result)) { | |
| setArchivedTasks(result); | |
| } | |
| } catch { | |
| // silently ignore | |
| } | |
| }, 100); | |
| return () => clearTimeout(timeoutId); | |
| }, [project.id]); |
Then handle cleanup in the useEffect.
| useEffect(() => { | ||
| refetchArchivedTasks(); | ||
| }, [project.id, activeTasksLength, refetchArchivedTasks]); |
There was a problem hiding this comment.
archived tasks are fetched even when showFilter === 'active', wasting resources
The previous implementation only fetched archived tasks when needed (showFilter === 'all'). Now they're always fetched whenever activeTasksLength changes, even when the user is only viewing active tasks.
Consider adding showFilter to the dependency array and only fetching when needed:
| useEffect(() => { | |
| refetchArchivedTasks(); | |
| }, [project.id, activeTasksLength, refetchArchivedTasks]); | |
| useEffect(() => { | |
| if (showFilter === 'all') { | |
| refetchArchivedTasks(); | |
| } else { | |
| setArchivedTasks([]); | |
| } | |
| }, [project.id, activeTasksLength, showFilter, refetchArchivedTasks]); |
| exitSelectMode(); | ||
|
|
||
| if (deletedNames.length > 0) { | ||
| refetchArchivedTasks(); |
There was a problem hiding this comment.
double refetch - both explicit call here and useEffect (line 352) will trigger when activeTasksLength changes after deletion
| exitSelectMode(); | ||
|
|
||
| if (archivedNames.length > 0) { | ||
| refetchArchivedTasks(); |
There was a problem hiding this comment.
double refetch - both explicit call here and useEffect (line 352) will trigger when activeTasksLength changes after archiving
|
Hi @thisisharsh7, From the description it is quite hard to understand what this PR does and what is being fixed. Would love another description. |
|
hey, this PR needs a few fixes before merging:
i've added a review for reference |
|
@yashdev9274 thank you! |
|
Thanks for the quick turnaround! @thisisharsh7 |
|
very good catch! @thisisharsh7 |
before :

after:

before:
Screen.Recording.2026-02-27.at.6.24.47.AM.mov
after:
Screen.Recording.2026-02-27.at.6.28.44.AM.mov
Before:
Screen.Recording.2026-02-27.at.6.33.22.AM.mov
After:
Screen.Recording.2026-02-27.at.6.31.41.AM.mov