@@ -148,13 +148,45 @@ interface ChatInputProps {
148148
149149export const ChatInput : React . FC < ChatInputProps > = ( { data, isGlobal } ) => {
150150 const [ chatInput , setChatInput ] = useState ( '' ) ;
151+ const [ editor , setEditor ] = useState < monaco . editor . IStandaloneCodeEditor | null > ( null ) ;
151152 const [ showDropdown , setShowDropdown ] = useState ( false ) ;
152153
153154 // Handle content changes
154155 const handleEditorChange = useCallback ( ( value : string | undefined ) => {
155156 setChatInput ( value || '' ) ;
156157 } , [ ] ) ;
157158
159+ const handleAgentClick = useCallback ( ( agent : string ) => {
160+ let finalInput : string ;
161+ const currentInput = chatInput . trim ( ) ;
162+
163+ if ( ! currentInput ) {
164+ // Empty input - just set the agent
165+ finalInput = agent ;
166+ } else {
167+ // Check if input starts with an agent pattern
168+ const agentMatch = currentInput . match ( / ^ @ ( l o c a l | c o p i l o t ) \s * / ) ;
169+ if ( agentMatch ) {
170+ // Replace existing agent with the clicked one
171+ finalInput = agent + currentInput . substring ( agentMatch [ 0 ] . length ) ;
172+ } else {
173+ // No agent at start - prepend the clicked agent
174+ finalInput = agent + currentInput ;
175+ }
176+ }
177+
178+ setChatInput ( finalInput ) ;
179+ if ( editor ) {
180+ editor . focus ( ) ;
181+ // Position cursor at the end
182+ const model = editor . getModel ( ) ;
183+ if ( model ) {
184+ const position = model . getPositionAt ( finalInput . length ) ;
185+ editor . setPosition ( position ) ;
186+ }
187+ }
188+ } , [ chatInput , editor ] ) ;
189+
158190 const handleSendChat = useCallback ( ( ) => {
159191 if ( chatInput . trim ( ) ) {
160192 const trimmedInput = chatInput . trim ( ) ;
@@ -206,6 +238,8 @@ export const ChatInput: React.FC<ChatInputProps> = ({ data, isGlobal }) => {
206238
207239 // Setup editor instance when it mounts
208240 const handleEditorDidMount = useCallback ( ( editorInstance : monaco . editor . IStandaloneCodeEditor , monaco : Monaco ) => {
241+ setEditor ( editorInstance ) ;
242+
209243 // Auto-resize editor based on content
210244 const updateHeight = ( ) => {
211245 const model = editorInstance . getModel ( ) ;
@@ -346,7 +380,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({ data, isGlobal }) => {
346380 </ div >
347381 </ div >
348382
349- { isGlobal && < GlobalInstructions /> }
383+ { isGlobal && < GlobalInstructions onAgentClick = { handleAgentClick } /> }
350384
351385 < div className = "quick-actions" >
352386 { ! isGlobal && (
@@ -356,7 +390,15 @@ export const ChatInput: React.FC<ChatInputProps> = ({ data, isGlobal }) => {
356390 < strong > Reference issues:</ strong > Use the syntax < code > org/repo#123</ code > to start work on specific issues from any repository.
357391 </ p >
358392 < p >
359- < strong > Choose your agent:</ strong > Use < code > @local</ code > to work locally or < code > @copilot</ code > to use GitHub Copilot.
393+ < strong > Choose your agent:</ strong > Use < code
394+ style = { { cursor : 'pointer' } }
395+ onClick = { ( ) => handleAgentClick ( '@local ' ) }
396+ title = "Click to add @local to input"
397+ > @local</ code > to work locally or < code
398+ style = { { cursor : 'pointer' } }
399+ onClick = { ( ) => handleAgentClick ( '@copilot ' ) }
400+ title = "Click to add @copilot to input"
401+ > @copilot</ code > to use GitHub Copilot.
360402 </ p >
361403 < p >
362404 < strong > Mention projects:</ strong > You can talk about projects by name to work across multiple repositories.
0 commit comments