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:
- 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.
- 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 aclaudethat a person runs (R10). - It creates a record of kind
codingin the session's folder, with the Claude Code id asprovider_session. - TranscriptImport turns the transcript into events, once. Each block carries
"imported": true. - 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.