Skip to content

Sessions: default to one working directory per session (auto-worktree in shared clones) #126

Description

@defangdevs

Follow-up to the sessions design (#59). With many sessions under one user, the remaining pain of the shared-HOME model is workspace trampling: two agents editing the same checkout, needing to be reminded to use git worktrees.

Fix it structurally at the session layer instead of by convention:

  • claude-box-session add (and the settings-daemon add form) should default workingDirectory to a fresh per-session directory instead of inheriting a shared cwd.
  • When the requested cwd is inside an existing git clone that another session already uses, create a git worktree for the new session automatically (e.g. ~/worktrees/<repo>-<session> or .worktrees/<session> inside the clone) and point the session there.
  • Seeded main session keeps today's behavior (back-compat; single-session boxes are unaffected).
  • Document the "one session = one directory" convention in the README sessions section.

Open questions: worktree cleanup on claude-box-session rm (remove if clean, keep + warn if dirty?), and whether the auto-worktree applies only when a collision is detected or always.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions