MCPcopy
hub / github.com/anomalyco/opencode / registerIpcHandlers

Function registerIpcHandlers

packages/desktop/src/main/ipc.ts:42–244  ·  view source on GitHub ↗
(deps: Deps)

Source from the content-addressed store, hash-verified

40}
41
42export function registerIpcHandlers(deps: Deps) {
43 const updaterSubscriptions = createUpdaterSubscriptions()
44 app.once("will-quit", updaterSubscriptions.clear)
45
46 ipcMain.handle("kill-sidecar", () => deps.killSidecar())
47 ipcMain.handle("await-initialization", () => deps.awaitInitialization())
48 ipcMain.handle("consume-initial-deep-links", () => deps.consumeInitialDeepLinks())
49 ipcMain.handle("get-default-server-url", () => deps.getDefaultServerUrl())
50 ipcMain.handle("set-default-server-url", (_event: IpcMainInvokeEvent, url: string | null) =>
51 deps.setDefaultServerUrl(url),
52 )
53 ipcMain.handle("get-display-backend", () => deps.getDisplayBackend())
54 ipcMain.handle("set-display-backend", (_event: IpcMainInvokeEvent, backend: string | null) =>
55 deps.setDisplayBackend(backend),
56 )
57 ipcMain.handle("parse-markdown", (_event: IpcMainInvokeEvent, markdown: string) => deps.parseMarkdown(markdown))
58 ipcMain.handle("check-app-exists", (_event: IpcMainInvokeEvent, appName: string) => deps.checkAppExists(appName))
59 ipcMain.handle("resolve-app-path", (_event: IpcMainInvokeEvent, appName: string) => deps.resolveAppPath(appName))
60 ipcMain.handle("updater-subscribe", (event) => {
61 const id = event.sender.id
62 updaterSubscriptions.set(
63 id,
64 deps.updater.subscribe((state) => {
65 if (event.sender.isDestroyed()) return updaterSubscriptions.delete(id)
66 event.sender.send("updater-state", state)
67 }),
68 )
69 event.sender.once("destroyed", () => updaterSubscriptions.delete(id))
70 })
71 ipcMain.handle("updater-unsubscribe", (event) => updaterSubscriptions.delete(event.sender.id))
72 ipcMain.handle("updater-check", () => deps.updater.check())
73 ipcMain.handle("updater-install", () => deps.updater.install())
74 ipcMain.handle("set-background-color", (_event: IpcMainInvokeEvent, color: string) => deps.setBackgroundColor(color))
75 ipcMain.handle("export-debug-logs", () => deps.exportDebugLogs())
76 ipcMain.handle("record-fatal-renderer-error", (_event: IpcMainInvokeEvent, error: FatalRendererError) =>
77 deps.recordFatalRendererError(error),
78 )
79 ipcMain.handle("store-get", (_event: IpcMainInvokeEvent, name: string, key: string) => {
80 try {
81 const store = getStore(name)
82 const value = store.get(key)
83 if (value === undefined || value === null) return null
84 return typeof value === "string" ? value : JSON.stringify(value)
85 } catch {
86 return null
87 }
88 })
89 ipcMain.handle("store-set", (_event: IpcMainInvokeEvent, name: string, key: string, value: string) => {
90 getStore(name).set(key, value)
91 })
92 ipcMain.handle("store-delete", (_event: IpcMainInvokeEvent, name: string, key: string) => {
93 getStore(name).delete(key)
94 void removeStoreFileIfEmpty(name)
95 })
96 ipcMain.handle("store-clear", (_event: IpcMainInvokeEvent, name: string) => {
97 getStore(name).clear()
98 void removeStoreFileIfEmpty(name)
99 })

Callers 1

index.tsFile · 0.90

Calls 15

getStoreFunction · 0.90
removeStoreFileIfEmptyFunction · 0.90
assertAttachmentBudgetFunction · 0.90
getWindowIDFunction · 0.90
updateTitlebarFunction · 0.90
getPinchZoomEnabledFunction · 0.90
setPinchZoomEnabledFunction · 0.90
setTitlebarFunction · 0.90
runDesktopMenuActionFunction · 0.90
pickerFiltersFunction · 0.85
onMethod · 0.80

Tested by

no test coverage detected