cx-wtndw acpmux: the session list pages by keyset cursor

Merged
TE
23d ago
+1210-298

cx-wtndw. This is the second slice of Leo's 10-14 ask for cursor-based paging on the unbounded lists that cross the daemon/server boundary. All Chats landed in #20554; this one covers the session list.

What changes

  • _acpmux/sessions and _acpmux/watch take an optional limit and cursor.
    • With a limit, the reply is {sessions, nextCursor}, and nextCursor is null on the last page.
    • Without a limit, the reply is the full list, unchanged, with no nextCursor. The app's sidebar, permission and census feeds keep working as they are.
  • The cursor uses the same keyset design as #20554: k<updatedAt hex>.<FNV-1a of sessionId>, at most 30 characters. The time is clamped the same way where the cursor is built and where it is looked up. If the named session is gone, the next page starts at the first session no newer than it. A bad cursor or limit is refused with invalid_params.
  • The list now has a stable order: updatedAt descending, then sessionId ascending.
  • The _acpmux/presets request arm moves verbatim into server/requests/presets.rs, so requests.rs stays under the god-file budget. That check passes for every touched file.

Evidence

session_list_order::session_list_pages_neither_repeat_nor_skip_while_sessions_move pages a list with limit 5 while sessions move and leave. It also checks that a call without a limit still returns everything.

  • Red at 38f2b4a558933: page one is the whole list, because the limit was ignored.
  • Green at 72b4977bfe29f.
  • Merged head b1aba2b115a8e: session_list 2 passed, chats_deltas + chats 12 passed, cargo clippy -p acpmux --tests -D warnings clean.
  • All of the above ran on the private Linux builder.
  • crash_ratchet.py and check-no-godfiles.sh --only rust pass.

The sessionId tie-break is not exercised directly, because the fixtures use distinct times. macOS hosted Rust jobs did not run.

Changelog

  • none (daemon API addition; no client uses the limit yet)

🤖 Generated with Claude Code


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


Summary by cubic

Adds keyset cursor paging to _acpmux/sessions and _acpmux/watch so clients can page through long session lists without fetching them all at once.

New Features

  • With limit and optional cursor, the reply is {sessions, nextCursor}, with nextCursor null on the last page; without limit, the full list is returned unchanged, so the sidebar, permission, and census feeds keep working as before.
  • The cursor is k<updatedAt hex>.<FNV-1a of sessionId>, at most 30 characters, and pages neither repeat nor skip a session when sessions move or leave between pages.
  • A bad cursor, a zero limit, or a limit that is not a positive integer is refused with invalid_params.
  • The session list now has a stable order: updatedAt descending, then sessionId ascending.
  • _acpmux/presets moved verbatim into server/requests/presets.rs, keeping requests.rs under the god-file budget.