Skip to content

fix: sort v2 session list by updated time#27954

Merged
Hona merged 1 commit into
anomalyco:devfrom
Hona:luke/session-list-sort
May 17, 2026
Merged

fix: sort v2 session list by updated time#27954
Hona merged 1 commit into
anomalyco:devfrom
Hona:luke/session-list-sort

Conversation

@Hona
Copy link
Copy Markdown
Member

@Hona Hona commented May 17, 2026

TL;DR: "Load more" looked random because the backend and sidebar disagreed on what "newest" meant.

From the actual local DB investigation, the API was selecting/paginating root sessions by created time, but the app sidebar displays sessions by updated time. That means a session created days ago but touched recently can be outside the first page, then appear near the top after clicking Load more. Concrete example from the repro data: "fix: ResizeObserver crash" now ranks #7 by updated time in C:\Repos\sst\opencode, so it belongs in the initial page.

Per review feedback, this removes the proposed sort parameter and just flips v2 session list ordering to updated time. Nothing was using the v2 endpoint yet.

Summary:

  • Sort v2 session list pagination by updated time.
  • Encode cursor boundaries with updated time.
  • Trim app sidebar root sessions by updated order.

Diff size:

  • 3 files
  • 10 insertions / 8 deletions

Validation:

  • Verified against real local DB: 697 root non-archived sessions, target session rank feature: Interactive Configuration #7, page 2 all below page 1 by updated time.
  • bun test src/context/global-sync.test.ts src/context/global-sync/session-trim.test.ts (packages/app)
  • bun test --timeout 30000 test/server/httpapi-session.test.ts (packages/opencode)
  • bun typecheck (packages/opencode, packages/app)

@Hona Hona force-pushed the luke/session-list-sort branch from 5b1fc4a to a4cf0b1 Compare May 17, 2026 01:26
@Hona Hona force-pushed the luke/session-list-sort branch 3 times, most recently from 015ae8c to 78335b8 Compare May 17, 2026 22:46
@Hona Hona force-pushed the luke/session-list-sort branch from 78335b8 to 2de638b Compare May 17, 2026 22:51
@Hona Hona changed the title fix: sort app sessions by updated time fix: sort v2 session list by updated time May 17, 2026
@Hona Hona marked this pull request as ready for review May 17, 2026 23:01
@Hona Hona requested a review from adamdotdevin as a code owner May 17, 2026 23:01
Copilot AI review requested due to automatic review settings May 17, 2026 23:01
@Hona Hona merged commit fc19dcc into anomalyco:dev May 17, 2026
10 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes inconsistent ordering between the v2 session list API and the app sidebar. The backend was paginating root sessions by creation time while the sidebar sorted by update time, causing recently-updated older sessions to skip the first page and reappear after "Load more". This change switches the v2 session list query/cursor and the app's trim logic to consistently order by update time.

Changes:

  • v2 session.list orders, cursor comparisons, and the start filter now use time_updated instead of time_created.
  • Encoded session cursor now stores time as epoch ms of session.time.updated.
  • trimSessions sorts root sessions by compareSessionRecent (updated time) before slicing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/opencode/src/v2/session.ts Switch list query ordering, cursor boundary, and start filter to time_updated.
packages/opencode/src/server/routes/instance/httpapi/handlers/v2/session.ts Encode cursor time from session.time.updated via DateTime.toEpochMillis.
packages/app/src/context/global-sync/session-trim.ts Sort root sessions by recency before trimming.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants