[Bug]: Mobile Add Project fails when the destination is already a project#23246

opened10d agobyUunmanbearpig

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/mobile

Steps to reproduce

Local folder:

  1. In the mobile app, connect to an environment that already has a project rooted at /home/<user>/projects/bureaucracy/bike-documents (any registered folder works).
  2. New thread → Choose project → + → Local folder.
  3. Enter the same folder as a home-relative path: ~/projects/bureaucracy/bike-documents/.
  4. Tap Add project.

Clone:

  1. Same environment, with a project already registered at ~/t3-dupfix-demo/Hello-World (stored as an absolute path).
  2. + → Git URL → https://github.com/octocat/Hello-World.git → Continue.
  3. Set the destination to ~/t3-dupfix-demo/Hello-World and tap Clone project. A prompt link (t3code-dev://new?prompt=…&repo=octocat/Hello-World) reaches the same screen with the default ~/<repo> destination.

Expected behavior

The app opens the existing project's new-task draft, as if the user had picked it from the project list (the web command palette already does this for duplicate paths). A prompt that came from a prompt link is kept in that draft. No second project is created and nothing is cloned.

Actual behavior

  • Local folder shows Failed to mutate project. The server log has ProjectConflictError: Workspace /home/<user>/t3-dupfix-demo/bike-documents already belongs to project <id>.
  • Clone (environments with clone tracking) shows Failed to create clone project. Environments without clone tracking try git clone into the non-empty folder and fail.
  • The prompt from a prompt link is lost.

The client looks for an existing project before creating one, but it compares the typed path with stored workspace roots, which the server always stores as absolute paths. A ~/ path never matches, so the client sends project.create and the server rejects it as a duplicate. The default clone destination is ~/<repo> when no add-project base directory is set, so the clone flow hits this by default. Absolute paths are matched, but the local-folder flow still shows a "Project already exists" alert before opening the project, and the clone flow never checks.

Impact

Major degradation or frequent failure

Version or commit

pingdotgg/t3code main at ed9b7ca9c53843ea1e6b466bf7d52928d10e7db0

Environment

Android 16 emulator (T3 Code Dev client), isolated dev:server on Linux. The code path is shared with iOS.

Logs or stack traces

1ProjectConflictError: Workspace /home/<user>/t3-dupfix-demo/bike-documents already belongs to project 51d0b45b-8aa6-4ede-ae27-8da471803580

Screenshots, recordings, or supporting files

Local folder, ~/ pathClone into an existing project
External imageExternal image

Workaround

Pick the project from the project list instead of adding it again.

Earlier attempts: #8229 (missed ~ expansion) and #18667 (closed for missing before/after mobile evidence).

Reproduced on a50cd989ae with the real isolated Linux server and EAS iPhone 17/iOS 26.5 client: home-relative local duplicates failed, absolute duplicates showed an alert, and tracked cloning attempted the occupied destination. With the fix, those paths open the existing draft; the tracked prompt-link case keeps the prompt and sends no new clone RPC.

Fix: #23500. Before/after native recordings and coverage limits. Android, Windows-host and the listed legacy/fallback/multi-environment rows remain unverified.