Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.1 KB
Raw Blame
import React, { useState } from "react";
import { Box, Text, useInput } from "ink";

export function ConfirmDialog({ message, onConfirm, onCancel }) {
  const [selected, setSelected] = useState(1); // 0=yes, 1=no (default no)

  useInput((input, key) => {
    if (key.leftArrow || input === "y") setSelected(0);
    if (key.rightArrow || input === "n") setSelected(1);
    if (key.return) {
      if (selected === 0) onConfirm?.();
      else onCancel?.();
    }
    if (key.escape) onCancel?.();
  });

  return (
    <Box flexDirection="column" borderStyle="round" borderColor="yellow" padding={1}>
      <Text bold color="yellow">
        {message}
      </Text>
      <Box marginTop={1} gap={2}>
        <Text
          bold={selected === 0}
          color={selected === 0 ? "green" : undefined}
          inverse={selected === 0}
        >
          Yes
        </Text>
        <Text
          bold={selected === 1}
          color={selected === 1 ? "red" : undefined}
          inverse={selected === 1}
        >
          No
        </Text>
      </Box>
    </Box>
  );
}