Skip to content

Regression: worktree observations still tagged with worktree dir name in v10.6.2 #1500

@knutwannheden

Description

@knutwannheden

Description

The worktree project name bug reported in #1081 (fixed in v9.x) and #1317 (fixed in v10.5.5) has regressed. On v10.6.2, observations are still stored under the worktree directory name instead of the parent repository name, and every new worktree session shows "No previous sessions found."

Environment

  • claude-mem version: 10.6.2 (installed 2026-03-24)
  • Platform: macOS (Darwin 25.4.0)
  • Claude Code CLI

Worktree layout

My worktrees live inside the main repo under a .worktrees/ directory (excluded via .git/info/exclude):

/Users/me/git/myproject/                   ← main repo (git toplevel)
├── .git/                                  ← real .git directory
│   ├── info/exclude                       ← contains "/.worktrees/"
│   └── worktrees/
│       ├── noble-hare/                    ← git worktree metadata
│       ├── jolly-condor/
│       └── ...
├── .worktrees/                            ← excluded from git
│   ├── noble-hare/                        ← worktree checkout (cwd when using Claude Code)
│   │   └── .git                           ← file: "gitdir: /Users/me/git/myproject/.git/worktrees/noble-hare"
│   ├── jolly-condor/
│   └── ...
├── src/
└── ...

Key details:

  • Worktrees are created inside the repo: git worktree add .worktrees/noble-hare
  • .worktrees/ is in .git/info/exclude so it doesn't show up in git status
  • The .git file in each worktree correctly points to the main repo's .git/worktrees/<name>
  • git rev-parse --git-common-dir from any worktree correctly returns the main repo's .git

Evidence

Every distinct project name in my database is a worktree name — the parent repo name rewrite never appears:

sqlite> SELECT DISTINCT project FROM observations ORDER BY project;
-- Returns: csharp-typed-capture-generics, deft-marmot, noble-iguana, ...
-- Never: rewrite

Every new worktree session starts with "No previous sessions found" because it queries for observations where project = '<new-worktree-name>'.

Root cause (still)

The context-generator.cjs function that determines the project name still falls through to path.basename(cwd) in certain code paths. From the minified source in v10.6.2:

function fe(r) {
  if (!r || r.trim() === "") return "unknown-project";
  let e = path.basename(r);
  // ...
  return e;
}

The worktree-aware detection function exists and works for SessionStart context injection, but observation storage, search API defaults, and the "No previous sessions" check still use basename(cwd).

Expected behavior

  • Observations from all worktrees should be stored under the parent repo project name (rewrite)
  • Search from any worktree should find observations from all worktrees of the same repo
  • Session start should find previous sessions regardless of which worktree they ran in

Workaround

Manually passing project="rewrite" in search calls, or retroactively fixing with:

UPDATE observations SET project = 'rewrite'
WHERE project IN ('noble-hare', 'jolly-condor', ...);

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions