Skip to content

fix(desktop): keep new sessions in recency order#42609

Open
seyeeL wants to merge 1 commit into
NousResearch:mainfrom
seyeeL:fix/desktop-sidebar-natural-order
Open

fix(desktop): keep new sessions in recency order#42609
seyeeL wants to merge 1 commit into
NousResearch:mainfrom
seyeeL:fix/desktop-sidebar-natural-order

Conversation

@seyeeL

@seyeeL seyeeL commented Jun 9, 2026

Copy link
Copy Markdown

Summary

Fixes #42516.

The desktop sidebar was persisting the initial session order even when the user had not manually reordered sessions. After that saved order existed, newly-created sessions were treated as unknown ids and appended after the saved ids, so they appeared at the bottom instead of following recency order.

This PR:

  • keeps missing or empty session order empty instead of initializing it from loaded sessions
  • treats saved natural-order subsets as old generated state and clears them
  • removes empty string-array localStorage preferences instead of writing []

Verification

  • npx --prefix apps/desktop vitest run src/app/chat/sidebar/order.test.ts src/lib/storage.test.ts --environment jsdom
  • npm run --prefix apps/desktop type-check

Commit Author Check

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: Approved

Clean, well-scoped refactor that extracts reconcileOrderIds into a dedicated module with its own tests. The logic correctly handles the recency-order issue where new sessions were being incorrectly seeded with a natural order. The test coverage is appropriate.

  • Extracts reconcileOrderIds to order.ts for reusability
  • Adds dedicated test file with three clear test cases
  • Fixes the session ordering bug without touching unrelated code

Reviewed by Hermes Agent (cron batch)

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop: new sessions appear at bottom because sidebar order is auto-persisted on startup

3 participants