@@ -151,19 +151,37 @@ export class GlCommitDetails extends GlDetailsBase {
151151 > </ commit-identity >
152152 ` ,
153153 ) }
154- < div class ="message-block ">
154+ < div >
155+ < div class ="message-block ">
156+ ${ when (
157+ index === - 1 ,
158+ ( ) =>
159+ html `< p class ="message-block__text scrollable " data-region ="message ">
160+ < strong > ${ unsafeHTML ( message ) } </ strong >
161+ </ p > ` ,
162+ ( ) =>
163+ html `< p class ="message-block__text scrollable " data-region ="message ">
164+ < strong > ${ unsafeHTML ( message . substring ( 0 , index ) ) } </ strong > < br /> < span
165+ > ${ unsafeHTML ( message . substring ( index + 3 ) ) } </ span
166+ >
167+ </ p > ` ,
168+ ) }
169+ </ div >
155170 ${ when (
156- index === - 1 ,
157- ( ) =>
158- html `< p class ="message-block__text scrollable " data-region ="message ">
159- < strong > ${ unsafeHTML ( message ) } </ strong >
160- </ p > ` ,
161- ( ) =>
162- html `< p class ="message-block__text scrollable " data-region ="message ">
163- < strong > ${ unsafeHTML ( message . substring ( 0 , index ) ) } </ strong > < br /> < span
164- > ${ unsafeHTML ( message . substring ( index + 3 ) ) } </ span
165- >
166- </ p > ` ,
171+ this . state ?. orgSettings . ai !== false ,
172+ ( ) => html `
173+ < div class ="message-block-actions ">
174+ < action-item
175+ label ="Explain this ${ this . isStash ? 'Stash' : 'Commit' } "
176+ icon ="sparkle "
177+ data-action ="explain-commit "
178+ aria-busy ="${ this . explainBusy ? 'true' : nothing } "
179+ ?disabled ="${ this . explainBusy ? true : nothing } "
180+ @click =${ this . onExplainChanges }
181+ @keydown =${ this . onExplainChanges }
182+ > </ action-item >
183+ </ div >
184+ ` ,
167185 ) }
168186 </ div >
169187 </ div >
@@ -429,59 +447,6 @@ export class GlCommitDetails extends GlDetailsBase {
429447 ` ;
430448 }
431449
432- private renderExplainAi ( ) {
433- if ( this . state ?. orgSettings . ai === false ) return undefined ;
434-
435- const markdown =
436- this . explain ?. result != null ? `${ this . explain . result . summary } \n\n${ this . explain . result . body } ` : undefined ;
437-
438- // TODO: add loading and response states
439- return html `
440- < webview-pane collapsable data-region ="explain-pane ">
441- < span slot ="title "> Explain (AI)</ span >
442- < action-nav slot ="actions ">
443- < action-item
444- data-action ="switch-ai "
445- label ="Switch AI Provider/Model "
446- icon ="arrow-swap "
447- > </ action-item >
448- </ action-nav >
449-
450- < div class ="section ">
451- < p > Let AI assist in understanding the changes made with this commit.</ p >
452- < p class ="button-container ">
453- < span class ="button-group button-group--single ">
454- < gl-button
455- full
456- class ="button--busy "
457- data-action ="explain-commit "
458- aria-busy ="${ this . explainBusy ? 'true' : nothing } "
459- @click =${ this . onExplainChanges }
460- @keydown =${ this . onExplainChanges }
461- > < code-icon icon ="loading " modifier ="spin " slot ="prefix "> </ code-icon > Explain
462- Changes</ gl-button
463- >
464- </ span >
465- </ p >
466- ${ markdown
467- ? html `< div class ="ai-content " data-region ="commit-explanation ">
468- < gl-markdown
469- class ="ai-content__summary scrollable "
470- markdown ="${ markdown } "
471- > </ gl-markdown >
472- </ div > `
473- : this . explain ?. error
474- ? html `< div class ="ai-content has-error " data-region ="commit-explanation ">
475- < p class ="ai-content__summary scrollable ">
476- ${ this . explain . error . message ?? 'Error retrieving content' }
477- </ p >
478- </ div > `
479- : undefined }
480- </ div >
481- </ webview-pane >
482- ` ;
483- }
484-
485450 override render ( ) : unknown {
486451 if ( this . state ?. commit == null ) {
487452 return this . renderEmptyContent ( ) ;
@@ -495,7 +460,6 @@ export class GlCommitDetails extends GlDetailsBase {
495460 this . isStash ? 'stash' : 'commit' ,
496461 this . renderCommitStats ( this . state . commit . stats ) ,
497462 ) }
498- ${ this . renderExplainAi ( ) }
499463 </ webview-pane-group >
500464 ` ;
501465 }
0 commit comments