fix: restore log and device table search/sort behavior#1823
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughFrontend now derives an explicit active order from columns, normalizes sortable flags, and unconditionally triggers reloads (respecting an Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant UI as Table Component
participant Order as getActiveOrder()
participant API as Backend Function
participant DB as Database
User->>UI: Click column / change search or date
UI->>UI: update column.sortable, call requestReload()
UI->>Order: derive active order (string-sortable cols)
Order-->>UI: [{key, sortable}, ...]
UI->>API: Fetch/export with order + cursor/search params
API->>DB: Query with cursor comparison (gt/lt) and ORDER BY updated_at (ASC/DESC), device_id ASC
DB-->>API: Return ordered, paginated rows
API-->>UI: Respond with data
UI-->>User: Render table
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c163aea615
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01272fad40
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Merged origin/main and resolved the conflict in the deployment/log tables. I kept the branch’s helper (instead of the inline ) so the stats request keeps sending the same computed sort payload after the merge. |
|
Merged origin/main and resolved the conflict in the deployment/log tables. I kept the branch’s |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3ec4461bc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| newColumns.forEach((col, index) => { | ||
| if (index !== key && col.sortable && typeof col.sortable === 'string') | ||
| newColumns[index] = { ...col, sortable: true } |
There was a problem hiding this comment.
Clear the default sort when restoring URL sort state
This new single-sort reset logic only runs on click. loadFromUrlParams() still starts from props.columns, so a bookmarked/shared URL like ?sort_action=asc leaves the default created_at: 'desc' column active and adds action: 'asc' on top. Because /private/stats applies orders in column order, logs/deployments opened from a sort URL will still be primarily sorted by created_at, making the restored sort state incorrect.
Useful? React with 👍 / 👎.
|
CI is failing on an auth regression unrelated to the search/sort changes in this PR. Failing job: https://github.com/Cap-go/capgo/actions/runs/23280657065/job/67693315697. The only failing suite is tests/app.test.ts, case [GET] /app subkey ownership enforcement, where the test expects 200 and gets 401 at tests/app.test.ts:241. This PR mainly changes table sorting/search wiring plus backend ordering/search helpers, so the failure looks like fallout from the main merge or another auth-path change rather than from the intended feature work here. |
|
@riderx We just need you. Thank you for the pull request. We just need you to reply or fix your pull request according to the AI comments. When the AI reviewer is done and the build passes in the CI, we will merge your pull request. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f64a11077a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
CI is still red on this run. The current failure is in : the hook times out at / after 60s. The branch diff is limited to table UI/helpers and backend ordering/search utilities, so this does not look like a simple branch-local fix. The current failure appears to be a shared test setup / seeding timeout rather than behavior introduced by this PR. |
|
CI is still red on https://github.com/Cap-go/capgo/actions/runs/23290936479/job/67726094876. The current failure is in tests/events.test.ts: the beforeAll hook times out at resetAndSeedAppData(APPNAME_EVENT) and resetAndSeedAppDataStats(APPNAME_EVENT) after 60s. The branch diff is limited to table UI/helpers and backend ordering/search utilities, so this does not look like a simple branch-local fix. The current failure appears to be a shared test setup / seeding timeout rather than behavior introduced by this PR. |
|
CI is still red on https://github.com/Cap-go/capgo/actions/runs/23290936479/job/67726094876. The failing |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/components/tables/LogTable.vue (1)
28-32: Consider extractinggetActiveOrderto a shared utility.This helper is duplicated in
DeploymentTable.vue. For DRY, consider moving it to a shared location (e.g.,~/services/table.tsor~/components/comp_def.ts).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/tables/LogTable.vue` around lines 28 - 32, Extract the duplicated helper getActiveOrder (signature getActiveOrder(columns: TableColumn[])) into a shared utility module (e.g., services/table.ts or components/comp_def.ts): create an exported function that returns columns.filter(col => typeof col.sortable === 'string').map(col => ({ key: col.key, sortable: col.sortable })), then replace the local implementations in LogTable.vue and DeploymentTable.vue with an import of that shared getActiveOrder to remove duplication and keep behavior identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/TableLog.vue`:
- Around line 385-389: The ESLint failure is caused by unnecessary parentheses
around single arrow parameters in the expressions that compute hasSortParam and
newColumns; update the arrow functions used in hasSortParam (currently using
(col) => ...) and the map callback for newColumns (currently using (col) => ...)
to use the single-parameter shorthand (col => ...) so the hasSortParam and
newColumns computations conform to the style/arrow-parens rule while preserving
the same logic for setting sortable.
---
Nitpick comments:
In `@src/components/tables/LogTable.vue`:
- Around line 28-32: Extract the duplicated helper getActiveOrder (signature
getActiveOrder(columns: TableColumn[])) into a shared utility module (e.g.,
services/table.ts or components/comp_def.ts): create an exported function that
returns columns.filter(col => typeof col.sortable === 'string').map(col => ({
key: col.key, sortable: col.sortable })), then replace the local implementations
in LogTable.vue and DeploymentTable.vue with an import of that shared
getActiveOrder to remove duplication and keep behavior identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 75820722-d467-4790-995f-baa6b013575f
📒 Files selected for processing (3)
src/components/TableLog.vuesrc/components/tables/DeploymentTable.vuesrc/components/tables/LogTable.vue
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5728cc7e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 30b4cca302
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const devicesOrder = getDevicesOrder(params.order) | ||
|
|
||
| // Cursor-based pagination only works when an updated_at order is active | ||
| if (params.cursor && devicesOrder) { |
There was a problem hiding this comment.
Restore cursor support without an explicit device sort
This change makes pagination depend on order containing updated_at, but the public device list endpoint still calls readDevices() with only app_id, cursor, and limit (supabase/functions/_backend/public/device/get.ts:101-105) while readDevices() continues to mint nextCursor as updated_at|device_id (supabase/functions/_backend/utils/stats.ts:324-329). As a result, any caller that follows nextCursor on /device now gets page 1 again because both readDevicesSB and readDevicesCF ignore the cursor when order is omitted, and the default ordering also changes from newest-first to device_id ASC.
Useful? React with 👍 / 👎.
|



Summary (AI generated)
TableLogso search, sort, and range changes emit reloads in manual modeMotivation (AI generated)
Search and sort interactions in the logs view were updating URL state without triggering fresh backend reads, and the Supabase search path did not match the same fields and semantics as the Cloudflare path. That made the logs page feel broken and created inconsistent behavior on the devices page.
Business Impact (AI generated)
This restores a core debugging workflow in the console. Users can filter and reorder logs again, and device searches behave consistently across local and Supabase-backed environments, which reduces friction when investigating rollout issues.
Test Plan (AI generated)
bun lintbun typecheckGenerated with AI
Summary by CodeRabbit
Bug Fixes
Improvements