[tasks] fix task pagination race in project view#39
Conversation
📝 WalkthroughWalkthroughThis change adds a shared latest-request guard and applies it to frontend search, dashboard, administration, project, and task loading flows. Project-task loading distinguishes initial and subsequent loading states, while pagination relies on reactive offset changes. ChangesLatest-request loading and search flows
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 Pull request artifacts
|
|
Это в целом очень популярный шаблон. Нет ли возможности его абстрагировать или может есть готовое решение? |
9eedd0e to
752c1da
Compare
|
Что изменилось? |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/src/lib/components/AssigneeCombobox.svelte (1)
60-76: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winAdd
loading = falsetoselectandclear.When a search is in-flight and the user selects an item or clears,
requestGuard.invalidate()prevents the pending request'sonFinallyfrom firing, leavingloadingstuck attrue. The empty-query branch indoSearch(line 35) already handles this —selectandclearshould too.🐛 Proposed fix
function select(user: UserBrief) { requestGuard.invalidate(); value = user.id; selectedName = user.name; query = ""; results = []; open = false; + loading = false; } function clear() { requestGuard.invalidate(); value = null; selectedName = ""; query = ""; results = []; open = false; + loading = false; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/lib/components/AssigneeCombobox.svelte` around lines 60 - 76, Set loading = false in both select and clear immediately after requestGuard.invalidate(), so cancelling an in-flight search cannot leave the component stuck in a loading state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/lib/pages/project-tasks.svelte`:
- Around line 98-99: Reset the project state whenever the route slug changes so
stale project data is not rendered during a new project load. Update the
slug-change handling in project-tasks.svelte to clear project (and any
associated error state as appropriate) before fetching the new project,
preserving initialLoading’s existing pagination behavior.
---
Outside diff comments:
In `@frontend/src/lib/components/AssigneeCombobox.svelte`:
- Around line 60-76: Set loading = false in both select and clear immediately
after requestGuard.invalidate(), so cancelling an in-flight search cannot leave
the component stuck in a loading state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: be6e4369-c6f0-4b5f-9989-adaff9c25aa7
📒 Files selected for processing (9)
frontend/src/lib/components/AssigneeCombobox.sveltefrontend/src/lib/components/TaskFilters.sveltefrontend/src/lib/latest-request.tsfrontend/src/lib/pages/admin-projects.sveltefrontend/src/lib/pages/admin-users.sveltefrontend/src/lib/pages/dashboard-personal.sveltefrontend/src/lib/pages/dashboard-tasks.sveltefrontend/src/lib/pages/project-tasks.sveltefrontend/src/lib/pages/projects.svelte
|
This PR is stale because it has been open for 7 days with no activity. |
3ee80b0 to
38363ac
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/src/lib/pages/project-tasks.svelte (1)
77-83: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winAvoid re-fetching project details on every pagination or filter change.
Currently,
getProject(slug)is executed alongsidelistTasks(filters)every timeload()runs. Sinceload()is triggered reactively by any filter or pagination offset change, this results in redundant network and database load for project data that is already populated.Because
projectis correctly reset tonullwhenever theslugchanges (lines 64-67), you can safely skip thegetProjectcall ifprojectis already loaded.⚡ Proposed optimization
- runLatest(requestGuard, () => Promise.all([getProject(slug), listTasks(filters)]), { + const projectReq = project ? Promise.resolve(project) : getProject(slug); + runLatest(requestGuard, () => Promise.all([projectReq, listTasks(filters)]), { onSuccess: ([proj, res]) => {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/lib/pages/project-tasks.svelte` around lines 77 - 83, Update the reactive load flow around runLatest so getProject(slug) is called only when project is null, while listTasks(filters) continues running for every pagination or filter change. Preserve the existing project assignment, task results, totals, and touchProject behavior, relying on the slug-change reset to trigger project loading for a new project.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@frontend/src/lib/pages/project-tasks.svelte`:
- Around line 77-83: Update the reactive load flow around runLatest so
getProject(slug) is called only when project is null, while listTasks(filters)
continues running for every pagination or filter change. Preserve the existing
project assignment, task results, totals, and touchProject behavior, relying on
the slug-change reset to trigger project loading for a new project.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b0923bee-cc3c-47da-af69-fc5c6b922dc1
📒 Files selected for processing (9)
frontend/src/lib/components/AssigneeCombobox.sveltefrontend/src/lib/components/TaskFilters.sveltefrontend/src/lib/latest-request.tsfrontend/src/lib/pages/admin-projects.sveltefrontend/src/lib/pages/admin-users.sveltefrontend/src/lib/pages/dashboard-personal.sveltefrontend/src/lib/pages/dashboard-tasks.sveltefrontend/src/lib/pages/project-tasks.sveltefrontend/src/lib/pages/projects.svelte
🚧 Files skipped from review as they are similar to previous changes (8)
- frontend/src/lib/pages/dashboard-tasks.svelte
- frontend/src/lib/pages/projects.svelte
- frontend/src/lib/latest-request.ts
- frontend/src/lib/pages/dashboard-personal.svelte
- frontend/src/lib/pages/admin-users.svelte
- frontend/src/lib/components/TaskFilters.svelte
- frontend/src/lib/pages/admin-projects.svelte
- frontend/src/lib/components/AssigneeCombobox.svelte
Summary by CodeRabbit