From a37dd82ae3a3f5b2ccc9cdbe62a14130e5921f19 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 21 Mar 2026 11:26:39 +0100 Subject: [PATCH] fix: parse file list API response format correctly API returns {"files": [{"name": "...", "data_type": "..."}]}, not a plain array. Extract file names from the nested structure. Co-Authored-By: Claude Opus 4.6 --- web/project_source.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/project_source.js b/web/project_source.js index 3513f8c..cde2a30 100644 --- a/web/project_source.js +++ b/web/project_source.js @@ -40,17 +40,17 @@ app.registerExtension({ ); if (!resp.ok) return; const data = await resp.json(); - if (!Array.isArray(data)) return; + const fileList = (data.files || []).map(f => f.name || f); + console.log(`[ProjectSource] refreshFiles: got ${fileList.length} files:`, fileList); const fileW = node.widgets?.find(w => w.name === "file_name"); if (fileW) { const currentValue = fileW.value; - fileW.options.values = data.length > 0 ? data : [""]; + fileW.options.values = fileList.length > 0 ? fileList : [""]; // Keep current selection if still valid - if (currentValue && data.includes(currentValue)) { + if (currentValue && fileList.includes(currentValue)) { fileW.value = currentValue; } - console.log(`[ProjectSource] refreshFiles: ${data.length} files loaded`); } } catch (e) { console.error("[ProjectSource] Failed to refresh files:", e);