feat: add status/author filters and sortable columns to sessions page#1518
feat: add status/author filters and sortable columns to sessions page#1518quay-devel wants to merge 5 commits intoambient-code:mainfrom
Conversation
…sions list Add phase filter dropdown (Active/Completed/Failed), "My sessions" toggle using current user identity, and clickable sortable Created column header. Filter params flow through PaginationParams -> API layer -> query keys for proper cache isolation. Includes 4 new tests for filter param passthrough. Ref: ambient-code#1515 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ist endpoint Add server-side filtering by phase and userId, plus configurable sort direction to the ListSessions handler, supporting the sessions page filter/sort UI (ambient-code#1515). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove unused sortSessionsByCreationTime() function (replaced by sortSessions()) - Add sortDirection to offset reset dependency array for correct UX on sort toggle Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✅ Deploy Preview for cheerful-kitten-f556a0 canceled.
|
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds server-side filtering and sorting to the sessions list. Backend extends ChangesSessions Filtering & Sorting
Sequence DiagramsequenceDiagram
participant User as User
participant Frontend as SessionsSection
participant API as API Client
participant Backend as ListSessions Handler
participant K8s as K8s API
User->>Frontend: Select phase filter, toggle "My sessions", click sort column
Frontend->>Frontend: Update state (phaseFilter, mySessionsOnly, sortBy, sortDirection)
Frontend->>API: listSessionsPaginated({phase, userId, sortBy, sortDirection})
API->>Backend: GET /sessions?phase=Running,Pending&userId=user123&sortBy=created&sortDirection=asc
Backend->>K8s: List all AgenticSession CRs
K8s-->>Backend: All sessions
Backend->>Backend: Apply search filter
Backend->>Backend: Apply phase filter (comma-separated values)
Backend->>Backend: Apply userId filter
Backend->>Backend: Sort by (column, direction)
Backend-->>API: Filtered & sorted sessions
API-->>Frontend: Sessions data
Frontend->>Frontend: Render table with active filter chips, sort indicators
Frontend-->>User: Display results
🚥 Pre-merge checks | ✅ 7 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (7 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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 |
Make the Name column header clickable for sorting, matching the existing Created column behavior. Clicking the active sort column toggles direction; clicking an inactive column switches to it with a sensible default (asc for name, desc for created). Arrow icons only show on the active sort column. The backend already supports sortBy=name, so no backend changes needed. Refs ambient-code#1515
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
components/backend/handlers/sessions_test.go (1)
342-386: ⚡ Quick winAdd coverage for
sortBy=namepathCurrent additions validate
sortDirection, but not the"name"branch itself. A regression insortBy=namewouldn’t be caught by this suite.🤖 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 `@components/backend/handlers/sessions_test.go` around lines 342 - 386, Add a test case that exercises the "sortBy=name" branch by calling the ListSessions handler with the query param sortBy=name (and both sortDirection=asc and the default/desc case) using httpUtils.CreateTestGinContext and the existing createTestSessionWithOptions("alpha-"+randomName...) / createTestSessionWithOptions("beta-"+randomName...) setup; assert HTTP 200, parse response items, and verify ordering by metadata.name (alpha before beta for asc, beta before alpha for desc) so the sortBy=name code path is covered.
🤖 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 `@components/backend/handlers/sessions.go`:
- Around line 803-816: The comparator used by sort.Slice currently compares
sessions[i].Metadata["name"] but the UI displays spec.displayName ||
metadata.name; update the "name" case in the comparator to compute vi and vj by
first checking the session's spec.displayName (type-assert to string) and using
it if non-empty, otherwise falling back to sessions[].Metadata["name"]; then
lowercase both values for comparison. Modify the comparator inside sort.Slice
(the "name" case) to read spec.displayName for sessions[i] and sessions[j],
fallback to metadata.name, and set vi/vj accordingly before returning vi < vj
(leaving the default case using getSessionCreationTimestamp unchanged).
In `@components/frontend/src/components/workspace-sections/sessions-section.tsx`:
- Around line 329-362: The sortable TableHead elements (the ones toggling sort
for 'name' and 'created') are currently click-only; make them
keyboard-accessible by ensuring they are focusable and respond to Enter/Space:
add tabIndex={0} (or use a semantic <button>), a role="button" if not a native
button, and an onKeyDown handler that invokes the same logic used in the onClick
(toggling setSortDirection or setting setSortBy and default sortDirection). Also
add ARIA state like aria-sort on those headers to reflect sortBy/sortDirection
for screen readers (use 'none'/'ascending'/'descending' based on sortBy and
sortDirection). Ensure handlers reference the same setSortBy/setSortDirection
logic currently in the TableHead click handlers for 'name' and 'created'.
- Around line 118-120: The request builder is using mySessionsOnly while
currentUser may still be unresolved, causing userId to be undefined and
returning unfiltered results; update the logic in the SessionsSection where
userId is set (userId: mySessionsOnly ? currentUser?.userId : undefined) to only
include userId when currentUser?.userId exists (e.g., userId: mySessionsOnly &&
currentUser?.userId ? currentUser.userId : undefined) so the API is not queried
as "my sessions" with an undefined id, and also disable the "My sessions" toggle
control (the UI toggle bound to mySessionsOnly) until currentUser is loaded so
the user cannot enable the filter before currentUser is known.
---
Nitpick comments:
In `@components/backend/handlers/sessions_test.go`:
- Around line 342-386: Add a test case that exercises the "sortBy=name" branch
by calling the ListSessions handler with the query param sortBy=name (and both
sortDirection=asc and the default/desc case) using
httpUtils.CreateTestGinContext and the existing
createTestSessionWithOptions("alpha-"+randomName...) /
createTestSessionWithOptions("beta-"+randomName...) setup; assert HTTP 200,
parse response items, and verify ordering by metadata.name (alpha before beta
for asc, beta before alpha for desc) so the sortBy=name code path is covered.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 02606c11-9e03-4797-9a17-67b53f51995f
📒 Files selected for processing (7)
components/backend/handlers/sessions.gocomponents/backend/handlers/sessions_test.gocomponents/backend/types/common.gocomponents/frontend/src/components/workspace-sections/sessions-section.tsxcomponents/frontend/src/services/api/sessions.tscomponents/frontend/src/services/queries/__tests__/use-sessions.test.tscomponents/frontend/src/types/api/common.ts
- Sort-by-name now uses displayName with fallback to metadata.name, matching what the UI displays - "My sessions" toggle disabled while currentUser is loading, and userId guard prevents unfiltered queries when user is unresolved - Sortable table headers are keyboard-accessible (tabIndex, role, onKeyDown, aria-sort) - Added sortBy=name test coverage (ascending and descending) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
PaginationParamswithphase,userId,sortBy,sortDirectionquery params. AddedfilterSessionsByPhase(),filterSessionsByUserID(), andsortSessions()functions to theListSessionshandler pipeline (applied after search, before pagination). Supports comma-separated phase values, configurable sort direction, and sorting by name or creation time.useCurrentUser()hook), and sortable "Created" and "Name" column headers with direction indicators. Clicking the active sort column toggles direction; clicking an inactive column switches to it with a sensible default (asc for name, desc for created). Active filters shown as dismissable chips. Pagination offset resets on any filter/sort change.Fixes #1515
Files Changed
components/backend/types/common.goPaginationParamsstruct with 4 new fieldscomponents/backend/handlers/sessions.gocomponents/backend/handlers/sessions_test.gocreateTestSessionWithOptionshelper + 5 test contextscomponents/frontend/src/types/api/common.tsPaginationParamstypecomponents/frontend/src/services/api/sessions.tslistSessionsPaginated()components/frontend/src/components/workspace-sections/sessions-section.tsxcomponents/frontend/src/services/queries/__tests__/use-sessions.test.tsTest plan
?phase=Runningreturns only Running sessions?phase=Running,Pendingreturns sessions in either phase?userId=<id>returns only that user's sessions?sortBy=name&sortDirection=ascsorts alphabetically?sortBy=created&sortDirection=descsorts newest-first (default)go veton backend changesnpx vitest runon frontend tests🤖 Generated with Claude Code
Summary by CodeRabbit
New Features