Skip to content

[Bug]: Onboarding never offers worktrees of a bare repository, so their agent sessions are never imported #16686

Description

@chris-allen

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Create a bare repository with linked worktrees, for example:
    git clone --bare <url> repo/.git
    git -C repo worktree add dev
  2. Run Claude Code or Codex sessions inside repo/dev.
  3. Start T3 Code with a fresh home and open the welcome screen.
  4. Look at the project candidates offered for import.

Expected behavior

repo/dev is listed as a candidate, and importing it brings in the sessions that ran there.

Actual behavior

Only repo (the bare root) appears. The worktree is never offered, so its sessions cannot be imported from onboarding.

AgentSessionScanner.readGitIdentity treats every .git file whose gitdir: points into a worktrees/ directory as a linked worktree and drops it, on the assumption that its history belongs to the main checkout. A bare repository has no main checkout, so none of its worktrees are ever offered. Adding the worktree as a project by hand does not help either, because the session import only runs from the welcome screen.

Impact

Major degradation or frequent failure

Version or commit

main at bfec238

Environment

Linux, web client served by npx t3 / dev server. Claude Code and Codex sessions.

Logs or stack traces

Scan result with a bare repo at ~/git/repo and six linked worktrees under it: only /home/user/git/repo is returned; none of the worktrees appear.

Workaround

None from the UI. Sessions can only be imported if they ran at the bare root.

Activity

  1. juliusmarminge commented on Oct 7, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    Thanks for the clear repro and pointer into the scanner — verified on main at bfec2387b8.

    Mechanism confirmed. AgentSessionScanner.readGitIdentity treats any .git file whose gitdir: resolves under a worktrees/ path as a linked worktree and returns { _tag: "Worktree" }. The scan then drops those candidates (key = ""), with an explicit comment that onboarding skips them because history is assumed to belong to the main checkout:

    • apps/server/src/project/AgentSessionScanner.ts — readGitIdentity (≈697–728): pointer → worktrees/ ⇒ _tag: "Worktree"
    • Same file, scan merge loop (≈1241–1244): if (gitIdentity._tag === "Worktree") key = ""
    • Covered by the unit test "skips linked git worktrees and reports the origin of real checkouts" in AgentSessionScanner.test.ts

    A bare layout (git clone --bare … repo/.git + worktree add) has a directory .git at the bare root (offered as a normal Repository) and only gitdir: pointers at each worktree. Those pointers match the same regex, so none of the worktrees are offered — exactly as you saw.

    Import surface. Session candidate scan / import is wired for the welcome wizard import step (apps/web/src/state/agentSessions.ts documents that; WelcomeWizard is the web caller of agentSessionImport). Adding a worktree as a project later does not re-run that onboarding import path on current main. Related open work like #10969 (auto-reconcile on project open) is not merged yet.

    Related (not duplicates): #8164 (bare-root layout as project root), #11860, #12204. Session-scanner PRs such as #16662 address other import bugs; nothing open/merged fixes this bare-repo worktree gap.

    Next step for a fix: when classifying a worktrees/ gitdir pointer, check whether a usable main working tree exists (or whether the common git dir is bare / has no non-worktree checkout). If there is no main checkout to “own” the history, keep offering the linked worktree as an import candidate (and ideally still attach remote/repository from the common dir’s config). A regression test with a bare root + one linked worktree cwd would lock this in.

    Happy to review a PR that takes that approach.

  2. added
    bugSomething is broken or behaving incorrectly.
    via-triageFiled through npx t3 triage
    on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions