fix(skill_tree): UNC fallback para encontrar registry desde Windows nativo

Problema: skill_tree.exe en Windows tenia 0 nodos porque discover_registry_root
solo probaba env FN_REGISTRY_ROOT y walk-up desde cwd. Cwd en deploy es
C:\Users\lucas\Desktop\apps\skill_tree\ — sin registry.db cerca.

Fix:
- Anadir 3a estrategia (#ifdef _WIN32): probar paths UNC a WSL.
- Distros: WSL_REGISTRY_PATH env > Ubuntu-22.04 > Ubuntu > kali-linux > Debian.
- Tanto \wsl.localhost\<distro>\... como \wsl$\<distro>\... (legacy).
- Banner rojo en panel Tree si root vacio, con instrucciones.

Diagnostico:
- Mover discover + reload a first render frame (fn_log no inicializado
  antes de fn::run_app). Ahora log captura el path encontrado.

Verificacion: log dice
  discover_registry_root -> '\\wsl.localhost\Ubuntu-22.04\home\lucas\fn_registry'
  reloaded 173 nodes, 0 parse errors

Roadmap proximo: 0109m (issues_api HTTP service) reemplazara UNC con
cliente HTTP cuando este disponible.

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
parent 3a76f04204
commit c93cca82ba
+50 -2
View File
@@ -127,13 +127,36 @@ static const char* ring_label(int ring) {
// ---- Registry root discovery -------------------------------------------
static fs::path discover_registry_root() {
// 1. env var
if (const char* env = std::getenv("FN_REGISTRY_ROOT")) {
fs::path p(env);
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()) {
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 {};
}
@@ -1022,6 +1045,22 @@ static void draw_tree() {
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.
int n_done = g_scan.count_by_status["completado"];
int n_inprog = g_scan.count_by_status["in-progress"];
@@ -1339,6 +1378,15 @@ static void draw_dashboard() {
}
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_inspector) draw_inspector();
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();
}
g_root = discover_registry_root();
reload_scan();
// discover_registry_root + reload_scan move to first render() frame
// (fn_log not initialized here yet — would lose discovery diagnostics).
static fn_ui::PanelToggle panels[] = {
{ "Tree", nullptr, &g_show_tree },