Skip to content

feat(admin): annotation filters and sorts on session list#158

Merged
gelbh merged 2 commits into
mainfrom
feat/admin-annotation-filters
Jul 24, 2026
Merged

feat(admin): annotation filters and sorts on session list#158
gelbh merged 2 commits into
mainfrom
feat/admin-annotation-filters

Conversation

@gelbh

@gelbh gelbh commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add lastAnnotationAt and activeAnnotationCount to listActiveSessions summaries.
  • Client filter: Annotated chip + sorts for last annotation / annotation count; row shows · N ann.

Test plan

  • npm test -- src/domain/admin/adminSessionFilters.test.ts
  • npm run typecheck

Summary by CodeRabbit

  • New Features

    • Added an “Annotated” filter for admin sessions.
    • Added sorting by most recent annotation and annotation count.
    • Admin session details now show the number of active annotations.
    • Session summaries include annotation activity information.
  • Tests

    • Added coverage for annotation filtering and sorting behavior.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Session summaries now include annotation recency and active counts. Admin users can filter annotated sessions, sort by annotation metadata, and see active annotation counts in session rows.

Changes

Annotated session administration

Layer / File(s) Summary
Annotation summary data
functions/admin/listActiveSessions.mjs, src/services/admin/adminSessions.ts, src/services/admin/adminSessions.test.ts
Active annotation counts and latest annotation timestamps are added to session summaries and their test fixtures.
Annotation filtering and sorting
src/domain/admin/adminSessionFilters.ts, src/domain/admin/adminSessionFilters.test.ts
Filtering supports annotated-only sessions, while sorting supports active annotation count and latest annotation time.
Admin annotation controls and display
src/routes/AdminPanel.tsx, src/components/admin/AdminSessionFilters.tsx, src/components/admin/AdminSessionRow.tsx, src/routes/AdminPanel.test.tsx
The admin panel wires the annotated-only state and sort options, and session rows display positive active annotation counts.
Estimated code review effort: 3 (Moderate) ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AdminSessionFilters
  participant AdminPanel
  participant filterAdminSessions
  participant AdminSessionRow
  AdminSessionFilters->>AdminPanel: toggle annotatedOnly or choose annotation sort
  AdminPanel->>filterAdminSessions: apply annotation filter and sort
  filterAdminSessions-->>AdminPanel: return ordered session summaries
  AdminPanel->>AdminSessionRow: render session summary
  AdminSessionRow-->>AdminPanel: display active annotation count
Loading

Possibly related PRs

  • gelbh/jetlag#9: Also extends session summaries with annotation-derived metadata.
  • gelbh/jetlag#11: Also changes active-session summary construction in listActiveSessions.mjs.
  • gelbh/jetlag#71: Also adds fields to active session summaries in listActiveSessions.mjs.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/admin-annotation-filters
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch feat/admin-annotation-filters

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

@gelbh
gelbh force-pushed the feat/admin-annotation-filters branch from 35215ab to 24dc16b Compare July 24, 2026 20:17

@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: 2

🤖 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/domain/admin/adminSessionFilters.test.ts`:
- Around line 114-123: Extend the admin session filter tests around
filterAdminSessions to cover lastAnnotation sorting with annotatedOnly disabled,
preserving the existing sort configuration and asserting session IDs in the
order many, few, none so the null lastAnnotationAt case is exercised.

In `@src/routes/AdminPanel.test.tsx`:
- Around line 126-127: Add a behavior-focused route test in AdminPanel.test.tsx
using sessions with both annotated and unannotated values, then click the
Annotated filter and assert only annotated sessions remain along with a visible
positive “N ann” count. Update the related fixtures currently using null/zero
annotation fields so the test exercises the annotation UI filtering and count
paths.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: ff71ac8b-895b-46b1-a2a5-a9dd1ab552cb

📥 Commits

Reviewing files that changed from the base of the PR and between e1fe678 and 24dc16b.

📒 Files selected for processing (9)
  • functions/admin/listActiveSessions.mjs
  • src/components/admin/AdminSessionFilters.tsx
  • src/components/admin/AdminSessionRow.tsx
  • src/domain/admin/adminSessionFilters.test.ts
  • src/domain/admin/adminSessionFilters.ts
  • src/routes/AdminPanel.test.tsx
  • src/routes/AdminPanel.tsx
  • src/services/admin/adminSessions.test.ts
  • src/services/admin/adminSessions.ts

Comment on lines +114 to +123
expect(
filterAdminSessions(sessions, {
query: "",
liveOnly: false,
annotatedOnly: true,
mode: "all",
state: null,
sort: "lastAnnotation",
}).map((entry) => entry.sessionId),
).toEqual(["many", "few"]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Cover lastAnnotation sorting when the timestamp is missing.

annotatedOnly: true removes none before sorting, so the lastAnnotationAt: null branch is untested. Add an unfiltered assertion expecting many, few, then none.

As per path instructions, **/*.test.{ts,tsx} requires edge cases for new logic.

🤖 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 `@src/domain/admin/adminSessionFilters.test.ts` around lines 114 - 123, Extend
the admin session filter tests around filterAdminSessions to cover
lastAnnotation sorting with annotatedOnly disabled, preserving the existing sort
configuration and asserting session IDs in the order many, few, none so the null
lastAnnotationAt case is exercised.

Source: Path instructions

Comment on lines +126 to +127
lastAnnotationAt: null,
activeAnnotationCount: 0,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Exercise the annotation UI behavior.

These fixtures only use null/zero annotation values. Add a route test with annotated and unannotated sessions that clicks Annotated and verifies filtering plus a visible positive N ann count.

As per path instructions, **/*.test.{ts,tsx} requires behavior-focused assertions on changed code paths.

Also applies to: 169-170, 228-229, 271-272

🤖 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 `@src/routes/AdminPanel.test.tsx` around lines 126 - 127, Add a
behavior-focused route test in AdminPanel.test.tsx using sessions with both
annotated and unannotated values, then click the Annotated filter and assert
only annotated sessions remain along with a visible positive “N ann” count.
Update the related fixtures currently using null/zero annotation fields so the
test exercises the annotation UI filtering and count paths.

Source: Path instructions

@gelbh
gelbh merged commit 484aad6 into main Jul 24, 2026
8 checks passed
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.

1 participant