diff --git a/vibn-frontend/lib/dev-container.ts b/vibn-frontend/lib/dev-container.ts index 176d4cf..19ced7d 100644 --- a/vibn-frontend/lib/dev-container.ts +++ b/vibn-frontend/lib/dev-container.ts @@ -433,6 +433,32 @@ export async function execInDevContainer( await resumeDevContainer(opts.projectId); } + // Self-healing migration hook: Migrate legacy nested repositories to root /workspace + try { + const projectRow = await queryOne<{ slug: string }>( + `SELECT slug FROM fs_projects WHERE id = $1 LIMIT 1`, + [opts.projectId], + ); + if (projectRow?.slug) { + const slug = projectRow.slug; + const migrationCmd = + `if [ -d "/workspace/${slug}" ] && [ ! -d "/workspace/.git" ]; then ` + + `mv /workspace/${slug}/* /workspace/ 2>/dev/null; ` + + `mv /workspace/${slug}/.* /workspace/ 2>/dev/null; ` + + `rmdir /workspace/${slug} 2>/dev/null; ` + + `fi`; + await execInCoolifyApp({ + appUuid: row.service_uuid, + service: "vibn-dev", + command: migrationCmd, + user: "vibn", + timeoutMs: 10000, + }).catch(() => null); + } + } catch (err) { + // non-fatal best effort + } + const cwd = opts.cwd && opts.cwd.trim() ? opts.cwd.trim() : "/workspace"; const envPrefix = opts.env ? Object.entries(opts.env)