fix: scanner catalog empty + left column blank

Scanner: new instance with existing sf_scan_state.json
did not populate in-memory _catalog. Now re-inspects
unchanged files to fill catalog on first scan.
Frontend: left column reads instrumentSelectorData.
soundfonts instead of sfPresets (null when no presets).
Click SF in left column triggers on-demand fetch.
This commit is contained in:
2026-07-28 07:32:40 +07:00
parent 14e3a561a3
commit d40ac47d65
3 changed files with 53 additions and 25 deletions
+23 -9
View File
@@ -17704,15 +17704,29 @@ const App = () => {
onClick: () => { setSelectedSoundFontId(null); setSynthCategory(null); },
className: "w-full text-left px-3 py-2 text-sm rounded " + (!selectedSoundFontId ? "bg-amber-700 text-white" : "bg-zinc-800 hover:bg-zinc-700 text-zinc-300")
}, "All Instruments"),
sfPresets === null ? (
/*#__PURE__*/React.createElement("p", { className: "text-sm text-zinc-500 py-2" }, "Loading...")
) : (
[...new Map(sfPresets.map(p => [p._sfId, p])).values()].map(sf => /*#__PURE__*/React.createElement("button", {
key: sf._sfId,
onClick: () => setSelectedSoundFontId(sf._sfId),
className: "w-full text-left px-3 py-2 text-sm rounded " + (selectedSoundFontId === sf._sfId ? "bg-amber-700 text-white" : "bg-zinc-800 hover:bg-zinc-700 text-zinc-300")
}, sf._sfName))
)
(instrumentSelectorData?.soundfonts || []).map(sf => {
const sfId = sf.id.startsWith('sf_') ? sf.id : 'sf_' + sf.id;
const sfName = sf.display || sf.name || sf.id;
return /*#__PURE__*/React.createElement("button", {
key: sfId,
onClick: () => {
setSelectedSoundFontId(sfId);
// Fetch instruments on demand if not yet loaded
if (!sf.presets && window.SonicAPI) {
const baseId = sfId.replace('sf_', '');
window.SonicAPI.listSoundfontInstruments(baseId).then(data => {
if (data && data.presets) {
const mapping = data.presets.map(p => ({ ...p, _sfId: sfId, _sfName: sfName, _sfDisplay: sfName.substring(0, 30) }));
setSfPresets(prev => prev ? [...prev, ...mapping] : mapping);
// Also update instrumentSelectorData cache
setInstrumentSelectorData(prev => prev ? { ...prev, soundfonts: (prev.soundfonts || []).map(s => s.id === sf.id ? { ...s, presets: data.presets } : s) } : prev);
}
}).catch(() => {});
}
},
className: "w-full text-left px-3 py-2 text-sm rounded " + (selectedSoundFontId === sfId ? "bg-amber-700 text-white" : "bg-zinc-800 hover:bg-zinc-700 text-zinc-300")
}, sfName);
})
),
/*#__PURE__*/React.createElement("div", { className: "flex-1 overflow-y-auto space-y-0.5" },
/*#__PURE__*/React.createElement("button", {
File diff suppressed because one or more lines are too long