2026-05-13 04:43:48 +00:00
|
|
|
/**
|
|
|
|
|
* WS-RPC client for editor and project settings.
|
|
|
|
|
*/
|
|
|
|
|
import { rpcCall } from "./rpc";
|
2026-05-13 07:10:00 +00:00
|
|
|
import type {
|
|
|
|
|
EditorSettingsResult,
|
|
|
|
|
OkResult,
|
|
|
|
|
OpenFileParams,
|
|
|
|
|
ProjectSettingsPayload,
|
|
|
|
|
PutEditorParams,
|
|
|
|
|
} from "./rpcContract";
|
2026-05-13 04:43:48 +00:00
|
|
|
|
2026-03-22 19:07:07 +00:00
|
|
|
export interface EditorSettings {
|
|
|
|
|
editor_command: string | null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-17 13:33:19 +00:00
|
|
|
export interface ProjectSettings {
|
|
|
|
|
default_qa: string;
|
|
|
|
|
default_coder_model: string | null;
|
|
|
|
|
max_coders: number | null;
|
|
|
|
|
max_retries: number;
|
|
|
|
|
base_branch: string | null;
|
|
|
|
|
rate_limit_notifications: boolean;
|
|
|
|
|
timezone: string | null;
|
|
|
|
|
rendezvous: string | null;
|
|
|
|
|
watcher_sweep_interval_secs: number;
|
|
|
|
|
watcher_done_retention_secs: number;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-22 19:07:07 +00:00
|
|
|
export interface OpenFileResult {
|
|
|
|
|
success: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const settingsApi = {
|
2026-05-13 04:43:48 +00:00
|
|
|
getProjectSettings(_baseUrl?: string): Promise<ProjectSettings> {
|
|
|
|
|
return rpcCall<ProjectSettings>("settings.get_project");
|
2026-04-17 13:33:19 +00:00
|
|
|
},
|
|
|
|
|
|
2026-05-13 07:10:00 +00:00
|
|
|
async putProjectSettings(
|
2026-04-17 13:33:19 +00:00
|
|
|
settings: ProjectSettings,
|
2026-05-13 07:10:00 +00:00
|
|
|
_baseUrl?: string,
|
2026-04-17 13:33:19 +00:00
|
|
|
): Promise<ProjectSettings> {
|
2026-05-13 07:10:00 +00:00
|
|
|
const params: ProjectSettingsPayload = settings;
|
|
|
|
|
return rpcCall<ProjectSettingsPayload>("settings.put_project", params);
|
2026-04-17 13:33:19 +00:00
|
|
|
},
|
|
|
|
|
|
2026-05-13 04:43:48 +00:00
|
|
|
getEditorCommand(_baseUrl?: string): Promise<EditorSettings> {
|
|
|
|
|
return rpcCall<EditorSettings>("settings.get_editor");
|
2026-03-22 19:07:07 +00:00
|
|
|
},
|
|
|
|
|
|
2026-05-13 07:10:00 +00:00
|
|
|
async setEditorCommand(
|
2026-03-22 19:07:07 +00:00
|
|
|
command: string | null,
|
2026-05-13 07:10:00 +00:00
|
|
|
_baseUrl?: string,
|
2026-03-22 19:07:07 +00:00
|
|
|
): Promise<EditorSettings> {
|
2026-05-13 07:10:00 +00:00
|
|
|
const params: PutEditorParams = { editor_command: command };
|
|
|
|
|
const r = await rpcCall<EditorSettingsResult>("settings.put_editor", params);
|
|
|
|
|
return { editor_command: r.editor_command };
|
2026-03-22 19:07:07 +00:00
|
|
|
},
|
|
|
|
|
|
2026-05-13 07:10:00 +00:00
|
|
|
async openFile(
|
2026-03-22 19:07:07 +00:00
|
|
|
path: string,
|
|
|
|
|
line?: number,
|
2026-05-13 07:10:00 +00:00
|
|
|
_baseUrl?: string,
|
2026-03-22 19:07:07 +00:00
|
|
|
): Promise<OpenFileResult> {
|
2026-05-13 07:10:00 +00:00
|
|
|
const params: OpenFileParams = { path, line: line ?? null };
|
|
|
|
|
const r = await rpcCall<OkResult>("settings.open_file", params);
|
|
|
|
|
return { success: r.ok };
|
2026-03-22 19:07:07 +00:00
|
|
|
},
|
|
|
|
|
};
|