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"
|
- "!scripts"
|
||||||
- "!release"
|
- "!release"
|
||||||
extraResources:
|
extraResources:
|
||||||
- from: assets/icon.png
|
|
||||||
to: icon.png
|
|
||||||
- from: ../surfsense_web/.next/standalone/surfsense_web/
|
- from: ../surfsense_web/.next/standalone/surfsense_web/
|
||||||
to: standalone/
|
to: standalone/
|
||||||
filter:
|
filter:
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,4 @@ export const IPC_CHANNELS = {
|
||||||
OPEN_EXTERNAL: 'open-external',
|
OPEN_EXTERNAL: 'open-external',
|
||||||
GET_APP_VERSION: 'get-app-version',
|
GET_APP_VERSION: 'get-app-version',
|
||||||
DEEP_LINK: 'deep-link',
|
DEEP_LINK: 'deep-link',
|
||||||
GET_CLIPBOARD_CONTENT: 'get-clipboard-content',
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ import { createMainWindow } from './modules/window';
|
||||||
import { setupDeepLinks, handlePendingDeepLink } from './modules/deep-links';
|
import { setupDeepLinks, handlePendingDeepLink } from './modules/deep-links';
|
||||||
import { setupAutoUpdater } from './modules/auto-updater';
|
import { setupAutoUpdater } from './modules/auto-updater';
|
||||||
import { setupMenu } from './modules/menu';
|
import { setupMenu } from './modules/menu';
|
||||||
import { setupTray } from './modules/tray';
|
|
||||||
import { registerIpcHandlers } from './ipc/handlers';
|
import { registerIpcHandlers } from './ipc/handlers';
|
||||||
import { registerClipboardHandlers } from './modules/clipboard';
|
|
||||||
|
|
||||||
registerGlobalErrorHandlers();
|
registerGlobalErrorHandlers();
|
||||||
|
|
||||||
|
|
@ -16,7 +14,6 @@ if (!setupDeepLinks()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
registerIpcHandlers();
|
registerIpcHandlers();
|
||||||
registerClipboardHandlers();
|
|
||||||
|
|
||||||
// App lifecycle
|
// App lifecycle
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
|
|
@ -29,7 +26,6 @@ app.whenReady().then(async () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
createMainWindow();
|
createMainWindow();
|
||||||
setupTray();
|
|
||||||
setupAutoUpdater();
|
setupAutoUpdater();
|
||||||
|
|
||||||
handlePendingDeepLink();
|
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),
|
openExternal: (url: string) => ipcRenderer.send(IPC_CHANNELS.OPEN_EXTERNAL, url),
|
||||||
getAppVersion: () => ipcRenderer.invoke(IPC_CHANNELS.GET_APP_VERSION),
|
getAppVersion: () => ipcRenderer.invoke(IPC_CHANNELS.GET_APP_VERSION),
|
||||||
getClipboardContent: () => ipcRenderer.invoke(IPC_CHANNELS.GET_CLIPBOARD_CONTENT),
|
|
||||||
onDeepLink: (callback: (url: string) => void) => {
|
onDeepLink: (callback: (url: string) => void) => {
|
||||||
const listener = (_event: unknown, url: string) => callback(url);
|
const listener = (_event: unknown, url: string) => callback(url);
|
||||||
ipcRenderer.on(IPC_CHANNELS.DEEP_LINK, listener);
|
ipcRenderer.on(IPC_CHANNELS.DEEP_LINK, listener);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,6 @@ interface InlineMentionEditorProps {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
initialDocuments?: MentionedDocument[];
|
initialDocuments?: MentionedDocument[];
|
||||||
initialText?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unique data attribute to identify chip elements
|
// Unique data attribute to identify chip elements
|
||||||
|
|
@ -97,7 +96,6 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
|
||||||
disabled = false,
|
disabled = false,
|
||||||
className,
|
className,
|
||||||
initialDocuments = [],
|
initialDocuments = [],
|
||||||
initialText,
|
|
||||||
},
|
},
|
||||||
ref
|
ref
|
||||||
) => {
|
) => {
|
||||||
|
|
@ -117,16 +115,6 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
|
||||||
}
|
}
|
||||||
}, [initialDocuments]);
|
}, [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
|
// Focus at the end of the editor
|
||||||
const focusAtEnd = useCallback(() => {
|
const focusAtEnd = useCallback(() => {
|
||||||
if (!editorRef.current) return;
|
if (!editorRef.current) return;
|
||||||
|
|
|
||||||
|
|
@ -330,16 +330,6 @@ const Composer: FC = () => {
|
||||||
const composerRuntime = useComposerRuntime();
|
const composerRuntime = useComposerRuntime();
|
||||||
const hasAutoFocusedRef = useRef(false);
|
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 isThreadEmpty = useAssistantState(({ thread }) => thread.isEmpty);
|
||||||
const isThreadRunning = useAssistantState(({ thread }) => thread.isRunning);
|
const isThreadRunning = useAssistantState(({ thread }) => thread.isRunning);
|
||||||
|
|
||||||
|
|
@ -546,7 +536,6 @@ const Composer: FC = () => {
|
||||||
onDocumentRemove={handleDocumentRemove}
|
onDocumentRemove={handleDocumentRemove}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
initialText={clipboardText}
|
|
||||||
className="min-h-[24px]"
|
className="min-h-[24px]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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;
|
openExternal: (url: string) => void;
|
||||||
getAppVersion: () => Promise<string>;
|
getAppVersion: () => Promise<string>;
|
||||||
getClipboardContent: () => Promise<string>;
|
|
||||||
onDeepLink: (callback: (url: string) => void) => () => void;
|
onDeepLink: (callback: (url: string) => void) => () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue