"""Patch ChatInput.tsx - Fixed import for DatasetUploadResponse.""" CHAT_INPUT = "/source/frontend/src/components/Chat/ChatInput.tsx" def patch(): import os, re if not os.path.exists(CHAT_INPUT): print(f"SKIP: {CHAT_INPUT} not found") return with open(CHAT_INPUT, "r", encoding="utf-8") as f: content = f.read() # 1. Add Button to MUI imports if "Button" not in content and "@mui/material" in content: content = content.replace( "import { Box, IconButton, Stack, Tooltip } from '@mui/material';", "import { Box, IconButton, Stack, Tooltip, Button } from '@mui/material';" ) # 2. Fix DatasetUploadResponse import - check existing imports if "DatasetUploadResponse" not in content: # Find existing import from types/agent if "from '@/types/agent'" in content: content = content.replace( "from '@/types/agent'", "from '@/types/agent'" ) # Add DatasetUploadResponse to existing import content = content.replace( "import type { ", "import type { DatasetUploadResponse, " ) else: content = content.replace( "import { apiFetch } from '@/utils/api';", "import { apiFetch } from '@/utils/api';\nimport type { DatasetUploadResponse } from '@/types/agent';" ) # 3. Add props to interface if "showAutoContinue" not in content: props_code = ''' interface ChatInputProps { sessionId: string; initialModelPath: string | null | undefined; onSend: (text: string) => Promise; onStop: () => void; onDatasetUploaded: () => Promise; isProcessing: boolean; disabled: boolean; placeholder?: string; showAutoContinue?: boolean; taskIncompleteInfo?: { incompletePlan: Array<{ id: string; content: string; status: string }> } | null; startAutoContinue?: () => void; cancelAutoContinue?: () => void; } ''' match = re.search(r'interface ChatInputProps[^}]*[}][^}]*[}]', content, re.DOTALL) if match: content = content.replace(match.group(0), props_code) else: content = content.replace( "export default function ChatInput", props_code + "\nexport default function ChatInput" ) # 4. Add auto-continue buttons before the flex box buttons_code = ''' {/* Auto-continue controls for free models */} {showAutoContinue && taskIncompleteInfo && ( )} ''' if "Tự động tiếp tục" not in content: content = content.replace( "