MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / handleInput

Function handleInput

web/src/components/TerminalDemo.tsx:449–950  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

447
448 // Handle various input commands
449 const handleInput = async (input: string) => {
450 const cleanInput = input.trim().toLowerCase()
451
452 // Add the user's command to the terminal
453 setTerminalLines((prev) => [
454 ...prev,
455 <TerminalOutput key={`user-cmd-${Date.now()}`} className="text-wrap">
456 {'>'} {input}
457 </TerminalOutput>,
458 ])
459
460 match(cleanInput)
461 .with('help', () => {
462 posthog.capture(AnalyticsEvent.DEMO_TERMINAL_HELP_VIEWED)
463 setTerminalLines((prev) => [
464 ...prev,
465 <TerminalOutput key={`help-${Date.now()}`}>
466 <div className="bg-zinc-800/50 p-3 rounded-md border border-zinc-700/50 my-2">
467 <p className="text-yellow-400 font-bold mb-2">
468 CODEBUFF COMMANDS:
469 </p>
470 <p className="mb-1">
471 • <span className="text-blue-400">"optimize performance"</span>{' '}
472 - Speed up your application
473 </p>
474 <p className="mb-1">
475 • <span className="text-blue-400">"refactor auth flow"</span> -
476 Improve code organization
477 </p>
478 <p className="mb-1">
479 • <span className="text-blue-400">"add dark mode"</span> -
480 Implement a new feature
481 </p>
482 <p className="mb-1">
483 • <span className="text-blue-400">"fix memory leak"</span> -
484 Resolve coding issues
485 </p>
486 <p className="mb-1">
487 • <span className="text-blue-400">"change theme"</span> - Change
488 the preview theme
489 </p>
490 <p className="mt-3 text-green-400">
491 ℹ️ This is a demo with limited functionality. Install Codebuff
492 for full capabilities:
493 </p>
494 <p className="font-mono bg-black/30 p-2 rounded text-white/90 mt-1">
495 npm install -g codebuff
496 </p>
497 </div>
498 </TerminalOutput>,
499 ])
500 })
501 .with(
502 P.string.includes('optimize'),
503 P.string.includes('performance'),
504 () => {
505 posthog.capture(AnalyticsEvent.DEMO_TERMINAL_OPTIMIZE_REQUESTED)
506 const response = SAMPLE_RESPONSES.optimize

Callers 1

TerminalDemoFunction · 0.85

Calls 3

getRandomFilesFunction · 0.85
setTimeoutFunction · 0.85
captureMethod · 0.80

Tested by

no test coverage detected