Skip to content

Conversation

@usvimal
Copy link

@usvimal usvimal commented Jan 4, 2026

Summary

  • Filter out archived sessions server-side in the /session list endpoint
  • Sort sessions by most recently updated first (descending)

Problem

The session list API was returning all sessions including archived ones, leaving filtering to the client. This causes:

  1. Unnecessary data transfer for archived sessions
  2. Client-side filtering overhead
  3. Sessions returned in arbitrary order

Solution

Use pipe() with filter() and sortBy() from remeda to:

  1. Exclude sessions where time.archived is set
  2. Sort by -time.updated (descending, most recent first)
const sessions = pipe(
  await Array.fromAsync(Session.list()),
  filter((s) => !s.time.archived),
  sortBy((s) => -s.time.updated),
)

Note

The client-side code in global-sync.tsx and sync.tsx already does similar filtering/sorting, but doing it server-side reduces data transfer and is more efficient.

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