import { basename, relative } from 'path';
import React from 'react';
import { Box, Text, Pane } from '@anthropic/ink';
import { getCwd } from '../utils/cwd.js';
import { isSupportedVSCodeTerminal } from '../utils/ide.js';
import { Select } from './CustomSelect/index.js';
import type {
PermissionOption,
PermissionOptionWithLabel,
} from './permissions/FilePermissionDialog/permissionOptions.js';
type Props = {
filePath: string;
input: A;
onChange: (option: PermissionOption, args: A, feedback?: string) => void;
options: PermissionOptionWithLabel[];
ideName: string;
symlinkTarget?: string | null;
rejectFeedback: string;
acceptFeedback: string;
setFocusedOption: (value: string) => void;
onInputModeToggle: (value: string) => void;
focusedOption: string;
yesInputMode: boolean;
noInputMode: boolean;
};
export function ShowInIDEPrompt({
onChange,
options,
input,
filePath,
ideName,
symlinkTarget,
rejectFeedback,
acceptFeedback,
setFocusedOption,
onInputModeToggle,
focusedOption,
yesInputMode,
noInputMode,
}: Props): React.ReactNode {
return (
Opened changes in {ideName} ⧉
{symlinkTarget && (
{relative(getCwd(), symlinkTarget).startsWith('..')
? `This will modify ${symlinkTarget} (outside working directory) via a symlink`
: `Symlink target: ${symlinkTarget}`}
)}
{isSupportedVSCodeTerminal() && Save file to continue…}
Do you want to make this edit to {basename(filePath)}?
Esc to cancel
{((focusedOption === 'yes' && !yesInputMode) || (focusedOption === 'no' && !noInputMode)) &&
' · Tab to amend'}
);
}