From 63023d486de2f7c5f49bd86ab015d00a7373ea47 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Wed, 1 Apr 2026 23:04:23 +0000 Subject: [PATCH] fix: resolve TypeScript errors from cockpit refactor (Phase 7) - Remove unused imports (ChatMessage, TaskLane) - Remove unused handleTaskSubmit and handleFlowPilotAnswer - Remove unused setActiveStepIndex setter - Add triage fields to AISessionDetail construction in useFlowPilotSession - npx tsc -b passes clean Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/hooks/useFlowPilotSession.ts | 5 ++ frontend/src/pages/AssistantChatPage.tsx | 66 ++--------------------- 2 files changed, 10 insertions(+), 61 deletions(-) diff --git a/frontend/src/hooks/useFlowPilotSession.ts b/frontend/src/hooks/useFlowPilotSession.ts index 873b3846..45dc9699 100644 --- a/frontend/src/hooks/useFlowPilotSession.ts +++ b/frontend/src/hooks/useFlowPilotSession.ts @@ -95,6 +95,11 @@ export function useFlowPilotSession(): UseFlowPilotSession { pending_task_lane: null, is_branching: false, active_branch_id: null, + client_name: null, + asset_name: null, + issue_category: null, + triage_hypothesis: null, + evidence_items: null, }) setAllSteps([firstStep]) setCurrentStep(firstStep) diff --git a/frontend/src/pages/AssistantChatPage.tsx b/frontend/src/pages/AssistantChatPage.tsx index 40668d69..57a4aa85 100644 --- a/frontend/src/pages/AssistantChatPage.tsx +++ b/frontend/src/pages/AssistantChatPage.tsx @@ -11,8 +11,9 @@ import { useBranching } from '@/hooks/useBranching' import { analytics } from '@/lib/analytics' import { toast } from '@/lib/toast' import { ChatSidebar, ChatSidebarCollapsedBar } from '@/components/assistant/ChatSidebar' -import { ChatMessage } from '@/components/assistant/ChatMessage' -import { TaskLane } from '@/components/assistant/TaskLane' +// ChatMessage and TaskLane kept in codebase but no longer imported here +// import { ChatMessage } from '@/components/assistant/ChatMessage' +// import { TaskLane } from '@/components/assistant/TaskLane' import { ConcludeSessionModal } from '@/components/assistant/ConcludeSessionModal' import { StatusUpdateModal } from '@/components/flowpilot/StatusUpdateModal' import { IncidentHeader } from '@/components/assistant/IncidentHeader' @@ -83,7 +84,7 @@ export default function AssistantChatPage() { const saved = localStorage.getItem('rf-assistant-work-zone-height') return saved ? parseFloat(saved) : 55 }) - const [activeStepIndex, setActiveStepIndex] = useState(0) + const [activeStepIndex] = useState(0) const splitContainerRef = useRef(null) const toggleSidebarCollapse = () => { const next = !sidebarCollapsed @@ -380,56 +381,6 @@ export default function AssistantChatPage() { } } - const handleTaskSubmit = async (responses: Array<{ type: string; state: string; value: string; text?: string; label?: string }>) => { - if (!activeChatId || loading) return - - // Format task responses into a structured message for the AI - const parts: string[] = [] - for (const r of responses) { - const name = r.type === 'question' ? `Q: ${r.text}` : r.label || 'Check' - if (r.state === 'done' && r.value.trim()) { - parts.push(`**${name}:**\n\`\`\`\n${r.value.trim()}\n\`\`\``) - } else if (r.state === 'skipped') { - parts.push(`**${name}:** _(skipped)_`) - } - } - const userMessage = parts.join('\n\n') - - setMessages(prev => [...prev, { role: 'user', content: userMessage }]) - setLoading(true) - - try { - const response = await aiSessionsApi.sendChatMessage(activeChatId, { message: userMessage }) - setMessages(prev => [ - ...prev, - { role: 'assistant', content: response.content, suggestedFlows: response.suggested_flows, fork: response.fork, actions: response.actions, questions: response.questions }, - ]) - if (response.fork && activeChatId) { - branching.loadBranches(activeChatId) - } - // Update task lane based on AI response - const hasQuestions = response.questions && response.questions.length > 0 - const hasActions = response.actions && response.actions.length > 0 - if (hasQuestions || hasActions) { - setActiveQuestions(response.questions || []) - setActiveActions(response.actions || []) - setShowTaskLane(true) - } else { - // AI sent no new tasks — clear the lane - setShowTaskLane(false) - setActiveQuestions([]) - setActiveActions([]) - } - } catch { - setMessages(prev => [ - ...prev, - { role: 'assistant', content: 'Sorry, something went wrong processing your responses. Please try again.' }, - ]) - } finally { - setLoading(false) - } - } - const handleConclude = async (outcome: ConclusionOutcome, _notes: string): Promise => { if (!activeChatId) throw new Error('No active chat') @@ -529,14 +480,7 @@ export default function AssistantChatPage() { } }, [activeChatId, triageMeta.evidence_items]) - const handleFlowPilotAnswer = useCallback((answer: string) => { - setInput(answer) - // Trigger send after a tick so the input state is set - setTimeout(() => { - const event = new KeyboardEvent('keydown', { key: 'Enter' }) - inputRef.current?.dispatchEvent(event) - }, 0) - }, []) + // Merge triage_update from AI response into local state const mergeTriageUpdate = useCallback((update: TriageUpdate) => {