feat: integrate MinIO-backed user filesystem
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
import { getStatus, listSessions, wsManager } from '@/lib/api';
|
||||
import { useChatStore } from '@/lib/store';
|
||||
@ -37,6 +38,7 @@ function isSessionUpdatedEvent(data: WsEvent | Record<string, unknown>): data is
|
||||
}
|
||||
|
||||
export function AppRuntimeBridge() {
|
||||
const pathname = usePathname();
|
||||
const sessionId = useChatStore((state) => state.sessionId);
|
||||
const setSessions = useChatStore((state) => state.setSessions);
|
||||
const setWsStatus = useChatStore((state) => state.setWsStatus);
|
||||
@ -45,6 +47,7 @@ export function AppRuntimeBridge() {
|
||||
const ingestProcessEvent = useChatStore((state) => state.ingestProcessEvent);
|
||||
const statusCheckCleanupRef = React.useRef<(() => void) | null>(null);
|
||||
const statusCheckInFlightRef = React.useRef(false);
|
||||
const chatRuntimeEnabled = pathname === '/' || pathname.startsWith('/tasks') || pathname.startsWith('/notifications');
|
||||
|
||||
const loadSessions = React.useCallback(async () => {
|
||||
try {
|
||||
@ -73,15 +76,27 @@ export function AppRuntimeBridge() {
|
||||
}, [setBeaverReady]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!chatRuntimeEnabled) {
|
||||
return;
|
||||
}
|
||||
void loadSessions();
|
||||
}, [loadSessions]);
|
||||
}, [chatRuntimeEnabled, loadSessions]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!chatRuntimeEnabled) {
|
||||
wsManager.disconnect();
|
||||
setWsStatus('disconnected');
|
||||
setBeaverReady(null);
|
||||
return;
|
||||
}
|
||||
resetProcessState();
|
||||
wsManager.connect(sessionId);
|
||||
}, [resetProcessState, sessionId]);
|
||||
}, [chatRuntimeEnabled, resetProcessState, sessionId, setBeaverReady, setWsStatus]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!chatRuntimeEnabled) {
|
||||
return;
|
||||
}
|
||||
const unsubStatus = wsManager.onStatusChange((status) => {
|
||||
setWsStatus(status);
|
||||
if (status === 'connected') {
|
||||
@ -98,9 +113,12 @@ export function AppRuntimeBridge() {
|
||||
statusCheckCleanupRef.current = null;
|
||||
unsubStatus();
|
||||
};
|
||||
}, [scheduleStatusCheck, setBeaverReady, setWsStatus]);
|
||||
}, [chatRuntimeEnabled, scheduleStatusCheck, setBeaverReady, setWsStatus]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!chatRuntimeEnabled) {
|
||||
return;
|
||||
}
|
||||
const unsubMessage = wsManager.onMessage((data) => {
|
||||
if (isSessionUpdatedEvent(data)) {
|
||||
void loadSessions();
|
||||
@ -115,7 +133,7 @@ export function AppRuntimeBridge() {
|
||||
return () => {
|
||||
unsubMessage();
|
||||
};
|
||||
}, [ingestProcessEvent, loadSessions]);
|
||||
}, [chatRuntimeEnabled, ingestProcessEvent, loadSessions]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user