fix: arborescence dédoublée + dossiers fermés visibles + preview pages FlowDeck
FlowDeck CI / test (push) Failing after 4s
FlowDeck CI / docker (push) Has been skipped

1. Tree affichage: displayTree contient maintenant les racines uniquement
   (plus de flatten). _markTree ajoute depth/db_id sans aplatir, et
   renderChildren gère la récursion. Les enfants n'apparaissent plus
   quand le dossier est fermé, et plus de dédoublement à l'ouverture.

2. Filtre: _filterTree travaille sur l'arbre hiérarchique, clone les
   nodes pour préserver la structure.

3. Preview pages FlowDeck: nouvelle API GET /api/local-workspace/page-content/{id}.
   showPreview détecte content_format='file' → /api/files/, sinon → API page-content.
   Plus de 'file not found' sur les fichiers créés dans FlowDeck.

4. API tree: ajout content_format dans la réponse pour distinguer
   fichiers uploadés vs pages FlowDeck.
This commit is contained in:
2026-07-11 10:08:33 -04:00
parent 8bd737cef6
commit 722c7103de
2 changed files with 59 additions and 27 deletions
+18 -2
View File
@@ -554,6 +554,21 @@ async def local_workspace_tree(request: Request, folder: int = None):
return {"tree": roots, "breadcrumb": [], "current_folder": None}
@router.get("/api/local-workspace/page-content/{page_id:int}")
async def get_page_content(page_id: int):
"""Return the raw content of a page (for preview)."""
with get_conn() as conn:
row = conn.execute(
"SELECT content, content_format FROM pages WHERE id=?", (page_id,)
).fetchone()
if not row:
return JSONResponse({"error": "Not found"}, status_code=404)
fmt = row["content_format"]
if fmt == "file":
return JSONResponse({"content": "(uploaded file)", "format": fmt})
return {"content": row["content"] or "", "format": fmt}
@router.get("/api/local-workspace/breadcrumb")
async def local_workspace_breadcrumb(request: Request, folder: int):
"""Return breadcrumb trail for a folder."""
@@ -566,13 +581,13 @@ def _build_tree_children(conn, parent_id: int | None, ws_id: int) -> list:
"""Recursively build the tree of children for a node."""
if parent_id is None:
rows = conn.execute(
"SELECT id, title, parent_section FROM pages "
"SELECT id, title, parent_section, content_format FROM pages "
"WHERE parent_id IS NULL AND workspace_id=? ORDER BY created_at DESC",
(ws_id,),
).fetchall()
else:
rows = conn.execute(
"SELECT id, title, parent_section FROM pages "
"SELECT id, title, parent_section, content_format FROM pages "
"WHERE parent_id=? AND workspace_id=? ORDER BY created_at DESC",
(parent_id, ws_id),
).fetchall()
@@ -586,6 +601,7 @@ def _build_tree_children(conn, parent_id: int | None, ws_id: int) -> list:
"name": r["title"] or "Untitled",
"type": "folder" if is_folder else "page",
"is_folder": is_folder,
"content_format": r["content_format"] if not is_folder else None,
"children": children,
"has_children": len(children) > 0,
})