@@ -10,12 +10,13 @@ import {
1010 addContextualItemAction ,
1111 updateSelectorStateAction ,
1212 clearContextualStateAction ,
13+ ContextualItem ,
1314} from '@/common/state/atoms/contextualSelector' ;
14- import { ContextualSelector , ContextualItem } from '../ContextualSelector' ;
15+ import { ContextualSelector } from '../ContextualSelector' ;
1516import { MessageAttachments } from './MessageAttachments' ;
1617import { ImagePreviewInline } from './ImagePreviewInline' ;
1718import { getAgentTitle , isContextualSelectorEnabled } from '@/config/web-ui-config' ;
18- import { composeMessageContent , isMessageEmpty } from './utils' ;
19+ import { composeMessageContent , isMessageEmpty , parseContextualReferences } from './utils' ;
1920
2021interface ChatInputProps {
2122 onSubmit : ( content : string | ChatCompletionContentPart [ ] ) => Promise < void > ;
@@ -85,9 +86,6 @@ export const ChatInput: React.FC<ChatInputProps> = ({
8586 }
8687 } , [ initialValue , contextualState . input , setContextualState ] ) ;
8788
88- // Remove the effect that keeps images during processing
89- // Images should be cleared immediately after sending
90-
9189 useEffect ( ( ) => {
9290 if ( ! isDisabled && autoFocus && inputRef . current ) {
9391 inputRef . current . focus ( ) ;
@@ -146,35 +144,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({
146144 } ;
147145
148146 // Parse contextual references from input text
149- const parseContextualReferences = ( text : string ) : ContextualItem [ ] => {
150- const contextualReferencePattern = / @ ( f i l e | d i r ) : ( [ ^ \s ] + ) / g;
151- const workspacePattern = / @ w o r k s p a c e / g;
152-
153- const contextualRefs = Array . from ( text . matchAll ( contextualReferencePattern ) ) . map (
154- ( match , index ) => {
155- const [ fullMatch , type , relativePath ] = match ;
156- const name = relativePath . split ( / [ / \\ ] / ) . pop ( ) || relativePath ;
157-
158- return {
159- id : `${ type } -${ relativePath } -${ index } ` ,
160- type : type as 'file' | 'directory' ,
161- name,
162- path : relativePath ,
163- relativePath,
164- } ;
165- } ,
166- ) ;
167-
168- const workspaceRefs = Array . from ( text . matchAll ( workspacePattern ) ) . map ( ( match , index ) => ( {
169- id : `workspace-${ index } ` ,
170- type : 'workspace' as const ,
171- name : 'workspace' ,
172- path : '/' ,
173- relativePath : '.' ,
174- } ) ) ;
175147
176- return [ ...contextualRefs , ...workspaceRefs ] ;
177- } ;
178148
179149 const handleContextualSelect = ( item : ContextualItem ) => {
180150 addContextualItem ( item ) ;
0 commit comments