()
| 298 | } |
| 299 | |
| 300 | const TerminalDemo = () => { |
| 301 | const [terminalLines, setTerminalLines] = useState<React.ReactNode[]>([ |
| 302 | <TerminalOutput key="welcome"> |
| 303 | <span className="text-green-400 font-bold">Codebuff CLI v1.5.0</span> |
| 304 | <p>Interactive coding assistant that understands your entire codebase.</p> |
| 305 | <p> |
| 306 | Working directory:{' '} |
| 307 | <span className="text-blue-400">/my-demo-project</span> |
| 308 | </p> |
| 309 | <p> |
| 310 | Type <span className="text-yellow-400 font-bold">"help"</span> for a |
| 311 | list of commands or try a natural language request. |
| 312 | </p> |
| 313 | </TerminalOutput>, |
| 314 | ]) |
| 315 | const [previewContent, setPreviewContent] = |
| 316 | useState<string>(`<div style="padding: 16px; border-radius: 8px;"> |
| 317 | <h1 class="text-xl font-bold">👋 Welcome to the Codebuff Demo!</h1> |
| 318 | <p class="dim" style="margin-top: 16px;">Try these example prompts in the terminal:</p> |
| 319 | <div style="margin: 16px 0; padding: 16px; background: rgba(59,130,246,0.1); border-radius: 8px;"> |
| 320 | <p>🚀 <b>"Optimize performance"</b> - Speed up your application</p> |
| 321 | <p>🔄 <b>"Refactor auth flow"</b> - Improve code architecture</p> |
| 322 | <p>🌙 <b>"Add dark mode"</b> - Implement new feature</p> |
| 323 | <p>🐛 <b>"Fix memory leak"</b> - Resolve coding issues</p> |
| 324 | </div> |
| 325 | <p class="dim">Type <b>"help"</b> to see all available commands!</p> |
| 326 | <div style="margin-top: 16px; padding: 8px; background: rgba(74,222,128,0.1); border-radius: 4px; border-left: 3px solid rgba(74,222,128,0.5);"> |
| 327 | <p style="font-style: italic; font-size: 0.9em;">This is just a demo. Install Codebuff to experience the full capabilities with your own projects!</p> |
| 328 | </div>`) |
| 329 | const [showError, setShowError] = useState(FIX_BUG_FLAG) |
| 330 | |
| 331 | const isRainbow = false |
| 332 | const [previewTheme, setPreviewTheme] = useState<PreviewTheme>('default') |
| 333 | const [messages, setMessages] = useState<string[]>([]) |
| 334 | const [autoTypeIndex, setAutoTypeIndex] = useState(0) |
| 335 | const [isAutoTyping, setIsAutoTyping] = useState(false) |
| 336 | const exampleCommands = useRef([ |
| 337 | 'optimize performance', |
| 338 | 'fix memory leak', |
| 339 | 'refactor auth flow', |
| 340 | ]) |
| 341 | const terminalRef = useRef<HTMLDivElement>(null) |
| 342 | |
| 343 | const demoMutation = useMutation<DemoResponse, Error, string>({ |
| 344 | mutationFn: async (input: string) => { |
| 345 | const response = await fetch('/api/demo', { |
| 346 | method: 'POST', |
| 347 | headers: { 'Content-Type': 'application/json' }, |
| 348 | body: JSON.stringify({ |
| 349 | prompt: [...messages, input], |
| 350 | }), |
| 351 | }) |
| 352 | |
| 353 | if (!response.ok) { |
| 354 | const error = await response.json() |
| 355 | if (response.status === 429) { |
| 356 | throw new Error('Rate limit exceeded. Please try again in a minute.') |
| 357 | } |
nothing calls this directly
no test coverage detected