@@ -82,6 +82,9 @@ const useStyles = makeStyles({
8282 backgroundColor : 'var(--colorNeutralBackground2)' ,
8383 color : 'var(--colorNeutralForeground1)' ,
8484 maxWidth : '100%' ,
85+ width : '100%' ,
86+ boxSizing : 'border-box' ,
87+ overflowX : 'hidden' ,
8588 alignSelf : 'flex-start' ,
8689
8790 } ,
@@ -219,10 +222,10 @@ const renderAgentMessages = (
219222 />
220223 ) ,
221224 img : ( { node : _imgNode , ...props } ) => (
222- < div style = { { position : 'relative' , display : 'inline- block' , marginTop : '8px' } } >
225+ < div style = { { position : 'relative' , display : 'block' , width : '100%' , maxWidth : '100%' , marginTop : '8px' , overflow : 'hidden ' } } >
223226 < img
224227 { ...props }
225- style = { { maxWidth : '100%' , borderRadius : '8px ' , display : 'block ' } }
228+ style = { { display : 'block' , width : '100%' , maxWidth : '100%' , height : 'auto ' , borderRadius : '8px ' } }
226229 />
227230 < Button
228231 appearance = "subtle"
@@ -239,13 +242,27 @@ const renderAgentMessages = (
239242 color : 'white' ,
240243 borderRadius : '4px' ,
241244 } }
242- onClick = { ( ) => {
245+ onClick = { async ( ) => {
243246 const url = props . src ;
244- if ( url ) {
247+ if ( ! url ) return ;
248+ const filename = `ad-image-${ Date . now ( ) } .png` ;
249+ try {
250+ const response = await fetch ( url , { mode : 'cors' } ) ;
251+ if ( ! response . ok ) throw new Error ( `Failed to fetch image (${ response . status } )` ) ;
252+ const blob = await response . blob ( ) ;
253+ const blobUrl = URL . createObjectURL ( blob ) ;
254+ const link = document . createElement ( 'a' ) ;
255+ link . href = blobUrl ;
256+ link . download = filename ;
257+ document . body . appendChild ( link ) ;
258+ link . click ( ) ;
259+ document . body . removeChild ( link ) ;
260+ URL . revokeObjectURL ( blobUrl ) ;
261+ } catch ( err ) {
262+ // Fallback: trigger direct download (works for same-origin or CORS-enabled URLs)
245263 const link = document . createElement ( 'a' ) ;
246264 link . href = url ;
247- link . download = `ad-image-${ Date . now ( ) } .png` ;
248- link . target = '_blank' ;
265+ link . download = filename ;
249266 document . body . appendChild ( link ) ;
250267 link . click ( ) ;
251268 document . body . removeChild ( link ) ;
@@ -254,6 +271,38 @@ const renderAgentMessages = (
254271 title = "Download image"
255272 />
256273 </ div >
274+ ) ,
275+ p : ( { node : _pNode , ...props } ) => (
276+ < p { ...props } style = { { margin : '0 0 8px 0' } } />
277+ ) ,
278+ h1 : ( { node : _hNode , ...props } ) => (
279+ < h1 { ...props } style = { { fontSize : '20px' , fontWeight : 600 , margin : '16px 0 8px 0' , lineHeight : '1.3' } } />
280+ ) ,
281+ h2 : ( { node : _hNode , ...props } ) => (
282+ < h2 { ...props } style = { { fontSize : '17px' , fontWeight : 600 , margin : '14px 0 8px 0' , lineHeight : '1.3' } } />
283+ ) ,
284+ h3 : ( { node : _hNode , ...props } ) => (
285+ < h3 { ...props } style = { { fontSize : '15px' , fontWeight : 600 , margin : '12px 0 6px 0' , lineHeight : '1.3' } } />
286+ ) ,
287+ ul : ( { node : _ulNode , ...props } ) => (
288+ < ul { ...props } style = { { margin : '8px 0' , paddingLeft : '24px' } } />
289+ ) ,
290+ ol : ( { node : _olNode , ...props } ) => (
291+ < ol { ...props } style = { { margin : '8px 0' , paddingLeft : '24px' } } />
292+ ) ,
293+ li : ( { node : _liNode , ...props } ) => (
294+ < li { ...props } style = { { margin : '4px 0' , lineHeight : '1.5' } } />
295+ ) ,
296+ blockquote : ( { node : _bqNode , ...props } ) => (
297+ < blockquote
298+ { ...props }
299+ style = { {
300+ margin : '8px 0' ,
301+ padding : '8px 12px' ,
302+ borderLeft : '3px solid var(--colorNeutralStroke1)' ,
303+ color : 'var(--colorNeutralForeground2)'
304+ } }
305+ />
257306 )
258307 } }
259308 >
0 commit comments