Skip to content

fix(files): let phone uploads land in WSL folders on Windows hosts - #51491

Merged
AmoabaKelvin merged 2 commits into
mainfrom
fix/phone-upload-no-hardlink-fallback
Nov 28, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
fix/phone-upload-no-hardlink-fallback

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

Uploading a file from the phone into a project that lives inside WSL on a Windows computer always failed with "this drive can't create files safely". Now the file lands, with the same safety rules as everywhere else.

Files Added Deleted Net
Test 0 0 0 0
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62

What Changed

  • Before: the phone upload (files.uploadBegin / saveChunk / uploadCommit, feat(files): host methods to upload a file from the phone into a workspace folder #51195) wrote the bytes to a hidden temp beside the target, then published it with a hard link so a taken name is refused atomically. Windows can't create hard links on WSL's \\wsl.localhost share (the call fails with "Incorrect function"; Codex settings reach WSL accounts again: save the usual atomic way where hard links aren't available #46060 hit the same thing). So every upload into a WSL repo on a Windows host was refused.
  • After: when the hard link is refused on Windows and both files are on the same distro's share, Orca makes the link inside the distro instead. It runs wsl.exe -d <distro> --exec sh -c 'ln -T -- "$1" "$2"', which is Linux link() on the Linux filesystem, and the guest answers with a stdout marker. The temp is still removed in finally on every outcome.
  • The extra process runs only on that refused-link path. Uploads that hard-link normally (NTFS, APFS, ext4, /mnt/c paths, which are already mapped to C:\) do no extra work.
  • Other drives without hard links keep refusing with the same message, on purpose: exFAT, SMB shares, and other 9P mounts outside WSL.

Why

  • Root cause: the publish step assumed the drive holding the workspace can make hard links. That holds for every local filesystem Orca runs on, but not for WSL's share as seen from Windows, which is where most WSL repos on Windows hosts live (in-distro WSL hosts are still gated).
  • Why link inside the distro: it keeps all three upload guarantees:
    • an existing file or folder is never replaced (link() refuses any taken name atomically, and -T refuses a folder instead of linking into it);
    • a partial file is never exposed under the final name (the temp is complete and closed first);
    • nothing is left behind on abort.
  • Alternatives rejected:

Linked Issue

No GitHub issue; follow-up to #51195 (phone upload host methods).

Visual Proof

N/A, host-only. Real Windows + WSL (Ubuntu) runs of the Windows WSL E2E workflow, each with a temporary probe that drove the real upload RPCs into a \\wsl.localhost folder three times. The probe was never merged.

  • Before, current main: every upload failed with Can't add 'fresh.txt' here: this drive can't create files safely.
  • After, this branch: 3/3 passed. The run's overall red is the workflow's own participation step, which expects exactly 3 tests and counted my 3 extra probe runs.
[wsl-upload-probe] fresh.txt bytes=32000 expected=32000
[wsl-upload-probe] race commit -> A file or folder named 'race.txt' already exists in this location
[wsl-upload-probe] listing=["fresh.txt","race.txt"]
  • fresh.txt lands whole.
  • race.txt, taken in the guest between begin and commit, is refused, and the other program's bytes are kept.
  • An aborted upload leaves nothing, and no .orca-upload-* temp remains.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

  • Windows + WSL: verified on real runners as above, against both main and this branch.

  • macOS: pnpm check:changed and tc:node pass.

  • No permanent test: the behaviour needs a real Windows host with a WSL distro, which only the dedicated workflow has. Its suite is kept to the agent-launch journey.

Performance

None, because the wsl.exe spawn happens only when a hard link is refused on a WSL share during an upload commit. That is one short-lived process per such upload, capped at 30 s, spawned with an async working-directory check. Normal uploads return before reaching it.

Risk

Level: Low

  • Who it touches: only uploads into WSL repos from a Windows host, which all failed before.
  • On a distro without GNU ln -T (e.g. old busybox), ln fails, no marker is printed, and the upload is refused as before. Nothing is replaced or exposed.
  • A wedged wsl.exe is cut at 30 s. If its link lands after that, the name holds the complete file, never a partial one.
  • Back out: plain revert.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Paths go to the guest as $1/$2, never inside the shell text, so spaces, quotes and $ in file names can't be interpreted.
  • The script is a single line because newlines don't survive wsl.exe argv encoding reliably.
  • exFAT, SMB and 9P workspaces still refuse phone uploads with the existing message. Supporting them safely would need a native no-replace rename on each platform.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…the distro

Windows can't create hard links on WSL's \\wsl.localhost share, so every
upload into a WSL repo on a Windows host was refused. When the link is
refused and both paths are on one distro's share, link inside the distro,
where link() still refuses a taken name atomically.
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

On Windows, publishNoClobber now tries to create a hard link inside a WSL distro when the normal link operation fails with a recognized no-hard-links error. The helper checks that both paths belong to the same distro, runs ln -T with a 30-second timeout, and handles success, an existing destination, and other process failures.

Merge Risk: Low · up to 19c26

Uploads to WSL folders on Windows now work through an in-distro hard link. In a rare timeout case, an upload can be reported as failed even though the file was published, and a retry then fails because the name is taken. The risk is narrow, so this is mergeable with awareness.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: phone uploads into WSL folders on Windows hosts. It matches the changeset, which adds an in-distro hard-link fallback for uploads that Windows refuses on the \\wsl.localhos…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is thorough and follows the repository template. It includes ELI5, What Changed (before/after and mechanism), Why (root cause and rejected alternatives), a linked-issue note, Visual Pr…
Full details: Title check

Explanation

The title names the change: phone uploads into WSL folders on Windows hosts. It matches the changeset, which adds an in-distro hard-link fallback for uploads that Windows refuses on the \wsl.localhost share. The type prefix and scope are conventional and the title is specific.

Full details: Description check

Explanation

The description is thorough and follows the repository template. It includes ELI5, What Changed (before/after and mechanism), Why (root cause and rejected alternatives), a linked-issue note, Visual Proof with run links and probe output, Testing, Performance, Risk with level and back-out plan, and a completed checklist. The Linked Issue section does not contain a "Fixes #" reference. It names a follow-up to #51195 and states that no GitHub issue exists. The template asks outside contributors to link an actual issue, so this is a gap to confirm. The AI Disclosure and Review sections are empty. The AI Disclosure section is for outside contributors only, so its absence is minor. The local lint, typecheck, test, and build checkbox is unchecked, and the author notes that CI covers it. Testing reports macOS checks only, and the Windows checks rely on temporary probe runs that were not merged.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a232b94-d0e6-4176-be0f-19cd656993a8
Commits

Reviewing files that changed from the base of the PR and between 420b0cd and 19c26d5.

Files selected for processing: 2

  • src/main/filesystem/local-file-io/filesystem-create-path.ts
  • src/main/wsl/filesystem/wsl-unc-hard-link.ts

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

args,
env: { ...process.env, WSL_UTF8: '1' },
cwd: await resolveWslInteropSpawnCwdAsync(),
timeoutMs: WSL_LINK_TIMEOUT_MS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Heavy lift

Report publication state accurately when the WSL link times out.

When the 30-second deadline expires, runProcess settles with the stdout captured so far. tryLinkInsideWslDistro treats a missing LINKED_MARKER as a generic failure. If ln -T already created the destination, the upload reports failure while the destination remains. A retry then receives the EEXIST name-taken error for a file the first attempt published.

The helper must return a result that reflects whether the destination now exists. The fix needs a decision about how to determine that state after a timeout or a missing marker, so no specific change is prescribed here.

@AmoabaKelvin
AmoabaKelvin merged commit d62aa60 into main Nov 28, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant