- toggle defaults on for any target the project scan reports (repo or worktree); only the free-text escape hatch pays for /api/gitroot - branch mode control switches between creating a new branch (named after the session name, as before) and picking an existing one from GET /api/branches; branches held by another worktree stay visible but disabled, labelled with that worktree's path - emits create_branch: false on the wire for existing-mode picks - branch-list load follows the form's ready/destroyed discipline so a late response cannot corrupt a rebuilt draft
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
// Mirror of `maestro-protocol::routes`. Keep in sync with
|
|
// crates/maestro-protocol/src/routes.rs.
|
|
|
|
import type { Uuid } from "./types.js";
|
|
|
|
export const API_PREFIX = "/api";
|
|
|
|
export const SESSIONS = "/api/sessions";
|
|
export const INFO = "/api/info";
|
|
export const DIRS = "/api/dirs";
|
|
export const RECENT_DIRS = "/api/recent-dirs";
|
|
export const PROJECTS = "/api/projects";
|
|
export const GITROOT = "/api/gitroot";
|
|
export const NAMES = "/api/names";
|
|
export const BRANCHES = "/api/branches";
|
|
export const EVENTS = "/api/events";
|
|
|
|
/** Name of the query parameter `DIRS` and `GITROOT` both take. */
|
|
export const PATH_QUERY = "path";
|
|
|
|
/** Name of the query parameter `NAMES` takes. */
|
|
export const COUNT_QUERY = "count";
|
|
|
|
export function session(id: Uuid): string {
|
|
return `${SESSIONS}/${encodeURIComponent(id)}`;
|
|
}
|
|
|
|
export function attach(id: Uuid): string {
|
|
return `${API_PREFIX}/attach/${encodeURIComponent(id)}`;
|
|
}
|
|
|
|
/** Append the `path` query parameter `DIRS` and `GITROOT` accept. */
|
|
export function withPathQuery(route: string, value: string): string {
|
|
return `${route}?${PATH_QUERY}=${encodeURIComponent(value)}`;
|
|
}
|
|
|
|
/** Same-origin WebSocket base — `wss:` under TLS, `ws:` otherwise. */
|
|
export function wsBase(): string {
|
|
const proto = location.protocol === "https:" ? "wss:" : "ws:";
|
|
return `${proto}//${location.host}`;
|
|
}
|
|
|
|
export function eventsWsUrl(): string {
|
|
return `${wsBase()}${EVENTS}`;
|
|
}
|
|
|
|
export function attachWsUrl(id: Uuid): string {
|
|
return `${wsBase()}${attach(id)}`;
|
|
}
|