# Code coverage report for src/components/features/python-runner/PythonTerminal.tsx

# All files / src/components/features/python-runner PythonTerminal.tsx

100% Statements 57/57
100% Branches 3/3
100% Functions 2/2
100% Lines 57/57

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    581x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    29x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
    31x
     'use client'

    import { useRef, useEffect } from 'react'
    import { usePythonTerminal } from '@/hooks/usePythonTerminal'
    import { TerminalHeader } from '@/components/features/python-runner/TerminalHeader'
    import { TerminalOutput } from '@/components/features/python-runner/TerminalOutput'
    import { TerminalInput } from '@/components/features/python-runner/TerminalInput'

    interface PythonTerminalProps {
      code: string
    }

    export function PythonTerminal({ code }: PythonTerminalProps) {
      const {
        lines,
        isRunning,
        isInitializing,
        inputValue,
        waitingForInput,
        setInputValue,
        handleInputSubmit,
        handleRun,
      } = usePythonTerminal()

      const terminalEndRef = useRef<HTMLDivElement>(null)

      useEffect(() => {
        terminalEndRef.current?.scrollIntoView({ behavior: 'smooth' })
      }, [lines])

      return (
        <div className="flex flex-col h-full bg-card" data-testid="python-terminal">
          <TerminalHeader
            onRun={() => handleRun(code)}
            isRunning={isRunning}
            isInitializing={isInitializing}
            waitingForInput={waitingForInput}
          />

          <div
            className="flex-1 overflow-auto p-4 font-mono text-sm bg-background/50"
            data-testid="terminal-output-area"
            role="region"
            aria-label="Terminal output"
          >
            <TerminalOutput lines={lines} isRunning={isRunning} />
            <TerminalInput
              waitingForInput={waitingForInput}
              inputValue={inputValue}
              onInputChange={setInputValue}
              onSubmit={handleInputSubmit}
            />
            <div ref={terminalEndRef} />
          </div>
        </div>
      )
    }