Skip to content

feat(claude): mirror host session transcripts into container#27

Merged
dlovell merged 1 commit into
mainfrom
feat/mirror-host-sessions-into-container
Jun 25, 2026
Merged

feat(claude): mirror host session transcripts into container#27
dlovell merged 1 commit into
mainfrom
feat/mirror-host-sessions-into-container

Conversation

@dlovell

@dlovell dlovell commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Problem

setup-claude copies prefs, settings, and memory into the container's isolated ~/.claude, but not session transcripts. Worse, Claude locates a resumable session by a project-dir key derived from the cwd — which differs between host (-home-dan-repos-...) and container (-workspaces-src). So claude --resume <id> could never find a host session from inside a devcontainer, even though the host ~/.claude is mounted read-only at ~/.claude-host.

Change

  • setup-claude.py — new copy_sessions() step (run in main after setup_project_settings): mirrors every *.jsonl from the host project key into the container project key, rewriting the DEV_WORKSPACEDEV_CONTAINER_WORKSPACE cwd prefix so resume locates the session and historical file paths resolve to the container workspace. Host → container only; transcripts already present container-side are skipped so continued work isn't clobbered.
  • lib/host-bridge.sh — threads -e DEV_WORKSPACE into the setup-claude exec (the project key is a lossy s|/|-|g and can't be reversed, so the host prefix must be passed explicitly).

Notes

  • The container runs the image-baked /usr/local/bin/setup-claude, so this takes effect on the next image rebuild.
  • Optional/defensive: if DEV_WORKSPACE is unset the copy still runs, just without the prefix rewrite.

🤖 Generated with Claude Code

setup-claude copied prefs, settings, and memory but not session
transcripts, and the cwd-derived project key differs between host
(-home-...) and container (-workspaces-src), so `claude --resume`
could never find a host session inside the container.

Add copy_sessions(): mirror every *.jsonl from the host project key
into the container project key, rewriting the DEV_WORKSPACE ->
DEV_CONTAINER_WORKSPACE cwd prefix so resume locates the session and
historical file paths resolve. Host -> container only; existing
container-side transcripts are skipped so continued work is not
clobbered.

Thread DEV_WORKSPACE through the setup-claude exec in host-bridge.sh
(the project key is a lossy s|/|-|g and cannot be reversed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017DVwgrgGj75dw1AwiZQnzr
@dlovell dlovell marked this pull request as ready for review June 25, 2026 13:15
@dlovell dlovell merged commit 3abbc61 into main Jun 25, 2026
6 checks passed
@dlovell dlovell deleted the feat/mirror-host-sessions-into-container branch June 25, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant