@@ -144,22 +144,27 @@ export class AgentSessionRenderer implements ICompressibleTreeRenderer<IAgentSes
144144 if ( typeof session . element . description === 'string' ) {
145145 template . description . textContent = session . element . description ;
146146 } else {
147- template . elementDisposable . add ( this . markdownRendererService . render ( session . element . description , {
147+ const descriptionMarkdown = this . markdownRendererService . render ( session . element . description , {
148148 sanitizerConfig : {
149149 replaceWithPlaintext : true ,
150150 allowedTags : {
151151 override : allowedChatMarkdownHtmlTags ,
152152 } ,
153153 allowedLinkSchemes : { augment : [ this . productService . urlProtocol ] }
154154 } ,
155- } , template . description ) ) ;
156-
157- // TODO@bpasero this is needed so that a user can click into a link of the session
158- // without opening the session itself. Revisit this approach as we want to move
159- // away from allowing different results based on where the user clicks.
160- template . elementDisposable . add ( addDisposableListener ( template . description , EventType . MOUSE_DOWN , e => e . stopPropagation ( ) ) ) ;
161- template . elementDisposable . add ( addDisposableListener ( template . description , EventType . CLICK , e => e . stopPropagation ( ) ) ) ;
162- template . elementDisposable . add ( addDisposableListener ( template . description , EventType . AUXCLICK , e => e . stopPropagation ( ) ) ) ;
155+ } , template . description ) ;
156+ template . elementDisposable . add ( descriptionMarkdown ) ;
157+
158+ // Prevent link clicks from opening the session itself
159+ // by stopping propagation of mouse events from links
160+ // within (TODO@bpasero revisit this in the future).
161+ // eslint-disable-next-line no-restricted-syntax
162+ const anchors = descriptionMarkdown . element . querySelectorAll ( 'a' ) ;
163+ for ( const anchor of anchors ) {
164+ template . elementDisposable . add ( addDisposableListener ( anchor , EventType . MOUSE_DOWN , e => e . stopPropagation ( ) ) ) ;
165+ template . elementDisposable . add ( addDisposableListener ( anchor , EventType . CLICK , e => e . stopPropagation ( ) ) ) ;
166+ template . elementDisposable . add ( addDisposableListener ( anchor , EventType . AUXCLICK , e => e . stopPropagation ( ) ) ) ;
167+ }
163168 }
164169
165170 // Status (updated every minute)
0 commit comments