Skip to content

feat(acp): session history — list and resume past conversations #1004

@bug-ops

Description

@bug-ops

Problem

ACP clients (e.g. Zed) display a "Recent" panel listing previous sessions and allow users to resume them. Zeph currently stores ACP session events in SQLite (acp_sessions + acp_session_events tables via SqliteStore) but exposes no API surface to list or resume past sessions. Clients have no way to query history and render the panel.

Solution

1. ACP transport — new endpoints

Implement two new HTTP/WS endpoints in zeph-acp transport layer:

  • GET /sessions — returns a paginated list of sessions with metadata:
    [
      { "id": "...", "title": "...", "created_at": "...", "updated_at": "...", "message_count": 5 }
    ]
  • GET /sessions/{session_id}/messages — returns the full event log for a session so the client can replay it.

2. ACP agent — resume protocol

When a client sends POST /runs (or opens a WS) with an existing session_id, the agent must:

  1. Load stored events from SqliteStore::load_acp_events.
  2. Reconstruct conversation context and inject it into the ContextBuilder before the first LLM call.
  3. Continue appending new events to the same session row.

Currently SqliteStore::create_acp_session uses INSERT OR IGNORE, so re-using an existing ID is safe — but the agent loop does not yet load prior context on resume.

3. Session title inference

After the first assistant turn, auto-generate a short title (first ~60 chars of the first user message, or a one-shot summarisation call) and persist it via SqliteStore::update_session_title.

4. TUI — session browser panel

Add a collapsible session history panel (keybind: H) to zeph-tui:

  • List recent sessions with truncated title + relative timestamp.
  • Enter switches the active session, loading its context.
  • D deletes a session (with confirmation prompt).

5. Config

Add [memory.sessions] section to config.toml:

[memory.sessions]
max_history = 100          # sessions to keep; 0 = unlimited
title_max_chars = 60

6. CLI

zeph sessions list              # print sessions table
zeph sessions resume <id>       # open existing session in interactive mode
zeph sessions delete <id>       # remove session and events

Affected crates

Crate Change
zeph-acp new HTTP handlers, resume logic in agent loop
zeph-memory list_acp_sessions already exists; add updated_at + message_count columns
zeph-tui new session browser panel
zeph-core / src/main.rs CLI subcommands, config struct

Acceptance criteria

  • GET /sessions returns sessions ordered by updated_at DESC.
  • Client sending an existing session_id receives conversation context from previous turns.
  • Session title is auto-populated after the first assistant reply.
  • TUI shows recent sessions and allows switching.
  • zeph sessions list prints a table with ID, title, date.
  • Unit tests cover resume context reconstruction and title inference.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions