refactor: Relocate handleClear Logic: Move the chat and diagram clearing logic to ChatPanel (or a Server Action) and have ChatInput call the onClearChat prop. Introduce a clearDiagram method in DiagramContext.

This commit is contained in:
dayuan.jiang
2025-03-27 08:09:22 +00:00
parent 7e0790d60f
commit 6c8b5c48a2
3 changed files with 16 additions and 10 deletions

View File

@@ -20,6 +20,7 @@ export default function ChatPanel() {
loadDiagram: onDisplayChart,
handleExport: onExport,
resolverRef,
clearDiagram,
} = useDiagram();
const onFetchChart = () => {
@@ -123,7 +124,10 @@ export default function ChatPanel() {
status={status}
onSubmit={onFormSubmit}
onChange={handleInputChange}
onClearChat={() => setMessages([])}
onClearChat={() => {
setMessages([]);
clearDiagram();
}}
files={files}
onFileChange={handleFileChange}
showHistory={showHistory}