Skip to content

feat(serve): list past sessions with a name, folder and last activity - #970

Merged
ajianaz merged 3 commits into
developfrom
feat/serve-list-past-sessions
Nov 19, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/serve-list-past-sessions

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds GET /sessions/index?limit=&cursor= to tole serve: the past sessions on disk, newest first, as metadata only. Closes #572 (part of #523).

Why

A remote client could only show sessions it created itself: GET /sessions lists live sessions, and POST /sessions {"resume"} needs an id the client already knows. After a restart, or on a second device, there was no way to learn the ids.

Changes

  • New module crates/tole-cli/src/serve/past_sessions.rs; serve.rs only gets the route arm (before /sessions/{id}) and the mod line.
  • Response: {"sessions": [{id, name, folder, lastActivity, entries, turns, parent, live, busy}], "nextCursor", "skipped", "scanTruncated"}. No prompt, preview, tool output or transcript text.
  • Scope: the server's own sessions directory only; the request never names a path. With --sessions-dir (possibly shared), a session whose recorded folder is outside the workspace is not listed. The cwd of serve-opened sessions is not recorded in their header, so they show the workspace as folder.
  • Paging: limit default 50, clamped to 100 (0 or non-number is 400); cursor <mtime_ms>.<session id>, validated with the session-id charset, malformed is 400. Order: file mtime desc, id as tie-break.
  • Bounds per request: 10,000 directory entries (names and stat only), 200 files opened, 16 MiB per file (larger is skipped, not replayed), 64 MiB total. A torn, unreadable or oversized file is skipped, never an error. Symlinks and non-regular files are ignored.
  • docs/mobile-control.md and CHANGELOG ([Unreleased] / Added, Behavior Change) updated. An id from the list works with POST /sessions {"resume"}.

Decision for review: workspace-only scope (the issue's recommendation) rather than the machine-wide global index; the label is the fact/session_name register only, not the first user message, to keep transcript text out of the listing.

Testing

  • Unit tests (cargo test -p tole-cli --bin tole -- past_sessions): shape and paging, newest first, ties, bad limit/cursor 400, no transcript text, other folders never listed, unreadable/oversized/foreign files skipped, scan/open/byte bounds.
  • Integration tests/serve_past_sessions.rs: sessions listed after a restart, paging, bad cursor, resume of a listed id, 401 without a token.
  • cargo fmt --all; clippy -D warnings in default, --no-default-features, --no-default-features --features shell-tools; cargo test -p tole-cli: 1614 passed, 0 failed.

@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 2541207 into develop Nov 19, 2026
23 checks passed
@ajianaz
ajianaz deleted the feat/serve-list-past-sessions branch November 20, 2026 08:37
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.

feat(serve): list past sessions with a name, folder and last activity

1 participant