MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / ExportDialog

Function ExportDialog

source code/components/ExportDialog.tsx:27–129  ·  view source on GitHub ↗
({
  content,
  defaultFilename,
  onDone
}: ExportDialogProps)

Source from the content-addressed store, hash-verified

25};
26type ExportOption = 'clipboard' | 'file';
27export function ExportDialog({
28 content,
29 defaultFilename,
30 onDone
31}: ExportDialogProps): React.ReactNode {
32 const [, setSelectedOption] = useState<ExportOption | null>(null);
33 const [filename, setFilename] = useState<string>(defaultFilename);
34 const [cursorOffset, setCursorOffset] = useState<number>(defaultFilename.length);
35 const [showFilenameInput, setShowFilenameInput] = useState(false);
36 const {
37 columns
38 } = useTerminalSize();
39
40 // Handle going back from filename input to option selection
41 const handleGoBack = useCallback(() => {
42 setShowFilenameInput(false);
43 setSelectedOption(null);
44 }, []);
45 const handleSelectOption = async (value: string): Promise<void> => {
46 if (value === 'clipboard') {
47 // Copy to clipboard immediately
48 const raw = await setClipboard(content);
49 if (raw) process.stdout.write(raw);
50 onDone({
51 success: true,
52 message: 'Conversation copied to clipboard'
53 });
54 } else if (value === 'file') {
55 setSelectedOption('file');
56 setShowFilenameInput(true);
57 }
58 };
59 const handleFilenameSubmit = () => {
60 const finalFilename = filename.endsWith('.txt') ? filename : filename.replace(/\.[^.]+$/, '') + '.txt';
61 const filepath = join(getCwd(), finalFilename);
62 try {
63 writeFileSync_DEPRECATED(filepath, content, {
64 encoding: 'utf-8',
65 flush: true
66 });
67 onDone({
68 success: true,
69 message: `Conversation exported to: ${filepath}`
70 });
71 } catch (error) {
72 onDone({
73 success: false,
74 message: `Failed to export conversation: ${error instanceof Error ? error.message : 'Unknown error'}`
75 });
76 }
77 };
78
79 // Dialog calls onCancel when Escape is pressed. If we are in the filename
80 // input sub-screen, go back to the option list instead of closing entirely.
81 const handleCancel = useCallback(() => {
82 if (showFilenameInput) {
83 handleGoBack();
84 } else {

Callers

nothing calls this directly

Calls 3

useTerminalSizeFunction · 0.85
useKeybindingFunction · 0.85
onDoneFunction · 0.50

Tested by

no test coverage detected