mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-29 04:32:57 +00:00
* fix(daemon): keep lifecycle operations on the selected instance Restart reconstructed launch inputs and address fallback could redirect a home-selected shutdown to another daemon. Let supervisors publish bound endpoints, retain their worker restart contract, and share captured local lifecycle ownership between CLI and Desktop. * test(daemon): verify bounded desktop readiness and cancellable artifacts * test(cli): verify reload target hints and durable offline pairing * test(daemon): align lifecycle fixtures with ownership and targeting * fix(daemon): preserve reachability when status details time out Provider discovery can outlast a status request after authentication succeeds. Keep local connection facts separate from unavailable details, while explicit remote queries retain their error outcome. Migrate CLI and packaged Desktop fixtures to persistent managed configuration and explicit targets. Isolate generic Git observation from forge discovery and reuse disposable CLI homes on Windows. * test(daemon): observe restart through the worker status RPC The bounded CLI status observation may omit worker details while an authenticated connection remains healthy. Exercise the app-style restart through its full RPC and retain the replacement observation, with a real slow provider probe covering the distinction.
50 lines
2.0 KiB
TypeScript
50 lines
2.0 KiB
TypeScript
import type { Command } from "commander";
|
|
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
import type { CommandError, OutputSchema, SingleResult } from "../../output/index.js";
|
|
|
|
interface WorkspaceSetupResult {
|
|
workspaceId: string;
|
|
status: "started" | "already_allowed";
|
|
}
|
|
|
|
const workspaceSetupSchema: OutputSchema<WorkspaceSetupResult> = {
|
|
idField: "workspaceId",
|
|
columns: [
|
|
{ header: "WORKSPACE ID", field: "workspaceId", width: 20 },
|
|
{ header: "STATUS", field: "status", width: 18 },
|
|
],
|
|
};
|
|
|
|
export async function runSetupCommand(
|
|
workspaceId: string,
|
|
options: { host?: string; daemonTarget: import("../../utils/daemon-target.js").DaemonTarget },
|
|
_command: Command,
|
|
): Promise<SingleResult<WorkspaceSetupResult>> {
|
|
const host = getDaemonHost({ target: options.daemonTarget });
|
|
const client = await connectToDaemon({ target: options.daemonTarget }).catch((error: unknown) => {
|
|
throw {
|
|
code: "DAEMON_NOT_RUNNING",
|
|
message: `Cannot connect to daemon at ${host}: ${error instanceof Error ? error.message : String(error)}`,
|
|
} satisfies CommandError;
|
|
});
|
|
try {
|
|
// COMPAT(workspaceSetupRun): added in v0.7.3, remove gate after 2027-09-02.
|
|
if (!client.getLastServerInfoMessage()?.features?.workspaceSetupRun) {
|
|
throw { code: "DAEMON_UPDATE_REQUIRED", message: "Update the host to run workspace setup." };
|
|
}
|
|
const payload = await client.runWorkspaceSetup(workspaceId);
|
|
if (payload.error) throw new Error(payload.error);
|
|
return {
|
|
type: "single",
|
|
data: { workspaceId, status: payload.started ? "started" : "already_allowed" },
|
|
schema: workspaceSetupSchema,
|
|
};
|
|
} catch (error) {
|
|
if (error && typeof error === "object" && "code" in error) throw error;
|
|
const message = error instanceof Error ? error.message : String(error);
|
|
throw { code: "WORKSPACE_SETUP_FAILED", message } satisfies CommandError;
|
|
} finally {
|
|
await client.close().catch(() => undefined);
|
|
}
|
|
}
|