Open History to see the last commit
1import {
2 ContextMenuItemSchema,
3 DesktopAppBrandingSchema,
4 DesktopEnvironmentBootstrapSchema,
5 DesktopMediaReadSchema,
6 DesktopThemeSchema,
7 EDITORS,
8 EditorId,
9 PickedThemeFileSchema,
10 PickFolderOptionsSchema,
11 PRIMARY_LOCAL_ENVIRONMENT_ID,
12 REMOTE_CAPABLE_EDITOR_IDS,
13 SystemSettingsPaneSchema,
14 type DesktopEnvironmentBootstrap,
15 type PickedThemeFile,
16} from "@t3tools/contracts";
17import { PROJECT_FAVICON_EXTENSIONS } from "@t3tools/shared/projectFavicon";
18import { resolveEditorCommand } from "@t3tools/shared/editor";
19import * as HostProcess from "@t3tools/shared/HostProcess";
20import { isRelayTracingEnabled } from "@t3tools/shared/otelEnvironment";
21import * as FileSystem from "effect/FileSystem";
22import * as Path from "effect/Path";
23import * as Effect from "effect/Effect";
24import * as Option from "effect/Option";
25import * as Schema from "effect/Schema";
26
27import * as DesktopBackendConfiguration from "../../backend/DesktopBackendConfiguration.ts";
28import * as DesktopBackendPool from "../../backend/DesktopBackendPool.ts";
29import * as DesktopLocalEnvironmentAuth from "../../backend/DesktopLocalEnvironmentAuth.ts";
30import * as DesktopEnvironment from "../../app/DesktopEnvironment.ts";
31import * as DesktopManagedPolicy from "../../app/DesktopManagedPolicy.ts";
32import * as DesktopPrimaryPaste from "../../app/DesktopPrimaryPaste.ts";
33import * as DesktopAppSettings from "../../settings/DesktopAppSettings.ts";
34import * as DesktopWslBackend from "../../wsl/DesktopWslBackend.ts";
35import * as DesktopWslEnvironment from "../../wsl/DesktopWslEnvironment.ts";
36import * as ElectronApp from "../../electron/ElectronApp.ts";
37import * as ElectronDialog from "../../electron/ElectronDialog.ts";
38import * as ElectronMenu from "../../electron/ElectronMenu.ts";
39import * as ElectronShell from "../../electron/ElectronShell.ts";
40import * as ElectronTheme from "../../electron/ElectronTheme.ts";
41import * as ElectronWindow from "../../electron/ElectronWindow.ts";
42import * as Electron from "electron";
43import * as MacPermissions from "../../permissions/MacPermissions.ts";
44import { safariPermissionCheck } from "../../preview/BrowserImport/SafariPermission.ts";
45import * as IpcChannels from "../channels.ts";
46import * as DesktopIpc from "../DesktopIpc.ts";
47import {
48 extractDistroFromUncPath,
49 resolveWslPickFolderDefaultPath,
50 wslUncPathToLinuxPath,
51} from "../../wsl/wslPathParsing.ts";
52
53const ContextMenuPosition = Schema.Struct({
54 x: Schema.Number,
55 y: Schema.Number,
56});
57
58const ContextMenuInput = Schema.Struct({
59 items: Schema.Array(ContextMenuItemSchema),
60 position: Schema.optionalKey(ContextMenuPosition),
61});
62
63function toWebSocketBaseUrl(httpBaseUrl: URL): string {
64 const url = new URL(httpBaseUrl.href);
65 url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
66 return url.href;
67}
68
69export const getAppBranding = DesktopIpc.makeSyncIpcMethod({
70 channel: IpcChannels.GET_APP_BRANDING_CHANNEL,
71 result: Schema.NullOr(DesktopAppBrandingSchema),
72 handler: Effect.fn("desktop.ipc.window.getAppBranding")(function* () {
73 const environment = yield* DesktopEnvironment.DesktopEnvironment;
74 return environment.branding;
75 }),
76});
77
78/**
79 * Relay traces leave the machine, so a policy with `telemetry: false`, or one that cannot be read,
80 * stops them. Read once here: a sync IPC handler cannot wait on the filesystem.
81 */
82export const installRelayTelemetryEnabled = Effect.fn("desktop.ipc.window.installRelayTelemetry")(
83 function* () {
84 const ipc = yield* DesktopIpc.DesktopIpc;
85 const enabled =
86 isRelayTracingEnabled(yield* HostProcess.Environment) &&
87 (yield* (yield* DesktopManagedPolicy.DesktopManagedPolicy).read.pipe(
88 Effect.map((found) => found?.document.limits?.telemetry !== false),
89 Effect.orElseSucceed(() => false),
90 ));
91 yield* ipc.handleSync(
92 DesktopIpc.makeSyncIpcMethod({
93 channel: IpcChannels.GET_RELAY_TELEMETRY_ENABLED_CHANNEL,
94 result: Schema.Boolean,
95 handler: () => Effect.succeed(enabled),
96 }),
97 );
98 },
99);
100
101export const getSystemLocale = DesktopIpc.makeSyncIpcMethod({
102 channel: IpcChannels.GET_SYSTEM_LOCALE_CHANNEL,
103 result: Schema.String,
104 handler: Effect.fn("desktop.ipc.window.getSystemLocale")(function* () {
105 const electronApp = yield* ElectronApp.ElectronApp;
106 return yield* electronApp.systemLocale;
107 }),
108});
109
110export const getPrimaryPasteEnabled = DesktopIpc.makeSyncIpcMethod({
111 channel: IpcChannels.GET_PRIMARY_PASTE_ENABLED_CHANNEL,
112 result: Schema.Boolean,
113 handler: Effect.fn("desktop.ipc.window.getPrimaryPasteEnabled")(function* () {
114 const primaryPaste = yield* DesktopPrimaryPaste.DesktopPrimaryPaste;
115 return primaryPaste.enabled;
116 }),
117});
118
119export const getPreferredSystemLanguages = DesktopIpc.makeSyncIpcMethod({
120 channel: IpcChannels.GET_PREFERRED_SYSTEM_LANGUAGES_CHANNEL,
121 result: Schema.Array(Schema.String),
122 handler: Effect.fn("desktop.ipc.window.getPreferredSystemLanguages")(function* () {
123 const electronApp = yield* ElectronApp.ElectronApp;
124 return yield* electronApp.preferredSystemLanguages;
125 }),
126});
127
128export const getWindowFullscreenState = DesktopIpc.makeSyncIpcMethod({
129 channel: IpcChannels.GET_WINDOW_FULLSCREEN_STATE_CHANNEL,
130 result: Schema.Boolean,
131 handler: Effect.fn("desktop.ipc.window.getWindowFullscreenState")(function* () {
132 const electronWindow = yield* ElectronWindow.ElectronWindow;
133 const window = yield* electronWindow.currentMainOrFirst;
134 return Option.isSome(window) && window.value.isFullScreen();
135 }),
136});
137
138export const getLocalEnvironmentBootstraps = DesktopIpc.makeSyncIpcMethod({
139 channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL,
140 result: Schema.Array(DesktopEnvironmentBootstrapSchema),
141 handler: Effect.fn("desktop.ipc.window.getLocalEnvironmentBootstraps")(function* () {
142 const pool = yield* DesktopBackendPool.DesktopBackendPool;
143 const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
144 const instances = yield* pool.list;
145 const bootstraps: DesktopEnvironmentBootstrap[] = [];
146 for (const instance of instances) {
147 const isPrimary = instance.id === PRIMARY_LOCAL_ENVIRONMENT_ID;
148 const config = yield* instance.currentConfig;
149 const snapshot = yield* instance.snapshot;
150 if (Option.isNone(config) || Option.isSome(config.value.preflightFailure)) {
151 const fatalPreflight =
152 Option.isSome(config) &&
153 Option.isSome(config.value.preflightFailure) &&
154 config.value.preflightFailure.value.fatal;
155 const stoppedPreflight =
156 Option.isSome(config) &&
157 Option.isSome(config.value.preflightFailure) &&
158 (!snapshot.desiredRunning || !snapshot.restartScheduled);
159 if (isPrimary || fatalPreflight || stoppedPreflight) continue;
160 bootstraps.push({
161 id: instance.id,
162 label: yield* instance.label,
163 runningDistro: null,
164 httpBaseUrl: null,
165 wsBaseUrl: null,
166 });
167 continue;
168 }
169 const { bootstrap, httpBaseUrl } = config.value;
170 const runningDistro = config.value.runningDistro ?? null;
171 bootstraps.push({
172 id: instance.id,
173 label: runningDistro === null ? yield* instance.label : `WSL (${runningDistro})`,
174 runningDistro,
175 httpBaseUrl: httpBaseUrl.href,
176 wsBaseUrl: toWebSocketBaseUrl(httpBaseUrl),
177 // Use the current window's derived token; the launch config's token may be stale.
178 ...(bootstrap.desktopBootstrapSecret
179 ? { bootstrapToken: yield* configuration.currentBootstrapToken }
180 : bootstrap.desktopBootstrapToken
181 ? { bootstrapToken: bootstrap.desktopBootstrapToken }
182 : {}),
183 });
184 }
185 return bootstraps;
186 }),
187});
188
189function extractWslDistroFromEnvironmentId(envId: string): string | null {
190 if (!envId.startsWith(DesktopWslBackend.WSL_INSTANCE_ID_PREFIX)) {
191 return null;
192 }
193 const suffix = envId.slice(DesktopWslBackend.WSL_INSTANCE_ID_PREFIX.length);
194 return suffix === "default" || suffix.length === 0 ? null : suffix;
195}
196
197export const getLocalEnvironmentBearerToken = DesktopIpc.makeIpcMethod({
198 channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BEARER_TOKEN_CHANNEL,
199 payload: Schema.Void,
200 result: Schema.String,
201 handler: Effect.fn("desktop.ipc.window.getLocalEnvironmentBearerToken")(function* () {
202 const localAuth = yield* DesktopLocalEnvironmentAuth.DesktopLocalEnvironmentAuth;
203 return yield* localAuth.getBearerToken;
204 }),
205});
206
207export const pickFolder = DesktopIpc.makeIpcMethod({
208 channel: IpcChannels.PICK_FOLDER_CHANNEL,
209 payload: Schema.UndefinedOr(PickFolderOptionsSchema),
210 result: Schema.NullOr(Schema.String),
211 handler: Effect.fn("desktop.ipc.window.pickFolder")(function* (options) {
212 const dialog = yield* ElectronDialog.ElectronDialog;
213 const electronWindow = yield* ElectronWindow.ElectronWindow;
214 const environment = yield* DesktopEnvironment.DesktopEnvironment;
215 const appSettings = yield* DesktopAppSettings.DesktopAppSettings;
216 const wslEnvironment = yield* DesktopWslEnvironment.DesktopWslEnvironment;
217 const settings = yield* appSettings.get;
218 // A picked path only means something to a backend on this machine.
219 if (!settings.localEnvironmentEnabled) {
220 return null;
221 }
222 const targetId = options?.targetEnvironmentId;
223 const wslDistroFromTarget =
224 targetId !== undefined && targetId.startsWith(DesktopWslBackend.WSL_INSTANCE_ID_PREFIX)
225 ? extractWslDistroFromEnvironmentId(targetId)
226 : null;
227 const useWsl =
228 targetId !== undefined &&
229 targetId !== PRIMARY_LOCAL_ENVIRONMENT_ID &&
230 targetId.startsWith(DesktopWslBackend.WSL_INSTANCE_ID_PREFIX);
231 // Match the orchestrator's persisted distro fallback for wsl:default.
232 const wslDistro = useWsl ? (wslDistroFromTarget ?? settings.wslDistro) : null;
233 const defaultPath = useWsl
234 ? Option.fromNullishOr(
235 resolveWslPickFolderDefaultPath(
236 options,
237 { distro: wslDistro },
238 yield* wslEnvironment.listDistros,
239 Option.getOrNull(yield* wslEnvironment.getUserHome(wslDistro)),
240 ),
241 )
242 : environment.resolvePickFolderDefaultPath(options);
243 const selectedPath = yield* dialog.pickFolder({
244 owner: yield* electronWindow.focusedMainOrFirst,
245 defaultPath,
246 });
247 if (Option.isNone(selectedPath)) {
248 return null;
249 }
250 if (!useWsl) {
251 return selectedPath.value;
252 }
253
254 const linuxUncPath = wslUncPathToLinuxPath(selectedPath.value);
255 if (linuxUncPath !== null) {
256 return linuxUncPath;
257 }
258
259 const converted = yield* wslEnvironment.windowsToWslPath(
260 extractDistroFromUncPath(selectedPath.value) ?? wslDistro,
261 selectedPath.value,
262 );
263 return Option.getOrElse(converted, () => selectedPath.value);
264 }),
265});
266
267export const pickProjectFavicon = DesktopIpc.makeIpcMethod({
268 channel: IpcChannels.PICK_PROJECT_FAVICON_CHANNEL,
269 payload: Schema.UndefinedOr(Schema.String),
270 result: Schema.NullOr(Schema.String),
271 handler: Effect.fn("desktop.ipc.window.pickProjectFavicon")(function* (initialPath) {
272 const dialog = yield* ElectronDialog.ElectronDialog;
273 const electronWindow = yield* ElectronWindow.ElectronWindow;
274 const appSettings = yield* DesktopAppSettings.DesktopAppSettings;
275 if (!(yield* appSettings.get).localEnvironmentEnabled) {
276 return null;
277 }
278 const paths = yield* dialog.pickFiles({
279 owner: yield* electronWindow.focusedMainOrFirst,
280 defaultPath: Option.fromNullishOr(initialPath),
281 multiple: false,
282 filters: [
283 {
284 name: "Images",
285 extensions: PROJECT_FAVICON_EXTENSIONS.map((extension) => extension.slice(1)),
286 },
287 ],
288 });
289 return paths[0] ?? null;
290 }),
291});
292
293export const setTheme = DesktopIpc.makeIpcMethod({
294 channel: IpcChannels.SET_THEME_CHANNEL,
295 payload: DesktopThemeSchema,
296 result: Schema.Void,
297 handler: Effect.fn("desktop.ipc.window.setTheme")(function* (theme) {
298 const electronTheme = yield* ElectronTheme.ElectronTheme;
299 yield* electronTheme.setSource(theme);
300 }),
301});
302
303export const showContextMenu = DesktopIpc.makeIpcMethod({
304 channel: IpcChannels.CONTEXT_MENU_CHANNEL,
305 payload: ContextMenuInput,
306 result: Schema.NullOr(Schema.String),
307 handler: Effect.fn("desktop.ipc.window.showContextMenu")(function* (input) {
308 const electronMenu = yield* ElectronMenu.ElectronMenu;
309 const electronWindow = yield* ElectronWindow.ElectronWindow;
310 const window = yield* electronWindow.focusedMainOrFirst;
311 if (Option.isNone(window)) {
312 return null;
313 }
314
315 const selectedItemId = yield* electronMenu.showContextMenu({
316 window: window.value,
317 items: input.items,
318 position: Option.fromNullishOr(input.position),
319 });
320 return Option.getOrNull(selectedItemId);
321 }),
322});
323
324export const openExternal = DesktopIpc.makeIpcMethod({
325 channel: IpcChannels.OPEN_EXTERNAL_CHANNEL,
326 payload: Schema.String,
327 result: Schema.Boolean,
328 handler: Effect.fn("desktop.ipc.window.openExternal")(function* (url) {
329 const shell = yield* ElectronShell.ElectronShell;
330 return yield* shell.openExternal(url);
331 }),
332});
333
334const READ_MEDIA_MAX_BYTES = 256 * 1024 * 1024;
335
336// No URL field: media URLs can carry signed query tokens.
337class MediaReadError extends Schema.TaggedError<MediaReadError>()("MediaReadError", {
338 message: Schema.String,
339 cause: Schema.Defect(),
340}) {}
341
342// The renderer can display media it cannot fetch(); reading here keeps Save and Copy working for it.
343export const readMedia = DesktopIpc.makeIpcMethod({
344 channel: IpcChannels.READ_MEDIA_CHANNEL,
345 payload: Schema.String,
346 result: Schema.NullOr(DesktopMediaReadSchema),
347 handler: Effect.fn("desktop.ipc.window.readMedia")(function* (url, event) {
348 const window = yield* (yield* ElectronWindow.ElectronWindow).main;
349 if (
350 event === undefined ||
351 Option.isNone(window) ||
352 window.value.webContents.id !== event.sender.id ||
353 !/^https?:$/.test(URL.parse(url)?.protocol ?? "")
354 ) {
355 return null;
356 }
357 const session = window.value.webContents.session;
358 return yield* Effect.tryPromise({
359 try: async () => {
360 // Like an <img>, send the session's cookies.
361 const response = await session.fetch(url, { credentials: "include" });
362 const mimeType = response.headers.get("content-type") ?? "";
363 if (!response.ok || !response.body) {
364 await response.body?.cancel();
365 return { status: response.status, mimeType, data: new Uint8Array() };
366 }
367 // The whole body crosses IPC, so stop before a huge file can exhaust main-process memory.
368 const chunks: Uint8Array[] = [];
369 let size = 0;
370 for await (const chunk of response.body) {
371 size += chunk.byteLength;
372 if (size > READ_MEDIA_MAX_BYTES) {
373 return { status: 413, mimeType, data: new Uint8Array() };
374 }
375 chunks.push(chunk);
376 }
377 return { status: response.status, mimeType, data: Buffer.concat(chunks) };
378 },
379 catch: (cause) => new MediaReadError({ message: "Could not read media.", cause }),
380 }).pipe(Effect.orElseSucceed(() => null));
381 }),
382});
383
384export const openSystemSettings = DesktopIpc.makeIpcMethod({
385 channel: IpcChannels.OPEN_SYSTEM_SETTINGS_CHANNEL,
386 payload: SystemSettingsPaneSchema,
387 result: Schema.Boolean,
388 handler: Effect.fn("desktop.ipc.window.openSystemSettings")(function* (pane) {
389 const shell = yield* ElectronShell.ElectronShell;
390 const environment = yield* DesktopEnvironment.DesktopEnvironment;
391 if (environment.platform !== "darwin") return false;
392 const owner = Electron.BrowserWindow.getFocusedWindow();
393 const opened = yield* shell.openSystemSettings(pane);
394 if (opened && environment.isPackaged) {
395 const permissions = yield* MacPermissions.MacPermissions;
396 const isGranted = yield* safariPermissionCheck;
397 yield* permissions.showHelper(pane, owner, isGranted);
398 }
399 return opened;
400 }),
401});
402
403export const probeRemoteEditors = DesktopIpc.makeIpcMethod({
404 channel: IpcChannels.PROBE_REMOTE_EDITORS_CHANNEL,
405 payload: Schema.Undefined,
406 result: Schema.Array(EditorId),
407 handler: Effect.fn("desktop.ipc.window.probeRemoteEditors")(function* () {
408 const available: Array<EditorId> = [];
409 const env = yield* HostProcess.Environment;
410 for (const editorId of REMOTE_CAPABLE_EDITOR_IDS) {
411 const editor = EDITORS.find((editor) => editor.id === editorId);
412 if (editor && Option.isSome(yield* resolveEditorCommand(editor, env))) {
413 available.push(editorId);
414 }
415 }
416 return available;
417 }),
418});
419
420export const pasteAsText = DesktopIpc.makeIpcMethod({
421 channel: IpcChannels.PASTE_AS_TEXT_CHANNEL,
422 payload: Schema.Undefined,
423 result: Schema.Void,
424 handler: Effect.fn("desktop.ipc.window.pasteAsText")(function* (_input, event) {
425 const electronWindow = yield* ElectronWindow.ElectronWindow;
426 const window = yield* electronWindow.main;
427 if (
428 event === undefined ||
429 Option.isNone(window) ||
430 window.value.isDestroyed() ||
431 window.value.webContents.id !== event.sender.id
432 ) {
433 return;
434 }
435 const focused = Electron.webContents.getFocusedWebContents();
436 if (
437 focused &&
438 !focused.isDestroyed() &&
439 Electron.BrowserWindow.fromWebContents(focused) === window.value
440 ) {
441 focused.paste();
442 }
443 }),
444});
445
446export const revealWindow = DesktopIpc.makeIpcMethod({
447 channel: IpcChannels.REVEAL_WINDOW_CHANNEL,
448 payload: Schema.Undefined,
449 result: Schema.Void,
450 handler: Effect.fn("desktop.ipc.window.revealWindow")(function* (_input, event) {
451 const electronWindow = yield* ElectronWindow.ElectronWindow;
452 const window = yield* electronWindow.main;
453 if (
454 event === undefined ||
455 Option.isNone(window) ||
456 window.value.webContents.id !== event.sender.id
457 ) {
458 return;
459 }
460 yield* electronWindow.reveal(window.value);
461 }),
462});
463
464const htmlFullscreenStates = new WeakMap<
465 Electron.BrowserWindow,
466 { owned: boolean; leaving: boolean }
467>();
468
469const htmlFullscreenState = (window: Electron.BrowserWindow) => {
470 const existing = htmlFullscreenStates.get(window);
471 if (existing !== undefined) return existing;
472 const state = { owned: false, leaving: false };
473 window.on("leave-full-screen", () => {
474 // Leaving OS fullscreen any other way, such as F11, hands the window back to the user.
475 if (!state.leaving) state.owned = false;
476 state.leaving = false;
477 });
478 htmlFullscreenStates.set(window, state);
479 return state;
480};
481
482// The main window keeps HTML fullscreen inside itself so preview guests stay in their webview,
483// so the app's own fullscreen elements, such as chat videos, take the screen here.
484export const syncHtmlFullscreen = DesktopIpc.makeIpcMethod({
485 channel: IpcChannels.SYNC_HTML_FULLSCREEN_CHANNEL,
486 payload: Schema.Boolean,
487 result: Schema.Void,
488 handler: Effect.fn("desktop.ipc.window.syncHtmlFullscreen")(function* (fullscreen, event) {
489 const electronWindow = yield* ElectronWindow.ElectronWindow;
490 const main = yield* electronWindow.main;
491 if (
492 event === undefined ||
493 Option.isNone(main) ||
494 main.value.isDestroyed() ||
495 main.value.webContents.id !== event.sender.id
496 ) {
497 return;
498 }
499 const window = main.value;
500 const state = htmlFullscreenState(window);
501 if (fullscreen) {
502 // macOS reports fullscreen until its exit animation ends, and Electron queues the re-entry.
503 if (state.owned || (window.isFullScreen() && !state.leaving)) return;
504 state.owned = true;
505 window.setFullScreen(true);
506 } else if (state.owned) {
507 state.owned = false;
508 state.leaving = window.isFullScreen();
509 window.setFullScreen(false);
510 }
511 }),
512});
513
514const PICKED_THEME_FILE_MAX_BYTES = 256 * 1024;
515
516export const pickThemeFiles = DesktopIpc.makeIpcMethod({
517 channel: IpcChannels.PICK_THEME_FILES_CHANNEL,
518 payload: Schema.Undefined,
519 result: Schema.NullOr(Schema.Array(PickedThemeFileSchema)),
520 handler: Effect.fn("desktop.ipc.window.pickThemeFiles")(function* () {
521 const dialog = yield* ElectronDialog.ElectronDialog;
522 const electronWindow = yield* ElectronWindow.ElectronWindow;
523 const fileSystem = yield* FileSystem.FileSystem;
524 const path = yield* Path.Path;
525 const extensionsDir = path.join(yield* HostProcess.HomeDirectory, ".vscode", "extensions");
526 const defaultPath = yield* fileSystem
527 .exists(extensionsDir)
528 .pipe(Effect.orElseSucceed(() => false));
529 const paths = yield* dialog.pickFiles({
530 owner: yield* electronWindow.focusedMainOrFirst,
531 defaultPath: defaultPath ? Option.some(extensionsDir) : Option.none(),
532 filters: [{ name: "JSON", extensions: ["json"] }],
533 multiple: true,
534 });
535 if (paths.length === 0) {
536 return null;
537 }
538 return yield* Effect.forEach(paths, (filePath) => {
539 const name = path.basename(filePath);
540 return Effect.gen(function* () {
541 const info = yield* fileSystem.stat(filePath);
542 const size = Number(info.size);
543 if (size > PICKED_THEME_FILE_MAX_BYTES) {
544 return { name, size, text: "" } satisfies PickedThemeFile;
545 }
546 const text = yield* fileSystem.readFileString(filePath);
547 return { name, size, text } satisfies PickedThemeFile;
548 }).pipe(Effect.orElseSucceed((): PickedThemeFile => ({ name, size: 0, text: "" })));
549 });
550 }),
551});
552
553export const checkSystemPermission = DesktopIpc.makeIpcMethod({
554 channel: IpcChannels.CHECK_SYSTEM_PERMISSION_CHANNEL,
555 payload: SystemSettingsPaneSchema,
556 result: Schema.Boolean,
557 handler: Effect.fn("desktop.ipc.window.checkSystemPermission")(function* () {
558 const environment = yield* DesktopEnvironment.DesktopEnvironment;
559 if (environment.platform !== "darwin") return false;
560 const check = yield* safariPermissionCheck;
561 return yield* Effect.promise(check);
562 }),
563});