Repository navigation
Derive a moved project's path from a cwd that still exists - #115
Open
PirateIncognito wants to merge 1 commit into
Open
PirateIncognito wants to merge 1 commit into
PirateIncognito wants to merge 1 commit into
Conversation
A Claude projects folder can hold a transcript from the project's old location (e.g. an old session copied in after the project moved). deriveProjectPath took the cwd of the first .jsonl in directory order, so such a folder resolved to the old, missing directory; every session was filed under it, and New session failed in open-terminal with "project directory no longer exists". The renderer kept that error in a hidden terminal, so the button appeared to do nothing. - deriveProjectPath tries transcripts newest first and returns the first cwd that exists (up to 10 tried), else the newest cwd. - planFolderRefresh passes every transcript through again when the folder's project changed, so cached rows move to the new path (an unchanged transcript resumes at its end, so no re-parse). - Reconcile re-plans a folder whose recorded project directory is gone once per run, so caches written by older builds are corrected without waiting for a new session in that folder. - launchNewSession shows the terminal holding a launch error instead of leaving it hidden. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
After a project folder is moved, its Claude projects folder (
~/.claude/projects/<encoded>) can still hold a transcript recorded at the old location.deriveProjectPathused the cwd of the first.jsonlin directory order, so if that old transcript sorted first, the whole folder resolved to the old, now-missing directory:open-terminalwithproject directory no longer exists: ...;Fix
harnesses/claude.jsderiveProjectPath: tries transcripts newest first and returns the first cwd that still exists (at most 10 are checked). If none exist, it falls back to the newest cwd.session-cache.jsplanFolderRefresh: when a folder's resolved project path has changed, every transcript is passed through again so cached rows move to the new path. Unchanged transcripts resume from their end, so nothing is re-parsed.session-cache.jsreconcile gates: a folder whose recorded project directory no longer exists is re-planned once per run, so caches written by older builds correct themselves without waiting for a new session in that folder.public/app.jslaunchNewSession: a failed launch now shows the terminal with the error instead of leaving it hidden.Tests
test/harness-claude.test.js: a cwd that exists wins over a missing one, even when the missing one sorts first and is newer; when no cwd exists, the newest is used.test/reconcile-cache.test.js: a folder cached under a missing directory, with an unchanged mtime, has all its rows re-filed under the existing path and is left alone on the next pass./tmp/proj-currentas its cwd. That path doesn't exist on Windows, so with this change the test would trip the new missing-directory re-check. It now uses a real temp directory and still tests the mtime gate.I checked the fix on Windows against real data: a project that had moved out of a OneDrive folder, where New session did nothing before the fix and works after it. On Windows, some existing tests already fail on
main(mostly path-separator assertions). This change doesn't touch them.🤖 Generated with Claude Code