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