fix: promote first project when config default is missing from DB

Fresh CLI installs auto-create main in config but never sync it to the
projects table; the first project add now becomes default when the
configured default has no DB row. Fixes #974.

Signed-off-by: rudi193-cmd <rudi193@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
rudi193-cmd
2026-06-12 06:44:55 -06:00
committed by Paul Hernandez
parent 0247ef0ead
commit b92b0340d5
2 changed files with 59 additions and 0 deletions
@@ -256,6 +256,19 @@ class ProjectService:
await self.repository.set_as_default(created_project.id)
self.config_manager.set_default_project(name)
logger.info(f"Project '{name}' set as default")
else:
config_default = self.config_manager.default_project
if config_default is not None:
db_default_project = await self.repository.get_by_name(config_default)
if db_default_project is None:
await self.repository.set_as_default(created_project.id)
self.config_manager.set_default_project(name)
logger.info(
"Promoted project '%s' to default because configured default '%s' "
"is missing from database",
name,
config_default,
)
logger.info(f"Project '{name}' added at {resolved_path}")