仓库 →

Sessions & Undo

AtomCode persists every conversation by default, so you can restore, resume, clear, or compact at any time. A single /undo rewinds conversation memory back to any earlier turn.

Session lifecycle

Each atomcode launch creates a session. A session contains:

Session data is persisted under ~/.atomcode/sessions/, grouped by project (working-directory hash).

Resuming sessions

Continue the last one from the CLI

atomcode -c        # or atomcode --continue

The most common case: pick up exactly where you left off yesterday.

Switch sessions inside the TUI

/resume

Opens the session picker. It lists this project's historical sessions newest-first; jump to any of them quickly. Each entry uses the most recent user prompt as its label for easy recognition.

Start a clean new session

/session

Spin up a fresh context without changing the working directory. Good for "the previous task is wrapped — onto something totally unrelated".

Background sessions (/bg)

Need to juggle multiple tasks without losing the current conversation? /bg parks the current session in the background and opens a fresh foreground — switch back any time. Up to 16 concurrent background slots.

CommandWhat it does
/bgSend the current session to the background and open a new foreground
/bg list (alias /bg ls)List all background sessions: slot, ID, state, created, summary
/bg <N>Resume slot N as foreground (the current foreground is swapped to background)
/bg drop <N>Drop background slot N
/bg help (aliases -h, --help)Show built-in help

Session states

The state column in /bg list reflects what each background session is doing:

So /bg isn't just "suspend" — the model actually keeps working in the background; when you switch back, the result is already there.

/background <task> — one-shot dispatch

If you don't want to swap foreground/background manually and just want to "have it look something up real quick", use the /background compatibility entry:

/background list every unused dependency under src

It starts a one-shot task in a /bg slot (configured with a read-only tool subset by default so the main conversation context isn't polluted). When done, check /bg list, use /bg <N> to read the result, /bg drop <N> to discard.

Typical pattern

The foreground is debugging module A; the model is editing and running cargo check (slow). You realise you also want to refactor module B — /bg straight to a new foreground for B. The build on A finishes in the background, state flips to done; /bg 1 to switch back and read the result.

Clear vs compact vs new session

CommandKeeps historyKeeps session IDWhen to use
/clearNoYes"Reset the dialogue" within the same session; keep the session entry so you can /resume later
/compactPartial (summarised)YesContext is filling up but you don't want to lose the earlier thread
/sessionStarts new threadNo (new ID)Beginning a completely unrelated task

Rewinding conversation memory with /undo

/undo rewinds conversation memory to before a given turn — removing that turn and everything after it — and drops the prompt you typed for that turn back into the input box so you can edit and resend it.

/undo      # rewind the last turn
/undo N    # rewind to turn N (1-based; counts only the prompts you actually typed)

The scrollback dividers for the removed turns are cleared too, and the session is saved immediately — so your next /resume reflects the rewound state.

Where the boundary is

/undo rewinds conversation memory only — it does not restore files on disk. If the AI edited code during those turns, those changes stay in your working tree; use /diff to review and revert them manually, or rely on git. You can't /undo while a turn is in flight — press Esc to cancel it first.

Inspecting and trimming cost

/cost

Shows cumulative input / output tokens for the current session. When the number approaches the provider's context_window:

Multi-project workflows

AtomCode groups sessions by working directory. Recommended ways to switch:

Next steps