Skip to content

Add sort dropdown to session list #18

Description

@Mr-Godot

Context

Sessions are always sorted by recency with pinned items boosted. Users want control over sort order.

Action

  1. Add sort param to route search schema: z.enum(['latest', 'mostActive', 'longest', 'mostTokens', 'starred']).default('latest')
  2. Add sort dropdown to SessionFilters (Row 1 alongside search)
  3. Update paginatedSessionsInputSchema in sessions.api.ts to accept sort
  4. Implement server-side sort logic in paginateAndFilterSessions:
    • latest: lastActiveAt DESC (default, with pin boost)
    • mostActive: messageCount DESC, then lastActiveAt DESC
    • longest: durationMs DESC, then lastActiveAt DESC
    • mostTokens: needs token data — may need to add to SessionSummary or approximate from fileSizeBytes
    • starred: filter to pinned only, then by lastActiveAt DESC
  5. Update sessions.queries.ts to pass sort param

Note on "mostTokens"

SessionSummary currently has no token count field. Options:

  • Use fileSizeBytes as proxy (larger files = more tokens)
  • Add totalTokens to SessionSummary by reading stats-cache
  • Parse token usage from JSONL during summary scan

Acceptance Criteria

  • Sort dropdown visible next to search
  • All 5 sort options work correctly
  • URL reflects sort choice (?sort=mostActive)
  • Page resets to 1 when sort changes
  • Default: "Latest"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions