From ab44824e07832774b0a466536c0ca87e4f1482b1 Mon Sep 17 00:00:00 2001
From: Jacob Richman <jacob314@gmail.com>
Date: Sat, 7 Jun 2025 14:48:56 -0700
Subject: Auto insert @ when dragging and dropping files. (#812)

---
 packages/cli/src/ui/components/InputPrompt.tsx | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'packages/cli/src/ui/components/InputPrompt.tsx')

diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx
index b86f2a3f..534d7112 100644
--- a/packages/cli/src/ui/components/InputPrompt.tsx
+++ b/packages/cli/src/ui/components/InputPrompt.tsx
@@ -4,6 +4,7 @@
  * SPDX-License-Identifier: Apache-2.0
  */
 
+import * as fs from 'fs';
 import React, { useCallback, useEffect, useState } from 'react';
 import { Text, Box, useInput, useStdin } from 'ink';
 import { Colors } from '../colors.js';
@@ -58,11 +59,20 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
 
   const { stdin, setRawMode } = useStdin();
 
+  const isValidPath = useCallback((filePath: string): boolean => {
+    try {
+      return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
+    } catch (_e) {
+      return false;
+    }
+  }, []);
+
   const buffer = useTextBuffer({
     initialText: '',
     viewport: { height, width: effectiveWidth },
     stdin,
     setRawMode,
+    isValidPath,
   });
 
   const completion = useCompletion(
-- 
cgit v1.2.3

