Skip to content

accounts: keep the list order stable — always - #162

Merged
wingleeio merged 2 commits into
mainfrom
zeron/account-order-stability
Aug 18, 2026
Merged

wingleeio merged 2 commits into
mainfrom
zeron/account-order-stability

Conversation

@wingleeio

@wingleeio wingleeio commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #161, plus the related UX complaint: switching accounts moved the switched-to card to the top of the accounts page.

Two reshuffle sources, both removed

Same-millisecond logins (#161). The page sorts slots by created_at, which has millisecond resolution. Two logins saved back-to-back tie, and the stable sort then preserves input order — which is read_dir enumeration, filesystem-arbitrary for UUID-named slot files. That's the cursor_slot_swap_round_trip flip ([frank, erin] vs [erin, frank]), and it equally means a user's page could reorder between restarts. Fix: write_slot stamps a brand-new slot strictly after every sibling (max+1 bump), so creation stamps are collision-free going forward; the sort also carries the slot id as a deterministic tie-break for any pre-existing collided files.

Active-first re-sort. The engine deliberately lists in creation order — its comment says "never active-first — switching must not reshuffle the cards" — but the UI's provider_accounts re-sorted active-first, defeating it. Removed; the Active badge already marks the live account. The UI test that enshrined the old behavior now asserts the opposite (provider_grouping_keeps_engine_order_even_when_active_is_later).

Also: workspace build repair

cargo test --workspace was failing to compile on main: #159 added RunRequest.worktree and updated every initializer except the opencode probe example that landed in parallel via #157 (no CI job builds examples). One-line fix included here.

Validation

  • m5c_accounts_uploads_titles green 5/5 consecutive runs (previously order-dependent).
  • Full workspace suite: 925 passed, 0 failed.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

wing-anara and others added 2 commits August 18, 2026 20:19
Two ways the accounts page reshuffled, both gone:

- Same-millisecond logins (issue #161): the sort key was created_at
  alone, ms-resolution; a tie fell back to read_dir enumeration order,
  which is filesystem-arbitrary for UUID-named slot files — the flaky
  cursor_slot_swap_round_trip flip. New slots now get stamped strictly
  after every sibling (max+1 bump in write_slot), and the sort carries
  the slot id as a deterministic tie-break for pre-existing collided
  files.

- Switching accounts moved the switched-to card to the top: the engine
  deliberately lists in creation order ("never active-first"), but the
  UI's provider_accounts re-sorted active-first, defeating it. The
  re-sort is removed; the Active badge already marks the live account,
  and a list that reshuffles under the click reads as broken.

Fixes #161.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PR #159 added RunRequest.worktree and updated every initializer except
the opencode probe example, which landed in parallel via #157 — the
cross-PR race broke `cargo test --workspace` (examples compile there;
no CI job builds them).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@wingleeio
wingleeio merged commit d33f798 into main Aug 18, 2026
1 check passed
guilhermexp pushed a commit to guilhermexp/comet that referenced this pull request Aug 30, 2026
…lity

accounts: keep the list order stable — always
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.

m5c cursor_slot_swap_round_trip fails on main: account list order unstable

2 participants