fix: Alpine x-for errors — tree init + unique keys + _loaded guard
FlowDeck CI / test (push) Failing after 4s
FlowDeck CI / docker (push) Has been skipped

- tree starts as [] (not undefined) so x-for doesn't crash
- :key uses node.db_id || 'item-'+idx for uniqueness
- _loaded guard prevents rendering before async init completes
- Empty state shows while loading, tree only renders after load()
This commit is contained in:
2026-07-10 21:45:41 -04:00
parent 418fe19f33
commit 05369f1856
+5 -3
View File
@@ -71,8 +71,8 @@
</div>
<!-- Recursive tree -->
<ul class="ws-tree" x-show="tree.length">
<template x-for="node in tree" :key="node.id">
<ul class="ws-tree" x-show="tree.length && _loaded">
<template x-for="(node, idx) in tree" :key="node.db_id || 'item-'+idx">
<li>
<div class="ws-tree-item"
:data-id="node.db_id"
@@ -162,6 +162,7 @@ function wsPage() {
createType: 'file', newName: '', parentFolder: null,
renameTarget: null, deleteTarget: null,
expandedFolders: {},
_loaded: false,
async init() { await this.load(); },
@@ -170,7 +171,8 @@ function wsPage() {
const r = await fetch('/api/local-workspace/tree');
const data = await r.json();
this.tree = this.flattenTree(data.tree || [], 0);
} catch(e) { console.error(e); }
this._loaded = true;
} catch(e) { console.error(e); this._loaded = true; }
},
flattenTree(nodes, depth) {