Repository navigation
Replies: 1 comment
|
my agent helped me to import by temporarily changing worktree session cwd to main repo path and changing them back after import. but yeah good to have native support for worktree sessions |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
Session import never finds a session whose working directory is a linked git worktree of the project. Such worktrees are created by
claude --worktree, by the Claude desktop app, or by hand withgit worktree add. The scanner does not offer the worktree as its own project, and it does not count the session toward the main checkout's project either, so the session cannot be imported at all.For people who run every task in a worktree, this leaves out most of their history. Claude Code on my machine has 95 open sessions. 43 of them ran in worktrees of repositories I have already added to T3, and 14 of my 15 pinned sessions are among those 43. All 43 worktree directories still exist on disk. The import brought in 6 threads in total, none of them from a worktree.
Why it happens (at
32a05317)readGitIdentitiesinapps/server/src/project/AgentSessionScanner.tsalready resolves a linked worktree'scommondirback to its main repository. It then tags every worktree of a non-bare repository as{ _tag: "Worktree" }, and the candidate loop drops that tag (key = ""). The comment explains that this is deliberate: only worktrees of a bare repository are offered on their own. Keeping worktrees out of the project list makes sense, but nothing then assigns their sessions to the main repository.prepareRecentThreadsaccepts a transcript only whendirectoryIdentity(cwd)equals the project root's identity. That identity is an inode or a real path, so a worktree directory never matches. The check runs once on the candidate and again on the transcript's owncwd.AgentSessionImporter.tscreates every imported thread withworktreePath: null,branch: nullandruntimePayload: { cwd: project.workspaceRoot }.Proposed behavior
When the project root is the main checkout, import sessions whose
cwdis a linked worktree of that root's repository (the same common git directory). Each imported thread records the worktree as itsworktreePathand the worktree's branch, and resumes with that worktree as its working directory. Claude Code stores transcripts by working directory, so resuming from the project root would likely not find them.Things that stay the same:
Questions for maintainers
worktreePath, so T3's worktree lifecycle and cleanup then apply to a directory another tool created? Or should it record the worktree only as the thread's working directory?If the direction is approved, I can open one focused PR covering the scanner, the importer and their tests (
AgentSessionScanner.test.ts,AgentSessionImporter.test.ts), with evidence from a real import.Related: #10961 (import is unreachable after onboarding), #27165 (configurable import limits), #6873 (continuing threads from Claude Code).
All reactions