Repository navigation
fix(agent-manager): preserve untracked symlinks when moving to worktree - #15489
markjoin123 wants to merge 2 commits into
Conversation
| try { | ||
| await fs.mkdir(nodePath.dirname(full), { recursive: true }) | ||
| if (file.link != null) { | ||
| await fs.symlink(file.link, full) |
There was a problem hiding this comment.
[WARNING]: A failed fs.symlink silently drops the untracked entry while apply still returns { ok: true }
Unlike fs.writeFile (which overwrites), fs.symlink throws when full already exists, and it also fails where symlinks are unsupported or unprivileged (Windows without developer mode, SMB/network shares, FAT/exFAT). The setup script runs before the transfer (prepareWorktree runs runSetupScript, then transferState), so a setup script that creates the same path now causes the symlink to be skipped instead of overwritten. The only signal is the log line, and the move reports success with that untracked path missing. This also diverges from the JetBrains implementation, which fails the transfer and rolls back on the same error. Consider await fs.rm(full, { force: true }) before fs.symlink for parity with the writeFile path, or returning { ok: false } so callers can roll back. Note the new tests skip Windows entirely, so this branch has no coverage on the platform where symlink creation fails most often.
| } | ||
| }) | ||
|
|
||
| it.skipIf(process.platform === "win32")("logs and skips an untracked symlink that cannot be created", async () => { |
There was a problem hiding this comment.
[SUGGESTION]: This test does not reach the symlink-creation failure it names. target/sub is a regular file, so fs.mkdir(dirname(full), { recursive: true }) throws EEXIST before fs.symlink runs, and the assertion only checks that the path appears in some log line. Making target/sub a directory that already contains an active.txt file would exercise the fs.symlink EEXIST path (the overwrite-vs-fail case above) instead.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The incremental changes resolve both earlier findings. In VS Code, Files Reviewed (4 files)
Previous Review Summary (commit 05d87af)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 05d87af)Status: 2 Issues Found | Recommendation: Address before merge Overview
The core fix is sound: capture now records link text via Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (5 files)
Reviewed by deepseek-flash-latest · Input: 58K · Output: 12.3K · Cached: 517.1K Review guidance: REVIEW.md from base branch |
|
Addressed both review points in cb46709:
Tests: |
Issue
Fixes #15488
Context
Move to Worktree copied an untracked symlink as a regular file holding the target's contents.
active.txt -> settings.txt(?? active.txt) arrived in the new worktree as a normal file containingoriginal, so later edits tosettings.txtno longer showed through the link. Staged symlinks already survived because they travel through a git patch.Implementation
The untracked capture path now records the link text from
lstat/readlink(VS Code) andNOFOLLOW_LINKS/readSymbolicLink(JetBrains), and apply recreates that same target. Relative targets stay relative. A link that points outside the repo is recreated as that link, and the outside file is left unread. Regular files still copy as files. Dangling and directory symlinks are preserved as links.If symlink creation fails, VS Code logs and skips that path, matching its other untracked write errors. JetBrains logs and fails the transfer so the move rolls back, matching its existing untracked write failures.
Screenshots / Video
N/A. This is file-transfer behavior, with no UI change.
How to Test
Manual/local verification
Unit and integration tests, listed below. The VS Code cases replay the issue: an untracked
active.txt -> settings.txtis still a symlink after transfer,readlinkissettings.txt, and writingchangedtosettings.txtin the destination is what the link reads.Reviewer test steps
settings.txtwith contentsoriginal, thenln -s settings.txt active.txt.git status --shortshows?? active.txt.ls -l active.txtshowsactive.txt -> settings.txt.echo changed > settings.txt, then read throughactive.txt. It printschanged.Blocked checks and substitute verification
None.
bun test --timeout 20000 tests/unit/git-transfer.test.ts(packages/kilo-vscode): 27 pass, 0 fail. (At the default 5s hook timeout a busy machine timed out somebeforeEach/afterEachhooks, including existing tests; the symlink cases alone,-t "symlink", pass 4/4 in under a second.)bun run typecheckandbun run lint(packages/kilo-vscode): exit 0.bun typecheck --filter='!@kilocode/kilo-jetbrains'(repo root): 29 successful../gradlew :backend:test --tests ai.kilocode.backend.rpc.KiloWorktreeRpcApiImplTest(packages/kilo-jetbrains): BUILD SUCCESSFUL, 164 tests, 0 failures, 0 errors, 0 skipped../gradlew typecheck(packages/kilo-jetbrains): BUILD SUCCESSFUL.Checklist
This change was AI-assisted. It was reviewed and tested as described above.