Repository navigation
Description
Environment
macOS 26.6.2, arm64.
Termic 1.4.4.
Claude Code 2.1.273.
Tasks on a main checkout, several of them with two claude tabs.
The problem
After a relaunch, a claude tab resumes a session other than the one it was last working in.
The agent then says it never worked on the thing the tab was doing, and the user has to hunt through transcripts for the right session and resume it by hand.
It is not caused by two agent tabs in one task: every tab's stored session id points at a real session in the right config dir.
Cause: /clear (and /resume) start a new session termic never hears about
Termic stores one session id per tab (TerminalTab.sessionId), minted with --session-id and resumed with --resume <id>.
/clear inside claude starts a NEW session with a new id in the same process.
All work after it goes into the new session, but the tab keeps the old id, so the next relaunch resumes the session from before the /clear.
Every relaunch then brings back the original session, and every /clear after it leaves one more branch that termic cannot find.
The agent, asked what it was doing, searches transcripts itself and can land on an intermediate branch rather than the latest one.
Evidence from one task (anonymised)
One tab, one --name, spawned by termic as claude --resume <A> --name <task> on every relaunch (debug log):
| Session | Active | Started by | Contents |
|---|---|---|---|
| A | Aug 20 → Sep 15 13:43 | first spawn, the id termic stores | sporadic mentions of the ticket |
| B | Sep 11 → Sep 16 | /clear |
a few mentions |
| C | Sep 14 18:58 → Sep 15 11:21 | /clear |
the ticket, review round 2, waiting on the user |
| D | Sep 15 13:43 → 20:15 | /clear issued in A after a relaunch (D's first entry is A's last) |
the ticket to the end: merged and closed |
After another relaunch the tab resumed A.
The agent said the ticket was not worked in this session and pointed at C, whose last state ("waiting for round 3 or hold") was already stale: D had finished it.
At the time of writing, three more live tasks on the same machine have the same shape: the stored id is older than a same-named session that starts with /clear.
They will resume the pre-/clear session on the next relaunch.
No orphaned session was found that started any other way than /clear.
Measurements
SessionStart hook that logs its stdin payload and environment, claude 2.1.273, interactive session in a scratch directory:
| Action | source |
session_id |
CLAUDE_CODE_ENTRYPOINT |
|---|---|---|---|
| startup | startup |
S1 | cli |
/compact (real conversation) |
compact |
S1 (unchanged) | cli |
/clear |
clear |
S2 (new, every time; twice in a row gave two new ids) | cli |
/resume <S1> |
resume |
S1 (the resumed session) | cli |
/compact on an empty conversation |
no event | ||
nested claude -p inheriting the tab's TERMIC_TASK_ID / TERMIC_PTY |
startup |
its own id | sdk-cli (set by claude even when the parent env says cli) |
Notes from measuring:
session_idis always the session the work continues in, so it is exactly what the tab should store afterclear,resumeandcompact.CLAUDE_CODE_CHILD_SESSIONis NOT a usable nesting signal: claude sets it for every hook subprocess, the main session's included.- A claude process started from inside another claude session also inherits
CLAUDE_CODE_CHILD_SESSION, which turns transcript saving off ("Transcript saving is off, inherited CLAUDE_CODE_CHILD_SESSION marker"). Worth knowing for anyone measuring this from an agent.
Proposed fix
Termic already has the channel: codex and devin report their session id from SessionStart over the hook OSC (session <id>), and TerminalPane stores it with setTabSessionId.
Do the same for claude, with a guard:
- accept the id only when
sourceisclear,resumeorcompact, neverstartup(termic already knows that id: it passed--session-id/--resume); - and only when
CLAUDE_CODE_ENTRYPOINTiscli, so a nestedclaude -p(sdk-cli), which inheritsTERMIC_PTYand would otherwise write into the tab's terminal, cannot overwrite the tab's id.
Not covered by that guard: an INTERACTIVE claude started from inside the agent and then /cleared. Rare (the agent has no interactive terminal to start one in), but worth a note.
Until then, the workaround is /resume <id> inside the tab with the right session's id after a relaunch.
Activity
fix(agents): resume the claude session a tab moved to with /clear (si…
simion commentedon Sep 17, 2026
This shipped in v1.5.0, released today. Thanks for reporting!
feat(agents): a failed resume opens the agent's own session picker (#311
fix(agents): resume the claude session a tab moved to with /clear (si…