Skip to content

Implement replay_session RPC and wire up the CLI replay command - #62

Merged
seanwevans merged 1 commit into
mainfrom
claude/replay-session-rpc
Jun 27, 2026
Merged

Implement replay_session RPC and wire up the CLI replay command#62
seanwevans merged 1 commit into
mainfrom
claude/replay-session-rpc

Conversation

@seanwevans

Copy link
Copy Markdown
Owner

Summary

The CLI replay command POSTed to /rpc/replay_session, but no such function
existed — so it always failed. This implements the function (a v0.3 roadmap
item) and makes the command work end to end.

Changes

  • sql/replay_session.sqlreplay_session(user_id UUID, start_id INTEGER) RETURNS UUID. Re-queues the user's original commands
    (replay_of_command_id IS NULL) with id >= start_id, in order, by calling
    submit_command for each — so every replayed row is tagged with
    replay_of_command_id (the source) and a shared replay_run_id, and the
    executor is notified. Validates the user up front (SQLSTATE 22023) and
    returns the run id. This mirrors workers/replay_agent.py. Replaying only
    originals means a range that already contains prior replays can't snowball.
  • sql/install.sql / tests/conftest.py — install the new function.
  • cli/shell_cli.py — the replay subcommand now takes --user / --start
    and posts p_user_id / p_start_id, consistent with the other RPC clients.
    (The old --session arg pointed at a non-existent endpoint.)
  • SPEC.md — documents the new RPC under §2.

Tests

  • SQL (DB-backed): requeue-from-start tagging/ordering, originals-only on
    repeat replay, and unknown-user error.
  • CLI: replay posts the correct prefixed args, and main dispatches
    --user/--start correctly.

Verification

  • Full suite against a live Postgres 16: 48 passed.
  • install.sql applies cleanly; manual end-to-end shows replay_session returns
    a run id and queues the originals as new pending rows tagged to their sources.

🤖 Generated with Claude Code


Generated by Claude Code

The CLI `replay` command posted to /rpc/replay_session, but no such
function existed, so it always failed. Add the function and make the
command work end to end.

- sql/replay_session.sql: replay_session(user_id, start_id) re-queues the
  user's original commands (replay_of_command_id IS NULL) with id >=
  start_id, in order, via submit_command so each is tagged with
  replay_of_command_id and a shared replay_run_id and the executor is
  notified. Validates the user (SQLSTATE 22023) and returns the run id.
  Replaying a range that already contains prior replays cannot snowball.
- sql/install.sql and tests/conftest.py install the new function.
- cli/shell_cli.py: replay now takes --user/--start and posts
  p_user_id/p_start_id, consistent with the other RPC clients.
- SPEC.md documents the new RPC.
- Tests cover the SQL behavior (requeue from start, originals-only,
  unknown user) and the CLI argument wiring.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BixPb34oe2Ae5cXuz9WxbP
@seanwevans
seanwevans merged commit 0a41fdb into main Jun 27, 2026
2 checks passed
@seanwevans
seanwevans deleted the claude/replay-session-rpc branch June 27, 2026 13:23
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.

2 participants