fix(desktop): DeerFlow UI — ChatArea refactor + ai-elements + dead CSS cleanup
ChatArea retry button uses setInput instead of direct sendToGateway, fix bootstrap spinner stuck for non-logged-in users, remove dead CSS (aurora-title/sidebar-open/quick-action-chips), add ai components (ReasoningBlock/StreamingText/ChatMode/ModelSelector/TaskProgress), add ClassroomPlayer + ResizableChatLayout + artifact panel Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
76
desktop/src/hooks/useClassroom.ts
Normal file
76
desktop/src/hooks/useClassroom.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* useClassroom — React hook wrapping the classroom store for component consumption.
|
||||
*
|
||||
* Provides a simplified interface for classroom generation and chat.
|
||||
*/
|
||||
|
||||
import { useCallback } from 'react';
|
||||
import {
|
||||
useClassroomStore,
|
||||
type GenerationRequest,
|
||||
} from '../store/classroomStore';
|
||||
import type {
|
||||
Classroom,
|
||||
ClassroomChatMessage,
|
||||
} from '../types/classroom';
|
||||
|
||||
export interface UseClassroomReturn {
|
||||
/** Is generation in progress */
|
||||
generating: boolean;
|
||||
/** Current generation stage name */
|
||||
progressStage: string | null;
|
||||
/** Progress percentage 0-100 */
|
||||
progressPercent: number;
|
||||
/** The active classroom */
|
||||
activeClassroom: Classroom | null;
|
||||
/** Chat messages for active classroom */
|
||||
chatMessages: ClassroomChatMessage[];
|
||||
/** Is a chat request loading */
|
||||
chatLoading: boolean;
|
||||
/** Error message, if any */
|
||||
error: string | null;
|
||||
/** Start classroom generation */
|
||||
startGeneration: (request: GenerationRequest) => Promise<string>;
|
||||
/** Cancel active generation */
|
||||
cancelGeneration: () => void;
|
||||
/** Send a chat message in the active classroom */
|
||||
sendChatMessage: (message: string, sceneContext?: string) => Promise<void>;
|
||||
/** Clear current error */
|
||||
clearError: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for classroom generation and multi-agent chat.
|
||||
*
|
||||
* Components should use this hook rather than accessing the store directly,
|
||||
* to keep the rendering logic decoupled from state management.
|
||||
*/
|
||||
export function useClassroom(): UseClassroomReturn {
|
||||
const {
|
||||
generating,
|
||||
progressStage,
|
||||
progressPercent,
|
||||
activeClassroom,
|
||||
chatMessages,
|
||||
chatLoading,
|
||||
error,
|
||||
startGeneration,
|
||||
cancelGeneration,
|
||||
sendChatMessage,
|
||||
clearError,
|
||||
} = useClassroomStore();
|
||||
|
||||
return {
|
||||
generating,
|
||||
progressStage,
|
||||
progressPercent,
|
||||
activeClassroom,
|
||||
chatMessages,
|
||||
chatLoading,
|
||||
error,
|
||||
startGeneration: useCallback((req: GenerationRequest) => startGeneration(req), [startGeneration]),
|
||||
cancelGeneration: useCallback(() => cancelGeneration(), [cancelGeneration]),
|
||||
sendChatMessage: useCallback((msg, ctx) => sendChatMessage(msg, ctx), [sendChatMessage]),
|
||||
clearError: useCallback(() => clearError(), [clearError]),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user