Context
Sessions are always sorted by recency with pinned items boosted. Users want control over sort order.
Action
- Add
sort param to route search schema: z.enum(['latest', 'mostActive', 'longest', 'mostTokens', 'starred']).default('latest')
- Add sort dropdown to SessionFilters (Row 1 alongside search)
- Update
paginatedSessionsInputSchema in sessions.api.ts to accept sort
- 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
- 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"
Context
Sessions are always sorted by recency with pinned items boosted. Users want control over sort order.
Action
sortparam to route search schema:z.enum(['latest', 'mostActive', 'longest', 'mostTokens', 'starred']).default('latest')paginatedSessionsInputSchemain sessions.api.ts to acceptsortpaginateAndFilterSessions:latest: lastActiveAt DESC (default, with pin boost)mostActive: messageCount DESC, then lastActiveAt DESClongest: durationMs DESC, then lastActiveAt DESCmostTokens: needs token data — may need to add to SessionSummary or approximate from fileSizeBytesstarred: filter to pinned only, then by lastActiveAt DESCsessions.queries.tsto pass sort paramNote on "mostTokens"
SessionSummary currently has no token count field. Options:
fileSizeBytesas proxy (larger files = more tokens)totalTokensto SessionSummary by reading stats-cacheAcceptance Criteria
?sort=mostActive)