@@ -3,8 +3,10 @@ import { customElement, property, state } from 'lit/decorators.js';
33import { unsafeHTML } from 'lit/directives/unsafe-html.js' ;
44import { when } from 'lit/directives/when.js' ;
55import type { Autolink } from '../../../../autolinks/models/autolinks' ;
6+ import type { ExplainWipCommandArgs } from '../../../../commands/explainWip' ;
67import type { IssueOrPullRequest } from '../../../../git/models/issueOrPullRequest' ;
78import type { PullRequestShape } from '../../../../git/models/pullRequest' ;
9+ import { createCommandLink } from '../../../../system/commands' ;
810import type { Serialized } from '../../../../system/serialize' ;
911import type { State } from '../../../commitDetails/protocol' ;
1012import { messageHeadlineSplitterToken } from '../../../commitDetails/protocol' ;
@@ -120,6 +122,37 @@ export class GlCommitDetails extends GlDetailsBase {
120122 ` ;
121123 }
122124
125+ private renderExplainChanges ( ) {
126+ if ( this . state ?. orgSettings . ai === false || this . state ?. preferences . aiEnabled === false ) return undefined ;
127+
128+ if ( this . isUncommitted ) {
129+ return html `
130+ < gl-action-chip
131+ label ="Explain Working Changes "
132+ icon ="sparkle "
133+ data-action ="explain-commit "
134+ aria-busy ="${ this . explainBusy ? 'true' : nothing } "
135+ ?disabled ="${ this . explainBusy ? true : nothing } "
136+ @click =${ this . onExplainChanges }
137+ @keydown =${ this . onExplainChanges }
138+ > < span > explain</ span > </ gl-action-chip
139+ >
140+ ` ;
141+ }
142+ return html `
143+ < gl-action-chip
144+ label ="Explain this ${ this . isStash ? 'Stash' : 'Commit' } "
145+ icon ="sparkle "
146+ data-action ="explain-commit "
147+ aria-busy ="${ this . explainBusy ? 'true' : nothing } "
148+ ?disabled ="${ this . explainBusy ? true : nothing } "
149+ @click =${ this . onExplainChanges }
150+ @keydown =${ this . onExplainChanges }
151+ > < span > explain</ span > </ gl-action-chip
152+ >
153+ ` ;
154+ }
155+
123156 private renderCommitMessage ( ) {
124157 const details = this . state ?. commit ;
125158 if ( details == null ) return undefined ;
@@ -140,21 +173,7 @@ export class GlCommitDetails extends GlDetailsBase {
140173 > </ gl-commit-author >
141174 ` ,
142175 ) }
143- ${ when (
144- this . state ?. orgSettings . ai !== false && this . state ?. preferences . aiEnabled !== false ,
145- ( ) => html `
146- < gl-action-chip
147- label ="Explain this ${ this . isStash ? 'Stash' : 'Commit' } "
148- icon ="sparkle "
149- data-action ="explain-commit "
150- aria-busy ="${ this . explainBusy ? 'true' : nothing } "
151- ?disabled ="${ this . explainBusy ? true : nothing } "
152- @click =${ this . onExplainChanges }
153- @keydown =${ this . onExplainChanges }
154- > < span > explain</ span > </ gl-action-chip
155- >
156- ` ,
157- ) }
176+ ${ this . renderExplainChanges ( ) }
158177 </ div >
159178 < div >
160179 < div class ="message-block ">
@@ -284,7 +303,7 @@ export class GlCommitDetails extends GlDetailsBase {
284303
285304 private renderAutoLinksChips ( ) {
286305 const autolinkState = this . autolinkState ;
287- if ( autolinkState == null ) return html ` < span > </ span > ` ;
306+ if ( autolinkState == null ) return this . renderLearnAboutAutolinks ( ) ;
288307
289308 const { autolinks, issues, prs, size } = autolinkState ;
290309
0 commit comments