SessionAdoption

Adopt a Claude Code session that runs, or ran, in a terminal into the session store, and build the command that hands a session back to a terminal (trove-parts §TPN-7).

Group libllmsession

In the namespace octomy::llmsession. Declared in src/libs/libllmsession/llmsession/SessionAdoption.hpp.

Detailed description

adopt() follows the steps of §TPN-7:

  1. It finds the transcript: by its path, by the session id, or in the folder. A folder with more than one session gives the candidates, newest first, and adopts nothing.
  2. It needs confirmClosed: the caller states that no terminal still runs the session. Two live copies of one Claude Code session write into one transcript (§TPR-7), and the part cannot see a claude that a person runs (R10).
  3. It creates a record of kind coding in the session's folder, with the Claude Code id as provider_session.
  4. TranscriptImport turns the transcript into events, once. Each block carries "imported": true.
  5. When the folder is a linked git worktree, the record names it, so that Trove can give the session a lane.

The next message to the session resumes it with the stream transport, in its folder. exportCommand() is the way back: the command that resumes the session in Claude Code's own view.

See also octomy::llmsession::TranscriptImport, octomy::llmsession::SessionRunner.

In this section