authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-06-19 20:10:33-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-06-20 03:10:33+00:00
log938b19a6bb2e361845cb5a497174d4062549c39c
tree6186ca27ae6ee3b061588661e26bca5c589915d8
parent3b56dc17a5550de0f3ffd376ed2785cc12fbb96b
signature Signed by PGP key B5690EEEBB952194

[codex] Normalize Desktop IPC Effect service (#3203)

Co-authored-by: codex <codex@users.noreply.github.com>

9 files changed, 76 insertions(+), 74 deletions(-)

apps/desktop/src/ipc/DesktopIpc.ts+16-14
...@@ -1,5 +1,6 @@...@@ -1,5 +1,6 @@
1import * as Context from "effect/Context";1import * as Context from "effect/Context";
2import * as Effect from "effect/Effect";2import * as Effect from "effect/Effect";
3import * as Layer from "effect/Layer";
3import * as Schema from "effect/Schema";4import * as Schema from "effect/Schema";
4import * as Scope from "effect/Scope";5import * as Scope from "effect/Scope";
56
...@@ -33,20 +34,19 @@ export interface DesktopSyncIpcMethod<E, R> {...@@ -33,20 +34,19 @@ export interface DesktopSyncIpcMethod<E, R> {
33 readonly handler: () => Effect.Effect<unknown, E, R>;34 readonly handler: () => Effect.Effect<unknown, E, R>;
34}35}
3536
36export interface DesktopIpcShape {37export class DesktopIpc extends Context.Service<
37 readonly handle: <E, R>(38 DesktopIpc,
38 input: DesktopIpcMethod<E, R>,39 {
39 ) => Effect.Effect<void, never, R | Scope.Scope>;40 readonly handle: <E, R>(
40 readonly handleSync: <E, R>(41 input: DesktopIpcMethod<E, R>,
41 input: DesktopSyncIpcMethod<E, R>,42 ) => Effect.Effect<void, never, R | Scope.Scope>;
42 ) => Effect.Effect<void, never, R | Scope.Scope>;43 readonly handleSync: <E, R>(
43}44 input: DesktopSyncIpcMethod<E, R>,
4445 ) => Effect.Effect<void, never, R | Scope.Scope>;
45export class DesktopIpc extends Context.Service<DesktopIpc, DesktopIpcShape>()(46 }
46 "@t3tools/desktop/ipc/DesktopIpc",47>()("@t3tools/desktop/ipc/DesktopIpc") {}
47) {}48
4849export const make = (ipcMain: DesktopIpcMain): DesktopIpc["Service"] =>
49export const make = (ipcMain: DesktopIpcMain): DesktopIpcShape =>
50 DesktopIpc.of({50 DesktopIpc.of({
51 handle: Effect.fn("desktop.ipc.registerInvoke")(function* <E, R>({51 handle: Effect.fn("desktop.ipc.registerInvoke")(function* <E, R>({
52 channel,52 channel,
...@@ -97,6 +97,8 @@ export const make = (ipcMain: DesktopIpcMain): DesktopIpcShape =>...@@ -97,6 +97,8 @@ export const make = (ipcMain: DesktopIpcMain): DesktopIpcShape =>
97 }),97 }),
98 });98 });
9999
100export const layer = (ipcMain: DesktopIpcMain) => Layer.succeed(DesktopIpc, make(ipcMain));
101
100/**102/**
101 * Convenience helpers for creating IPC methods103 * Convenience helpers for creating IPC methods
102 */104 */
apps/desktop/src/ipc/methods/clientSettings.ts+3-3
...@@ -5,9 +5,9 @@ import * as Schema from "effect/Schema";...@@ -5,9 +5,9 @@ import * as Schema from "effect/Schema";
55
6import * as DesktopClientSettings from "../../settings/DesktopClientSettings.ts";6import * as DesktopClientSettings from "../../settings/DesktopClientSettings.ts";
7import * as IpcChannels from "../channels.ts";7import * as IpcChannels from "../channels.ts";
8import { makeIpcMethod } from "../DesktopIpc.ts";8import * as DesktopIpc from "../DesktopIpc.ts";
99
10export const getClientSettings = makeIpcMethod({10export const getClientSettings = DesktopIpc.makeIpcMethod({
11 channel: IpcChannels.GET_CLIENT_SETTINGS_CHANNEL,11 channel: IpcChannels.GET_CLIENT_SETTINGS_CHANNEL,
12 payload: Schema.Void,12 payload: Schema.Void,
13 result: Schema.NullOr(ClientSettingsSchema),13 result: Schema.NullOr(ClientSettingsSchema),
...@@ -17,7 +17,7 @@ export const getClientSettings = makeIpcMethod({...@@ -17,7 +17,7 @@ export const getClientSettings = makeIpcMethod({
17 }),17 }),
18});18});
1919
20export const setClientSettings = makeIpcMethod({20export const setClientSettings = DesktopIpc.makeIpcMethod({
21 channel: IpcChannels.SET_CLIENT_SETTINGS_CHANNEL,21 channel: IpcChannels.SET_CLIENT_SETTINGS_CHANNEL,
22 payload: ClientSettingsSchema,22 payload: ClientSettingsSchema,
23 result: Schema.Void,23 result: Schema.Void,
apps/desktop/src/ipc/methods/connectionCatalog.ts+4-4
...@@ -4,9 +4,9 @@ import * as Schema from "effect/Schema";...@@ -4,9 +4,9 @@ import * as Schema from "effect/Schema";
44
5import * as DesktopConnectionCatalogStore from "../../app/DesktopConnectionCatalogStore.ts";5import * as DesktopConnectionCatalogStore from "../../app/DesktopConnectionCatalogStore.ts";
6import * as IpcChannels from "../channels.ts";6import * as IpcChannels from "../channels.ts";
7import { makeIpcMethod } from "../DesktopIpc.ts";7import * as DesktopIpc from "../DesktopIpc.ts";
88
9export const getConnectionCatalog = makeIpcMethod({9export const getConnectionCatalog = DesktopIpc.makeIpcMethod({
10 channel: IpcChannels.GET_CONNECTION_CATALOG_CHANNEL,10 channel: IpcChannels.GET_CONNECTION_CATALOG_CHANNEL,
11 payload: Schema.Void,11 payload: Schema.Void,
12 result: Schema.NullOr(Schema.String),12 result: Schema.NullOr(Schema.String),
...@@ -16,7 +16,7 @@ export const getConnectionCatalog = makeIpcMethod({...@@ -16,7 +16,7 @@ export const getConnectionCatalog = makeIpcMethod({
16 }),16 }),
17});17});
1818
19export const setConnectionCatalog = makeIpcMethod({19export const setConnectionCatalog = DesktopIpc.makeIpcMethod({
20 channel: IpcChannels.SET_CONNECTION_CATALOG_CHANNEL,20 channel: IpcChannels.SET_CONNECTION_CATALOG_CHANNEL,
21 payload: Schema.String,21 payload: Schema.String,
22 result: Schema.Boolean,22 result: Schema.Boolean,
...@@ -26,7 +26,7 @@ export const setConnectionCatalog = makeIpcMethod({...@@ -26,7 +26,7 @@ export const setConnectionCatalog = makeIpcMethod({
26 }),26 }),
27});27});
2828
29export const clearConnectionCatalog = makeIpcMethod({29export const clearConnectionCatalog = DesktopIpc.makeIpcMethod({
30 channel: IpcChannels.CLEAR_CONNECTION_CATALOG_CHANNEL,30 channel: IpcChannels.CLEAR_CONNECTION_CATALOG_CHANNEL,
31 payload: Schema.Void,31 payload: Schema.Void,
32 result: Schema.Void,32 result: Schema.Void,
apps/desktop/src/ipc/methods/preview.ts+23-23
...@@ -27,7 +27,7 @@ import { pathToFileURL } from "node:url";...@@ -27,7 +27,7 @@ import { pathToFileURL } from "node:url";
27import * as PreviewManager from "../../preview/Manager.ts";27import * as PreviewManager from "../../preview/Manager.ts";
28import { PREVIEW_WEBVIEW_PREFERENCES } from "../../preview/WebviewPreferences.ts";28import { PREVIEW_WEBVIEW_PREFERENCES } from "../../preview/WebviewPreferences.ts";
29import * as IpcChannels from "../channels.ts";29import * as IpcChannels from "../channels.ts";
30import { makeIpcMethod } from "../DesktopIpc.ts";30import * as DesktopIpc from "../DesktopIpc.ts";
3131
32const broadcast = (channel: string, ...args: ReadonlyArray<unknown>): void => {32const broadcast = (channel: string, ...args: ReadonlyArray<unknown>): void => {
33 for (const window of BrowserWindow.getAllWindows()) {33 for (const window of BrowserWindow.getAllWindows()) {
...@@ -52,7 +52,7 @@ export const installPreviewEventForwarding = Effect.fn(...@@ -52,7 +52,7 @@ export const installPreviewEventForwarding = Effect.fn(
52 });52 });
53});53});
5454
55export const createTab = makeIpcMethod({55export const createTab = DesktopIpc.makeIpcMethod({
56 channel: IpcChannels.PREVIEW_CREATE_TAB_CHANNEL,56 channel: IpcChannels.PREVIEW_CREATE_TAB_CHANNEL,
57 payload: DesktopPreviewTabInputSchema,57 payload: DesktopPreviewTabInputSchema,
58 result: Schema.Void,58 result: Schema.Void,
...@@ -62,7 +62,7 @@ export const createTab = makeIpcMethod({...@@ -62,7 +62,7 @@ export const createTab = makeIpcMethod({
62 }),62 }),
63});63});
6464
65export const closeTab = makeIpcMethod({65export const closeTab = DesktopIpc.makeIpcMethod({
66 channel: IpcChannels.PREVIEW_CLOSE_TAB_CHANNEL,66 channel: IpcChannels.PREVIEW_CLOSE_TAB_CHANNEL,
67 payload: DesktopPreviewTabInputSchema,67 payload: DesktopPreviewTabInputSchema,
68 result: Schema.Void,68 result: Schema.Void,
...@@ -72,7 +72,7 @@ export const closeTab = makeIpcMethod({...@@ -72,7 +72,7 @@ export const closeTab = makeIpcMethod({
72 }),72 }),
73});73});
7474
75export const registerWebview = makeIpcMethod({75export const registerWebview = DesktopIpc.makeIpcMethod({
76 channel: IpcChannels.PREVIEW_REGISTER_WEBVIEW_CHANNEL,76 channel: IpcChannels.PREVIEW_REGISTER_WEBVIEW_CHANNEL,
77 payload: DesktopPreviewRegisterWebviewInputSchema,77 payload: DesktopPreviewRegisterWebviewInputSchema,
78 result: Schema.Void,78 result: Schema.Void,
...@@ -82,7 +82,7 @@ export const registerWebview = makeIpcMethod({...@@ -82,7 +82,7 @@ export const registerWebview = makeIpcMethod({
82 }),82 }),
83});83});
8484
85export const navigate = makeIpcMethod({85export const navigate = DesktopIpc.makeIpcMethod({
86 channel: IpcChannels.PREVIEW_NAVIGATE_CHANNEL,86 channel: IpcChannels.PREVIEW_NAVIGATE_CHANNEL,
87 payload: DesktopPreviewNavigateInputSchema,87 payload: DesktopPreviewNavigateInputSchema,
88 result: Schema.Void,88 result: Schema.Void,
...@@ -100,7 +100,7 @@ const tabMethod = (...@@ -100,7 +100,7 @@ const tabMethod = (
100 tabId: string,100 tabId: string,
101 ) => Effect.Effect<void, PreviewManager.PreviewManagerError>,101 ) => Effect.Effect<void, PreviewManager.PreviewManagerError>,
102) =>102) =>
103 makeIpcMethod({103 DesktopIpc.makeIpcMethod({
104 channel,104 channel,
105 payload: DesktopPreviewTabInputSchema,105 payload: DesktopPreviewTabInputSchema,
106 result: Schema.Void,106 result: Schema.Void,
...@@ -166,7 +166,7 @@ export const stopRecording = tabMethod(...@@ -166,7 +166,7 @@ export const stopRecording = tabMethod(
166 (manager, tabId) => manager.stopRecording(tabId),166 (manager, tabId) => manager.stopRecording(tabId),
167);167);
168168
169export const clearCookies = makeIpcMethod({169export const clearCookies = DesktopIpc.makeIpcMethod({
170 channel: IpcChannels.PREVIEW_CLEAR_COOKIES_CHANNEL,170 channel: IpcChannels.PREVIEW_CLEAR_COOKIES_CHANNEL,
171 payload: Schema.Void,171 payload: Schema.Void,
172 result: Schema.Void,172 result: Schema.Void,
...@@ -176,7 +176,7 @@ export const clearCookies = makeIpcMethod({...@@ -176,7 +176,7 @@ export const clearCookies = makeIpcMethod({
176 }),176 }),
177});177});
178178
179export const clearCache = makeIpcMethod({179export const clearCache = DesktopIpc.makeIpcMethod({
180 channel: IpcChannels.PREVIEW_CLEAR_CACHE_CHANNEL,180 channel: IpcChannels.PREVIEW_CLEAR_CACHE_CHANNEL,
181 payload: Schema.Void,181 payload: Schema.Void,
182 result: Schema.Void,182 result: Schema.Void,
...@@ -186,7 +186,7 @@ export const clearCache = makeIpcMethod({...@@ -186,7 +186,7 @@ export const clearCache = makeIpcMethod({
186 }),186 }),
187});187});
188188
189export const getPreviewConfig = makeIpcMethod({189export const getPreviewConfig = DesktopIpc.makeIpcMethod({
190 channel: IpcChannels.PREVIEW_GET_CONFIG_CHANNEL,190 channel: IpcChannels.PREVIEW_GET_CONFIG_CHANNEL,
191 payload: DesktopPreviewConfigInputSchema,191 payload: DesktopPreviewConfigInputSchema,
192 result: DesktopPreviewWebviewConfigSchema,192 result: DesktopPreviewWebviewConfigSchema,
...@@ -201,7 +201,7 @@ export const getPreviewConfig = makeIpcMethod({...@@ -201,7 +201,7 @@ export const getPreviewConfig = makeIpcMethod({
201 }),201 }),
202});202});
203203
204export const setAnnotationTheme = makeIpcMethod({204export const setAnnotationTheme = DesktopIpc.makeIpcMethod({
205 channel: IpcChannels.PREVIEW_SET_ANNOTATION_THEME_CHANNEL,205 channel: IpcChannels.PREVIEW_SET_ANNOTATION_THEME_CHANNEL,
206 payload: DesktopPreviewAnnotationThemeInputSchema,206 payload: DesktopPreviewAnnotationThemeInputSchema,
207 result: Schema.Void,207 result: Schema.Void,
...@@ -211,7 +211,7 @@ export const setAnnotationTheme = makeIpcMethod({...@@ -211,7 +211,7 @@ export const setAnnotationTheme = makeIpcMethod({
211 }),211 }),
212});212});
213213
214export const pickElement = makeIpcMethod({214export const pickElement = DesktopIpc.makeIpcMethod({
215 channel: IpcChannels.PREVIEW_PICK_ELEMENT_CHANNEL,215 channel: IpcChannels.PREVIEW_PICK_ELEMENT_CHANNEL,
216 payload: DesktopPreviewTabInputSchema,216 payload: DesktopPreviewTabInputSchema,
217 result: Schema.NullOr(PreviewAnnotationPayloadSchema),217 result: Schema.NullOr(PreviewAnnotationPayloadSchema),
...@@ -221,7 +221,7 @@ export const pickElement = makeIpcMethod({...@@ -221,7 +221,7 @@ export const pickElement = makeIpcMethod({
221 }),221 }),
222});222});
223223
224export const captureScreenshot = makeIpcMethod({224export const captureScreenshot = DesktopIpc.makeIpcMethod({
225 channel: IpcChannels.PREVIEW_CAPTURE_SCREENSHOT_CHANNEL,225 channel: IpcChannels.PREVIEW_CAPTURE_SCREENSHOT_CHANNEL,
226 payload: DesktopPreviewTabInputSchema,226 payload: DesktopPreviewTabInputSchema,
227 result: DesktopPreviewScreenshotArtifactSchema,227 result: DesktopPreviewScreenshotArtifactSchema,
...@@ -231,7 +231,7 @@ export const captureScreenshot = makeIpcMethod({...@@ -231,7 +231,7 @@ export const captureScreenshot = makeIpcMethod({
231 }),231 }),
232});232});
233233
234export const revealArtifact = makeIpcMethod({234export const revealArtifact = DesktopIpc.makeIpcMethod({
235 channel: IpcChannels.PREVIEW_REVEAL_ARTIFACT_CHANNEL,235 channel: IpcChannels.PREVIEW_REVEAL_ARTIFACT_CHANNEL,
236 payload: DesktopPreviewArtifactInputSchema,236 payload: DesktopPreviewArtifactInputSchema,
237 result: Schema.Void,237 result: Schema.Void,
...@@ -241,7 +241,7 @@ export const revealArtifact = makeIpcMethod({...@@ -241,7 +241,7 @@ export const revealArtifact = makeIpcMethod({
241 }),241 }),
242});242});
243243
244export const copyArtifactToClipboard = makeIpcMethod({244export const copyArtifactToClipboard = DesktopIpc.makeIpcMethod({
245 channel: IpcChannels.PREVIEW_COPY_ARTIFACT_CHANNEL,245 channel: IpcChannels.PREVIEW_COPY_ARTIFACT_CHANNEL,
246 payload: DesktopPreviewArtifactInputSchema,246 payload: DesktopPreviewArtifactInputSchema,
247 result: Schema.Void,247 result: Schema.Void,
...@@ -251,7 +251,7 @@ export const copyArtifactToClipboard = makeIpcMethod({...@@ -251,7 +251,7 @@ export const copyArtifactToClipboard = makeIpcMethod({
251 }),251 }),
252});252});
253253
254export const automationStatus = makeIpcMethod({254export const automationStatus = DesktopIpc.makeIpcMethod({
255 channel: IpcChannels.PREVIEW_AUTOMATION_STATUS_CHANNEL,255 channel: IpcChannels.PREVIEW_AUTOMATION_STATUS_CHANNEL,
256 payload: DesktopPreviewTabInputSchema,256 payload: DesktopPreviewTabInputSchema,
257 result: PreviewAutomationStatus,257 result: PreviewAutomationStatus,
...@@ -261,7 +261,7 @@ export const automationStatus = makeIpcMethod({...@@ -261,7 +261,7 @@ export const automationStatus = makeIpcMethod({
261 }),261 }),
262});262});
263263
264export const automationSnapshot = makeIpcMethod({264export const automationSnapshot = DesktopIpc.makeIpcMethod({
265 channel: IpcChannels.PREVIEW_AUTOMATION_SNAPSHOT_CHANNEL,265 channel: IpcChannels.PREVIEW_AUTOMATION_SNAPSHOT_CHANNEL,
266 payload: DesktopPreviewTabInputSchema,266 payload: DesktopPreviewTabInputSchema,
267 result: PreviewAutomationSnapshot,267 result: PreviewAutomationSnapshot,
...@@ -271,7 +271,7 @@ export const automationSnapshot = makeIpcMethod({...@@ -271,7 +271,7 @@ export const automationSnapshot = makeIpcMethod({
271 }),271 }),
272});272});
273273
274export const automationClick = makeIpcMethod({274export const automationClick = DesktopIpc.makeIpcMethod({
275 channel: IpcChannels.PREVIEW_AUTOMATION_CLICK_CHANNEL,275 channel: IpcChannels.PREVIEW_AUTOMATION_CLICK_CHANNEL,
276 payload: DesktopPreviewAutomationClickInputSchema,276 payload: DesktopPreviewAutomationClickInputSchema,
277 result: Schema.Void,277 result: Schema.Void,
...@@ -281,7 +281,7 @@ export const automationClick = makeIpcMethod({...@@ -281,7 +281,7 @@ export const automationClick = makeIpcMethod({
281 }),281 }),
282});282});
283283
284export const automationType = makeIpcMethod({284export const automationType = DesktopIpc.makeIpcMethod({
285 channel: IpcChannels.PREVIEW_AUTOMATION_TYPE_CHANNEL,285 channel: IpcChannels.PREVIEW_AUTOMATION_TYPE_CHANNEL,
286 payload: DesktopPreviewAutomationTypeInputSchema,286 payload: DesktopPreviewAutomationTypeInputSchema,
287 result: Schema.Void,287 result: Schema.Void,
...@@ -291,7 +291,7 @@ export const automationType = makeIpcMethod({...@@ -291,7 +291,7 @@ export const automationType = makeIpcMethod({
291 }),291 }),
292});292});
293293
294export const automationPress = makeIpcMethod({294export const automationPress = DesktopIpc.makeIpcMethod({
295 channel: IpcChannels.PREVIEW_AUTOMATION_PRESS_CHANNEL,295 channel: IpcChannels.PREVIEW_AUTOMATION_PRESS_CHANNEL,
296 payload: DesktopPreviewAutomationPressInputSchema,296 payload: DesktopPreviewAutomationPressInputSchema,
297 result: Schema.Void,297 result: Schema.Void,
...@@ -301,7 +301,7 @@ export const automationPress = makeIpcMethod({...@@ -301,7 +301,7 @@ export const automationPress = makeIpcMethod({
301 }),301 }),
302});302});
303303
304export const automationScroll = makeIpcMethod({304export const automationScroll = DesktopIpc.makeIpcMethod({
305 channel: IpcChannels.PREVIEW_AUTOMATION_SCROLL_CHANNEL,305 channel: IpcChannels.PREVIEW_AUTOMATION_SCROLL_CHANNEL,
306 payload: DesktopPreviewAutomationScrollInputSchema,306 payload: DesktopPreviewAutomationScrollInputSchema,
307 result: Schema.Void,307 result: Schema.Void,
...@@ -311,7 +311,7 @@ export const automationScroll = makeIpcMethod({...@@ -311,7 +311,7 @@ export const automationScroll = makeIpcMethod({
311 }),311 }),
312});312});
313313
314export const automationEvaluate = makeIpcMethod({314export const automationEvaluate = DesktopIpc.makeIpcMethod({
315 channel: IpcChannels.PREVIEW_AUTOMATION_EVALUATE_CHANNEL,315 channel: IpcChannels.PREVIEW_AUTOMATION_EVALUATE_CHANNEL,
316 payload: DesktopPreviewAutomationEvaluateInputSchema,316 payload: DesktopPreviewAutomationEvaluateInputSchema,
317 result: Schema.Unknown,317 result: Schema.Unknown,
...@@ -321,7 +321,7 @@ export const automationEvaluate = makeIpcMethod({...@@ -321,7 +321,7 @@ export const automationEvaluate = makeIpcMethod({
321 }),321 }),
322});322});
323323
324export const automationWaitFor = makeIpcMethod({324export const automationWaitFor = DesktopIpc.makeIpcMethod({
325 channel: IpcChannels.PREVIEW_AUTOMATION_WAIT_FOR_CHANNEL,325 channel: IpcChannels.PREVIEW_AUTOMATION_WAIT_FOR_CHANNEL,
326 payload: DesktopPreviewAutomationWaitForInputSchema,326 payload: DesktopPreviewAutomationWaitForInputSchema,
327 result: Schema.Void,327 result: Schema.Void,
...@@ -331,7 +331,7 @@ export const automationWaitFor = makeIpcMethod({...@@ -331,7 +331,7 @@ export const automationWaitFor = makeIpcMethod({
331 }),331 }),
332});332});
333333
334export const saveRecording = makeIpcMethod({334export const saveRecording = DesktopIpc.makeIpcMethod({
335 channel: IpcChannels.PREVIEW_RECORDING_SAVE_CHANNEL,335 channel: IpcChannels.PREVIEW_RECORDING_SAVE_CHANNEL,
336 payload: DesktopPreviewRecordingSaveInputSchema,336 payload: DesktopPreviewRecordingSaveInputSchema,
337 result: DesktopPreviewRecordingArtifactSchema,337 result: DesktopPreviewRecordingArtifactSchema,
apps/desktop/src/ipc/methods/serverExposure.ts+5-5
...@@ -9,14 +9,14 @@ import * as Schema from "effect/Schema";...@@ -9,14 +9,14 @@ import * as Schema from "effect/Schema";
9import * as DesktopLifecycle from "../../app/DesktopLifecycle.ts";9import * as DesktopLifecycle from "../../app/DesktopLifecycle.ts";
10import * as DesktopServerExposure from "../../backend/DesktopServerExposure.ts";10import * as DesktopServerExposure from "../../backend/DesktopServerExposure.ts";
11import * as IpcChannels from "../channels.ts";11import * as IpcChannels from "../channels.ts";
12import { makeIpcMethod } from "../DesktopIpc.ts";12import * as DesktopIpc from "../DesktopIpc.ts";
1313
14const SetTailscaleServeEnabledInput = Schema.Struct({14const SetTailscaleServeEnabledInput = Schema.Struct({
15 enabled: Schema.Boolean,15 enabled: Schema.Boolean,
16 port: Schema.optionalKey(Schema.Number),16 port: Schema.optionalKey(Schema.Number),
17});17});
1818
19export const getServerExposureState = makeIpcMethod({19export const getServerExposureState = DesktopIpc.makeIpcMethod({
20 channel: IpcChannels.GET_SERVER_EXPOSURE_STATE_CHANNEL,20 channel: IpcChannels.GET_SERVER_EXPOSURE_STATE_CHANNEL,
21 payload: Schema.Void,21 payload: Schema.Void,
22 result: DesktopServerExposureStateSchema,22 result: DesktopServerExposureStateSchema,
...@@ -26,7 +26,7 @@ export const getServerExposureState = makeIpcMethod({...@@ -26,7 +26,7 @@ export const getServerExposureState = makeIpcMethod({
26 }),26 }),
27});27});
2828
29export const setServerExposureMode = makeIpcMethod({29export const setServerExposureMode = DesktopIpc.makeIpcMethod({
30 channel: IpcChannels.SET_SERVER_EXPOSURE_MODE_CHANNEL,30 channel: IpcChannels.SET_SERVER_EXPOSURE_MODE_CHANNEL,
31 payload: DesktopServerExposureModeSchema,31 payload: DesktopServerExposureModeSchema,
32 result: DesktopServerExposureStateSchema,32 result: DesktopServerExposureStateSchema,
...@@ -41,7 +41,7 @@ export const setServerExposureMode = makeIpcMethod({...@@ -41,7 +41,7 @@ export const setServerExposureMode = makeIpcMethod({
41 }),41 }),
42});42});
4343
44export const setTailscaleServeEnabled = makeIpcMethod({44export const setTailscaleServeEnabled = DesktopIpc.makeIpcMethod({
45 channel: IpcChannels.SET_TAILSCALE_SERVE_ENABLED_CHANNEL,45 channel: IpcChannels.SET_TAILSCALE_SERVE_ENABLED_CHANNEL,
46 payload: SetTailscaleServeEnabledInput,46 payload: SetTailscaleServeEnabledInput,
47 result: DesktopServerExposureStateSchema,47 result: DesktopServerExposureStateSchema,
...@@ -58,7 +58,7 @@ export const setTailscaleServeEnabled = makeIpcMethod({...@@ -58,7 +58,7 @@ export const setTailscaleServeEnabled = makeIpcMethod({
58 }),58 }),
59});59});
6060
61export const getAdvertisedEndpoints = makeIpcMethod({61export const getAdvertisedEndpoints = DesktopIpc.makeIpcMethod({
62 channel: IpcChannels.GET_ADVERTISED_ENDPOINTS_CHANNEL,62 channel: IpcChannels.GET_ADVERTISED_ENDPOINTS_CHANNEL,
63 payload: Schema.Void,63 payload: Schema.Void,
64 result: Schema.Array(AdvertisedEndpoint),64 result: Schema.Array(AdvertisedEndpoint),
apps/desktop/src/ipc/methods/sshEnvironment.ts+9-9
...@@ -33,7 +33,7 @@ import * as Effect from "effect/Effect";...@@ -33,7 +33,7 @@ import * as Effect from "effect/Effect";
33import * as Schema from "effect/Schema";33import * as Schema from "effect/Schema";
3434
35import * as IpcChannels from "../channels.ts";35import * as IpcChannels from "../channels.ts";
36import { makeIpcMethod } from "../DesktopIpc.ts";36import * as DesktopIpc from "../DesktopIpc.ts";
37import * as DesktopSshEnvironment from "../../ssh/DesktopSshEnvironment.ts";37import * as DesktopSshEnvironment from "../../ssh/DesktopSshEnvironment.ts";
38import * as DesktopSshPasswordPrompts from "../../ssh/DesktopSshPasswordPrompts.ts";38import * as DesktopSshPasswordPrompts from "../../ssh/DesktopSshPasswordPrompts.ts";
3939
...@@ -107,7 +107,7 @@ const withLoopbackSshApi =...@@ -107,7 +107,7 @@ const withLoopbackSshApi =
107 ),107 ),
108 );108 );
109109
110export const discoverSshHosts = makeIpcMethod({110export const discoverSshHosts = DesktopIpc.makeIpcMethod({
111 channel: IpcChannels.DISCOVER_SSH_HOSTS_CHANNEL,111 channel: IpcChannels.DISCOVER_SSH_HOSTS_CHANNEL,
112 payload: Schema.Void,112 payload: Schema.Void,
113 result: Schema.Array(DesktopDiscoveredSshHostSchema),113 result: Schema.Array(DesktopDiscoveredSshHostSchema),
...@@ -117,7 +117,7 @@ export const discoverSshHosts = makeIpcMethod({...@@ -117,7 +117,7 @@ export const discoverSshHosts = makeIpcMethod({
117 }),117 }),
118});118});
119119
120export const ensureSshEnvironment = makeIpcMethod({120export const ensureSshEnvironment = DesktopIpc.makeIpcMethod({
121 channel: IpcChannels.ENSURE_SSH_ENVIRONMENT_CHANNEL,121 channel: IpcChannels.ENSURE_SSH_ENVIRONMENT_CHANNEL,
122 payload: DesktopSshEnvironmentEnsureInputSchema,122 payload: DesktopSshEnvironmentEnsureInputSchema,
123 result: DesktopSshEnvironmentEnsureResultSchema,123 result: DesktopSshEnvironmentEnsureResultSchema,
...@@ -139,7 +139,7 @@ export const ensureSshEnvironment = makeIpcMethod({...@@ -139,7 +139,7 @@ export const ensureSshEnvironment = makeIpcMethod({
139 }),139 }),
140});140});
141141
142export const disconnectSshEnvironment = makeIpcMethod({142export const disconnectSshEnvironment = DesktopIpc.makeIpcMethod({
143 channel: IpcChannels.DISCONNECT_SSH_ENVIRONMENT_CHANNEL,143 channel: IpcChannels.DISCONNECT_SSH_ENVIRONMENT_CHANNEL,
144 payload: DesktopSshEnvironmentTargetSchema,144 payload: DesktopSshEnvironmentTargetSchema,
145 result: Schema.Void,145 result: Schema.Void,
...@@ -149,7 +149,7 @@ export const disconnectSshEnvironment = makeIpcMethod({...@@ -149,7 +149,7 @@ export const disconnectSshEnvironment = makeIpcMethod({
149 }),149 }),
150});150});
151151
152export const fetchSshEnvironmentDescriptor = makeIpcMethod({152export const fetchSshEnvironmentDescriptor = DesktopIpc.makeIpcMethod({
153 channel: IpcChannels.FETCH_SSH_ENVIRONMENT_DESCRIPTOR_CHANNEL,153 channel: IpcChannels.FETCH_SSH_ENVIRONMENT_DESCRIPTOR_CHANNEL,
154 payload: DesktopSshHttpBaseUrlInputSchema,154 payload: DesktopSshHttpBaseUrlInputSchema,
155 result: ExecutionEnvironmentDescriptor,155 result: ExecutionEnvironmentDescriptor,
...@@ -160,7 +160,7 @@ export const fetchSshEnvironmentDescriptor = makeIpcMethod({...@@ -160,7 +160,7 @@ export const fetchSshEnvironmentDescriptor = makeIpcMethod({
160 }),160 }),
161});161});
162162
163export const bootstrapSshBearerSession = makeIpcMethod({163export const bootstrapSshBearerSession = DesktopIpc.makeIpcMethod({
164 channel: IpcChannels.BOOTSTRAP_SSH_BEARER_SESSION_CHANNEL,164 channel: IpcChannels.BOOTSTRAP_SSH_BEARER_SESSION_CHANNEL,
165 payload: DesktopSshBearerBootstrapInputSchema,165 payload: DesktopSshBearerBootstrapInputSchema,
166 result: AuthAccessTokenResult,166 result: AuthAccessTokenResult,
...@@ -177,7 +177,7 @@ export const bootstrapSshBearerSession = makeIpcMethod({...@@ -177,7 +177,7 @@ export const bootstrapSshBearerSession = makeIpcMethod({
177 }),177 }),
178});178});
179179
180export const fetchSshSessionState = makeIpcMethod({180export const fetchSshSessionState = DesktopIpc.makeIpcMethod({
181 channel: IpcChannels.FETCH_SSH_SESSION_STATE_CHANNEL,181 channel: IpcChannels.FETCH_SSH_SESSION_STATE_CHANNEL,
182 payload: DesktopSshBearerRequestInputSchema,182 payload: DesktopSshBearerRequestInputSchema,
183 result: AuthSessionState,183 result: AuthSessionState,
...@@ -194,7 +194,7 @@ export const fetchSshSessionState = makeIpcMethod({...@@ -194,7 +194,7 @@ export const fetchSshSessionState = makeIpcMethod({
194 }),194 }),
195});195});
196196
197export const issueSshWebSocketTicket = makeIpcMethod({197export const issueSshWebSocketTicket = DesktopIpc.makeIpcMethod({
198 channel: IpcChannels.ISSUE_SSH_WEBSOCKET_TOKEN_CHANNEL,198 channel: IpcChannels.ISSUE_SSH_WEBSOCKET_TOKEN_CHANNEL,
199 payload: DesktopSshBearerRequestInputSchema,199 payload: DesktopSshBearerRequestInputSchema,
200 result: AuthWebSocketTicketResult,200 result: AuthWebSocketTicketResult,
...@@ -211,7 +211,7 @@ export const issueSshWebSocketTicket = makeIpcMethod({...@@ -211,7 +211,7 @@ export const issueSshWebSocketTicket = makeIpcMethod({
211 }),211 }),
212});212});
213213
214export const resolveSshPasswordPrompt = makeIpcMethod({214export const resolveSshPasswordPrompt = DesktopIpc.makeIpcMethod({
215 channel: IpcChannels.RESOLVE_SSH_PASSWORD_PROMPT_CHANNEL,215 channel: IpcChannels.RESOLVE_SSH_PASSWORD_PROMPT_CHANNEL,
216 payload: DesktopSshPasswordPromptResolutionInputSchema,216 payload: DesktopSshPasswordPromptResolutionInputSchema,
217 result: Schema.Void,217 result: Schema.Void,
apps/desktop/src/ipc/methods/updates.ts+6-6
...@@ -9,9 +9,9 @@ import * as Schema from "effect/Schema";...@@ -9,9 +9,9 @@ import * as Schema from "effect/Schema";
99
10import * as DesktopUpdates from "../../updates/DesktopUpdates.ts";10import * as DesktopUpdates from "../../updates/DesktopUpdates.ts";
11import * as IpcChannels from "../channels.ts";11import * as IpcChannels from "../channels.ts";
12import { makeIpcMethod } from "../DesktopIpc.ts";12import * as DesktopIpc from "../DesktopIpc.ts";
1313
14export const getUpdateState = makeIpcMethod({14export const getUpdateState = DesktopIpc.makeIpcMethod({
15 channel: IpcChannels.UPDATE_GET_STATE_CHANNEL,15 channel: IpcChannels.UPDATE_GET_STATE_CHANNEL,
16 payload: Schema.Void,16 payload: Schema.Void,
17 result: DesktopUpdateStateSchema,17 result: DesktopUpdateStateSchema,
...@@ -21,7 +21,7 @@ export const getUpdateState = makeIpcMethod({...@@ -21,7 +21,7 @@ export const getUpdateState = makeIpcMethod({
21 }),21 }),
22});22});
2323
24export const setUpdateChannel = makeIpcMethod({24export const setUpdateChannel = DesktopIpc.makeIpcMethod({
25 channel: IpcChannels.UPDATE_SET_CHANNEL_CHANNEL,25 channel: IpcChannels.UPDATE_SET_CHANNEL_CHANNEL,
26 payload: DesktopUpdateChannelSchema,26 payload: DesktopUpdateChannelSchema,
27 result: DesktopUpdateStateSchema,27 result: DesktopUpdateStateSchema,
...@@ -31,7 +31,7 @@ export const setUpdateChannel = makeIpcMethod({...@@ -31,7 +31,7 @@ export const setUpdateChannel = makeIpcMethod({
31 }),31 }),
32});32});
3333
34export const downloadUpdate = makeIpcMethod({34export const downloadUpdate = DesktopIpc.makeIpcMethod({
35 channel: IpcChannels.UPDATE_DOWNLOAD_CHANNEL,35 channel: IpcChannels.UPDATE_DOWNLOAD_CHANNEL,
36 payload: Schema.Void,36 payload: Schema.Void,
37 result: DesktopUpdateActionResultSchema,37 result: DesktopUpdateActionResultSchema,
...@@ -41,7 +41,7 @@ export const downloadUpdate = makeIpcMethod({...@@ -41,7 +41,7 @@ export const downloadUpdate = makeIpcMethod({
41 }),41 }),
42});42});
4343
44export const installUpdate = makeIpcMethod({44export const installUpdate = DesktopIpc.makeIpcMethod({
45 channel: IpcChannels.UPDATE_INSTALL_CHANNEL,45 channel: IpcChannels.UPDATE_INSTALL_CHANNEL,
46 payload: Schema.Void,46 payload: Schema.Void,
47 result: DesktopUpdateActionResultSchema,47 result: DesktopUpdateActionResultSchema,
...@@ -51,7 +51,7 @@ export const installUpdate = makeIpcMethod({...@@ -51,7 +51,7 @@ export const installUpdate = makeIpcMethod({
51 }),51 }),
52});52});
5353
54export const checkForUpdate = makeIpcMethod({54export const checkForUpdate = DesktopIpc.makeIpcMethod({
55 channel: IpcChannels.UPDATE_CHECK_CHANNEL,55 channel: IpcChannels.UPDATE_CHECK_CHANNEL,
56 payload: Schema.Void,56 payload: Schema.Void,
57 result: DesktopUpdateCheckResultSchema,57 result: DesktopUpdateCheckResultSchema,
apps/desktop/src/ipc/methods/window.ts+9-9
...@@ -18,7 +18,7 @@ import * as ElectronShell from "../../electron/ElectronShell.ts";...@@ -18,7 +18,7 @@ import * as ElectronShell from "../../electron/ElectronShell.ts";
18import * as ElectronTheme from "../../electron/ElectronTheme.ts";18import * as ElectronTheme from "../../electron/ElectronTheme.ts";
19import * as ElectronWindow from "../../electron/ElectronWindow.ts";19import * as ElectronWindow from "../../electron/ElectronWindow.ts";
20import * as IpcChannels from "../channels.ts";20import * as IpcChannels from "../channels.ts";
21import { makeIpcMethod, makeSyncIpcMethod } from "../DesktopIpc.ts";21import * as DesktopIpc from "../DesktopIpc.ts";
2222
23const ContextMenuPosition = Schema.Struct({23const ContextMenuPosition = Schema.Struct({
24 x: Schema.Number,24 x: Schema.Number,
...@@ -36,7 +36,7 @@ function toWebSocketBaseUrl(httpBaseUrl: URL): string {...@@ -36,7 +36,7 @@ function toWebSocketBaseUrl(httpBaseUrl: URL): string {
36 return url.href;36 return url.href;
37}37}
3838
39export const getAppBranding = makeSyncIpcMethod({39export const getAppBranding = DesktopIpc.makeSyncIpcMethod({
40 channel: IpcChannels.GET_APP_BRANDING_CHANNEL,40 channel: IpcChannels.GET_APP_BRANDING_CHANNEL,
41 result: Schema.NullOr(DesktopAppBrandingSchema),41 result: Schema.NullOr(DesktopAppBrandingSchema),
42 handler: Effect.fn("desktop.ipc.window.getAppBranding")(function* () {42 handler: Effect.fn("desktop.ipc.window.getAppBranding")(function* () {
...@@ -45,7 +45,7 @@ export const getAppBranding = makeSyncIpcMethod({...@@ -45,7 +45,7 @@ export const getAppBranding = makeSyncIpcMethod({
45 }),45 }),
46});46});
4747
48export const getLocalEnvironmentBootstrap = makeSyncIpcMethod({48export const getLocalEnvironmentBootstrap = DesktopIpc.makeSyncIpcMethod({
49 channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL,49 channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL,
50 result: Schema.NullOr(DesktopEnvironmentBootstrapSchema),50 result: Schema.NullOr(DesktopEnvironmentBootstrapSchema),
51 handler: Effect.fn("desktop.ipc.window.getLocalEnvironmentBootstrap")(function* () {51 handler: Effect.fn("desktop.ipc.window.getLocalEnvironmentBootstrap")(function* () {
...@@ -65,7 +65,7 @@ export const getLocalEnvironmentBootstrap = makeSyncIpcMethod({...@@ -65,7 +65,7 @@ export const getLocalEnvironmentBootstrap = makeSyncIpcMethod({
65 }),65 }),
66});66});
6767
68export const getLocalEnvironmentBearerToken = makeIpcMethod({68export const getLocalEnvironmentBearerToken = DesktopIpc.makeIpcMethod({
69 channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BEARER_TOKEN_CHANNEL,69 channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BEARER_TOKEN_CHANNEL,
70 payload: Schema.Void,70 payload: Schema.Void,
71 result: Schema.String,71 result: Schema.String,
...@@ -75,7 +75,7 @@ export const getLocalEnvironmentBearerToken = makeIpcMethod({...@@ -75,7 +75,7 @@ export const getLocalEnvironmentBearerToken = makeIpcMethod({
75 }),75 }),
76});76});
7777
78export const pickFolder = makeIpcMethod({78export const pickFolder = DesktopIpc.makeIpcMethod({
79 channel: IpcChannels.PICK_FOLDER_CHANNEL,79 channel: IpcChannels.PICK_FOLDER_CHANNEL,
80 payload: Schema.UndefinedOr(PickFolderOptionsSchema),80 payload: Schema.UndefinedOr(PickFolderOptionsSchema),
81 result: Schema.NullOr(Schema.String),81 result: Schema.NullOr(Schema.String),
...@@ -91,7 +91,7 @@ export const pickFolder = makeIpcMethod({...@@ -91,7 +91,7 @@ export const pickFolder = makeIpcMethod({
91 }),91 }),
92});92});
9393
94export const confirm = makeIpcMethod({94export const confirm = DesktopIpc.makeIpcMethod({
95 channel: IpcChannels.CONFIRM_CHANNEL,95 channel: IpcChannels.CONFIRM_CHANNEL,
96 payload: Schema.String,96 payload: Schema.String,
97 result: Schema.Boolean,97 result: Schema.Boolean,
...@@ -104,7 +104,7 @@ export const confirm = makeIpcMethod({...@@ -104,7 +104,7 @@ export const confirm = makeIpcMethod({
104 }),104 }),
105});105});
106106
107export const setTheme = makeIpcMethod({107export const setTheme = DesktopIpc.makeIpcMethod({
108 channel: IpcChannels.SET_THEME_CHANNEL,108 channel: IpcChannels.SET_THEME_CHANNEL,
109 payload: DesktopThemeSchema,109 payload: DesktopThemeSchema,
110 result: Schema.Void,110 result: Schema.Void,
...@@ -114,7 +114,7 @@ export const setTheme = makeIpcMethod({...@@ -114,7 +114,7 @@ export const setTheme = makeIpcMethod({
114 }),114 }),
115});115});
116116
117export const showContextMenu = makeIpcMethod({117export const showContextMenu = DesktopIpc.makeIpcMethod({
118 channel: IpcChannels.CONTEXT_MENU_CHANNEL,118 channel: IpcChannels.CONTEXT_MENU_CHANNEL,
119 payload: ContextMenuInput,119 payload: ContextMenuInput,
120 result: Schema.NullOr(Schema.String),120 result: Schema.NullOr(Schema.String),
...@@ -135,7 +135,7 @@ export const showContextMenu = makeIpcMethod({...@@ -135,7 +135,7 @@ export const showContextMenu = makeIpcMethod({
135 }),135 }),
136});136});
137137
138export const openExternal = makeIpcMethod({138export const openExternal = DesktopIpc.makeIpcMethod({
139 channel: IpcChannels.OPEN_EXTERNAL_CHANNEL,139 channel: IpcChannels.OPEN_EXTERNAL_CHANNEL,
140 payload: Schema.String,140 payload: Schema.String,
141 result: Schema.Boolean,141 result: Schema.Boolean,
apps/desktop/src/main.ts+1-1
...@@ -109,7 +109,7 @@ const electronLayer = Layer.mergeAll(...@@ -109,7 +109,7 @@ const electronLayer = Layer.mergeAll(
109 ElectronTheme.layer,109 ElectronTheme.layer,
110 ElectronUpdater.layer,110 ElectronUpdater.layer,
111 ElectronWindow.layer,111 ElectronWindow.layer,
112 Layer.succeed(DesktopIpc.DesktopIpc, DesktopIpc.make(Electron.ipcMain)),112 DesktopIpc.layer(Electron.ipcMain),
113);113);
114114
115const desktopFoundationLayer = Layer.mergeAll(115const desktopFoundationLayer = Layer.mergeAll(