Sessions & Resume
Every pw code run creates a local session (a transcript of your conversation, the model used, and the workspace it ran in) stored on your machine. You can leave a session at any time and pick the conversation back up later, with the full history restored.
How Sessions Are Saved
Sessions are saved as one file per session under ~/.local/state/pw/code-sessions (the location respects XDG_STATE_HOME if set). Session IDs encode the start time plus a random suffix, for example 20260719-153045-a1b2c3d4.
A session in which you never sent a message is not listed and cannot be resumed, so launching pw code and quitting immediately leaves nothing behind.
Resuming a Session
# Resume the most recent session
pw code -r latest
# Resume a specific session by ID
pw code -r 20260719-153045-a1b2c3d4
# Pick a session from an interactive list
pw code --resumeIf you do not specify a model when resuming, the session's original model is used. When you exit an interactive session, pw code prints the exact command to resume that conversation.
The Session Picker
Running pw code --resume with no session ID opens an interactive picker listing your saved sessions, newest first. You can also open it from inside a running session with the /resume slash command.
In the picker you can:
- Filter as you type: The search box matches against a session's name, its first message, and its workspace path.
- Toggle scope: By default only sessions from the current directory are shown; switch Scope to All to see every saved session.
- Change sort order: Sort by last-updated (default) or creation time.
- Preview a session: Press Ctrl+T to view the selected session's full history, rendered as it would appear on resume, before committing to it. Scroll with the arrow keys; press Enter to resume or Esc to go back to the list.
- Expand details: Press Ctrl+E to show the selected session's workspace, model, timestamps, and message count.
- Toggle density: Press Ctrl+O to switch between compact and comfortable row spacing.
Press Enter to resume the highlighted session, or Esc to leave the picker without resuming.
Naming Sessions
Inside a session, use /rename <name> to give it a label. Named sessions show their name in the picker, which makes long-running work easier to find than a first-message preview.
Resuming After a One-Shot Run
One-shot (non-interactive) runs are saved as sessions too, and print a ready-to-run resume command when they finish. The reverse also works: combine -r with -p to continue any saved session non-interactively. See Resuming a One-Shot Session.
Session Retention
Sessions are kept forever by default. Sweeping is opt-in: set the sessionRetentionDays setting to a positive number, and each time pw code starts, session transcripts that have not been touched within that many days are deleted.
| Value | Behavior |
|---|---|
0 (or unset, or any negative value) | Sessions are kept forever (the default) |
| A positive number | Sessions untouched for that many days are deleted at startup |
The session you are currently resuming is never swept, and resuming a session restarts its retention clock. The window can also be changed from the Session retention row in /settings. See Settings for where to configure sessionRetentionDays.
Subagent transcripts
Transcripts of subagents are stored alongside their parent session and share its lifetime: they are cleaned up with the parent and revived together with it when you resume.
Local Sessions vs Account Chats
pw code sessions live only on your machine. They are not saved to your account and do not appear in the web Chat list. Chats saved to your account are managed separately; the pw code overview lists the pw ai chats commands.
Related Documentation
- pw code Overview: Feature overview and quick start
- Non-Interactive Mode: One-shot prompts and JSON output
- Slash Commands: In-session commands like
/resumeand/rename - Settings: Configure
sessionRetentionDaysand other options - Subagents: Parallel task delegation
- Interface & Shortcuts: The terminal interface
- pw code command reference: Full CLI reference