mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-01-30 06:12:06 +00:00
fix: decouple project name from folder path in project creation
Remove automatic subfolder creation when creating projects. Users now select the exact folder they want to use, enabling support for existing projects without requiring folder names to match project names. Changes: - NewProjectModal.tsx: Remove path concatenation that appended project name to selected folder. Update instruction text to clarify users select THE project folder, not a parent location. - FolderBrowser.tsx: Add visual indicator "This folder will contain all project files" to clarify selection behavior. - projects.py: Add duplicate path validation to prevent multiple projects from registering the same directory. Includes case-insensitive path comparison on Windows for proper cross-platform support. This allows users to: - Use Auto Coder on existing projects by selecting their folder directly - Have project names that differ from folder names (name is a registry label) - Get clear feedback when a path is already registered under another name Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ Uses project registry for path lookups instead of fixed generations/ directory.
|
||||
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
@@ -131,7 +132,7 @@ async def list_projects():
|
||||
async def create_project(project: ProjectCreate):
|
||||
"""Create a new project at the specified path."""
|
||||
_init_imports()
|
||||
register_project, _, get_project_path, _, _ = _get_registry_functions()
|
||||
register_project, _, get_project_path, list_registered_projects, _ = _get_registry_functions()
|
||||
|
||||
name = validate_project_name(project.name)
|
||||
project_path = Path(project.path).resolve()
|
||||
@@ -144,6 +145,22 @@ async def create_project(project: ProjectCreate):
|
||||
detail=f"Project '{name}' already exists at {existing}"
|
||||
)
|
||||
|
||||
# Check if path already registered under a different name
|
||||
all_projects = list_registered_projects()
|
||||
for existing_name, info in all_projects.items():
|
||||
existing_path = Path(info["path"]).resolve()
|
||||
# Case-insensitive comparison on Windows
|
||||
if sys.platform == "win32":
|
||||
paths_match = str(existing_path).lower() == str(project_path).lower()
|
||||
else:
|
||||
paths_match = existing_path == project_path
|
||||
|
||||
if paths_match:
|
||||
raise HTTPException(
|
||||
status_code=409,
|
||||
detail=f"Path '{project_path}' is already registered as project '{existing_name}'"
|
||||
)
|
||||
|
||||
# Security: Check if path is in a blocked location
|
||||
from .filesystem import is_path_blocked
|
||||
if is_path_blocked(project_path):
|
||||
|
||||
Reference in New Issue
Block a user