@@ -2,7 +2,6 @@ import { useCallback, useEffect, useState } from "react"
22import { Edit } from "lucide-react"
33
44import { Button , StandardTooltip } from "@/components/ui"
5- import { vscode } from "@/utils/vscode"
65
76import { useAppTranslation } from "@src/i18n/TranslationContext"
87import { useExtensionState } from "@src/context/ExtensionStateContext"
@@ -12,8 +11,8 @@ const DEFAULT_FOLLOWUP_TIMEOUT_MS = 60000
1211const COUNTDOWN_INTERVAL_MS = 1000
1312
1413interface FollowUpSuggestProps {
15- suggestions ?: ( string | SuggestionItem ) [ ]
16- onSuggestionClick ?: ( answer : string , event ?: React . MouseEvent ) => void
14+ suggestions ?: SuggestionItem [ ]
15+ onSuggestionClick ?: ( suggestion : SuggestionItem , event ?: React . MouseEvent ) => void
1716 ts : number
1817 onUnmount ?: ( ) => void
1918}
@@ -67,18 +66,7 @@ export const FollowUpSuggest = ({ suggestions = [], onSuggestionClick, ts = 1, o
6766 onUnmount ,
6867 ] )
6968 const handleSuggestionClick = useCallback (
70- ( suggestion : string | SuggestionItem , event : React . MouseEvent ) => {
71- const suggestionText = typeof suggestion === "string" ? suggestion : suggestion . answer
72- const mode = typeof suggestion === "object" ? suggestion . mode : undefined
73-
74- // If there's a mode switch and it's not a shift-click (which just copies to input), switch modes first
75- if ( mode && ! event . shiftKey ) {
76- vscode . postMessage ( {
77- type : "mode" ,
78- text : mode ,
79- } )
80- }
81-
69+ ( suggestion : SuggestionItem , event : React . MouseEvent ) => {
8270 // Mark a suggestion as selected if it's not a shift-click (which just copies to input)
8371 if ( ! event . shiftKey ) {
8472 setSuggestionSelected ( true )
@@ -87,7 +75,9 @@ export const FollowUpSuggest = ({ suggestions = [], onSuggestionClick, ts = 1, o
8775 onUnmount ?.( )
8876 }
8977
90- onSuggestionClick ?.( suggestionText , event )
78+ // Pass the suggestion object to the parent component
79+ // The parent component will handle mode switching if needed
80+ onSuggestionClick ?.( suggestion , event )
9181 } ,
9282 [ onSuggestionClick , onUnmount ] ,
9383 )
@@ -100,18 +90,16 @@ export const FollowUpSuggest = ({ suggestions = [], onSuggestionClick, ts = 1, o
10090 return (
10191 < div className = "flex mb-2 flex-col h-full gap-2" >
10292 { suggestions . map ( ( suggestion , index ) => {
103- const suggestionText = typeof suggestion === "string" ? suggestion : suggestion . answer
104- const mode = typeof suggestion === "object" ? suggestion . mode : undefined
10593 const isFirstSuggestion = index === 0
10694
10795 return (
108- < div key = { `${ suggestionText } -${ ts } ` } className = "w-full relative group" >
96+ < div key = { `${ suggestion . answer } -${ ts } ` } className = "w-full relative group" >
10997 < Button
11098 variant = "outline"
11199 className = "text-left whitespace-normal break-words w-full h-auto py-3 justify-start pr-8"
112100 onClick = { ( event ) => handleSuggestionClick ( suggestion , event ) }
113- aria-label = { suggestionText } >
114- { suggestionText }
101+ aria-label = { suggestion . answer } >
102+ { suggestion . answer }
115103 { isFirstSuggestion && countdown !== null && ! suggestionSelected && (
116104 < span
117105 className = "ml-2 px-1.5 py-0.5 text-xs rounded-full bg-vscode-badge-background text-vscode-badge-foreground"
@@ -120,10 +108,10 @@ export const FollowUpSuggest = ({ suggestions = [], onSuggestionClick, ts = 1, o
120108 </ span >
121109 ) }
122110 </ Button >
123- { mode && (
111+ { suggestion . mode && (
124112 < div className = "absolute bottom-0 right-0 text-[10px] bg-vscode-badge-background text-vscode-badge-foreground px-1 py-0.5 border border-vscode-badge-background flex items-center gap-0.5" >
125113 < span className = "codicon codicon-arrow-right" style = { { fontSize : "8px" } } />
126- { mode }
114+ { suggestion . mode }
127115 </ div >
128116 ) }
129117 < StandardTooltip content = { t ( "chat:followUpSuggest.copyToInput" ) } >
@@ -132,7 +120,7 @@ export const FollowUpSuggest = ({ suggestions = [], onSuggestionClick, ts = 1, o
132120 onClick = { ( e ) => {
133121 e . stopPropagation ( )
134122 // Simulate shift-click by directly calling the handler with shiftKey=true.
135- onSuggestionClick ?.( suggestionText , { ...e , shiftKey : true } )
123+ onSuggestionClick ?.( suggestion , { ...e , shiftKey : true } )
136124 } } >
137125 < Button variant = "ghost" size = "icon" >
138126 < Edit />
0 commit comments