Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat: restore clipboard after paste

Gabriel Stein67f83066d834
diff --git a/main.js b/main.js
index 5a9b60d58..a36b5ce37 100644
--- a/main.js
+++ b/main.js
@@ -639,6 +639,10 @@ ipcMain.handle('window-is-maximized', () => {
// IPC handlers
ipcMain.handle("paste-text", async (event, text) => {
try {
+ // Save original clipboard content first
+ const originalClipboard = clipboard.readText();
+ console.log('πŸ’Ύ Saved original clipboard content:', originalClipboard.substring(0, 50) + '...');
+
// Copy text to clipboard first - this always works
clipboard.writeText(text);
console.log('πŸ“‹ Text copied to clipboard:', text.substring(0, 50) + '...');
@@ -678,6 +682,11 @@ ipcMain.handle("paste-text", async (event, text) => {
if (code === 0) {
console.log('βœ… Text pasted successfully via Cmd+V simulation');
+ // Restore original clipboard content
+ setTimeout(() => {
+ clipboard.writeText(originalClipboard);
+ console.log('πŸ”„ Original clipboard content restored');
+ }, 100); // Small delay to ensure paste is complete
resolve();
} else {
console.error('❌ Failed to paste text, code:', code);
@@ -723,6 +732,11 @@ ipcMain.handle("paste-text", async (event, text) => {
pasteProcess.on('close', (code) => {
if (code === 0) {
console.log('βœ… Text pasted successfully on Windows');
+ // Restore original clipboard content
+ setTimeout(() => {
+ clipboard.writeText(originalClipboard);
+ console.log('πŸ”„ Original clipboard content restored');
+ }, 100);
resolve();
} else {
console.error('❌ Failed to paste on Windows, code:', code);
@@ -744,6 +758,11 @@ ipcMain.handle("paste-text", async (event, text) => {
pasteProcess.on('close', (code) => {
if (code === 0) {
console.log('βœ… Text pasted successfully on Linux');
+ // Restore original clipboard content
+ setTimeout(() => {
+ clipboard.writeText(originalClipboard);
+ console.log('πŸ”„ Original clipboard content restored');
+ }, 100);
resolve();
} else {
console.error('❌ Failed to paste on Linux, code:', code);
diff --git a/src/App.jsx b/src/App.jsx
index 5ab65ead9..1152bee15 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -141,8 +141,10 @@ export default function App() {
throw new Error(`Local Whisper not available: ${installCheck.error || 'Installation check failed'}`);
}
+ // Convert Blob to ArrayBuffer for IPC transfer
+ const arrayBuffer = await audioBlob.arrayBuffer();
const options = { model };
- const result = await window.electronAPI.transcribeLocalWhisper(audioBlob, options);
+ const result = await window.electronAPI.transcribeLocalWhisper(arrayBuffer, options);
if (result.success && result.text) {
const text = result.text.trim();
@@ -291,12 +293,12 @@ export default function App() {
// Get microphone button properties based on state
const getMicButtonProps = () => {
- const baseClasses = 'rounded-full w-10 h-10 flex items-center justify-center relative overflow-hidden cursor-pointer';
+ const baseClasses = 'rounded-full w-10 h-10 flex items-center justify-center relative overflow-hidden border-2 border-white/70 cursor-pointer';
switch (micState) {
case 'idle':
return {
- className: `${baseClasses} bg-black/50 cursor-pointer border-2 border-white/70`,
+ className: `${baseClasses} bg-black/50 cursor-pointer`,
tooltip: "Click to speak"
};
case 'hover':