fix desktop tasks filter showing wrong results#6169
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR fixes a desktop task-filter regression where selecting "All" (or any non-status filter) would show far fewer tasks than expected. Two root causes are addressed: the 7-day categorization cutoff was always active instead of being gated on the
Confidence Score: 5/5Safe to merge — the fix correctly targets the root cause and all remaining findings are minor style/efficiency suggestions. Both root causes of the reported bug are addressed correctly. The No files require special attention; Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[selectedTags changed] --> B{hasStatusFilter?}
B -- Yes --> C{wantsDone / wantsTodo / wantsDeleted?}
C --> D[Load appropriate tasks from store]
B -- No / All --> E[loadCompletedTasks NEW]
A --> F{hasNonStatusFilters?}
F -- Yes --> G[loadFilteredTasksFromDatabase - async SQLite]
F -- No --> H[filteredFromDatabase cleared / recomputeDisplayCaches]
G --> I{filteredFromDatabase populated?}
I -- Yes --> J[sourceTasks = filteredFromDatabase]
I -- No async window --> K[sourceTasks = getSourceTasks in-memory]
K --> L{hasDateFilters?}
L -- Yes --> M[applyDateFilters manually NEW]
L -- No --> N[applyStatusFilters only]
J --> O[applyStatusFilters]
M --> P[sortTasks]
N --> P
O --> P
P --> Q{last7Days in selectedTags? FIXED}
Q -- Yes --> R[Skip incomplete tasks older than 7 days]
Q -- No --> S[Include all tasks]
R --> T[categorizedTasks]
S --> T
Reviews (1): Last reviewed commit: "fix desktop tasks filter showing wrong r..." | Re-trigger Greptile |
| } else { | ||
| // No status filter = "All" — load completed tasks so they show alongside todos | ||
| Task { await store.loadCompletedTasks() } | ||
| } |
There was a problem hiding this comment.
Redundant
loadCompletedTasks when non-status filters are active
When selectedTags contains non-status filters (e.g. last7Days, a category), both loadCompletedTasks() (line 507) and loadFilteredTasksFromDatabase() (line 512) are fired concurrently. The SQLite query path already returns completed tasks, so the extra network call to loadCompletedTasks is only useful for populating the in-memory store during the brief async window before the database results arrive.
This is not wrong, but it means every filter-tag toggle that keeps no status filter will issue a completed-tasks network request even when the SQLite path will supply them moments later. Consider guarding with !showCompleted (already used in the status-filter branch above) to skip the redundant fetch:
| } else { | |
| // No status filter = "All" — load completed tasks so they show alongside todos | |
| Task { await store.loadCompletedTasks() } | |
| } | |
| } else { | |
| // No status filter = "All" — ensure completed tasks are present for the in-memory fallback | |
| if !showCompleted { | |
| Task { await store.loadCompletedTasks() } | |
| } | |
| } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| let applySevenDayCutoffMore = selectedTags.contains(.last7Days) | ||
| let sevenDaysAgoMore = Date().addingTimeInterval(-7 * 24 * 60 * 60) |
There was a problem hiding this comment.
Unnecessary "More" suffix on local variable names
applySevenDayCutoffMore and sevenDaysAgoMore are local variables inside loadMoreFiltered and have no naming conflict with variables in recomputeDisplayCaches (different function scope). The More suffix adds noise without aiding readability.
| let applySevenDayCutoffMore = selectedTags.contains(.last7Days) | |
| let sevenDaysAgoMore = Date().addingTimeInterval(-7 * 24 * 60 * 60) | |
| let applySevenDayCutoff = selectedTags.contains(.last7Days) | |
| let sevenDaysAgo = Date().addingTimeInterval(-7 * 24 * 60 * 60) |
Then update the three usages of applySevenDayCutoffMore / sevenDaysAgoMore below accordingly.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…ve More suffix from locals Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Task filters not working properly — 14 Todos but only 1 showing, other filters also broken. **Bug demo:** https://github.com/user-attachments/assets/c0885a4a-7368-43c6-b57a-9e737686943d **Root cause:** Categorization always applied 7-day cutoff even without "Last 7 days" filter active. **Fix:** Gate the 7-day cutoff on the `last7Days` filter; load completed tasks when "All" is selected. **After fix:** https://github.com/user-attachments/assets/4251342e-ed1f-424e-9f9b-45c01d31b589 Closes BasedHardware#6168 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Task filters not working properly — 14 Todos but only 1 showing, other filters also broken.
Bug demo:
Screen.Recording.2026-03-30.at.9.23.45.AM.mov
Root cause: Categorization always applied 7-day cutoff even without "Last 7 days" filter active.
Fix: Gate the 7-day cutoff on the
last7Daysfilter; load completed tasks when "All" is selected.After fix:
Screen.Recording.2026-03-30.at.9.26.57.AM.mov
Closes #6168
🤖 Generated with Claude Code