diff options
Diffstat (limited to 'packages/cli/src/ui/hooks')
| -rw-r--r-- | packages/cli/src/ui/hooks/atCommandProcessor.ts | 12 | ||||
| -rw-r--r-- | packages/cli/src/ui/hooks/useInputHistory.ts | 10 |
2 files changed, 16 insertions, 6 deletions
diff --git a/packages/cli/src/ui/hooks/atCommandProcessor.ts b/packages/cli/src/ui/hooks/atCommandProcessor.ts index 2d93d1cb..50e81589 100644 --- a/packages/cli/src/ui/hooks/atCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/atCommandProcessor.ts @@ -106,16 +106,25 @@ export async function handleAtCommand({ // Add the original user query to history first addItem({ type: 'user', text: query }, userMessageTimestamp); + // If the atPath is just "@", pass the original query to the LLM + if (atPath === '@') { + setDebugMessage('Lone @ detected, passing directly to LLM.'); + return { processedQuery: [{ text: query }], shouldProceed: true }; + } + const pathPart = atPath.substring(1); // Remove leading '@' + // This error condition is for cases where pathPart becomes empty *after* the initial "@" check, + // which is unlikely with the current parser but good for robustness. if (!pathPart) { addItem( - { type: 'error', text: 'Error: No path specified after @.' }, + { type: 'error', text: 'Error: No valid path specified after @ symbol.' }, userMessageTimestamp, ); return { processedQuery: null, shouldProceed: false }; } + const contentLabel = pathPart; const toolRegistry = config.getToolRegistry(); const readManyFilesTool = toolRegistry.getTool('read_many_files'); @@ -129,7 +138,6 @@ export async function handleAtCommand({ // Determine path spec (file or directory glob) let pathSpec = pathPart; - const contentLabel = pathPart; try { const absolutePath = path.resolve(config.getTargetDir(), pathPart); const stats = await fs.stat(absolutePath); diff --git a/packages/cli/src/ui/hooks/useInputHistory.ts b/packages/cli/src/ui/hooks/useInputHistory.ts index 21d7b9bf..f8c873f1 100644 --- a/packages/cli/src/ui/hooks/useInputHistory.ts +++ b/packages/cli/src/ui/hooks/useInputHistory.ts @@ -4,13 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { useState, useCallback } from 'react'; +import { useCallback, useState } from 'react'; import { useInput } from 'ink'; interface UseInputHistoryProps { userMessages: readonly string[]; onSubmit: (value: string) => void; isActive: boolean; + query: string; + setQuery: React.Dispatch<React.SetStateAction<string>>; } interface UseInputHistoryReturn { @@ -25,8 +27,9 @@ export function useInputHistory({ userMessages, onSubmit, isActive, + query, + setQuery, }: UseInputHistoryProps): UseInputHistoryReturn { - const [query, setQuery] = useState(''); const [historyIndex, setHistoryIndex] = useState<number>(-1); const [originalQueryBeforeNav, setOriginalQueryBeforeNav] = useState<string>(''); @@ -41,9 +44,8 @@ export function useInputHistory({ (value: string) => { const trimmedValue = value.trim(); if (trimmedValue) { - onSubmit(trimmedValue); + onSubmit(trimmedValue); // This will call handleFinalSubmit, which then calls setQuery('') from App.tsx } - setQuery(''); resetHistoryNav(); }, [onSubmit, resetHistoryNav], |
