@@ -171,6 +171,10 @@ export const ChatRowContent = ({
171171 const [ editMode , setEditMode ] = useState < Mode > ( mode || "code" )
172172 const [ editImages , setEditImages ] = useState < string [ ] > ( [ ] )
173173
174+ // State for editing subtask instructions
175+ const [ isEditingSubtask , setIsEditingSubtask ] = useState ( false )
176+ const [ editedSubtaskContent , setEditedSubtaskContent ] = useState ( "" )
177+
174178 // Handle message events for image selection during edit mode
175179 useEffect ( ( ) => {
176180 const handleMessage = ( event : MessageEvent ) => {
@@ -815,6 +819,30 @@ export const ChatRowContent = ({
815819 </ >
816820 )
817821 case "newTask" :
822+ // Handle edit button click for subtask
823+ const handleEditSubtaskClick = ( ) => {
824+ setIsEditingSubtask ( true )
825+ setEditedSubtaskContent ( tool . content || "" )
826+ }
827+
828+ // Handle cancel edit for subtask
829+ const handleCancelEditSubtask = ( ) => {
830+ setIsEditingSubtask ( false )
831+ setEditedSubtaskContent ( tool . content || "" )
832+ }
833+
834+ // Handle save edit for subtask
835+ const handleSaveEditSubtask = ( ) => {
836+ setIsEditingSubtask ( false )
837+ // Send edited subtask content to backend
838+ vscode . postMessage ( {
839+ type : "submitEditedSubtask" ,
840+ messageTs : message . ts ,
841+ editedSubtaskContent : editedSubtaskContent ,
842+ mode : tool . mode ,
843+ } )
844+ }
845+
818846 return (
819847 < >
820848 < div style = { headerStyle } >
@@ -828,13 +856,15 @@ export const ChatRowContent = ({
828856 </ span >
829857 </ div >
830858 < div
859+ className = "group"
831860 style = { {
832861 marginTop : "4px" ,
833862 backgroundColor : "var(--vscode-badge-background)" ,
834863 border : "1px solid var(--vscode-badge-background)" ,
835864 borderRadius : "4px 4px 0 0" ,
836865 overflow : "hidden" ,
837866 marginBottom : "2px" ,
867+ position : "relative" ,
838868 } } >
839869 < div
840870 style = { {
@@ -846,13 +876,64 @@ export const ChatRowContent = ({
846876 color : "var(--vscode-badge-foreground)" ,
847877 display : "flex" ,
848878 alignItems : "center" ,
849- gap : "6px " ,
879+ justifyContent : "space-between " ,
850880 } } >
851- < span className = "codicon codicon-arrow-right" > </ span >
852- { t ( "chat:subtasks.newTaskContent" ) }
881+ < div style = { { display : "flex" , alignItems : "center" , gap : "6px" } } >
882+ < span className = "codicon codicon-arrow-right" > </ span >
883+ { t ( "chat:subtasks.newTaskContent" ) }
884+ </ div >
885+ { /* Edit button for subtask instructions */ }
886+ { message . type === "ask" && ! isStreaming && ! isEditingSubtask && (
887+ < div
888+ className = "cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity"
889+ onClick = { ( e ) => {
890+ e . stopPropagation ( )
891+ handleEditSubtaskClick ( )
892+ } }
893+ title = { t ( "chat:editSubtaskInstructions" ) }
894+ style = { {
895+ padding : "2px 4px" ,
896+ borderRadius : "3px" ,
897+ display : "flex" ,
898+ alignItems : "center" ,
899+ gap : "4px" ,
900+ } } >
901+ < Edit className = "w-4 h-4" aria-label = "Edit subtask instructions" />
902+ </ div >
903+ ) }
853904 </ div >
854905 < div style = { { padding : "12px 16px" , backgroundColor : "var(--vscode-editor-background)" } } >
855- < MarkdownBlock markdown = { tool . content } />
906+ { isEditingSubtask ? (
907+ < div className = "flex flex-col gap-2" >
908+ < textarea
909+ value = { editedSubtaskContent }
910+ onChange = { ( e ) => setEditedSubtaskContent ( e . target . value ) }
911+ className = "w-full p-2 border border-vscode-input-border bg-vscode-input-background text-vscode-input-foreground rounded"
912+ style = { {
913+ minHeight : "200px" ,
914+ resize : "vertical" ,
915+ fontFamily : "var(--vscode-editor-font-family)" ,
916+ fontSize : "var(--vscode-editor-font-size)" ,
917+ } }
918+ placeholder = { t ( "chat:editSubtaskInstructions.placeholder" ) }
919+ autoFocus
920+ />
921+ < div className = "flex gap-2 justify-end" >
922+ < button
923+ onClick = { handleCancelEditSubtask }
924+ className = "px-3 py-1 rounded bg-vscode-button-secondaryBackground text-vscode-button-secondaryForeground hover:bg-vscode-button-secondaryHoverBackground" >
925+ { t ( "chat:cancel" ) }
926+ </ button >
927+ < button
928+ onClick = { handleSaveEditSubtask }
929+ className = "px-3 py-1 rounded bg-vscode-button-background text-vscode-button-foreground hover:bg-vscode-button-hoverBackground" >
930+ { t ( "chat:save" ) }
931+ </ button >
932+ </ div >
933+ </ div >
934+ ) : (
935+ < MarkdownBlock markdown = { tool . content } />
936+ ) }
856937 </ div >
857938 </ div >
858939 </ >
0 commit comments