mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-02 19:55:18 +02:00
remove tray and clipboard-to-chat feature
This commit is contained in:
parent
f783b00d2e
commit
59e7f8f068
9 changed files with 0 additions and 119 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<InlineMentionEditorRef, InlineMent
|
|||
disabled = false,
|
||||
className,
|
||||
initialDocuments = [],
|
||||
initialText,
|
||||
},
|
||||
ref
|
||||
) => {
|
||||
|
|
@ -117,16 +115,6 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
|
|||
}
|
||||
}, [initialDocuments]);
|
||||
|
||||
// Seed editor with initialText on mount
|
||||
const initialTextAppliedRef = useRef(false);
|
||||
useEffect(() => {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -330,16 +330,6 @@ const Composer: FC = () => {
|
|||
const composerRuntime = useComposerRuntime();
|
||||
const hasAutoFocusedRef = useRef(false);
|
||||
|
||||
// Clipboard content
|
||||
const [clipboardText, setClipboardText] = useState<string | undefined>();
|
||||
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]"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
1
surfsense_web/types/window.d.ts
vendored
1
surfsense_web/types/window.d.ts
vendored
|
|
@ -9,7 +9,6 @@ interface ElectronAPI {
|
|||
};
|
||||
openExternal: (url: string) => void;
|
||||
getAppVersion: () => Promise<string>;
|
||||
getClipboardContent: () => Promise<string>;
|
||||
onDeepLink: (callback: (url: string) => void) => () => void;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue