diff --git a/surfsense_desktop/electron-builder.yml b/surfsense_desktop/electron-builder.yml index 715366e0c..eaca0f19b 100644 --- a/surfsense_desktop/electron-builder.yml +++ b/surfsense_desktop/electron-builder.yml @@ -13,8 +13,6 @@ files: - "!scripts" - "!release" extraResources: - - from: assets/icon.png - to: icon.png - from: ../surfsense_web/.next/standalone/surfsense_web/ to: standalone/ filter: diff --git a/surfsense_desktop/src/ipc/channels.ts b/surfsense_desktop/src/ipc/channels.ts index 4d0f3bf80..8ae21cfcf 100644 --- a/surfsense_desktop/src/ipc/channels.ts +++ b/surfsense_desktop/src/ipc/channels.ts @@ -2,5 +2,4 @@ export const IPC_CHANNELS = { OPEN_EXTERNAL: 'open-external', GET_APP_VERSION: 'get-app-version', DEEP_LINK: 'deep-link', - GET_CLIPBOARD_CONTENT: 'get-clipboard-content', } as const; diff --git a/surfsense_desktop/src/main.ts b/surfsense_desktop/src/main.ts index 10f442c08..aff64db22 100644 --- a/surfsense_desktop/src/main.ts +++ b/surfsense_desktop/src/main.ts @@ -5,9 +5,7 @@ import { createMainWindow } from './modules/window'; import { setupDeepLinks, handlePendingDeepLink } from './modules/deep-links'; import { setupAutoUpdater } from './modules/auto-updater'; import { setupMenu } from './modules/menu'; -import { setupTray } from './modules/tray'; import { registerIpcHandlers } from './ipc/handlers'; -import { registerClipboardHandlers } from './modules/clipboard'; registerGlobalErrorHandlers(); @@ -16,7 +14,6 @@ if (!setupDeepLinks()) { } registerIpcHandlers(); -registerClipboardHandlers(); // App lifecycle app.whenReady().then(async () => { @@ -29,7 +26,6 @@ app.whenReady().then(async () => { return; } createMainWindow(); - setupTray(); setupAutoUpdater(); handlePendingDeepLink(); diff --git a/surfsense_desktop/src/modules/clipboard.ts b/surfsense_desktop/src/modules/clipboard.ts deleted file mode 100644 index 4f9d7b802..000000000 --- a/surfsense_desktop/src/modules/clipboard.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ipcMain } from 'electron'; -import { IPC_CHANNELS } from '../ipc/channels'; - -let lastClipboardContent = ''; - -export function setClipboardContent(text: string): void { - lastClipboardContent = text; -} - -export function registerClipboardHandlers(): void { - ipcMain.handle(IPC_CHANNELS.GET_CLIPBOARD_CONTENT, () => { - return lastClipboardContent; - }); -} diff --git a/surfsense_desktop/src/modules/tray.ts b/surfsense_desktop/src/modules/tray.ts deleted file mode 100644 index 3527cf691..000000000 --- a/surfsense_desktop/src/modules/tray.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { app, BrowserWindow, clipboard, Menu, Tray } from 'electron'; -import path from 'path'; -import { getServerPort } from './server'; -import { setClipboardContent } from './clipboard'; - -let tray: Tray | null = null; -let clipWindow: BrowserWindow | null = null; - -function getIconPath(): string { - if (app.isPackaged) { - return path.join(process.resourcesPath, 'icon.png'); - } - return path.join(__dirname, '..', 'assets', 'icon.png'); -} - -function createClipWindow(): BrowserWindow { - if (clipWindow && !clipWindow.isDestroyed()) { - clipWindow.focus(); - return clipWindow; - } - - clipWindow = new BrowserWindow({ - width: 420, - height: 620, - resizable: true, - minimizable: false, - maximizable: false, - fullscreenable: false, - webPreferences: { - preload: path.join(__dirname, 'preload.js'), - contextIsolation: true, - nodeIntegration: false, - sandbox: true, - }, - show: false, - titleBarStyle: 'hiddenInset', - }); - - clipWindow.loadURL(`http://localhost:${getServerPort()}/dashboard`); - - clipWindow.once('ready-to-show', () => { - clipWindow?.show(); - }); - - clipWindow.on('closed', () => { - clipWindow = null; - }); - - return clipWindow; -} - -export function setupTray(): void { - tray = new Tray(getIconPath()); - tray.setToolTip('SurfSense'); - - const contextMenu = Menu.buildFromTemplate([ - { - label: 'Ask about clipboard', - click: () => { - const text = clipboard.readText(); - setClipboardContent(text); - createClipWindow(); - }, - }, - { type: 'separator' }, - { - label: 'Quit', - click: () => app.quit(), - }, - ]); - - tray.setContextMenu(contextMenu); -} diff --git a/surfsense_desktop/src/preload.ts b/surfsense_desktop/src/preload.ts index 3f0f4be1f..d36db8c22 100644 --- a/surfsense_desktop/src/preload.ts +++ b/surfsense_desktop/src/preload.ts @@ -10,7 +10,6 @@ contextBridge.exposeInMainWorld('electronAPI', { }, openExternal: (url: string) => ipcRenderer.send(IPC_CHANNELS.OPEN_EXTERNAL, url), getAppVersion: () => ipcRenderer.invoke(IPC_CHANNELS.GET_APP_VERSION), - getClipboardContent: () => ipcRenderer.invoke(IPC_CHANNELS.GET_CLIPBOARD_CONTENT), onDeepLink: (callback: (url: string) => void) => { const listener = (_event: unknown, url: string) => callback(url); ipcRenderer.on(IPC_CHANNELS.DEEP_LINK, listener); diff --git a/surfsense_web/components/assistant-ui/inline-mention-editor.tsx b/surfsense_web/components/assistant-ui/inline-mention-editor.tsx index be48b60fa..dacc845ec 100644 --- a/surfsense_web/components/assistant-ui/inline-mention-editor.tsx +++ b/surfsense_web/components/assistant-ui/inline-mention-editor.tsx @@ -47,7 +47,6 @@ interface InlineMentionEditorProps { disabled?: boolean; className?: string; initialDocuments?: MentionedDocument[]; - initialText?: string; } // Unique data attribute to identify chip elements @@ -97,7 +96,6 @@ export const InlineMentionEditor = forwardRef { @@ -117,16 +115,6 @@ export const InlineMentionEditor = forwardRef { - if (!initialText || initialTextAppliedRef.current || !editorRef.current) return; - initialTextAppliedRef.current = true; - editorRef.current.textContent = initialText; - setIsEmpty(false); - onChange?.(initialText, Array.from(mentionedDocs.values())); - }, [initialText]); // eslint-disable-line react-hooks/exhaustive-deps - // Focus at the end of the editor const focusAtEnd = useCallback(() => { if (!editorRef.current) return; diff --git a/surfsense_web/components/assistant-ui/thread.tsx b/surfsense_web/components/assistant-ui/thread.tsx index 0a38e19d5..081e234a8 100644 --- a/surfsense_web/components/assistant-ui/thread.tsx +++ b/surfsense_web/components/assistant-ui/thread.tsx @@ -330,16 +330,6 @@ const Composer: FC = () => { const composerRuntime = useComposerRuntime(); const hasAutoFocusedRef = useRef(false); - // Clipboard content - const [clipboardText, setClipboardText] = useState(); - useEffect(() => { - const api = window.electronAPI; - if (!api?.getClipboardContent) return; - api.getClipboardContent().then((text) => { - if (text) setClipboardText(text); - }); - }, []); - const isThreadEmpty = useAssistantState(({ thread }) => thread.isEmpty); const isThreadRunning = useAssistantState(({ thread }) => thread.isRunning); @@ -546,7 +536,6 @@ const Composer: FC = () => { onDocumentRemove={handleDocumentRemove} onSubmit={handleSubmit} onKeyDown={handleKeyDown} - initialText={clipboardText} className="min-h-[24px]" /> diff --git a/surfsense_web/types/window.d.ts b/surfsense_web/types/window.d.ts index 487e2058f..8d2c38c8b 100644 --- a/surfsense_web/types/window.d.ts +++ b/surfsense_web/types/window.d.ts @@ -9,7 +9,6 @@ interface ElectronAPI { }; openExternal: (url: string) => void; getAppVersion: () => Promise; - getClipboardContent: () => Promise; onDeepLink: (callback: (url: string) => void) => () => void; }