Repository navigation
Conversation
A folder-scoped CLAUDE_CONFIG_DIR is only visible to a login shell started in that directory, and main never asked one: chat tabs and every transcript, hooks and resume lookup assumed ~/.claude. Fixes ness-dev#325
Warming every worktree at once starts dozens of login shells together; they all overrun the timeout and the failure was then cached as the answer for the next minute, so a chat tab opened after a relaunch resolved the wrong home and never resumed.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #325
Why
A folder-scoped
CLAUDE_CONFIG_DIRis only visible to a login shell started in that directory. Main never asked one: chat tabs spawned the bundled binary from Ness's own env, and every transcript, resume and hooks lookup hardcoded~/.claude.What changes
src/main/claude-env.ts. Runs the user's login shell in the worktree with a sentinel-wrappedenv -0, caches the result per path, and re-probes on a spawn only when the entry is older than a minute so env edits made while Ness runs are picked up. Subdirectories resolve to their nearest cached ancestor.claudeConfigDirFor(cwd)falls back to Ness's env, then~/.claude; an explicitclaudeEnvVars.CLAUDE_CONFIG_DIRwins over the shell.process.env, so they see what a terminal tab'szsh -ilcsees.~/.claude/projectsreader (--resumedecision, transcripts, fork, context and cost trackers, cost roll-up) resolves through the same capture.settings.jsonof every Claude home a worktree maps to, and a newly seen home gets hooked when consent is already accepted.startJsonClaudeSession, theagent:*request handlers, fork kickoff) await it, and worktrees are warmed onworktrees/listChanged. A chat start waiting on the probe absorbs a duplicate start and is cancelled by a kill, so closing a tab in that window leaves no orphan.JsonClaudeManager(per-session tempCLAUDE_CONFIG_DIR) replaced with what the code does; CLAUDE.md gets a quirk entry.Testing
npm run typecheck,npx electron-vite build,npx vitest runall clean apart from threeworktree-rename.integrationtests that fail identically onmain.claude-env.test.tscovers parsing, cwd, timeout and missing-cwd handling, ancestor lookup, override precedence, in-flight dedup, and keeping the last good capture over a failed refresh.vitest.setup.tsclearsCLAUDE_CONFIG_DIRso the suite does not depend on the developer's own Claude home./tmpto~/.claude.Caveat
Sessions whose transcript was written to
~/.claudebefore the folder-scoped export existed still cannot resume, since the new home has no copy of them.