feat: add document bucket auto-creation, extension defaults, and chat widget on dashboard

Auto-create documents storage bucket on first upload. Default legacy general
extensions to enabled when no toggle row exists. Add ChatWidget to dashboard
root page with open-ai-chat event support and AI assistant quick action.
Add ensureInitialized to supplier invoices route for event emission.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Emil
2026-02-23 13:00:16 +01:00
co-authored by Claude Opus 4.6
parent 263c229903
commit ce66a21010
8 changed files with 86 additions and 7 deletions
+10 -4
View File
@@ -10,7 +10,6 @@ export function ChatWidget() {
const [isOpen, setIsOpen] = useState(false)
// Default to true for legacy compatibility (ai-chat defaults to enabled)
const [enabled, setEnabled] = useState(true)
const [loaded, setLoaded] = useState(false)
// Fetch initial toggle state
useEffect(() => {
@@ -22,8 +21,8 @@ export function ChatWidget() {
// Legacy: enabled by default when no toggle row exists
setEnabled(data?.enabled ?? true)
}
} finally {
setLoaded(true)
} catch {
// Keep default (enabled) on fetch failure
}
}
check()
@@ -42,7 +41,14 @@ export function ChatWidget() {
return () => window.removeEventListener('extension-toggle-changed', handler)
}, [])
if (!loaded || !enabled) return null
// Allow other components to open the chat via custom event
useEffect(() => {
const handler = () => setIsOpen(true)
window.addEventListener('open-ai-chat', handler)
return () => window.removeEventListener('open-ai-chat', handler)
}, [])
if (!enabled) return null
return (
<>