Files
kandev/apps/web/lib/api/domains/ssh-api.ts
T
José Almeida ce6d4e6e2a feat(web): add SSH executor settings UI
SSHConnectionCard: connection form (name, host_alias / host / port /
user, identity source = ssh-agent | file with optional file path,
optional ProxyJump) with a Test Connection button that runs the backend
probe, surfaces the observed host fingerprint, and only enables Save
when the user explicitly ticks "Trust this host". Editing the host /
port / user / identity fields resets both the test result and the trust
checkbox. On save, if the executor already has running sessions, a
confirm modal warns that those keep going on the old host and only new
sessions will use the new config.

SSHSessionsCard: 90s-polled table of active sessions for the executor,
mirroring SpritesInstancesCard / DockerContainersCard. Columns: task,
session, user@host, remote agentctl port, local forward port, uptime,
status badge. Backed by GET /api/v1/ssh/executors/:id/sessions.

Also registers the ssh entry in executor-icons.ts (label "SSH",
IconTerminal2) so it surfaces consistently in the rest of the settings
chrome.
2026-05-17 23:28:50 +01:00

28 lines
804 B
TypeScript

import { fetchJson, type ApiRequestOptions } from "../client";
import type { SSHTestRequest, SSHTestResult, SSHSession } from "@/lib/types/http-ssh";
export async function testSSHConnection(
request: SSHTestRequest,
options?: ApiRequestOptions,
): Promise<SSHTestResult> {
return fetchJson<SSHTestResult>("/api/v1/ssh/test", {
...options,
init: {
method: "POST",
headers: { "Content-Type": "application/json", ...(options?.init?.headers ?? {}) },
body: JSON.stringify(request),
...(options?.init ?? {}),
},
});
}
export async function listSSHSessions(
executorId: string,
options?: ApiRequestOptions,
): Promise<SSHSession[]> {
return fetchJson<SSHSession[]>(
`/api/v1/ssh/executors/${encodeURIComponent(executorId)}/sessions`,
options,
);
}