@@ -160,6 +160,17 @@ const Ask: React.FC<AskProps> = ({
160160 inputRef . current . focus ( ) ;
161161 }
162162 } ;
163+ const downloadresponse = ( ) => {
164+ const blob = new Blob ( [ response ] , { type : 'text/markdown' } ) ;
165+ const url = URL . createObjectURL ( blob ) ;
166+ const a = document . createElement ( 'a' ) ;
167+ a . href = url ;
168+ a . download = `response-${ new Date ( ) . toISOString ( ) . slice ( 0 , 19 ) . replace ( / : / g, '-' ) } .md` ;
169+ document . body . appendChild ( a ) ;
170+ a . click ( ) ;
171+ document . body . removeChild ( a ) ;
172+ URL . revokeObjectURL ( url ) ;
173+ }
163174
164175 // Function to check if research is complete based on response content
165176 const checkIfResearchComplete = ( content : string ) : boolean => {
@@ -763,6 +774,19 @@ const Ask: React.FC<AskProps> = ({
763774 </ div >
764775 ) }
765776
777+ < div className = "flex items-center space-x-2" >
778+ { /* Download button */ }
779+ < button
780+ onClick = { downloadresponse }
781+ className = "text-xs text-gray-500 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 px-2 py-1 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 flex items-center gap-1"
782+ title = "Download response as markdown file"
783+ >
784+ < svg className = "w-3 h-3" fill = "none" viewBox = "0 0 24 24" stroke = "currentColor" >
785+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 } d = "M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
786+ </ svg >
787+ Download
788+ </ button >
789+
766790 { /* Clear button */ }
767791 < button
768792 id = "ask-clear-conversation"
@@ -772,6 +796,7 @@ const Ask: React.FC<AskProps> = ({
772796 Clear conversation
773797 </ button >
774798 </ div >
799+ </ div >
775800 </ div >
776801 ) }
777802
0 commit comments