From b43dddac4ec63d1d5b6d668658797b6afe48366d Mon Sep 17 00:00:00 2001 From: mawkone Date: Tue, 9 Jun 2026 13:52:14 -0700 Subject: [PATCH] chore(telemetry): add container-level self-healing repository folder migration hook --- vibn-frontend/lib/dev-container.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/vibn-frontend/lib/dev-container.ts b/vibn-frontend/lib/dev-container.ts index 176d4cf6..19ced7dc 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)