refactor(e2e): extract SSH HTTP shapes into api-client-ssh.ts

api-client.ts was already over the 600-line lint cap on main (1528
lines); the SSH additions made it worse. Split the SSH HTTP shape
types into a dedicated module and re-export from api-client.ts so
existing callers keep working. The methods themselves stay on
ApiClient as thin pass-throughs since splitting them out across the
class boundary would change every test call site.

Also document the per-executor bound on the SSH listSessions per-row
GetTaskSession lookup (typical N < 10), and what a batch path would
need (a repo method to fetch task_sessions by id list). Cubic /
Greptile P2.
This commit is contained in:
José Almeida
2026-05-17 21:38:56 +01:00
parent 145e62a249
commit ed76b7b6f0
3 changed files with 66 additions and 48 deletions
+5
View File
@@ -330,6 +330,11 @@ func (h *Handler) testAgentctlCache(ctx context.Context, client *ssh.Client, res
// the TaskSession associated with each row — the row itself has an
// ExecutorID column but the lifecycle manager does not populate it for fresh
// executions, so it's unreliable as a filter.
//
// The runtime filter runs before the session lookup, so the per-row
// GetTaskSession call only fires for SSH rows — typically <10 per executor.
// If that count ever grows materially we should add a batch List by
// session-ID method to the repo and resolve in one query.
func (h *Handler) listSessions(ctx context.Context, executorID string) ([]SessionRow, error) {
rows, err := h.repo.ListExecutorsRunning(ctx)
if err != nil {
+51
View File
@@ -0,0 +1,51 @@
// SSH-specific HTTP shapes for the e2e ApiClient. Kept in a dedicated module
// (apart from helpers/api-client.ts) so adding SSH fields doesn't keep growing
// the omnibus client file. ApiClient methods that exercise these shapes live
// on the ApiClient class itself, alongside the rest of the surface.
export type SSHIdentitySourceBody = "agent" | "file";
export type SSHTestRequestBody = {
name: string;
host_alias?: string;
host?: string;
port?: number;
user?: string;
identity_source?: SSHIdentitySourceBody;
identity_file?: string;
proxy_jump?: string;
};
export type SSHTestStepBody = {
name: string;
duration_ms: number;
success: boolean;
output?: string;
error?: string;
};
export type SSHTestResultBody = {
success: boolean;
fingerprint?: string;
uname_all?: string;
arch?: string;
git_version?: string;
agentctl_action?: "cached" | "uploaded" | "skipped";
steps: SSHTestStepBody[];
total_duration_ms: number;
error?: string;
};
export type SSHSessionBody = {
session_id: string;
task_id: string;
task_title?: string;
host: string;
user?: string;
remote_task_dir?: string;
remote_agentctl_port?: number;
local_forward_port?: number;
status: string;
uptime_seconds: number;
created_at: string;
};
+10 -48
View File
@@ -7,6 +7,7 @@ import type {
TaskSessionState,
} from "../../lib/types/http";
import type { Agent, AgentProfile } from "../../lib/types/http-agents";
import type { SSHSessionBody, SSHTestRequestBody, SSHTestResultBody } from "./api-client-ssh";
// --- GitHub Mock Types ---
@@ -1519,54 +1520,15 @@ export class ApiClient {
}
}
// --- SSH HTTP shapes (kept here, alongside the rest of the api-client types) ---
export type SSHIdentitySourceBody = "agent" | "file";
export type SSHTestRequestBody = {
name: string;
host_alias?: string;
host?: string;
port?: number;
user?: string;
identity_source?: SSHIdentitySourceBody;
identity_file?: string;
proxy_jump?: string;
};
export type SSHTestStepBody = {
name: string;
duration_ms: number;
success: boolean;
output?: string;
error?: string;
};
export type SSHTestResultBody = {
success: boolean;
fingerprint?: string;
uname_all?: string;
arch?: string;
git_version?: string;
agentctl_action?: "cached" | "uploaded" | "skipped";
steps: SSHTestStepBody[];
total_duration_ms: number;
error?: string;
};
export type SSHSessionBody = {
session_id: string;
task_id: string;
task_title?: string;
host: string;
user?: string;
remote_task_dir?: string;
remote_agentctl_port?: number;
local_forward_port?: number;
status: string;
uptime_seconds: number;
created_at: string;
};
// SSH HTTP shapes live in api-client-ssh.ts; re-exported here so existing
// callers that imported them from api-client keep working.
export type {
SSHIdentitySourceBody,
SSHTestRequestBody,
SSHTestStepBody,
SSHTestResultBody,
SSHSessionBody,
} from "./api-client-ssh";
// --- Jira / Linear mock payload types ---