agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

Import project dead-ends on PATH_ALREADY_REGISTERED with no 'go to that project' option

Open OrcInc opened this issue 3 months ago • 2 comments

Bug

Importing a local folder that is already registered as a project dead-ends the Import project modal: it shows the raw daemon error A project at this path is already registered (PATH_ALREADY_REGISTERED) with only "Choose a different folder to try again" + Cancel. There is no path to the already-registered project, even though the daemon tells the client exactly which project it is.

Reporter's ask: instead of this error, offer an option to go to that project.

Source: Discord #bug-triage (2026-08-25) Reported by: @maaz Analyzed against: origin/main @ 4c3f4d72e Confidence: High — full chain traced end-to-end (daemon → envelope → apiClient → CreateProjectFlow) Priority: medium — degraded UX, workaround exists (find the project manually in the sidebar)

Reproduction

  1. Have a project registered at path P (it is in the sidebar)
  2. + → Import project → Choose a project folder → select P in the OS picker
  3. Confirm creation in the agent sheet
  4. Daemon returns 409 PATH_ALREADY_REGISTERED
  5. Modal re-opens in the bare folder-picker state: red error box with the raw message, footer "Choose a different folder to try again", only Cancel available — a dead end

Import project modal showing the PATH_ALREADY_REGISTERED dead-end

Root Cause

The daemon already returns everything needed to recover — the renderer discards it at every layer.

The daemon side is fine:

  • backend/internal/service/project/service.go:196-200 — Add() returns apierr.Conflict("PATH_ALREADY_REGISTERED", "A project at this path is already registered", map[string]any{"existingProjectId": existing.ID, "suggestedProjectId": ...})
  • backend/internal/httpd/envelope/envelope.go:44 — Details map[string]any json:"details,omitempty" — so details.existingProjectId is on the wire in the 409 response.

Where the renderer drops it:

  1. frontend/src/renderer/routes/_shell.tsx (createProject, ~L424-432):

    const failure = new Error(apiErrorMessage(error)) as Error & { code?: string };
    failure.code = apiErrorCode(error);
    throw failure;
    

    Only message + code survive. error.details — which carries existingProjectId — is dropped on the floor. There is no apiErrorDetails() helper at all (frontend/src/renderer/lib/api-client.ts has apiErrorMessage / apiErrorCode / apiErrorRequestId only).

  2. frontend/src/renderer/lib/api-client.ts (apiErrorMessage) renders `${body.message} (${code})` — which is exactly the (PATH_ALREADY_REGISTERED) suffix visible in the screenshot. Raw daemon code leaked into UI copy.

  3. frontend/src/renderer/components/CreateProjectFlow.tsx:212-235 (createProject catch): code is extracted (line 213) but is only branched on for NOT_A_GIT_REPO / PROJECT_UNBORN repository-setup recovery. There is no branch for PATH_ALREADY_REGISTERED / ID_ALREADY_REGISTERED. So: setError(message), and since shouldScanCreateFailure() (line 421-426) explicitly returns false for (PATH|ID)_ALREADY_REGISTERED, validationScan stays null → CreateProjectFolderDialog renders the bare dashed picker + error box + footer createProject.footerChoose ("Choose a different folder to try again", en.json:166).

  4. Pre-flight doesn't help either: the folder scan (frontend/src/main/import-folder-scan.ts, scanGitRepo) only knows git facts (bare, unborn, no remote, reserved name). It has no access to AO's registered-project list, so the user learns about the conflict only after confirming.

Fix

  1. Carry the conflict payload: in _shell.tsx createProject (and cloneProject for symmetry), attach error.details (or minimally existingProjectId) to the thrown error, e.g. add an apiErrorDetails(error) helper in api-client.ts next to the existing ones.
  2. Branch on the code in CreateProjectFlow's catch: for PATH_ALREADY_REGISTERED, render a dedicated state in CreateProjectFolderDialog — "This folder is already registered as a project" with a primary Go to project action (navigate to existingProjectId via the existing project navigation; the project is already in the sidebar) and secondary Choose a different folder. Same pattern applies to ID_ALREADY_REGISTERED.
  3. Optional belt-and-braces: during the folder scan, flag the selected repo as "already registered" (the renderer already has the workspace/project list) so the user finds out at picker time, before confirming.

Impact

  • Any user who re-imports a folder that's already registered (new machine, restored disk, or simply forgetting it's in the long sidebar list) hits a hard dead-end that reads like a system fault rather than guidance.
  • The error copy exposes the raw daemon code (PATH_ALREADY_REGISTERED) verbatim, inconsistent with the rest of the import flow's human-readable messaging.

Related

  • #2721 — same flow, non-Git/nested import error messaging (different failure class, same "raw error in modal" shape)

OrcInc avatar Aug 25 '26 02:08 OrcInc

Thanks for contributing to Agent Orchestrator.

This issue is being picked up by the current external contributor on-call pair:

  • @illegalcall
  • @somewherelostt

If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @somewherelostt here.

For faster context or live questions, you can also join the AO Discord.

Join the session here: https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

somewherelostt avatar Aug 25 '26 15:08 somewherelostt

I want to take up this issue. Pls assign me.

Vansh-Singhal avatar Sep 02 '26 11:09 Vansh-Singhal