mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-04 05:12:38 +02:00
feat: add active search space management to Electron API and UI
- Introduced IPC channels for getting and setting the active search space, enhancing user experience across the application. - Updated the preload script to expose new API methods for active search space management. - Modified the main window and quick ask functionalities to sync the active search space based on user navigation. - Enhanced the desktop and web applications to allow users to select and manage their default search space seamlessly. - Implemented automatic synchronization of the active search space during login and navigation events.
This commit is contained in:
parent
b74ac8a608
commit
7c6e52a0a5
12 changed files with 189 additions and 62 deletions
|
|
@ -2,16 +2,15 @@ import { clipboard, globalShortcut, ipcMain, screen } from 'electron';
|
|||
import { IPC_CHANNELS } from '../../ipc/channels';
|
||||
import { getFrontmostApp, getWindowTitle, hasAccessibilityPermission, simulatePaste } from '../platform';
|
||||
import { hasScreenRecordingPermission, requestAccessibility, requestScreenRecording } from '../permissions';
|
||||
import { getMainWindow } from '../window';
|
||||
import { captureScreen } from './screenshot';
|
||||
import { createSuggestionWindow, destroySuggestion, getSuggestionWindow } from './suggestion-window';
|
||||
import { getShortcuts } from '../shortcuts';
|
||||
import { getActiveSearchSpaceId } from '../active-search-space';
|
||||
|
||||
let currentShortcut = '';
|
||||
let autocompleteEnabled = true;
|
||||
let savedClipboard = '';
|
||||
let sourceApp = '';
|
||||
let lastSearchSpaceId: string | null = null;
|
||||
|
||||
function isSurfSenseWindow(): boolean {
|
||||
const app = getFrontmostApp();
|
||||
|
|
@ -37,21 +36,11 @@ async function triggerAutocomplete(): Promise<void> {
|
|||
return;
|
||||
}
|
||||
|
||||
const mainWin = getMainWindow();
|
||||
if (mainWin && !mainWin.isDestroyed()) {
|
||||
const mainUrl = mainWin.webContents.getURL();
|
||||
const match = mainUrl.match(/\/dashboard\/(\d+)/);
|
||||
if (match) {
|
||||
lastSearchSpaceId = match[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (!lastSearchSpaceId) {
|
||||
console.warn('[autocomplete] No active search space. Open a search space first.');
|
||||
const searchSpaceId = await getActiveSearchSpaceId();
|
||||
if (!searchSpaceId) {
|
||||
console.warn('[autocomplete] No active search space. Select a search space first.');
|
||||
return;
|
||||
}
|
||||
|
||||
const searchSpaceId = lastSearchSpaceId;
|
||||
const cursor = screen.getCursorScreenPoint();
|
||||
const win = createSuggestionWindow(cursor.x, cursor.y);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue