diff --git a/agent-node/agent_node/node.py b/agent-node/agent_node/node.py index 4e11d56..cbb14fd 100644 --- a/agent-node/agent_node/node.py +++ b/agent-node/agent_node/node.py @@ -254,7 +254,13 @@ stats = entry.stat() size = stats.st_size if not is_dir else 0 except: size = 0 - files.append(agent_pb2.FileInfo(path=entry.name, size=size, hash="", is_dir=is_dir)) + + # Calculate path relative to the actual base_sync_dir / session_dir + # rel_path is the directory we are currently browsing. + # entry.name is the file within it. + item_rel_path = os.path.relpath(os.path.join(watch_path, entry.name), base_dir) + + files.append(agent_pb2.FileInfo(path=item_rel_path, size=size, hash="", is_dir=is_dir)) else: # Deep walk with full hashes for reconciliation for root, dirs, filenames in os.walk(watch_path): diff --git a/ai-hub/app/api/routes/nodes.py b/ai-hub/app/api/routes/nodes.py index 4b4e250..c65330a 100644 --- a/ai-hub/app/api/routes/nodes.py +++ b/ai-hub/app/api/routes/nodes.py @@ -689,7 +689,16 @@ logger.warning(f"[FS] Explorer Error for {node_id}: {res['error']}") raise HTTPException(status_code=status_code, detail=res["error"]) - return schemas.DirectoryListing(node_id=node_id, path=path, files=res.get("files", [])) + files = res.get("files", []) + # M6: Check sync status by seeing if path exists in server ghost mirror + workspace_mirror = orchestrator.mirror.get_workspace_path("__fs_explorer__") + for f in files: + # We simply check if it exists in our local mirror stash + # To be perfect, we'd check hash, but ls shallow doesn't give hash. + mirror_item_path = os.path.join(workspace_mirror, f["path"]) + f["is_synced"] = os.path.exists(mirror_item_path) + + return schemas.DirectoryListing(node_id=node_id, path=path, files=files) except HTTPException: raise except Exception as e: diff --git a/ai-hub/app/api/schemas.py b/ai-hub/app/api/schemas.py index 14edea3..3f9b283 100644 --- a/ai-hub/app/api/schemas.py +++ b/ai-hub/app/api/schemas.py @@ -387,6 +387,7 @@ is_dir: bool size: int = 0 hash: Optional[str] = None + is_synced: bool = False class DirectoryListing(BaseModel): node_id: str diff --git a/ui/client-app/src/components/FileSystemNavigator.js b/ui/client-app/src/components/FileSystemNavigator.js index fcefd6b..2266e35 100644 --- a/ui/client-app/src/components/FileSystemNavigator.js +++ b/ui/client-app/src/components/FileSystemNavigator.js @@ -137,19 +137,30 @@ node.is_dir ? toggleFolder(node.path) : handleView(node.path)} > + {!node.is_dir && ( + + )} {node.name}
{node.is_dir && ( - + <> + + + )} -