Skip to content

fix(provisioner): preserve Claude session directory across restart (#12) - #57

Merged
HongmingWang-Rabbit merged 2 commits into
mainfrom
fix/issue-12-preserve-claude-sessions
Apr 14, 2026
Merged

fix(provisioner): preserve Claude session directory across restart (#12)#57
HongmingWang-Rabbit merged 2 commits into
mainfrom
fix/issue-12-preserve-claude-sessions

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Resolves #12.

Problem

On workspace restart, Postgres keeps current_session_id populated but the container filesystem (/root/.claude/sessions/) is recreated fresh. Next message → "No conversation found with session ID: " and the SDK dies (seen repeatedly on PM and Dev Lead after auth-token-rotation restarts).

Fix

Plumbed via a new ResetClaudeSession field on WorkspaceConfig and a provisionWorkspaceOpts handler helper so the flag stays request-scoped (not persisted on CreateWorkspacePayload).

Test plan

  • 3 new provisioner tests: deterministic naming, distinct-from-config-volume, field round-trip
  • go test -race ./... pass (platform-wide, all packages green)
  • go build ./... and go vet ./... clean
  • E2E: exercise ?reset=true against a running claude-code workspace once deployed

🤖 Generated with Claude Code

Hongming Wang and others added 2 commits April 14, 2026 10:37
- docs/edit-history/2026-04-14.md: append tick-3 section covering the
  admin test-token route (#53), the prior-tick doc-sync PR (#54), and
  the hermes required_env alignment (#55). Record measured test counts
  (Go +4 for the TestAdminTestToken_* quartet).
- CLAUDE.md: bump Go test count 695 → 699 with a note pointing at the
  new quartet. Route-table row and env-var mentions for the admin
  route already landed with #53; verified on main.
- .env.example: add MOLECULE_ENABLE_TEST_TOKENS with a comment about
  the prod-hidden default. Closes the code-review doc-sync flag from
  #53 (var was in CLAUDE.md but missing from .env.example).

No PLAN.md / README.md / README.zh-CN.md update needed — none of the
three merges expose a user-visible surface.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolves #12. The claude-code SDK stores conversations in
/root/.claude/sessions/ and Postgres tracks current_session_id, but the
container filesystem was recreated on every restart — next agent message
failed with "No conversation found with session ID: <uuid>".

Add a per-workspace named Docker volume (ws-<id>-claude-sessions) mounted
read-write at /root/.claude/sessions. Gated by runtime=claude-code so
other runtimes don't pay for a path they don't use. Volume is cleaned up
in RemoveVolume alongside the config volume.

Two opt-outs discard the volume before restart for a fresh session:
  - env WORKSPACE_RESET_SESSION=1 on the container
  - POST /workspaces/:id/restart?reset=true (or {"reset": true} body)

Plumbed via new ResetClaudeSession field on WorkspaceConfig +
provisionWorkspaceOpts helper so the flag stays request-scoped (not
persisted on CreateWorkspacePayload).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Provisioner: preserve Claude session directory across workspace restart

1 participant