Skip to content

fix(frontend): stop devices date filter from resetting pagination - #2953

Merged
riderx merged 4 commits into
mainfrom
cursor/fix-devices-pagination-date-06f4
Aug 9, 2026
Merged

fix(frontend): stop devices date filter from resetting pagination#2953
riderx merged 4 commits into
mainfrom
cursor/fix-devices-pagination-date-06f4

Conversation

@riderx

@riderx riderx commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary (AI generated)

  • Devices table query signature now uses a stable date-range mode identity instead of rolling now-based ISO timestamps
  • Page-only navigation skips the expensive device count query (keeps cached total) so Next works on 100k+ device apps
  • Date-range Apply applies the payload before refresh so the filter cannot race v-model and keep the old window
  • Rolling date bounds stay frozen for the paging session so cached cursors stay aligned; snap again only on Apply / Reset / toolbar Reload
  • Logs / deployments Load older no longer resets to page 1; it appends the previous time window (same bug class as devices pagination)

Motivation (AI generated)

A Brazil customer with ~213k devices after an App ID migration reported that Devices page date filters and pagination did not work. Root cause: every page change rebuilt rolling updated_at_gt / updated_at_lte from new Date(), changed the query signature, and reset currentPage to 1. Checking logs found the same failure mode: reload() forced page 1 on every Load older click. PR #2931 fixed dashboard UTC chart days only and did not cover these table paths.

Business Impact (AI generated)

Customers with large device fleets can page and filter Devices, and browse older logs/deployments again, reducing support noise after App ID migrations and large MAU apps.

Test Plan (AI generated)

  • bunx vitest run tests/date-range-query.unit.test.ts
  • bunx eslint on touched files
  • Devices page: click Next on an app with many devices — page advances and total stays stable
  • Leave a 30min Devices view open past the window, then click Next — page still loads (frozen bounds, no empty page)
  • Change date preset (e.g. 30min → 30day) and Apply — list and total update, page resets to 1
  • Reload toolbar button snaps the rolling window, resets to page 1, and recounts
  • Logs page: Load older appends an older time window instead of refetching page 1
  • Logs date Apply refreshes the list for the new range
  • Deployments Load older behaves the same as logs

Generated with AI

Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved pagination across deployment, device, and log tables.
    • Older results now load without unexpectedly resetting the current page or clearing existing rows.
    • Date-range changes and table refreshes now keep pagination and result totals synchronized.
    • Improved handling of rolling time windows when navigating between pages.
  • Tests
    • Expanded coverage for date-range filtering, reload behavior, and time-window pagination.

Rolling date presets rebuilt ISO bounds on every reload, so the query
signature changed on each Next click and pinned the table on page 1.
Use a stable mode-based signature, skip recount on page-only navigation,
and apply date-range payload before refresh.

Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds shared table date-range utilities, stabilizes device-table reload state, and changes deployment and log tables to load older pages without resetting existing results.

Changes

Table date-range pagination

Layer / File(s) Summary
Shared date-range utilities and tests
src/services/dateRange.ts, tests/date-range-query.unit.test.ts
Adds stable range signatures, reload recount decisions, and page-based time-window calculation with unit tests.
Device table reload state
src/components/tables/DeviceTable.vue
Applies date ranges before refresh, preserves rolling bounds, tracks page transitions, and conditionally recounts totals.
Older-page loading
src/components/tables/DeploymentTable.vue, src/components/tables/LogTable.vue
Uses shared time-window calculations and loads older results without clearing rows or resetting the current page.

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

Sequence Diagram(s)

sequenceDiagram
  participant DatePicker
  participant DeviceTable
  participant dateRange
  DatePicker->>DeviceTable: Apply date range
  DeviceTable->>dateRange: Create stable range signature
  DeviceTable->>dateRange: Decide recount behavior
  DeviceTable->>DeviceTable: Refresh bounds and pagination state
Loading

Possibly related PRs

Suggested labels: codex

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers scope, motivation, impact, and automated tests, but omits the required Screenshots and Checklist sections and leaves manual checks incomplete. Add the Screenshots and Checklist sections, complete applicable checklist items, and provide completed manual test steps for the changed frontend behavior.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: preventing the Devices date filter from resetting pagination.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

