Skip to content

docs(claude): derive project from cwd, not the zellij tab - #3

Merged
catomean merged 1 commit into
masterfrom
docs/session-detection-cwd
Aug 3, 2026
Merged

docs(claude): derive project from cwd, not the zellij tab#3
catomean merged 1 commit into
masterfrom
docs/session-detection-cwd

Conversation

@catomean

@catomean catomean commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Why

The session-start instructions told every agent to detect the current project by reading the zellij tab name. That mechanism is dead:

  • Tabs are no longer renamed per project. /tmp/claude-pane-0 currently contains the literal string Tab #1, which matches nothing in ~/.config/claude-projects.conf.
  • One pane now hosts many concurrent sessions, so ZELLIJ_PANE_ID is no longer unique — every session in a pane reads the same file.
  • _agent_post_launch deletes /tmp/claude-pane-$ZELLIJ_PANE_ID on exit, so the first session to finish removes the identity file out from under its still-running siblings.

Net effect: the detection ladder resolved to nothing, then fell through to guessing.

What changed

cwd is already resolved by the launcher, so it is the answer — no detection needed. This:

  • Replaces the tab-detection ladder with cwd, and marks tab detection + claude-projects.conf explicitly retired so no future agent revives them.
  • Re-keys the downstream steps that said "if tab matched" — memory load (Step 3), project bootstrap (Step 5), and continuation-prompt isolation.
  • Derives the project from the repo root, so ~/dev/orangecat/.claude/worktrees/foo correctly reads as OrangeCat rather than foo. This one is load-bearing now that auto-worktree puts most sessions inside a worktree.
  • Documents ~/.claude/sessions/<pid>.json as the SSOT for what is running concurrently, with a tested jq one-liner.
  • Scopes the concurrency warning correctly: _claude_autoworktree_enter already isolates files, so the residual risk is semantic collision. Both instances that bit this fleet were semantic — two sessions fixing the same bug (orangecat #498/#499) and two sessions picking the same migration timestamp (20260731110000).

Verification

Every claim checked against the live machine rather than recalled: the pane file's contents, the two claude() definitions in .bashrc, _agent_pre_launch / _agent_post_launch, _claude_autoworktree_enter, and the 7 live session JSONs. The jq one-liner was run before being written into the docs.

Markdown-only; no behavior change beyond the instructions themselves.

Tabs are no longer renamed per project (they read "Tab #1") and a single
pane now hosts many concurrent sessions, so ZELLIJ_PANE_ID is not unique
and /tmp/claude-pane-* is deleted by whichever session exits first. The
tab-detection ladder therefore resolved to nothing, and claude-projects.conf
went with it.

cwd is already resolved by the launcher, so it is the answer. Replaces the
detection ladder and re-keys the downstream steps (memory load, bootstrap,
continuation-prompt isolation) on cwd, including deriving the project from
the repo root so worktrees don't read as their own projects.

Also documents ~/.claude/sessions/<pid>.json as the SSOT for concurrent
sessions, and scopes the "check what else is running" advice to semantic
collisions (same bug, same migration timestamp) since _claude_autoworktree_enter
already handles file-level isolation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@catomean
catomean merged commit 5dfff96 into master Aug 3, 2026
1 check passed
@catomean
catomean deleted the docs/session-detection-cwd branch August 3, 2026 07:59
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