# Sessions & Resume

> Source: https://parallelworks.com/docs/ai/code/sessions

# 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

```bash
# 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 --resume
```

If 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 <kbd>Ctrl</kbd>+<kbd>T</kbd> 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 <kbd>Enter</kbd> to resume or <kbd>Esc</kbd> to go back to the list.
- **Expand details**: Press <kbd>Ctrl</kbd>+<kbd>E</kbd> to show the selected session's workspace, model, timestamps, and message count.
- **Toggle density**: Press <kbd>Ctrl</kbd>+<kbd>O</kbd> to switch between compact and comfortable row spacing.

Press <kbd>Enter</kbd> to resume the highlighted session, or <kbd>Esc</kbd> 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](/docs/ai/code/non-interactive#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](/docs/ai/code/settings) for where to configure `sessionRetentionDays`.

:::note Subagent transcripts
Transcripts of [subagents](/docs/ai/code/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](/docs/ai/chat) list. Chats saved to your account are managed separately; the [pw code overview](/docs/ai/code) lists the `pw ai chats` commands.

## Related Documentation

- [pw code Overview](/docs/ai/code): Feature overview and quick start
- [Non-Interactive Mode](/docs/ai/code/non-interactive): One-shot prompts and JSON output
- [Slash Commands](/docs/ai/code/slash-commands): In-session commands like `/resume` and `/rename`
- [Settings](/docs/ai/code/settings): Configure `sessionRetentionDays` and other options
- [Subagents](/docs/ai/code/subagents): Parallel task delegation
- [Interface & Shortcuts](/docs/ai/code/interface): The terminal interface
- [pw code command reference](/docs/cli/pw/code): Full CLI reference
