feat(open-webui): header entry, side panel, keybind and spotlight chat

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.
This commit is contained in:
Thomas Camlong committed 2026-07-11 19:11:12 +02:00
1 parent 3d2a2d7b55
commit e648abf78e
15 files changed
+272 -148

No files matched your search

+22 -1
View File
@@ -49,7 +49,15 @@ import { useCameraCapture } from "./use-camera-capture";
import { useChatStream } from "./use-chat-stream";
import { useVoiceRecording } from "./use-voice-recording";
export function Chat({ options, integrationIds, isEditMode }: WidgetComponentProps<"openWebUi">) {
// `initialQuery` is only supplied when the chat is opened from outside the board
// (spotlight / side panel "start chat with query"); the board widget renderer
// never passes it.
export function Chat({
options,
integrationIds,
isEditMode,
initialQuery,
}: WidgetComponentProps<"openWebUi"> & { initialQuery?: string }) {
const t = useI18n();
const integrationId = integrationIds.at(0);
@@ -151,6 +159,19 @@ export function Chat({ options, integrationIds, isEditMode }: WidgetComponentPro
viewportRef.current?.scrollTo({ top: viewportRef.current.scrollHeight, behavior: "smooth" });
}, [stream.messages, stream.streamingText, composerHeight]);
// When opened with an initial query (spotlight / side panel "start chat with
// query"), send it once the model has loaded. The caller remounts the chat per
// open (via key) so a fresh query is always delivered.
const autoSentRef = useRef(false);
useEffect(() => {
if (autoSentRef.current) return;
const trimmed = initialQuery?.trim();
if (!trimmed || !model || !integrationId || stream.isStreaming) return;
autoSentRef.current = true;
stream.send({ role: "user", content: trimmed });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [initialQuery, model, integrationId]);
// Nothing to send yet: no typed text and no inline image attachments.
const composerEmpty = !input.trim() && attachments.images.length === 0;