(id: string, relPath: string)
| 493 | } |
| 494 | |
| 495 | export async function listFiles(id: string, relPath: string): Promise<DirListing> { |
| 496 | // Electron app mode has a native file transport. Browser/dev/Docker keep the |
| 497 | // HTTP path, which is still the right shape for self-hosting and ordinary |
| 498 | // browser debugging. |
| 499 | const bridge = electronWorkspaceBridge(); |
| 500 | if (bridge) return bridge.listFiles({ id, path: relPath }); |
| 501 | const qs = relPath ? `?path=${encodeURIComponent(relPath)}` : ''; |
| 502 | const res = await fetch(`/api/workspaces/${encodeURIComponent(id)}/files${qs}`); |
| 503 | if (!res.ok) throw new Error(`list files failed: ${res.status}`); |
| 504 | return (await res.json()) as DirListing; |
| 505 | } |
| 506 | |
| 507 | /** |
| 508 | * Read a single UTF-8 text file from inside a workspace. Returns a |
no test coverage detected