feat(web): add an existing folder instead of cloning onto another machine

Draft
MA
13h ago
+306-41

[!note]
@marcelruhf sees this as a boundary case between a feature and a bug fix, and decided to give it a shot anyway. No hard feelings if maintainers decide to close it.

Why

Adding a project to another machine failed with "Source control repository operation cloneRepository failed for unknown: Destination path already exists and is not empty." whenever that machine already had a checkout at the destination. The user had nowhere to go from there, even though the folder they wanted was already on that machine.

What changed

  • Server: when the clone destination already holds files, SourceControlRepositoryError now carries occupiedDestination, the folder resolved on that machine (~ expanded). Clients key off this field instead of the error text. They need the resolved path because they can't expand ~ for another machine.
  • Web, Add to another machine dialog: when the clone is refused this way, the dialog's description says the folder exists and its main button becomes Add existing folder. If a project on that machine already owns the folder, for example one grouped separately or archived, the dialog opens that project, unarchiving it first if needed. Otherwise it creates a project at the folder. Either way it copies no ignored files, so the checkout's own .env and similar files stay as they are. The copy list and the SSH/HTTPS picker are hidden in this state. Editing the folder or switching machines returns the dialog to cloning. Create and unarchive go through useOrchestrationCommand, like the other add-project entry points.
  • New text is translated in all web locales.

The command palette's clone, the prompt-link clone, and the mobile Add Project clone receive the same typed error but don't offer this yet. They sit inside Add Project flows rather than this dialog.

Screenshots

Before (main) and after, at the moment a clone is refused because ~/code/t3code already exists on the Laptop. Both are Vitest browser renders of the dialog with the app stylesheet. Screenshots to be attached by the author below.

Verification

  • SourceControlRepositoryService.test.ts: a non-empty destination fails with occupiedDestination set to the resolved path. Fails with the server change reverted.
  • AddProjectToMachineDialog.logic.test.ts: the create, unarchive, or open decision for a taken folder (no owner, active owner, archived owner). Fails if an archived owner is opened without unarchiving.
  • AddProjectToMachineDialog.browser.test.tsx: a refused clone offers the folder, and editing the path returns to cloning.
  • Real app, two T3 servers in one sandbox (Workstation and Laptop): moved the project onto the Laptop into (1) an existing checkout with no project, which created the project and left the checkout's files and .env untouched; (2) a folder already owned by a separately grouped Laptop project, which opened that project and created no duplicate; (3) the same folder with that project archived, which unarchived and opened it.
  • vp run check:changed passes (format, lint, knip, typecheck for 43 packages, tests and React Compiler checks next to the changes). vp run i18n:check passes.

Model and harness: Claude Opus 5.5 in Amp (thread).


Summary by cubic

Moving a project to another machine now offers to add an existing folder when the destination already holds files. Previously the clone failed with "Destination path already exists and is not empty", leaving no way forward.

The server now carries the resolved destination path on that failure, and the "Add to another machine" dialog switches its main button to Add existing folder. Confirming creates the project at that path without copying files, so the checkout's own .env and similar files stay as they are. If a project on that machine already owns the folder, the dialog opens that project, unarchiving it first when needed. Editing the folder or switching machines returns the dialog to cloning. The command palette's clone and the mobile clone flow get the same failure but don't offer this yet.