Skip to content

[feature request] When a session resume fails, say so and offer the recent sessions instead of starting fresh in silence #311

Closed

Description

@GabrielDumbrava

Use case

A tab's stored session id can point at a conversation the CLI never wrote, or at one that is gone.
When that happens the spawn exits at once, termic falls back to a fresh session, and nothing says so: the tab looks normal and the agent simply does not know what it was doing.
The user only finds out by asking the agent, and then has to go through ~/.claude/projects/<cwd>/*.jsonl by hand to find the id worth resuming.

Seen on 1.4.6, before #306's fix was in: a tab minted a session at spawn, the user then /resumed another one inside it, and termic stored the minted id because nothing reported the move.
Renaming the task respawned the tabs, --resume <minted id> answered "No conversation found", and the tab started over.
#306 closes that particular road to it, but not every one: a session file can also be deleted, pruned by the agent's own retention, or live in an account store the task no longer runs under.

What I would like instead

On a resume that fails, say so in the tab and offer the recent sessions for that working directory, so the user can pick the one to continue.
Something like: "Could not resume . It has no conversation on disk." and a short list, newest first, each with a time and its first user message, plus "start fresh" as the explicit alternative.

Sketch

  • The failure is already detected: TerminalPane's rapid-exit path sets failedResumeRef and respawns fresh (RESUME_FAILURE_MS), and decideResume reads it. That is the hook to render on rather than a new detector.
  • The candidate list is a new Rust command over the agent's own transcript dir for the task's cwd (claude: <config dir>/projects/<slug>/*.jsonl; the config dir is already resolved per agent and per account by agent_dirs). Returning id, mtime and the first user line is enough to choose.
  • A per-agent capability, not a claude special case: codex and devin resume by id too, and an agent with no readable transcript dir simply offers nothing and keeps today's silent fallback.
  • The list is a suggestion, never automatic: picking one sets the tab's session id and respawns, which is the same path /resume would have taken.

I would like to implement this.

Activity

  1. GabrielDumbrava commented on Sep 21, 2026

    @GabrielDumbrava
    ContributorAuthor

    A second real cause, seen on 1.6.0, that the fix should cover.

    The stored id was correct this time: the tab's session had been continued by claude into a new one, and termic (with #306's hook) held the new id.
    The resume still exited within RESUME_FAILURE_MS, and termic started a fresh session.
    Loading the same id by hand, without sending anything, shows why:

    Session <id> is running as a background session (<short id>).
    Run `claude attach <short id>` to open it, or `claude stop <short id>` first to resume it here.
    Add --fork-session to branch off a copy instead.
    

    (exit code 1)

    So the conversation was not lost at all.
    It was alive in claude's background session registry (<config dir>/jobs/<short id>/state.json, state blocked, waiting on the user), and --resume refuses a session that is running there.
    The only information that would have saved it, claude's own message naming the two ways out, is exactly what the silent fallback throws away.

    For the fix:

    • Tell the two failures apart instead of treating every rapid exit the same. "No conversation on disk" wants the list of recent sessions; "running as a background session" wants the session it named, not a list.
    • For the background case, offer what claude offers: attach to it, or stop it and resume here (claude stop <id>, then the same --resume). Both need the SAME config dir the session ran under, which is the tab's account store, not necessarily the agent's default dir.
    • Either way, show claude's line rather than paraphrase it: it is specific and already correct.
  2. 5 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions