Replace the bottom-right floating chat button with app-wide launchers, as requested in review: - side panel: a right-side Drawer (OpenWebUiChat) reusing the chat widget, mounted app-wide and shown only to authed users who own an Open WebUI integration - header entry: an 'AI Chat' item in the user-avatar menu (like the Docker item) - keybind: mod+shift+a toggles the panel (hotkeys.toggleAiChat) - spotlight: a '?' 'Ask AI' mode that starts a conversation from the typed query and opens the panel pre-filled; also surfaced in the Cmd+K help/mode list when the integration is present - the panel and spotlight are bridged to the app via an openWebUiChatEvent window event (mirrors the existing media-request search event) The Chat widget gains an optional initialQuery that auto-sends once on open.
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { mediaRequestSearchEvent, openWebUiChatEvent, spotlightActions } from "./spotlight-store";
|
|
|
|
export { Spotlight } from "./components/spotlight";
|
|
export { openSpotlight, openMediaRequestSearch, openOpenWebUiChat };
|
|
export {
|
|
SpotlightProvider,
|
|
useRegisterSpotlightContextResults,
|
|
useRegisterSpotlightContextActions,
|
|
} from "./modes/home/context";
|
|
|
|
const openSpotlight = spotlightActions.open;
|
|
|
|
export interface OpenMediaRequestSearchOptions {
|
|
integrationIds?: string[];
|
|
query?: string;
|
|
}
|
|
|
|
const openMediaRequestSearch = (options: OpenMediaRequestSearchOptions = {}) => {
|
|
if (typeof window !== "undefined") {
|
|
window.dispatchEvent(new CustomEvent<OpenMediaRequestSearchOptions>(mediaRequestSearchEvent, { detail: options }));
|
|
}
|
|
|
|
spotlightActions.open();
|
|
};
|
|
|
|
export { mediaRequestSearchEvent, openWebUiChatEvent };
|
|
|
|
// Opens the Open WebUI chat side panel, optionally seeding it with a query to
|
|
// start a conversation from. Closes the spotlight so the panel takes over.
|
|
const openOpenWebUiChat = (query?: string) => {
|
|
if (typeof window !== "undefined") {
|
|
window.dispatchEvent(new CustomEvent<{ query?: string }>(openWebUiChatEvent, { detail: { query } }));
|
|
}
|
|
|
|
spotlightActions.close();
|
|
};
|