fix(desktop): preserve manual pinned session order - #66051
Conversation
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM / Comment
Clean fix that separates pinned session ordering (user-persisted drag order) from regular sessions (activity-sorted). New sessionEntriesForSection helper is simple and well-commented. Tests cover both order-preservation cases. No issues found.
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment (resubmit — prior COMMENT activity noted)
Notes
- Minor fix/feature.
- No security concerns, no debug artifacts.
- LGTM.
Reviewed by Hermes Agent
|
Thanks for the focused fix. Current The PR's Automated hermes-sweeper review. |
What does this PR do?
Fixes pinned sessions snapping back after drag reordering in Hermes Desktop.
Two independent paths were undoing or rejecting the user's order:
SidebarSessionsSectionpassed pinned rows throughflattenSessionsWithBranches(), which sorts top-level entries by activity and therefore overwrote the persisted drag order at render time.setPinnedSessionOrder()rejected a visible reorder whenever the durable pin store also contained an unresolved or deduplicated pin that was not currently rendered.Pinned sections now render in their already-persisted order, while regular session sections retain activity ordering. Visible pin reorders are persisted without dropping unresolved durable pins.
Related Issue
Related to #47728.
This is intentionally narrower than open PR #43661: that PR redesigns native drag-to-pin/unpin and positional drop UX, while this PR fixes the current dnd-kit reorder path's render and persistence invariants. At the latest reviewed head of #43661, both affected current-main code paths were unchanged.
Type of Change
Changes Made
How to Test
Pin multiple sessions and drag an older session above a newer active session.
Release the row and confirm the Pinned section keeps the chosen order instead of snapping back to activity order.
Repeat while the durable pin list contains an unresolved/hidden pin; confirm visible rows reorder and the hidden pin remains stored.
Run:
npm --prefix apps/desktop run typecheck npm --prefix apps/desktop exec vitest run --environment jsdom src/store/layout-pinned-order.test.ts src/app/chat/sidebar/sessions-section-order.test.tsChecklist
Code
Documentation & Housekeeping
cli-config.yaml.example: N/A (no config changes).CONTRIBUTING.md/AGENTS.md: N/A (no architecture/workflow changes).Screenshots / Logs
Regression verification:
The fix was also verified manually in the packaged macOS Desktop app: pinned rows no longer snap back after release.