From f43e34ca2b1585482d19807201512df7312d2af6 Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Thu, 23 Jul 2026 00:59:29 +0530 Subject: [PATCH] fix(ipc): re-type wrapper signatures to match handler return shapes Many IPC handlers were returning useful data but the wrappers typed 'void', silently dropping the response. Re-type all affected wrappers: - file.write: returns { path } (resolved after security validation) - file.delete/ensureDir/exists/isDirectory/copy/move: full wrappers (previously only on window.electronAPI.file.*) - crash.read: typed as Array<{...}> so callers can trust the shape - crash.delete: returns boolean - gitStage: returns { files, error? } so callers can detect failure - gitCommit: returns { summary } | { error } - updater.check/getState: returns { state } --- src/renderer/lib/ipc.ts | 47 +++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/src/renderer/lib/ipc.ts b/src/renderer/lib/ipc.ts index e45a707..5eb9350 100644 --- a/src/renderer/lib/ipc.ts +++ b/src/renderer/lib/ipc.ts @@ -62,10 +62,28 @@ export const ipc = { // Callers needing a file picker should use ipc.file.pickFile() directly. read: (path: string): Promise> => safeCall('file', 'read', path), - write: (path: string, content: string): Promise> => + write: (path: string, content: string): Promise> => safeCall('file', 'write', path, content), list: (dir: string): Promise> => safeCall('file', 'list', dir), + delete: (path: string): Promise> => + safeCall('file', 'delete', path), + ensureDir: (path: string): Promise> => + safeCall('file', 'ensureDir', path), + exists: (path: string): Promise> => + safeCall('file', 'exists', path), + isDirectory: (path: string): Promise> => + safeCall('file', 'isDirectory', path), + copy: ( + source: string, + destination: string + ): Promise> => + safeCall('file', 'copy', source, destination), + move: ( + source: string, + destination: string + ): Promise> => + safeCall('file', 'move', source, destination), pickFolder: (): Promise> => safeCall('file', 'pickFolder'), pickFile: (): Promise> => @@ -103,11 +121,13 @@ export const ipc = { gitStage: (args: { rootPath: string; files: string[]; - }): Promise> => safeCall('git', 'stage', args), + }): Promise> => + safeCall('git', 'stage', args), gitCommit: (args: { rootPath: string; message: string; - }): Promise> => safeCall('git', 'commit', args), + }): Promise> => + safeCall('git', 'commit', args), setCurrent: (path: string | null): void => { if (typeof window !== 'undefined' && window.electronAPI?.file?.setCurrent) { window.electronAPI.file.setCurrent(path); @@ -161,9 +181,11 @@ export const ipc = { }, }, updater: { - check: (): Promise> => safeCall('updater', 'check'), + check: (): Promise> => + safeCall('updater', 'check'), install: (): Promise> => safeCall('updater', 'install'), - getState: (): Promise> => safeCall('updater', 'getState'), + getState: (): Promise> => + safeCall('updater', 'getState'), onStatus: (cb: (payload: unknown) => void): (() => void) => { if (typeof window === 'undefined' || !window.electronAPI?.updater?.onStatus) { return () => {}; @@ -172,9 +194,20 @@ export const ipc = { }, }, crash: { - read: (): Promise> => safeCall('crash', 'read'), + read: (): Promise< + IpcResult< + | Array<{ + filename: string; + kind: string; + message?: string; + stack?: string; + timestamp: string; + }> + | ChannelMissing + > + > => safeCall('crash', 'read'), openDir: (): Promise> => safeCall('crash', 'openDir'), - delete: (filename: string): Promise> => + delete: (filename: string): Promise> => safeCall('crash', 'delete', filename), }, };