Skip to content

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

Closed

Description

@ajianaz

What problem does this solve?

A graphical client needs a session list: pick a session to continue, or start a new one. The TUI has it (/resume shows the newest 50 sessions from the global index, with a label, and leaves out the current one). tole serve does not:

  • GET /sessions lists only sessions that are live in the server process, with id and busy and nothing else (no name, folder or time).
  • POST /sessions {"resume": "<id>"} can reopen a session, but only a client that already knows the id can use it. After a serve restart, or on a second device (a phone next to a desktop), no client can learn the ids of existing sessions.

So without this, a remote client can only show the sessions it created itself. Found while writing the screen inventory for #561 (screen 2, gap A). It blocks the session list on every remote client (#527, #528, #529).

Proposed solution

An index read next to GET /sessions (route name to be decided in review, for example GET /sessions?scope=all or GET /sessions/index):

  • Newest first, paginated like GET /sessions/{id}/entries (a limit with a clamp, a cursor), so a large history never turns into one huge response.
  • Per session: id, a label (the fact/session_name register when set, otherwise the first user message, as the TUI's /resume does), workspace, last-activity time, live and busy.
  • Scope: only sessions under the server's own workspace (the same jail that POST /sessions {"resume"} applies to cwd), never other folders. The token already grants prompting and approvals, but an index of the whole machine would also reveal other folders and session titles. Recommended, to be confirmed by the owner.
  • Read the session index (session_index.rs) and avoid replaying every session file on each call: the existing sessions --all replays all files per listing and has no pagination (noted in the discussion of epic: UI stack — solid core seam first, then GPUI desktop, Flutter mobile, web #523). The cost has to be bounded here, for example by reading only the index record and the last entry timestamp, or by a small cache.

Alternatives considered

  • Extend GET /sessions with the extra fields only: no way to see sessions that are not live, which is the point of this issue.
  • Expose the global index of the whole machine: simplest, but widens what one token reveals.

Open question for the owner

Workspace-only scope (recommended) or the global index?

Acceptance criteria

  • The new route lists sessions that are not live (after a serve restart) with name, workspace and last activity, newest first, with pagination.
  • A session outside the server's workspace is never listed; covered by a test.
  • A listing with thousands of sessions does not replay every session file (a bounded cost, with a test or a measured number in the PR).
  • An id from the list can be passed to POST /sessions {"resume": ...} and works.
  • 401 without the token; docs/mobile-control.md and the CHANGELOG are updated in the same PR.

Part of #523. Related: #524, #561, #571.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpending

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions