refactor(maestro): flatten web UI to a single host

Session tree nests by working directory only; the daemon chips in the
header become a session tally, and the spawn form loses its host picker.
API calls move from /api/daemons/:id/* to /api/dirs, /api/recent-dirs,
/api/gitroot, and /api/info.
This commit is contained in:
Miguel Palhas
2026-08-22 10:14:10 +01:00
parent 6790f41652
commit 1bb464be4b
14 changed files with 155 additions and 467 deletions
+15 -22
View File
@@ -7,7 +7,6 @@ import type {
RecentDirs,
Session,
Uuid,
WebInfo,
} from "./types.js";
async function jsonOrError<T>(res: Response): Promise<T> {
@@ -25,10 +24,6 @@ async function jsonOrError<T>(res: Response): Promise<T> {
throw new Error(`${res.status} ${res.statusText}${detail ? ` — ${detail}` : ""}`);
}
export async function listDaemons(): Promise<DaemonInfo[]> {
return jsonOrError(await fetch("/api/daemons", { credentials: "same-origin" }));
}
export async function listSessions(): Promise<Session[]> {
return jsonOrError(await fetch("/api/sessions", { credentials: "same-origin" }));
}
@@ -53,31 +48,29 @@ export async function killSession(id: Uuid): Promise<void> {
);
}
/** List one directory's immediate subdirectories on `daemonId`'s host (NAP-329).
* `path` may be empty, `~`, relative, or absolute — the daemon resolves it
* against its own home dir. */
export async function listDir(daemonId: string, path: string): Promise<DirListing> {
const url = `/api/daemons/${encodeURIComponent(daemonId)}/dirs?path=${encodeURIComponent(path)}`;
/** List one directory's immediate subdirectories (NAP-329). `path` may be empty,
* `~`, relative, or absolute — the daemon resolves it against its home dir. */
export async function listDir(path: string): Promise<DirListing> {
const url = `/api/dirs?path=${encodeURIComponent(path)}`;
return jsonOrError(await fetch(url, { credentials: "same-origin" }));
}
/** Identity + spawn presets of the daemon this web app is connected to (#26). */
export async function getWebInfo(): Promise<WebInfo> {
return jsonOrError(await fetch("/api/web/info", { credentials: "same-origin" }));
export async function getDaemonInfo(): Promise<DaemonInfo> {
return jsonOrError(await fetch("/api/info", { credentials: "same-origin" }));
}
/** Recently-used working dirs on `daemonId`'s host, newest-first and deduped by
* dir (#26). Drives the spawn form's recents picker. */
export async function recentDirs(daemonId: string): Promise<RecentDirs> {
const url = `/api/daemons/${encodeURIComponent(daemonId)}/recent-dirs`;
return jsonOrError(await fetch(url, { credentials: "same-origin" }));
/** Recently-used working dirs, newest-first and deduped by dir (#26). Drives the
* spawn form's recents picker. */
export async function recentDirs(): Promise<RecentDirs> {
return jsonOrError(await fetch("/api/recent-dirs", { credentials: "same-origin" }));
}
/** Probe the enclosing git repo of `path` on `daemonId`'s host (#26). `root` is
* absent when the path isn't inside a repo. `path` may be `~`/relative/absolute;
* the daemon resolves it against its home dir. */
export async function gitRoot(daemonId: string, path: string): Promise<GitRoot> {
const url = `/api/daemons/${encodeURIComponent(daemonId)}/gitroot?path=${encodeURIComponent(path)}`;
/** Probe the enclosing git repo of `path` (#26). `root` is absent when the path
* isn't inside a repo. `path` may be `~`/relative/absolute; the daemon resolves
* it against its home dir. */
export async function gitRoot(path: string): Promise<GitRoot> {
const url = `/api/gitroot?path=${encodeURIComponent(path)}`;
return jsonOrError(await fetch(url, { credentials: "same-origin" }));
}