Skip to main content

Module history

Module history 

Source
Expand description

A harness’s own record of the conversations it had in a workspace, and the line that opens one of them again.

Every harness keeps its conversations under its home directory, which in QCode is the workspace’s home volume for the profile. The host cannot read a volume by itself (Docker keeps its volumes where only root reaches), so the reading happens inside the profile’s own container: the base image carries Node, and each harness has one short script, run with node -e, that knows where that harness writes and prints what it found. The script is the only part that knows a harness’s file format; everything it prints has one shape for all of them, and parse is where that shape is checked.

Each script is given two directories: where the workspace’s files are today (CODE_DIR) and where a QCode written earlier mounted them (LEGACY_CODE_DIR). A harness writes the working directory it was in into every conversation it records, so a conversation had before the mount was renamed names the old directory and only the old one; a script that knew a single name would leave every one of them out and the person would open the history list to find it empty. Both are looked under, and a conversation found twice is kept once.

What a script prints, one line per conversation of those directories and of no other: the conversation’s id, a tab, when it was last used in Unix milliseconds, a tab, and its title, which may be empty. A missing folder, an unreadable file or a record in a shape the script does not know is left out rather than guessed at, and nothing a script meets makes it fail: a harness that was never used in the workspace has simply had no conversations there. Each script reads files a line at a time, never holds a line longer than a mebibyte and stops a file after 256 MiB, so a transcript grown huge costs time but never the container’s memory.

Where each harness keeps its conversations was read from its documentation and source and checked in throwaway containers against Claude Code 2.1.276, opencode 1.18.31, Gemini CLI 0.60.0, Codex 0.155.0, Kimi Code CLI 2.1.0 and Qwen Code 0.24.4; the script of each one says what it relies on, and history_live.rs runs every script against records written the way those versions write them.

Structs§

Conversation
One conversation a harness had in the workspace.
Reading
The commands that read a harness’s conversations out of a workspace’s container for its profile.

Constants§

TITLE_CHARS
The most characters of a title that are kept. A title is a line in a list; the first words say which conversation it is, and a first prompt pasted whole would say nothing more.

Functions§

is_safe_id
Whether id can be handed to a harness on its command line as a conversation’s id.
parse
Reads what a harness’s script printed: every conversation it names, newest first.
read
Reads harness’s conversations in the workspace out of container, newest first.
read_starting
read, calling started when the container was stopped and had to be started for it, so the caller can note a container QCode left running.
reading
Spells out the commands that read harness’s conversations from container, or None for a harness whose conversations QCode cannot list.