refac
This commit is contained in:
@@ -46,7 +46,8 @@
|
|||||||
selectedTerminalId,
|
selectedTerminalId,
|
||||||
showFileNavPath,
|
showFileNavPath,
|
||||||
showFileNavDir,
|
showFileNavDir,
|
||||||
chatRequestQueues
|
chatRequestQueues,
|
||||||
|
desktopEvent
|
||||||
} from '$lib/stores';
|
} from '$lib/stores';
|
||||||
|
|
||||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||||
@@ -1225,7 +1226,19 @@
|
|||||||
showControls.set(true);
|
showControls.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($page.url.searchParams.get('q')) {
|
// Consume one-shot desktop event (e.g. Spotlight query + attachments)
|
||||||
|
if ($desktopEvent) {
|
||||||
|
const { query, files: eventFiles } = $desktopEvent;
|
||||||
|
desktopEvent.set(null);
|
||||||
|
|
||||||
|
// TODO: handle eventFiles (attach to chat)
|
||||||
|
|
||||||
|
if (query) {
|
||||||
|
messageInput?.setText(query);
|
||||||
|
await tick();
|
||||||
|
submitHandler(query);
|
||||||
|
}
|
||||||
|
} else if ($page.url.searchParams.get('q')) {
|
||||||
const q = $page.url.searchParams.get('q') ?? '';
|
const q = $page.url.searchParams.get('q') ?? '';
|
||||||
messageInput?.setText(q);
|
messageInput?.setText(q);
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,15 @@ export const artifactContents = writable(null);
|
|||||||
export const embed = writable(null);
|
export const embed = writable(null);
|
||||||
|
|
||||||
export const temporaryChatEnabled = writable(false);
|
export const temporaryChatEnabled = writable(false);
|
||||||
|
|
||||||
|
// Transient one-shot event from the desktop shell (Spotlight, drag-and-drop, etc.).
|
||||||
|
// Set by +layout.svelte, consumed and cleared by Chat.svelte.
|
||||||
|
export type DesktopEventFile = { name: string; mimeType: string; dataUrl: string };
|
||||||
|
export type DesktopEvent = {
|
||||||
|
query?: string;
|
||||||
|
files?: DesktopEventFile[];
|
||||||
|
};
|
||||||
|
export const desktopEvent: Writable<DesktopEvent | null> = writable(null);
|
||||||
export const scrollPaginationEnabled = writable(false);
|
export const scrollPaginationEnabled = writable(false);
|
||||||
export const currentChatPage = writable(1);
|
export const currentChatPage = writable(1);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
showControls,
|
showControls,
|
||||||
showFileNavPath,
|
showFileNavPath,
|
||||||
showFileNavDir,
|
showFileNavDir,
|
||||||
pyodideWorker
|
pyodideWorker,
|
||||||
|
desktopEvent
|
||||||
} from '$lib/stores';
|
} from '$lib/stores';
|
||||||
import { getFileContentById } from '$lib/apis/files';
|
import { getFileContentById } from '$lib/apis/files';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
@@ -711,7 +712,8 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.type === 'query' && event.data?.query) {
|
if (event.type === 'query' && event.data?.query) {
|
||||||
await goto(`/?q=${encodeURIComponent(event.data.query)}`);
|
desktopEvent.set({ query: event.data.query });
|
||||||
|
await goto('/');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.type === 'theme:update' && event.data?.theme) {
|
if (event.type === 'theme:update' && event.data?.theme) {
|
||||||
|
|||||||
Reference in New Issue
Block a user