Skip to content

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

Closed
marcelruhf wants to merge 4 commits into
mainfrom
feat/add-existing-folder-on-move
Closed

marcelruhf wants to merge 4 commits into
mainfrom
feat/add-existing-folder-on-move

Conversation

@marcelruhf

@marcelruhf marcelruhf commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

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.

Written for commit 0d82b12. Summary will update on new commits.

View guided diff Turn on auto-fix

…nother machine

Adding a project to another machine failed with "Destination path already
exists and is not empty" when that machine already had a checkout at the
destination, leaving the user at a dead end.

The server now tags that clone failure with reason "destination-not-empty".
The Add to another machine dialog reads it and offers "Add existing folder",
which adds the folder on that machine as the project without copying any
files. Changing the folder or machine returns the dialog to cloning.

Model and harness: Claude Opus 5.5 in Amp.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ff98-adfc-71e2-831e-72f58c684e8a
Co-authored-by: Marcel Ruhf <marcel@ruhf.eu>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 21, 2026
ampagent and others added 3 commits November 21, 2026 21:31
Adding the existing folder failed with "Failed to mutate project." when a
project on that machine already owned it, for example one grouped
separately or archived.

The clone refusal now carries the server's resolved folder path
(occupiedDestination) instead of a bare reason, since the client cannot
expand "~" for another machine. The dialog looks for a project at that
path on the target and opens it, unarchiving it first when needed, and
only creates a project when none owns the folder.

Model and harness: Claude Opus 5.5 in Amp.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ff98-adfc-71e2-831e-72f58c684e8a
Co-authored-by: Marcel Ruhf <marcel@ruhf.eu>
…r flow

Renames the dialog's refused-folder state, its resolved path, and the test
mocks so they read without explanation, and deletes a comment whose claims
were false (the folder need not be a checkout, nor already owned by a
project). The occupiedDestination contract doc keeps only what the field is.

Model and harness: Claude Opus 5.5 in Amp.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ff98-adfc-71e2-831e-72f58c684e8a
Co-authored-by: Marcel Ruhf <marcel@ruhf.eu>
The create, unarchive, or open decision moves into a pure
AddProjectToMachineDialog.logic.ts with a table test, reusing
findExistingAddProject, and the browser test keeps only the offer and its
reset. Project create and unarchive go through useOrchestrationCommand like
the other add-project entry points, so a connection without the operate
scope fails before the request. While the folder is offered, the dialog's
description says so instead of describing a clone, and the button reads
"Adding…" while it works.

Model and harness: Claude Opus 5.5 in Amp.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ff98-adfc-71e2-831e-72f58c684e8a
Co-authored-by: Marcel Ruhf <marcel@ruhf.eu>
@marcelruhf marcelruhf changed the title feat(web): offer to add an existing folder when moving a project to another machine feat(web): add an existing folder instead of cloning onto another machine Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Closing in favour of upstream pingdotgg#31106, which covers the same case (an existing folder at the clone destination) more completely, including Combine/Replace and mobile.

@marcelruhf marcelruhf closed this Nov 21, 2026
@marcelruhf
marcelruhf deleted the feat/add-existing-folder-on-move branch November 21, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants