Open History to see the last commit
1import type {
2 GitCheckoutInput,
3 GitCreateBranchInput,
4 GitPreparePullRequestThreadInput,
5 GitPreparePullRequestThreadResult,
6 GitPullRequestRefInput,
7 GitCreateWorktreeInput,
8 GitCreateWorktreeResult,
9 GitInitInput,
10 GitListBranchesInput,
11 GitListBranchesResult,
12 GitPullInput,
13 GitPullResult,
14 GitRemoveWorktreeInput,
15 GitResolvePullRequestResult,
16 GitStatusInput,
17 GitStatusResult,
18} from "./git";
19import type {
20 ProjectSearchEntriesInput,
21 ProjectSearchEntriesResult,
22 ProjectWriteFileInput,
23 ProjectWriteFileResult,
24} from "./project";
25import type {
26 ServerConfig,
27 ServerProviderUpdatedPayload,
28 ServerUpsertKeybindingResult,
29} from "./server";
30import type {
31 TerminalClearInput,
32 TerminalCloseInput,
33 TerminalEvent,
34 TerminalOpenInput,
35 TerminalResizeInput,
36 TerminalRestartInput,
37 TerminalSessionSnapshot,
38 TerminalWriteInput,
39} from "./terminal";
40import type { ServerUpsertKeybindingInput } from "./server";
41import type {
42 ClientOrchestrationCommand,
43 OrchestrationGetFullThreadDiffInput,
44 OrchestrationGetFullThreadDiffResult,
45 OrchestrationGetTurnDiffInput,
46 OrchestrationGetTurnDiffResult,
47 OrchestrationEvent,
48 OrchestrationReadModel,
49} from "./orchestration";
50import { EditorId } from "./editor";
51import { ServerSettings, ServerSettingsPatch } from "./settings";
52
53export interface ContextMenuItem<T extends string = string> {
54 id: T;
55 label: string;
56 destructive?: boolean;
57 disabled?: boolean;
58}
59
60export type DesktopUpdateStatus =
61 | "disabled"
62 | "idle"
63 | "checking"
64 | "up-to-date"
65 | "available"
66 | "downloading"
67 | "downloaded"
68 | "error";
69
70export type DesktopRuntimeArch = "arm64" | "x64" | "other";
71export type DesktopTheme = "light" | "dark" | "system";
72
73export interface DesktopRuntimeInfo {
74 hostArch: DesktopRuntimeArch;
75 appArch: DesktopRuntimeArch;
76 runningUnderArm64Translation: boolean;
77}
78
79export interface DesktopUpdateState {
80 enabled: boolean;
81 status: DesktopUpdateStatus;
82 currentVersion: string;
83 hostArch: DesktopRuntimeArch;
84 appArch: DesktopRuntimeArch;
85 runningUnderArm64Translation: boolean;
86 availableVersion: string | null;
87 downloadedVersion: string | null;
88 downloadPercent: number | null;
89 checkedAt: string | null;
90 message: string | null;
91 errorContext: "check" | "download" | "install" | null;
92 canRetry: boolean;
93}
94
95export interface DesktopUpdateActionResult {
96 accepted: boolean;
97 completed: boolean;
98 state: DesktopUpdateState;
99}
100
101export interface DesktopUpdateCheckResult {
102 checked: boolean;
103 state: DesktopUpdateState;
104}
105
106export interface DesktopBridge {
107 getWsUrl: () => string | null;
108 pickFolder: () => Promise<string | null>;
109 confirm: (message: string) => Promise<boolean>;
110 setTheme: (theme: DesktopTheme) => Promise<void>;
111 showContextMenu: <T extends string>(
112 items: readonly ContextMenuItem<T>[],
113 position?: { x: number; y: number },
114 ) => Promise<T | null>;
115 openExternal: (url: string) => Promise<boolean>;
116 onMenuAction: (listener: (action: string) => void) => () => void;
117 getUpdateState: () => Promise<DesktopUpdateState>;
118 checkForUpdate: () => Promise<DesktopUpdateCheckResult>;
119 downloadUpdate: () => Promise<DesktopUpdateActionResult>;
120 installUpdate: () => Promise<DesktopUpdateActionResult>;
121 onUpdateState: (listener: (state: DesktopUpdateState) => void) => () => void;
122}
123
124export interface NativeApi {
125 dialogs: {
126 pickFolder: () => Promise<string | null>;
127 confirm: (message: string) => Promise<boolean>;
128 };
129 terminal: {
130 open: (input: typeof TerminalOpenInput.Encoded) => Promise<TerminalSessionSnapshot>;
131 write: (input: typeof TerminalWriteInput.Encoded) => Promise<void>;
132 resize: (input: typeof TerminalResizeInput.Encoded) => Promise<void>;
133 clear: (input: typeof TerminalClearInput.Encoded) => Promise<void>;
134 restart: (input: typeof TerminalRestartInput.Encoded) => Promise<TerminalSessionSnapshot>;
135 close: (input: typeof TerminalCloseInput.Encoded) => Promise<void>;
136 onEvent: (callback: (event: TerminalEvent) => void) => () => void;
137 };
138 projects: {
139 searchEntries: (input: ProjectSearchEntriesInput) => Promise<ProjectSearchEntriesResult>;
140 writeFile: (input: ProjectWriteFileInput) => Promise<ProjectWriteFileResult>;
141 };
142 shell: {
143 openInEditor: (cwd: string, editor: EditorId) => Promise<void>;
144 openExternal: (url: string) => Promise<void>;
145 };
146 git: {
147 // Existing branch/worktree API
148 listBranches: (input: GitListBranchesInput) => Promise<GitListBranchesResult>;
149 createWorktree: (input: GitCreateWorktreeInput) => Promise<GitCreateWorktreeResult>;
150 removeWorktree: (input: GitRemoveWorktreeInput) => Promise<void>;
151 createBranch: (input: GitCreateBranchInput) => Promise<void>;
152 checkout: (input: GitCheckoutInput) => Promise<void>;
153 init: (input: GitInitInput) => Promise<void>;
154 resolvePullRequest: (input: GitPullRequestRefInput) => Promise<GitResolvePullRequestResult>;
155 preparePullRequestThread: (
156 input: GitPreparePullRequestThreadInput,
157 ) => Promise<GitPreparePullRequestThreadResult>;
158 // Stacked action API
159 pull: (input: GitPullInput) => Promise<GitPullResult>;
160 status: (input: GitStatusInput) => Promise<GitStatusResult>;
161 };
162 contextMenu: {
163 show: <T extends string>(
164 items: readonly ContextMenuItem<T>[],
165 position?: { x: number; y: number },
166 ) => Promise<T | null>;
167 };
168 server: {
169 getConfig: () => Promise<ServerConfig>;
170 refreshProviders: () => Promise<ServerProviderUpdatedPayload>;
171 upsertKeybinding: (input: ServerUpsertKeybindingInput) => Promise<ServerUpsertKeybindingResult>;
172 getSettings: () => Promise<ServerSettings>;
173 updateSettings: (patch: ServerSettingsPatch) => Promise<ServerSettings>;
174 };
175 orchestration: {
176 getSnapshot: () => Promise<OrchestrationReadModel>;
177 dispatchCommand: (command: ClientOrchestrationCommand) => Promise<{ sequence: number }>;
178 getTurnDiff: (input: OrchestrationGetTurnDiffInput) => Promise<OrchestrationGetTurnDiffResult>;
179 getFullThreadDiff: (
180 input: OrchestrationGetFullThreadDiffInput,
181 ) => Promise<OrchestrationGetFullThreadDiffResult>;
182 replayEvents: (fromSequenceExclusive: number) => Promise<OrchestrationEvent[]>;
183 onDomainEvent: (callback: (event: OrchestrationEvent) => void) => () => void;
184 };
185}