fix(server): session import skips T3 Code's own folders behind a symlinked home#23728

open1
main
GitHub fork: fix/session-import-symlinked-home
opened18d agobySsiddham-jain
View on GitHubTwo-way sync enabledPR last imported 2h ago

Problem

Fixes #23727.

When the T3 home is reached through a symlink (~/.t3 linked to another disk, or a T3CODE_HOME that points at a link), the welcome wizard offers every projectless chat's scratch/<id> folder as a project to import. Claude Code and Codex record the resolved cwd. The scanner checks the candidate again with links resolved, but compares it against baseDir and worktreesDir in their unresolved spelling, so the prefix check never matches.

Change

AgentSessionScanner resolves the base dir and worktrees dir through symlinks once, at construction, and excludes a candidate that falls under either spelling. A missing directory falls back to its resolved path, as before. The import path (recentThreads) uses the same exclusion, so it benefits as well.

Scope and approval

This is a small, focused fix for an obvious bug, reported in #23727. The scanner already intends to exclude these folders under resolved links (the "check again with links resolved" comment, and the existing test excludes sandboxes reached through a symlink into the worktrees dir). This makes that check compare like with like and changes no other behavior.

#18198 also edits this exclusion, for linked worktrees on the import path. It does not resolve baseDir or touch the scan path, so the two changes are independent. Whichever lands second has a small rebase.

Verification

  • Added excludes T3 Code's own folders when its home is reached through a symlink to AgentSessionScanner.test.ts. The config base dir is a symlink, and a Claude transcript records a scratch folder under the real base dir. It creates the link itself, so it fails on main on Linux as well as macOS (expected [ { …(7) } ] to deeply equal [], the scratch folder offered as a candidate) and passes with the fix.
  • The existing excludes sandboxes reached through a symlink into the worktrees dir failed on macOS on main, because /var/folders resolves to /private/var/folders. It passes now.
  • vp test run src/project/AgentSessionScanner.test.ts src/project/AgentSessionImporter.test.ts: 57 passed.
  • vp run check:changed: format, lint, knip, graphql, typecheck, and tests pass.

Not checked: a real install with a symlinked ~/.t3 in the desktop app. The new test covers the same scanner path.

Fixes pingdotgg/t3code#23727

Checks

8 successful · 2 skipped
All checks passed
4bfe030

Added 1 commit

  • fix(server): session import skips T3 Code's own folders behind a symlinked home4bfe030
Synced from GitHub

Approvability

Verdict: Approved at 4bfe030

Macroscope's review found this PR approvable — This is a small, focused server bug fix that extends an existing session-import exclusion check to both symlinked and resolved paths. It preserves normal-path behavior, adds a targeted regression test, and introduces no schema, default, infrastructure, security, or static-analysis changes.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

The scanner now checks project candidates against both configured T3 directories and their resolved real paths. A symlink-focused test verifies that a workspace under the real path of a symlinked T3 home is excluded.

Changes: Project exclusion

Layer / File(s)Summary
Resolve paths and exclude T3 directories
apps/server/src/project/AgentSessionScanner.ts, apps/server/src/project/AgentSessionScanner.test.ts
The scanner retains configured base and worktrees paths alongside their resolved real paths, falling back to the configured paths if resolution fails. Exclusion checks use both path forms. A test verifies exclusion under a symlinked T3 home.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

Suggested reviewers: juliusmarminge

Merge Risk: External image Minimal · up to 4bfe0

The reviewed change excludes T3-owned folders reached through symlinked paths. No merge-blocking issue was found.

Pre-merge checks: Passed 4

Check nameStatusExplanation
Title checkPassedThe title clearly and concisely describes the primary fix: preventing session import from treating T3 Code folders behind a symlinked home as projects.
Linked Issues checkPassedIssue #23727 requires the import scanner to reject T3 Code folders under scratch/, managed worktrees, and the T3 home when the home uses a symlink. The reviewed change resolves the configured base a…
Out of Scope Changes checkPassedThe reported changes are limited to AgentSessionScanner.ts and its focused test. The source change implements the exclusion required by issue #23727. The test change verifies the symlinked-home case…
Description checkPassedThe description includes all required sections. It explains the problem, the fix, the scope and issue approval, and the focused verification results. It also states what was not checked.
Full details: Linked Issues check

Explanation

Issue #23727 requires the import scanner to reject T3 Code folders under scratch/, managed worktrees, and the T3 home when the home uses a symlink. The reviewed change resolves the configured base and worktrees directories and applies exclusion checks to both original and resolved paths. The change also covers recentThreads. The added scanner test uses a symlinked T3 home and a transcript path under the real home. The reported scanner and import tests pass.

Full details: Out of Scope Changes check

Explanation

The reported changes are limited to AgentSessionScanner.ts and its focused test. The source change implements the exclusion required by issue #23727. The test change verifies the symlinked-home case. No unrelated product behavior or unrelated files are identified.

Finishing Touches

🧪 Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
ℹ️ Recent review info

⚙️ Run configuration

📥 Commits

Reviewing files that changed from the base of the PR and between f05599504ae10c395a6a39f5e7db31b7810ac239 and 4bfe030703fabe2d590dd1f3ddc104dc594ee314.

📒 Files selected for processing: 2

  • apps/server/src/project/AgentSessionScanner.test.ts
  • apps/server/src/project/AgentSessionScanner.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.