Skip to content

perf: filter archived sessions and sort by update time in session list API#6807

Closed
iso2kx wants to merge 1 commit into
anomalyco:devfrom
iso2kx:fix/session-list-double-load
Closed

perf: filter archived sessions and sort by update time in session list API#6807
iso2kx wants to merge 1 commit into
anomalyco:devfrom
iso2kx:fix/session-list-double-load

Conversation

@iso2kx

@iso2kx iso2kx commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Mar 5, 2026
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