import { Box, Text, useInput } from "ink"; import React, { useEffect } from "react"; import { ColoredDiff } from "./ColoredDiff.js"; interface DiffViewerProps { diffContent: string; onClose: () => void; } /** * Full-screen diff viewer overlay * Shows diff content with syntax highlighting and allows closing with ESC */ export const DiffViewer: React.FC = ({ diffContent, onClose, }) => { // Handle ESC key to close the diff viewer useInput((input, key) => { if (key.escape) { onClose(); } }); // Auto-focus when component mounts useEffect(() => { // Component is already focused by default in Ink }, []); return ( {/* Header */} Git Diff (Press ESC to close) {/* Diff content - scrollable */} {diffContent.trim() ? ( ) : ( No changes to display )} {/* Footer */} ESC to close ); };