Skip to content

feat(cli): rat resurrect — replay a dead log into a fresh daemon - #8

Closed
seamoss wants to merge 1 commit into
devfrom
feat/resurrect
Closed

seamoss wants to merge 1 commit into
devfrom
feat/resurrect

Conversation

@seamoss

@seamoss seamoss commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Summary

`rat resurrect ` spawns a fresh daemon whose log is pre-seeded with an old session's `PtyOutput`, then attaches. You get the visible scrollback back; the new shell, env, and cwd are fresh (the original PTY is gone).

```sh
rat resurrect ~/.local/state/rat/.log
rat resurrect agent # resolves via meta file (dead sessions OK)
rat resurrect agent -n agent-ii # give the new session a different name
```

Daemon gets a new `--seed-log ` flag. Seed replay happens between `SessionStarted` and the PTY spawn, followed by a yellow `-- rat resurrect: previous session replayed above --` separator.

Test plan

  • cargo build + clippy + fmt + test green
  • CI green
  • Smoke: create session, type content, kill daemon, `rat resurrect `, verify scrollback renders and new shell works

New `rat resurrect <source>` subcommand. Source is either a .log path
or a session name/id; for names, look up the meta file (works for
dead sessions too — metas outlive the process until clean shutdown
or `rat kill` sweeps them).

Plumbing:
- Daemon gets a new `--seed-log <path>` flag. Between SessionStarted
  and the PTY spawn, it reads the seed log's PtyOutput events and
  re-appends them to the fresh log, then writes a yellow separator
  marker so the user can see where the new shell begins. Non-visible
  events (ClientInput, Resized, SessionStarted/Ended) are dropped.
- Client gets `spawn_daemon_with_seed` as the plumbing core;
  `spawn_daemon` is now a thin `seed_log=None` shim over it, so the
  existing callers (`new`, `spawn_bare`, post-attach new-session) are
  unchanged.

What resurrect rebuilds: visible scrollback. What it doesn't: the
original process, env, cwd. This makes it genuinely useful after a
daemon crash or host reboot without pretending to be a full session
migration. Session migration is a separate roadmap item (durable
state across hosts).
@seamoss

seamoss commented Apr 24, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #11 — combined to avoid peer-merge conflict churn. Original commit preserved there.

@seamoss seamoss closed this Apr 24, 2026
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.

1 participant