({
status = "idle",
explanation,
mapping,
diagram,
cost,
}: LoadingProps)
| 78 | }; |
| 79 | |
| 80 | export default function Loading({ |
| 81 | status = "idle", |
| 82 | explanation, |
| 83 | mapping, |
| 84 | diagram, |
| 85 | cost, |
| 86 | }: LoadingProps) { |
| 87 | const [currentMessageIndex, setCurrentMessageIndex] = useState(0); |
| 88 | const scrollRef = useRef<HTMLDivElement>(null); |
| 89 | |
| 90 | useEffect(() => { |
| 91 | const interval = setInterval(() => { |
| 92 | setCurrentMessageIndex((prevIndex) => (prevIndex + 1) % messages.length); |
| 93 | }, 3000); |
| 94 | |
| 95 | return () => clearInterval(interval); |
| 96 | }, []); |
| 97 | |
| 98 | // Auto-scroll effect |
| 99 | useEffect(() => { |
| 100 | if (scrollRef.current) { |
| 101 | scrollRef.current.scrollTop = scrollRef.current.scrollHeight; |
| 102 | } |
| 103 | }, [explanation, mapping, diagram]); |
| 104 | |
| 105 | const shouldShowReasoning = (currentStatus: string) => { |
| 106 | if ( |
| 107 | currentStatus === "explanation_sent" || |
| 108 | (currentStatus.startsWith("explanation") && !explanation) |
| 109 | ) { |
| 110 | return "explanation"; |
| 111 | } |
| 112 | if ( |
| 113 | currentStatus === "mapping_sent" || |
| 114 | (currentStatus.startsWith("mapping") && !mapping) |
| 115 | ) { |
| 116 | return "mapping"; |
| 117 | } |
| 118 | if ( |
| 119 | currentStatus === "diagram_sent" || |
| 120 | (currentStatus.startsWith("diagram") && !diagram) |
| 121 | ) { |
| 122 | return "diagram"; |
| 123 | } |
| 124 | return null; |
| 125 | }; |
| 126 | |
| 127 | const renderReasoningMessage = () => { |
| 128 | const reasoningType = shouldShowReasoning(status); |
| 129 | switch (reasoningType) { |
| 130 | case "explanation": |
| 131 | return "Model is analyzing the repository structure and codebase..."; |
| 132 | case "mapping": |
| 133 | return "Model is identifying component relationships and dependencies..."; |
| 134 | case "diagram": |
| 135 | return "Model is planning the diagram layout and connections..."; |
| 136 | default: |
| 137 | return null; |
nothing calls this directly
no test coverage detected