Skip to content

fix: sort app sessions by updated time#27954

Draft
Hona wants to merge 1 commit into
anomalyco:devfrom
Hona:luke/session-list-sort
Draft

fix: sort app sessions by updated time#27954
Hona wants to merge 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" was created-rank 22 but updated-rank 6, so it appeared around position 6 only after increasing the loaded page.

This PR keeps the API default unchanged for compatibility, but gives app consumers a way to ask for the ordering they actually display.

Summary:

  • Add optional v2 session list sort=created|updated without changing the default created sort.
  • Include sort in session cursors so pagination stays on the selected timestamp.
  • Make the app sidebar session loader request updated sorting and trim by updated order.
  • Regenerate OpenAPI/JS SDK.

Tests:

  • 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; first run hit Windows cleanup flake, rerun passed)
  • bun test --timeout 30000 test/server/httpapi-query-schema-drift.test.ts (packages/opencode)
  • bun run script/httpapi-exercise.ts --mode coverage --fail-on-missing --fail-on-skip (packages/opencode)
  • bun typecheck (packages/opencode, packages/app, packages/sdk/js)
  • pre-push bun turbo typecheck

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