Skip to content
This repository was archived by the owner on Apr 10, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/electron-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
style-src 'self' 'unsafe-inline';
connect-src 'self' https://*.trycloudflare.com wss: ws: http: https:;
img-src 'self' data:;
media-src 'self' blob: file:;
"
/>
<style>
Expand Down
2 changes: 2 additions & 0 deletions apps/electron-app/src/common/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Switch } from '../render/components/react-flow/nodes/Switch';
import { Proximity } from '../render/components/react-flow/nodes/Proximity';
import { Llm } from '../render/components/react-flow/nodes/Llm';
import { Hotkey } from '../render/components/react-flow/nodes/Hotkey';
import { AudioPlayer } from '../render/components/react-flow/nodes/AudioPlayer/AudioPlayer';
import { Node } from '@xyflow/react';

export function isNodeTypeACodeType(node?: Node) {
Expand Down Expand Up @@ -80,6 +81,7 @@ export const NODE_TYPES: Record<string, (props: any) => JSX.Element> = {
Trigger: Trigger,
Vibration: Vibration,
Hotkey: Hotkey,
AudioPlayer: AudioPlayer,
} as const;

export type NodeType = keyof typeof NODE_TYPES;
28 changes: 28 additions & 0 deletions apps/electron-app/src/main/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,31 @@ export async function importFlow(): Promise<FlowState | null> {
});
});
}

export async function selectAudioFiles(): Promise<string[]> {
const result = await dialog.showOpenDialog({
title: 'Select Audio Files',
filters: [
{ name: 'Audio files', extensions: ['mp3', 'wav', 'ogg', 'm4a', 'aac', 'flac'] },
{ name: 'All files', extensions: ['*'] },
],
properties: ['openFile', 'multiSelections'],
});

if (result.canceled || !result.filePaths) {
return [];
}

return result.filePaths;
}

export async function readAudioFile(filePath: string): Promise<Buffer> {
return new Promise<Buffer>((resolve, reject) => {
fs.readFile(filePath, (err, data) => {
if (err) {
return reject(err);
}
resolve(data);
});
});
}
12 changes: 11 additions & 1 deletion apps/electron-app/src/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { app, ipcMain, Menu } from 'electron';
import { mainWindowReady } from './window';

import log from 'electron-log/node';
import { exportFlow } from './file';
import { exportFlow, selectAudioFiles, readAudioFile } from './file';
import { ensureRunnerProcess, getRunnerProcess, killRunnerProcess } from './board-connection';
import { checkConnectedPort, setupUSBDeviceListeners, stopPortPolling } from './port-manager';
import { Timer } from './utils';
Expand Down Expand Up @@ -51,6 +51,16 @@ ipcMain.on('ipc-external-value', (_event, data: { nodeId: string; value: unknown
runnerProcess?.send({ type: 'setExternal', nodeId: data.nodeId, value: data.value });
});

ipcMain.handle('ipc-select-audio-files', async () => {
return await selectAudioFiles();
});

ipcMain.handle('ipc-read-audio-file', async (_event, filePath: string) => {
const buffer = await readAudioFile(filePath);
// Convert buffer to base64 for transmission
return buffer.toString('base64');
});
Comment on lines +58 to +62

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no validation on the filePath parameter passed from the IPC call. A malicious or buggy renderer process could potentially pass arbitrary file paths, including system files. Consider adding path validation to restrict access to only audio files or specific directories, or at minimum check if the file exists and has an allowed extension before reading it.

Copilot uses AI. Check for mistakes.

killRunnerProcess().catch(log.debug);

app.on('before-quit', async event => {
Expand Down
2 changes: 1 addition & 1 deletion apps/electron-app/src/main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function handleSecondInstance(commandLine: string[]) {
export async function recreateWindowWhenNeeded() {
if (windows.length === 0) {
await createWindow();
await new Promise(resolve => setTimeout(resolve, 500));
await new Promise(resolve => setTimeout(resolve, 250));
}

return Promise.resolve();
Expand Down
8 changes: 7 additions & 1 deletion apps/electron-app/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export type Channels =
| 'ipc-deep-link'
| 'ipc-export-flow'
| 'ipc-flow'
| 'ipc-board';
| 'ipc-board'
| 'ipc-select-audio-files'
| 'ipc-read-audio-file';

type IpcCallback<Data> = (response: IpcResponse<Data>) => void;
type Listener = (event: IpcRendererEvent, response: IpcResponse<any>) => void;
Expand Down Expand Up @@ -54,6 +56,10 @@ export const electronHandler = {
console.debug('[IPC] <once>', channel);
ipcRenderer.once(channel, (_event, args) => callback(args));
},
invoke<Data>(channel: Channels, data?: Data): Promise<any> {
logger.debug('[IPC] <invoke>', channel, data);
return ipcRenderer.invoke(channel, data);
},
},
os: {
isMac: process.platform === 'darwin',
Expand Down
Loading
Loading