Codex: move chat to another machine
Find Codex session by name:
SESSION_NAME="session name to migrate"
CODEX_HOME=$HOME/.config/codex-docker/codex-home
REMOTE=myserver
REMOTE_CODEX_HOME=.config/codex-docker/codex-home
SESSION_ID=$(
jq -r --arg q "$SESSION_NAME" '
select(.thread_name? | test($q; "i")) |
.id
' "$CODEX_HOME/session_index.jsonl" |
tail -n 1
)
SESSION_FILE=$(find "$CODEX_HOME/sessions" -type f -name "*$SESSION_ID.jsonl" -print -quit)
REMOTE_FILE="$REMOTE_CODEX_HOME/${SESSION_FILE#"$CODEX_HOME"/}"
echo "ssh $REMOTE \"mkdir -p '$(dirname "$REMOTE_FILE")'\""
echo "scp '$SESSION_FILE' '$REMOTE:$REMOTE_FILE'"
echo "codex resume $SESSION_ID"
Run the printed ssh and scp commands locally.
Then run the printed codex resume command on the remote machine.
Do not rename the session file.
Keep the same path under sessions/.