Skip to content

Commit b01e32c

Browse files
committed
pure refactor
1 parent 81ccd80 commit b01e32c

13 files changed

Lines changed: 226 additions & 251 deletions

packages/cli/src/ui/AppContainer.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ import { calculatePromptWidths } from './components/InputPrompt.js';
8686
import { useApp, useStdout, useStdin } from 'ink';
8787
import { calculateMainAreaWidth } from './utils/ui-sizing.js';
8888
import ansiEscapes from 'ansi-escapes';
89-
import * as fs from 'node:fs';
9089
import { basename } from 'node:path';
9190
import { computeTerminalTitle } from '../utils/windowTitle.js';
9291
import { useTextBuffer } from './components/shared/text-buffer.js';
@@ -466,14 +465,6 @@ export const AppContainer = (props: AppContainerProps) => {
466465

467466
const staticAreaMaxItemHeight = Math.max(terminalHeight * 4, 100);
468467

469-
const isValidPath = useCallback((filePath: string): boolean => {
470-
try {
471-
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
472-
} catch (_e) {
473-
return false;
474-
}
475-
}, []);
476-
477468
const getPreferredEditor = useCallback(
478469
() => settings.merged.general.preferredEditor as EditorType,
479470
[settings.merged.general.preferredEditor],
@@ -484,7 +475,7 @@ export const AppContainer = (props: AppContainerProps) => {
484475
viewport: { height: 10, width: inputWidth },
485476
stdin,
486477
setRawMode,
487-
isValidPath,
478+
escapePastedPaths: true,
488479
shellModeActive,
489480
getPreferredEditor,
490481
});

packages/cli/src/ui/auth/ApiAuthDialog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export function ApiAuthDialog({
4949
width: viewportWidth,
5050
height: 4,
5151
},
52-
isValidPath: () => false, // No path validation needed for API key
5352
inputFilter: (text) =>
5453
text.replace(/[^a-zA-Z0-9_-]/g, '').replace(/[\r\n]/g, ''),
5554
singleLine: true,

packages/cli/src/ui/components/AskUserDialog.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ const TextQuestionView: React.FC<TextQuestionViewProps> = ({
285285
initialText: initialAnswer,
286286
viewport: { width: Math.max(1, bufferWidth), height: 1 },
287287
singleLine: true,
288-
isValidPath: () => false,
289288
});
290289

291290
const { text: textValue } = buffer;
@@ -564,7 +563,6 @@ const ChoiceQuestionView: React.FC<ChoiceQuestionViewProps> = ({
564563
initialText: initialCustomText,
565564
viewport: { width: Math.max(1, bufferWidth), height: 1 },
566565
singleLine: true,
567-
isValidPath: () => false,
568566
});
569567

570568
const customOptionText = customBuffer.text;

packages/cli/src/ui/components/ConfigExtensionDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const ConfigExtensionDialog: React.FC<ConfigExtensionDialogProps> = ({
7070
initialText: '',
7171
viewport: { width: 80, height: 1 },
7272
singleLine: true,
73-
isValidPath: () => true,
73+
escapePastedPaths: true,
7474
});
7575

7676
const mounted = useRef(true);

packages/cli/src/ui/components/SettingsDialog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ export function SettingsDialog({
219219
width: viewportWidth,
220220
height: 1,
221221
},
222-
isValidPath: () => false,
223222
singleLine: true,
224223
onChange: (text) => setSearchQuery(text),
225224
});

packages/cli/src/ui/components/shared/performance.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('text-buffer performance', () => {
1919
const { result } = renderHook(() =>
2020
useTextBuffer({
2121
viewport,
22-
isValidPath: () => false,
2322
}),
2423
);
2524

@@ -52,7 +51,6 @@ describe('text-buffer performance', () => {
5251
useTextBuffer({
5352
initialText,
5453
viewport,
55-
isValidPath: () => false,
5654
}),
5755
);
5856

0 commit comments

Comments
 (0)