LogTable and DeploymentTable treated TableLog reload as a full reset,
so Load older always snapped back to page 1. Append the previous window
instead and share the time-window helper with unit coverage.

Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
@cursor
cursor Bot temporarily deployed to deepsec-pr August 8, 2026 19:57 Inactive
@codspeed-hq

codspeed-hq Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing cursor/fix-devices-pagination-date-06f4 (15c67b6) with main (b62668a)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@riderx
riderx marked this pull request as ready for review August 8, 2026 20:01
@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_8ba37d17-9ea1-45a7-afa2-509ebd043949)

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/components/tables/DeviceTable.vue
Keep the applied rolling window fixed for cursor pagination so Next
reuses cursors against the same updated_at bounds. Snap the window only
on Apply, Reset, or toolbar Reload.

Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
@cursor
cursor Bot temporarily deployed to deepsec-pr August 8, 2026 22:33 Inactive
@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_999cde2a-e513-4b22-b782-968537dd8184)

@coderabbitai coderabbitai Bot added the codex label Aug 8, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@src/components/tables/LogTable.vue`:
- Around line 185-186: Update the range checks in getTimeWindowPageRange callers
so rangeStart and rangeEnd are compared explicitly against undefined rather than
tested for truthiness, preserving valid epoch timestamp 0. Apply this in
src/components/tables/LogTable.vue lines 185-186 and
src/components/tables/DeploymentTable.vue lines 50-51.
🪄 Autofix

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: ASSERTIVE

Plan: Pro

Run ID: 97ad6ebe-4829-41ba-bbf8-9bafba4476e9

📥 Commits

Reviewing files that changed from the base of the PR and between b62668a and cee7ef9.

📒 Files selected for processing (5)
  • src/components/tables/DeploymentTable.vue
  • src/components/tables/DeviceTable.vue
  • src/components/tables/LogTable.vue
  • src/services/dateRange.ts
  • tests/date-range-query.unit.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)

Comment thread src/components/tables/LogTable.vue Outdated

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/components/tables/DeviceTable.vue Outdated
Extract a shared DeviceTable pagination reset helper so reload paths
stay consistent, and treat epoch 0 as a valid logs time-window bound.

Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
@cursor
cursor Bot deployed to deepsec-pr August 9, 2026 07:53 Active
@cursor

cursor Bot commented Aug 9, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_be13f24c-997b-4a2c-b9d6-1c692d0bab20)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/date-range-query.unit.test.ts (1)

55-59: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Make the wall-clock test deterministic.

The test does not change the system time, so it does not prove stability across clock changes. Use vi.useFakeTimers() and two distinct vi.setSystemTime() values. Keep the test non-concurrent and restore real timers with vi.useRealTimers().

🤖 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 `@tests/date-range-query.unit.test.ts` around lines 55 - 59, Update the test
“keeps rolling table signatures stable across wall-clock ticks” to run
non-concurrently with vi.useFakeTimers(), capture signatures at two distinct
vi.setSystemTime() values, and compare them for stability. Restore real timers
with vi.useRealTimers() after the test.

Source: Learnings

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

Outside diff comments:
In `@tests/date-range-query.unit.test.ts`:
- Around line 55-59: Update the test “keeps rolling table signatures stable
across wall-clock ticks” to run non-concurrently with vi.useFakeTimers(),
capture signatures at two distinct vi.setSystemTime() values, and compare them
for stability. Restore real timers with vi.useRealTimers() after the test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8ccd4688-cf25-47ae-8fb1-c0b80cc417c3

📥 Commits

Reviewing files that changed from the base of the PR and between cee7ef9 and 15c67b6.

📒 Files selected for processing (4)
  • src/components/tables/DeploymentTable.vue
  • src/components/tables/DeviceTable.vue
  • src/components/tables/LogTable.vue
  • tests/date-range-query.unit.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)

@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2026

Copy link
Copy Markdown

@riderx
riderx merged commit 0722e85 into main Aug 9, 2026
81 checks passed
@riderx
riderx deleted the cursor/fix-devices-pagination-date-06f4 branch August 9, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants