Repository navigation
claude-profile: an opt-in --lane hands the final Claude launch to lane-start - #44
Conversation
…e-start New --lane <repo>-<n> (and CLAUDE_LANE fallback), off by default: when a lane is named, the final `exec "$claude_bin" …` in the `run` action becomes `exec lane-start "$lane" -- <the same claude args>`, with CLAUDE_BIN and CLAUDE_CONFIG_DIR exported so lane-start starts this same Claude under this same profile. lane-start then renames the tmux window to the lane, writes the lane register row, and launches with --resume/--name <lane>. With no --lane/CLAUDE_LANE, behaviour is unchanged (verified byte-for-byte against the prior exec's argv and tmux calls). A named lane whose lane-start is not on PATH refuses with the clone/link-estates fix and exits 2 before claude_run_is_interactive/start_profile_tmux ever run, so no tmux session is created. The interactive auto-tmux path re-invokes the launcher inside a new detached tmux session; CLAUDE_LANE is threaded through that re-invocation explicitly rather than relied on via tmux environment inheritance, which does not reliably hand a freshly-exported variable to a new session on an already-running tmux server. --lane/-h/--help are recognised only as leading options, before the action/profile, so anything after the profile name is still forwarded to Claude untouched. Adds devcontainer.test/test-claude-profile-lane-start.sh (fake tmux, lane-start and claude on PATH) proving: --help documents --lane/CLAUDE_LANE; no lane leaves lane-start uninvoked and Claude's args unchanged; --lane hands off with CLAUDE_BIN/CLAUDE_CONFIG_DIR set; a missing lane-start refuses before any tmux command runs; CLAUDE_LANE (env, no flag) behaves the same as --lane. Adds one paragraph to docs/claude-multi-account-profiles.md. Closes #43. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 1 hour and 7 minutes by commenting @sourcery-ai review. Upgrade to get a review now.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideThis PR adds an opt-in Sequence diagram for the optional lane-start Claude launchsequenceDiagram
participant User
participant Profile as claude-profile
participant Tmux
participant Lane as lane-start
participant Claude
User->>Profile: run [--lane lane]
Profile->>Profile: command -v lane-start
alt interactive auto-tmux
Profile->>Tmux: start_profile_tmux
Tmux->>Profile: re-invoke with CLAUDE_LANE
end
Profile->>Lane: exec lane-start lane -- Claude args
Lane->>Claude: launch with CLAUDE_BIN and CLAUDE_CONFIG_DIR
Claude-->>User: Claude session
Flow diagram for claude-profile lane option handlingflowchart TD
A[claude-profile leading options] --> B{lane selected?}
B -->|No| C[exec Claude with original args]
B -->|Yes| D{lane-start on PATH?}
D -->|No| E[exit 2 with setup fix]
D -->|Yes| F[export CLAUDE_BIN and CLAUDE_CONFIG_DIR]
F --> G[exec lane-start lane -- Claude args]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟡 Changes recommended
Moderate issues remain in option validation, interactive propagation, MCP handling, and test coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds opt-in --lane/CLAUDE_LANE support to delegate Claude profile launches to lane-start while preserving default behavior.
Changes:
- Adds lane parsing, validation, and handoff.
- Propagates profile context through tmux.
- Documents lane usage and adds regression tests.
File summaries
| File | Summary |
|---|---|
docs/claude-multi-account-profiles.md |
Documents lane-based launches and prerequisites. |
devcontainer.test/test-claude-profile-lane-start.sh |
Tests lane, no-lane, environment fallback, and failure behavior. |
base-image/files/claude-profile |
Implements lane parsing, validation, tmux propagation, and delegation. |
Review details
Suppressed comments (4)
base-image/files/claude-profile:266
--lane=leaveslaneempty, so this invocation silently takes the no-lane path;--lane --helplikewise consumes--helpas the lane and falls through to the defaultlistaction. The option is documented as requiring<repo>-<n>, so reject empty or option-looking values here instead of silently disabling the handoff.
--lane)
[[ $# -ge 2 ]] || { echo "pclaude: --lane needs a value: <repo>-<n>" >&2; exit 2; }
lane="$2"; shift 2 ;;
--lane=*) lane="${1#--lane=}"; shift ;;
base-image/files/claude-profile:159
- The successful lane cases force
TMUX=fake-session, soclaude_run_is_interactiveis false and this new propagation path is never exercised. The missing-lane-startpty case exits before constructing the tmux command, leaving successful outside-tmux launches unable to catch a brokenCLAUDE_LANEre-invocation. Add a fake-tmux scenario that executes or inspects the detached child command.
[[ -n "${lane:-}" ]] && env_prefix+=("CLAUDE_LANE=$lane")
devcontainer.test/test-claude-profile-lane-start.sh:84
- The positive lane cases set
TMUX, explicitly bypassingclaude_run_is_interactive; the only pty case exits beforestart_profile_tmuxbecauselane-startis missing. Thus the new environment-threading path is not covered by a successful interactive handoff, so a regression there can pass all of these tests.
# --lane's realistic case is a terminal already inside tmux (a lane is always
# started from an existing tmux window; lane-start itself refuses otherwise),
# which is also the simplest to simulate: TMUX set means claude_run_is_interactive
# is false, so the launcher does not try to wrap a NEW tmux session around it.
docs/claude-multi-account-profiles.md:135
- The launcher only recognizes
--lanebefore the action/profile, but this paragraph does not state that restriction. A user following it aspclaude work --lane ...will pass the option to Claude instead of starting a lane, so document the required placement.
Pass `--lane <repo>-<n>` (or set `CLAUDE_LANE=<repo>-<n>` in the environment)
- Files reviewed: 3/3 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # tmux does not reliably hand a freshly-exported variable to a new session | ||
| # on an already-running server, so it is threaded through explicitly here | ||
| # rather than relied on via inheritance — same idiom as the guard above. | ||
| [[ -n "${lane:-}" ]] && env_prefix+=("CLAUDE_LANE=$lane") |
| if [[ -n "${lane:-}" ]]; then | ||
| command -v lane-start >/dev/null 2>&1 || { | ||
| echo "pclaude: --lane $lane needs lane-start on PATH. Fix:" >&2 | ||
| echo " git clone [email protected]:opensoft/brett-wip.git ~/projects/brett-wip && ~/projects/brett-wip/scripts/link-estates" >&2 | ||
| exit 2 |
| # inherited from whatever shell runs the test — including a shell that is | ||
| # itself a claude-profile-launched tmux child (WORKBENCHES_CLAUDE_TMUX_CHILD=1) | ||
| # or already inside some other tmux session (TMUX set to a real socket). | ||
| unset TMUX WORKBENCHES_CLAUDE_TMUX_CHILD WORKBENCHES_TMUX_SESSION WORKBENCHES_TMUX_PANE TMUX_PANE 2>/dev/null || true |
| @@ -0,0 +1,187 @@ | |||
| #!/usr/bin/env bash | |||
…d734 devBenches/base-image: re-vendor openRepoTools at f98d734 -- restart retired, lane/lane-handoff/handoff arrive, 14 -> 18 vendored paths (openRepoTools#40 already fixed by #44)
Lane: openreposhape-2 (openRepoShape-2)
Claim: #43 (comment)
Closes #43.
Summary
base-image/files/claude-profilegains an opt-in--lane <repo>-<n>(andCLAUDE_LANEfallback): when named, therunaction's finalexec "$claude_bin" …becomesexec lane-start "$lane" -- <the same claude args>, withCLAUDE_BIN/CLAUDE_CONFIG_DIRexported solane-startstarts the same Claude under the same profile.
--lane/CLAUDE_LANE, behaviour is unchanged — verifiedbyte-for-byte (Claude's argv and every tmux call identical to the
pre-change script under matched inputs).
lane-startis not onPATHrefuses (exit 2, names theopensoft/brett-wipclone +scripts/link-estatesfix) beforeclaude_run_is_interactive/start_profile_tmuxever run, so no tmuxsession is created first.
detached tmux session;
CLAUDE_LANEis threaded through thatre-invocation explicitly (not relied on via tmux's environment
inheritance, which does not reliably hand a freshly-exported variable to a
new session on an already-running server).
--lane/-h/--helpare recognised only as leading options, before theaction/profile, so anything after the profile name still reaches Claude
untouched (e.g.
claude-profile work --helpstill shows Claude's help).Test plan
devcontainer.test/test-claude-profile-lane-start.sh(fake tmux,lane-start,claudeonPATH):--helpdocuments--lane/CLAUDE_LANE; no lane leaveslane-startuninvoked and Claude's argsunchanged;
--lanehands off withCLAUDE_BIN/CLAUDE_CONFIG_DIRset; a missing
lane-startrefuses before any tmux command runs;CLAUDE_LANE(env, no flag) behaves the same as--lane.test-claude-tmux-statusline.sh,test-claude-profile-preserves-model.sh,test-shared-mcp-profiles.sh— all pass.devBenches/devcontainer.test/test-openspeckit-bootstrap.sh(742pass),
test-speckit-git-feature.sh(56 pass),test-speckit-git-compat.sh(22 pass),
test-ct-launchers.sh(exit 0) — unaffected, all green.bash base-image/files/claude-profile --help | grep -n laneshows thenew option.
🤖 Generated with Claude Code
Summary by Sourcery
Enable optional Claude profile launches to hand off named sessions to lane-start without changing the default launch behavior.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: