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