merge issue/0109l-unc-fallback

UNC fallback para encontrar registry root desde Windows nativo.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 16:29:35 +02:00
+50 -2
View File
@@ -127,13 +127,36 @@ static const char* ring_label(int ring) {
// ---- Registry root discovery ------------------------------------------- // ---- Registry root discovery -------------------------------------------
static fs::path discover_registry_root() { static fs::path discover_registry_root() {
// 1. env var
if (const char* env = std::getenv("FN_REGISTRY_ROOT")) { if (const char* env = std::getenv("FN_REGISTRY_ROOT")) {
fs::path p(env); fs::path p(env);
if (fs::exists(p / "registry.db")) return p; if (fs::exists(p / "registry.db")) return p;
} }
// 2. walk up desde cwd
for (auto p = fs::current_path(); !p.empty() && p != p.root_path(); p = p.parent_path()) { for (auto p = fs::current_path(); !p.empty() && p != p.root_path(); p = p.parent_path()) {
if (fs::exists(p / "registry.db") && fs::exists(p / "dev" / "issues")) return p; if (fs::exists(p / "registry.db") && fs::exists(p / "dev" / "issues")) return p;
} }
#ifdef _WIN32
// 3. fallback Windows: acceso UNC al sistema de archivos WSL. La ruta del
// distro/usuario se puede sobreescribir con WSL_REGISTRY_PATH para otros
// setups; defaults asumen Ubuntu + lucas (este PC).
const char* unc_env = std::getenv("WSL_REGISTRY_PATH");
std::vector<std::string> candidates;
if (unc_env && *unc_env) candidates.push_back(unc_env);
// Default WSL distros to probe (orden por probabilidad en este setup).
const char* distros[] = { "Ubuntu-22.04", "Ubuntu", "kali-linux", "Debian" };
for (const char* d : distros) {
candidates.push_back(std::string("\\\\wsl.localhost\\") + d + "\\home\\lucas\\fn_registry");
candidates.push_back(std::string("\\\\wsl$\\") + d + "\\home\\lucas\\fn_registry");
}
for (const auto& c : candidates) {
fs::path p(c);
std::error_code ec;
if (fs::exists(p / "registry.db", ec) && fs::exists(p / "dev" / "issues", ec)) {
return p;
}
}
#endif
return {}; return {};
} }
@@ -1022,6 +1045,22 @@ static void draw_tree() {
return; return;
} }
// Banner si no encontramos registry root.
if (g_root.empty()) {
ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(80, 20, 20, 255));
ImGui::BeginChild("root_err", ImVec2(0, 80), ImGuiChildFlags_Borders);
ImGui::TextColored(ImVec4(1, 0.6f, 0.6f, 1),
TI_ALERT_TRIANGLE " No se encontro registry root.");
ImGui::TextWrapped("Probadas: env FN_REGISTRY_ROOT, walk-up desde cwd"
#ifdef _WIN32
", env WSL_REGISTRY_PATH, \\\\wsl.localhost\\Ubuntu\\home\\lucas\\fn_registry, \\\\wsl$\\..."
#endif
". Setea FN_REGISTRY_ROOT (o WSL_REGISTRY_PATH en Win) y relanza."
);
ImGui::EndChild();
ImGui::PopStyleColor();
}
// HUD strip. // HUD strip.
int n_done = g_scan.count_by_status["completado"]; int n_done = g_scan.count_by_status["completado"];
int n_inprog = g_scan.count_by_status["in-progress"]; int n_inprog = g_scan.count_by_status["in-progress"];
@@ -1339,6 +1378,15 @@ static void draw_dashboard() {
} }
static void render() { static void render() {
// Defer first reload to first frame so fn_log is initialized.
static bool first_init = true;
if (first_init) {
first_init = false;
g_root = discover_registry_root();
fn_log::log_info("skill_tree: discover_registry_root -> '%s'",
g_root.empty() ? "(empty)" : g_root.string().c_str());
reload_scan();
}
if (g_show_tree) draw_tree(); if (g_show_tree) draw_tree();
if (g_show_inspector) draw_inspector(); if (g_show_inspector) draw_inspector();
if (g_show_dashboard) draw_dashboard(); if (g_show_dashboard) draw_dashboard();
@@ -1388,8 +1436,8 @@ int main(int argc, char** argv) {
if (std::strcmp(argv[i], "--self-test") == 0) return run_self_test(); if (std::strcmp(argv[i], "--self-test") == 0) return run_self_test();
} }
g_root = discover_registry_root(); // discover_registry_root + reload_scan move to first render() frame
reload_scan(); // (fn_log not initialized here yet — would lose discovery diagnostics).
static fn_ui::PanelToggle panels[] = { static fn_ui::PanelToggle panels[] = {
{ "Tree", nullptr, &g_show_tree }, { "Tree", nullptr, &g_show_tree },