Skip to content

[tasks] fix task pagination race in project view#39

Open
dudina-ma wants to merge 1 commit into
masterfrom
fix/project-tasks-pagination-race
Open

[tasks] fix task pagination race in project view#39
dudina-ma wants to merge 1 commit into
masterfrom
fix/project-tasks-pagination-race

Conversation

@dudina-ma

@dudina-ma dudina-ma commented Jul 8, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • Bug Fixes
    • Prevented overlapping async loads across dashboards and admin pages from overwriting newer results with stale data.
    • Improved the project tasks page loading UX: full-page “Loading…” only on the initial load; later loads use a smaller inline indicator.
    • Fixed assignee user search so only the most recent query updates dropdown results, and selection clearing no longer allows stale updates.
    • Refined debounced task filter notifications to avoid redundant/incorrect search updates.
    • Updated pagination to rely on the existing reactive fetch trigger rather than manually forcing reloads.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This 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.

Changes

Latest-request loading and search flows

Layer / File(s) Summary
Latest-request guard utility
frontend/src/lib/latest-request.ts
Adds token-based request tracking and runLatest() callbacks that suppress stale success, error, and completion handlers.
Search request handling
frontend/src/lib/components/AssigneeCombobox.svelte, frontend/src/lib/components/TaskFilters.svelte
Guards overlapping assignee searches, invalidates pending searches on selection changes, and conditionally emits debounced filter changes.
Dashboard and administration loading
frontend/src/lib/pages/admin-projects.svelte, frontend/src/lib/pages/admin-users.svelte, frontend/src/lib/pages/dashboard-personal.svelte, frontend/src/lib/pages/dashboard-tasks.svelte
Routes project, user, task, and dashboard loads through latest-request callbacks while updating data, errors, and loading state.
Project and task page loading
frontend/src/lib/pages/projects.svelte, frontend/src/lib/pages/project-tasks.svelte
Replaces manual request versioning or promise handlers with guarded loading, adds subsequent-load messaging for project tasks, and lets pagination rely on reactive offset changes.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: capcom6

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main user-facing change: fixing a task pagination race in the project view.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

🤖 Pull request artifacts

Platform File
🐳 Docker GitHub Container Registry
🍎 Darwin arm64 backend_Darwin_arm64.tar.gz
🍎 Darwin x86_64 backend_Darwin_x86_64.tar.gz
🐧 Linux arm64 backend_Linux_arm64.tar.gz
🐧 Linux i386 backend_Linux_i386.tar.gz
🐧 Linux x86_64 backend_Linux_x86_64.tar.gz
🪟 Windows arm64 backend_Windows_arm64.zip
🪟 Windows i386 backend_Windows_i386.zip
🪟 Windows x86_64 backend_Windows_x86_64.zip

@capcom6

capcom6 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Это в целом очень популярный шаблон. Нет ли возможности его абстрагировать или может есть готовое решение?
Чтобы сделать один раз и использовать во всех запросах, где возможен эффект гонок.

@dudina-ma
dudina-ma force-pushed the fix/project-tasks-pagination-race branch from 9eedd0e to 752c1da Compare July 9, 2026 07:46
@capcom6

capcom6 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Что изменилось?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Add loading = false to select and clear.

When a search is in-flight and the user selects an item or clears, requestGuard.invalidate() prevents the pending request's onFinally from firing, leaving loading stuck at true. The empty-query branch in doSearch (line 35) already handles this — select and clear should 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

📥 Commits

Reviewing files that changed from the base of the PR and between 752c1da and 3b912ab.

📒 Files selected for processing (9)
  • frontend/src/lib/components/AssigneeCombobox.svelte
  • frontend/src/lib/components/TaskFilters.svelte
  • frontend/src/lib/latest-request.ts
  • frontend/src/lib/pages/admin-projects.svelte
  • frontend/src/lib/pages/admin-users.svelte
  • frontend/src/lib/pages/dashboard-personal.svelte
  • frontend/src/lib/pages/dashboard-tasks.svelte
  • frontend/src/lib/pages/project-tasks.svelte
  • frontend/src/lib/pages/projects.svelte

Comment thread frontend/src/lib/pages/project-tasks.svelte
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 7 days with no activity.

@github-actions github-actions Bot added the stale label Jul 19, 2026
@capcom6
capcom6 force-pushed the fix/project-tasks-pagination-race branch from 3ee80b0 to 38363ac Compare July 19, 2026 06:16
@capcom6 capcom6 removed the stale label Jul 19, 2026
@coderabbitai
coderabbitai Bot requested a review from capcom6 July 19, 2026 06:16

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
frontend/src/lib/pages/project-tasks.svelte (1)

77-83: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid re-fetching project details on every pagination or filter change.

Currently, getProject(slug) is executed alongside listTasks(filters) every time load() runs. Since load() 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 project is correctly reset to null whenever the slug changes (lines 64-67), you can safely skip the getProject call if project is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3ee80b0 and 38363ac.

📒 Files selected for processing (9)
  • frontend/src/lib/components/AssigneeCombobox.svelte
  • frontend/src/lib/components/TaskFilters.svelte
  • frontend/src/lib/latest-request.ts
  • frontend/src/lib/pages/admin-projects.svelte
  • frontend/src/lib/pages/admin-users.svelte
  • frontend/src/lib/pages/dashboard-personal.svelte
  • frontend/src/lib/pages/dashboard-tasks.svelte
  • frontend/src/lib/pages/project-tasks.svelte
  • frontend/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

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.

2 participants