569c20cf63
The frontend router navigates to /instances/:instanceId/terminal without
project_id or repo_id. The backend terminal REST endpoints were requiring
these path params, causing 404s.
- Simplify _get_terminal_instance to validate by instance_id only
- Update all REST routes from /projects/{pid}/repositories/{rid}/instances/{iid}/terminal/*
to /instances/{instance_id}/terminal/*
- Update frontend API client to match new paths
- Update useTerminalSessions hook to take instanceId only
- Update TerminalPage to use simplified hook
- Update tests to match new paths
Fixes: 404 on GET /projects/repositories/instances/{id}/terminal/sessions
78 lines
1.8 KiB
TypeScript
78 lines
1.8 KiB
TypeScript
import { apiClient } from "./client";
|
|
|
|
export interface TerminalSession {
|
|
id: string;
|
|
name: string;
|
|
status: string;
|
|
has_websockets: boolean;
|
|
created_at: string;
|
|
last_activity_at: string | null;
|
|
}
|
|
|
|
export interface TerminalSessionListResponse {
|
|
sessions: TerminalSession[];
|
|
}
|
|
|
|
export interface TerminalSessionCreateRequest {
|
|
name?: string;
|
|
}
|
|
|
|
export interface TerminalSessionCreateResponse {
|
|
id: string;
|
|
name: string;
|
|
status: string;
|
|
created_at: string;
|
|
}
|
|
|
|
export async function listTerminalSessions(
|
|
instanceId: string,
|
|
): Promise<TerminalSession[]> {
|
|
const response = await apiClient.get(
|
|
`/instances/${instanceId}/terminal/sessions`,
|
|
);
|
|
return response.data.sessions;
|
|
}
|
|
|
|
export async function createTerminalSession(
|
|
instanceId: string,
|
|
name?: string,
|
|
): Promise<TerminalSessionCreateResponse> {
|
|
const response = await apiClient.post(
|
|
`/instances/${instanceId}/terminal/sessions`,
|
|
{ name },
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function closeTerminalSession(
|
|
instanceId: string,
|
|
sessionId: string,
|
|
): Promise<{ status: string; session_id: string }> {
|
|
const response = await apiClient.delete(
|
|
`/instances/${instanceId}/terminal/sessions/${sessionId}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function resetTerminalSession(
|
|
instanceId: string,
|
|
sessionId: string,
|
|
): Promise<{ id: string; name: string; status: string }> {
|
|
const response = await apiClient.post(
|
|
`/instances/${instanceId}/terminal/sessions/${sessionId}/reset`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function renameTerminalSession(
|
|
instanceId: string,
|
|
sessionId: string,
|
|
name: string,
|
|
): Promise<{ id: string; name: string }> {
|
|
const response = await apiClient.post(
|
|
`/instances/${instanceId}/terminal/sessions/${sessionId}/rename`,
|
|
{ name },
|
|
);
|
|
return response.data;
|
|
}
|