From 124581744c08986d605e9b6718e927847d61e48e Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 16 Jun 2026 23:38:30 +0200 Subject: [PATCH] Deprecate explicit chat database selection components and hooks, standardizing workflow confirmation dialogs to reference 'Knowledge' instead of specific libraries. --- src/ChatDatabasePicker.jsx | 101 --------------- src/WebsearchSettings.jsx | 2 +- src/appConfig.js | 1 - src/useChatLibrarySelection.js | 124 ------------------- src/workflows/WorkflowConfirmationDialog.jsx | 2 +- 5 files changed, 2 insertions(+), 228 deletions(-) delete mode 100644 src/ChatDatabasePicker.jsx delete mode 100644 src/useChatLibrarySelection.js diff --git a/src/ChatDatabasePicker.jsx b/src/ChatDatabasePicker.jsx deleted file mode 100644 index 55cc1bb..0000000 --- a/src/ChatDatabasePicker.jsx +++ /dev/null @@ -1,101 +0,0 @@ -import { useEffect, useRef, useState } from 'react' - -export default function ChatDatabasePicker({ - activeSessionId, - chatLibrary, - chatLibrarySlug, - chatLibraryStatusSuffix, - isLibrarySyncing, - libraries, - setChatLibraryForSession, -}) { - const dbPickerRef = useRef(null) - const [isDbPickerOpen, setIsDbPickerOpen] = useState(false) - - useEffect(() => { - if (!isDbPickerOpen) return - - const onPointerDown = (event) => { - if (!dbPickerRef.current?.contains(event.target)) { - setIsDbPickerOpen(false) - } - } - - document.addEventListener('mousedown', onPointerDown) - return () => document.removeEventListener('mousedown', onPointerDown) - }, [isDbPickerOpen]) - - useEffect(() => { - setIsDbPickerOpen(false) - }, [activeSessionId]) - - return ( -
- - {isDbPickerOpen && ( -
- - {libraries.length === 0 ? ( -
No databases yet.
- ) : ( - libraries.map(library => { - const selected = chatLibrarySlug === library.slug - const syncing = isLibrarySyncing(library.slug) - const status = !library.files?.length - ? 'Empty' - : library.states?.is_indexed - ? 'Ready' - : syncing - ? 'Syncing' - : 'Needs sync' - - return ( - - ) - }) - )} -
- )} -
- ) -} diff --git a/src/WebsearchSettings.jsx b/src/WebsearchSettings.jsx index 27ad080..4402427 100644 --- a/src/WebsearchSettings.jsx +++ b/src/WebsearchSettings.jsx @@ -70,7 +70,7 @@ return ( onChange={handleBackendUrlChange} placeholder={`e.g., ${DEFAULT_BACKEND_API_URL}`} /> -

Internal UI requests like chats, sessions, and databases go to this URL.

+

Internal UI requests like chats, sessions, and Knowledge go to this URL.

diff --git a/src/appConfig.js b/src/appConfig.js index 812d129..f22481f 100644 --- a/src/appConfig.js +++ b/src/appConfig.js @@ -2,7 +2,6 @@ export const API_URL_KEY = 'backendApiUrl' export const COLOR_SCHEME_KEY = 'colorScheme' export const WEBSEARCH_URL_KEY = 'websearch.searxUrl' export const WEBSEARCH_ENGINES_KEY = 'websearch.engines' -export const CHAT_LIBRARY_MAP_KEY = 'chat.libraryBySession' export const CHAT_WORKFLOW_MAP_KEY = 'chat.workflowBySession' export const DEFAULT_SEARX_URL = 'http://127.0.0.1:8888' export const DEFAULT_BACKEND_API_URL = import.meta.env.VITE_API_URL ?? 'http://127.0.0.1:8000' diff --git a/src/useChatLibrarySelection.js b/src/useChatLibrarySelection.js deleted file mode 100644 index 6f023bf..0000000 --- a/src/useChatLibrarySelection.js +++ /dev/null @@ -1,124 +0,0 @@ -import { useEffect, useMemo, useState } from 'react' -import { CHAT_LIBRARY_MAP_KEY } from './appConfig' - -function libraryJobIsActive(job) { - return job?.status === 'queued' || job?.status === 'running' -} - -function getLibraryStatusSuffix(library, hasActiveJob) { - if (!library) return '' - if (!library.files?.length) return ' (empty)' - if (library.states?.is_indexed) return '' - return hasActiveJob ? ' (syncing)' : ' (needs sync)' -} - -function loadChatLibraryMap() { - try { - const raw = localStorage.getItem(CHAT_LIBRARY_MAP_KEY) - return raw ? JSON.parse(raw) : {} - } catch { - return {} - } -} - -export function useChatLibrarySelection({ activeSessionId, libraries, libraryJobs }) { - const [chatLibraryBySession, setChatLibraryBySession] = useState(loadChatLibraryMap) - - useEffect(() => { - try { - localStorage.setItem(CHAT_LIBRARY_MAP_KEY, JSON.stringify(chatLibraryBySession || {})) - } catch {} - }, [chatLibraryBySession]) - - useEffect(() => { - const validSlugs = new Set(libraries.map(library => library.slug)) - setChatLibraryBySession(prev => { - let changed = false - const next = {} - for (const [sessionId, slug] of Object.entries(prev || {})) { - if (validSlugs.has(slug)) { - next[sessionId] = slug - } else { - changed = true - } - } - return changed ? next : prev - }) - }, [libraries]) - - const chatLibrarySlug = activeSessionId ? (chatLibraryBySession[activeSessionId] || null) : null - - const chatLibrary = useMemo(() => { - return libraries.find(lib => lib.slug === chatLibrarySlug) || null - }, [chatLibrarySlug, libraries]) - - const chatLibraryHasActiveJob = useMemo(() => { - if (!chatLibrarySlug) return false - return libraryJobs.some(job => job.slug === chatLibrarySlug && libraryJobIsActive(job)) - }, [chatLibrarySlug, libraryJobs]) - - const chatLibraryStatusSuffix = useMemo(() => { - return getLibraryStatusSuffix(chatLibrary, chatLibraryHasActiveJob) - }, [chatLibrary, chatLibraryHasActiveJob]) - - function getChatLibrarySlugForSession(sessionId) { - if (!sessionId) return null - return chatLibraryBySession[sessionId] || null - } - - function getChatLibraryForSession(sessionId) { - const slug = getChatLibrarySlugForSession(sessionId) - if (!slug) return null - return libraries.find(lib => lib.slug === slug) || null - } - - function isLibrarySyncing(slug) { - if (!slug) return false - return libraryJobs.some(job => job.slug === slug && libraryJobIsActive(job)) - } - - function setChatLibraryForSession(sessionId, slug) { - if (!sessionId) return - setChatLibraryBySession(prev => { - const next = { ...(prev || {}) } - if (slug) { - next[sessionId] = slug - } else { - delete next[sessionId] - } - return next - }) - } - - function removeLibraryFromChatSelections(slug) { - if (!slug) return - setChatLibraryBySession(prev => { - let changed = false - const next = {} - for (const [sessionId, librarySlug] of Object.entries(prev || {})) { - if (librarySlug === slug) { - changed = true - continue - } - next[sessionId] = librarySlug - } - return changed ? next : prev - }) - } - - function clearChatLibrarySelections() { - setChatLibraryBySession({}) - } - - return { - chatLibrary, - chatLibraryBySession, - chatLibrarySlug, - chatLibraryStatusSuffix, - clearChatLibrarySelections, - getChatLibraryForSession, - isLibrarySyncing, - removeLibraryFromChatSelections, - setChatLibraryForSession, - } -} diff --git a/src/workflows/WorkflowConfirmationDialog.jsx b/src/workflows/WorkflowConfirmationDialog.jsx index 1d53039..221ad17 100644 --- a/src/workflows/WorkflowConfirmationDialog.jsx +++ b/src/workflows/WorkflowConfirmationDialog.jsx @@ -8,7 +8,7 @@ export default function WorkflowConfirmationDialog({ confirmation, onRespond })

Confirm workflow action

This workflow wants to run {confirmation.payload?.tool}.

- {args.library_slug &&

Destination: {args.library_slug}

} + {args.library_slug &&

Destination: Knowledge

} {args.title &&

Title: {args.title}

} {args.message_id &&

Message: {args.message_id}

} {args.url &&

URL: {args.url}

}