@@ -7,7 +7,10 @@ import type {
77} from '../../api/gitlens' ;
88import type { MaybeEnrichedAutolink } from '../../autolinks/models/autolinks' ;
99import { getPresenceDataUri } from '../../avatars' ;
10+ import { CopyShaToClipboardCommand } from '../../commands/copyShaToClipboard' ;
1011import { DiffWithCommand } from '../../commands/diffWith' ;
12+ import { ExplainCommitCommand } from '../../commands/explainCommit' ;
13+ import { ExplainWipCommand } from '../../commands/explainWip' ;
1114import { InspectCommand } from '../../commands/inspect' ;
1215import { OpenCommitOnRemoteCommand } from '../../commands/openCommitOnRemote' ;
1316import { OpenFileAtRevisionCommand } from '../../commands/openFileAtRevision' ;
@@ -46,6 +49,7 @@ import type { FormatOptions, RequiredTokenOptions } from './formatter';
4649import { Formatter } from './formatter' ;
4750
4851export interface CommitFormatOptions extends FormatOptions {
52+ aiEnabled ?: boolean ;
4953 avatarSize ?: number ;
5054 dateStyle ?: DateStyle ;
5155 editor ?: { line : number ; uri : Uri } ;
@@ -410,6 +414,8 @@ export class CommitFormatter extends Formatter<GitCommit, CommitFormatOptions> {
410414 return this . _padOrTruncate ( '' , this . _options . tokenOptions . commands ) ;
411415 }
412416
417+ const separator = ' | ' ;
418+
413419 let commands ;
414420 if ( this . _item . isUncommitted ) {
415421 const { previousLineComparisonUris : diffUris } = this . _options ;
@@ -422,7 +428,7 @@ export class CommitFormatter extends Formatter<GitCommit, CommitFormatOptions> {
422428 this . _item . repoPath ,
423429 ) } "Inspect Commit Details")`;
424430
425- commands += ` [$(chevron-left)$( compare-changes)](${ DiffWithCommand . createMarkdownCommandLink ( {
431+ commands += ` [$(compare-changes)](${ DiffWithCommand . createMarkdownCommandLink ( {
426432 lhs : { sha : diffUris . previous . sha ?? '' , uri : diffUris . previous . documentUri ( ) } ,
427433 rhs : { sha : diffUris . current . sha ?? '' , uri : diffUris . current . documentUri ( ) } ,
428434 repoPath : this . _item . repoPath ,
@@ -444,17 +450,27 @@ export class CommitFormatter extends Formatter<GitCommit, CommitFormatOptions> {
444450 ) } "Inspect Commit Details")`;
445451 }
446452
453+ if ( this . _options . aiEnabled ) {
454+ commands += `${ separator } [$(sparkle) Explain](${ ExplainWipCommand . createMarkdownCommandLink ( {
455+ repoPath : this . _item . repoPath ,
456+ staged : undefined ,
457+ source : { source : 'editor:hover' , type : 'wip' } ,
458+ } ) } "Explain Changes")`;
459+ }
460+
447461 return commands ;
448462 }
449463
450- const separator = ' | ' ;
451-
452464 commands = `---\n\n[\`$(git-commit) ${ this . id } \`](${ InspectCommand . createMarkdownCommandLink (
453465 this . _item . sha ,
454466 this . _item . repoPath ,
455467 ) } "Inspect Commit Details")`;
456468
457- commands += ` [$(chevron-left)$(compare-changes)](${ DiffWithCommand . createMarkdownCommandLink (
469+ commands += ` [$(copy)](${ CopyShaToClipboardCommand . createMarkdownCommandLink (
470+ this . _item . sha ,
471+ ) } "Copy SHA")`;
472+
473+ commands += ` [$(compare-changes)](${ DiffWithCommand . createMarkdownCommandLink (
458474 this . _item ,
459475 editorLineToDiffRange ( this . _options . editor ?. line ) ,
460476 ) } "Open Changes with Previous Revision")`;
@@ -472,7 +488,7 @@ export class CommitFormatter extends Formatter<GitCommit, CommitFormatOptions> {
472488 ) } "Open Blame Prior to this Change")`;
473489 }
474490
475- commands += ` [$(search)](${ createMarkdownCommandLink < ShowQuickCommitCommandArgs > (
491+ commands += `${ separator } [$(search)](${ createMarkdownCommandLink < ShowQuickCommitCommandArgs > (
476492 'gitlens.revealCommitInView' ,
477493 { repoPath : this . _item . repoPath , sha : this . _item . sha , revealInView : true } ,
478494 ) } "Reveal in Side Bar")`;
@@ -495,6 +511,14 @@ export class CommitFormatter extends Formatter<GitCommit, CommitFormatOptions> {
495511 ) } "Open Commit on ${ providers ?. length ? providers [ 0 ] . name : 'Remote' } ")`;
496512 }
497513
514+ if ( this . _options . aiEnabled ) {
515+ commands += `${ separator } [$(sparkle) Explain](${ ExplainCommitCommand . createMarkdownCommandLink ( {
516+ repoPath : this . _item . repoPath ,
517+ rev : this . _item . sha ,
518+ source : { source : 'editor:hover' , type : isStash ( this . _item ) ? 'stash' : 'commit' } ,
519+ } ) } "Explain Changes")`;
520+ }
521+
498522 if ( pr != null ) {
499523 if ( isPullRequest ( pr ) ) {
500524 commands += `${ separator } [$(git-pull-request) PR #${
@@ -532,19 +556,20 @@ export class CommitFormatter extends Formatter<GitCommit, CommitFormatOptions> {
532556 if ( Container . instance . actionRunners . count ( 'hover.commands' ) > 0 ) {
533557 const { name, email } = this . _item . author ;
534558
535- commands += `${ separator } [$(organization) Team${ GlyphChars . SpaceThinnest } ${
536- GlyphChars . Ellipsis
537- } ](${ createMarkdownActionCommandLink < HoverCommandsActionContext > ( 'hover.commands' , {
538- repoPath : this . _item . repoPath ,
539- commit : {
540- sha : this . _item . sha ,
541- author : { name : name , email : email , presence : this . _options . presence } ,
559+ commands += `${ separator } [$(organization)](${ createMarkdownActionCommandLink < HoverCommandsActionContext > (
560+ 'hover.commands' ,
561+ {
562+ repoPath : this . _item . repoPath ,
563+ commit : {
564+ sha : this . _item . sha ,
565+ author : { name : name , email : email , presence : this . _options . presence } ,
566+ } ,
567+ file :
568+ this . _options . editor != null
569+ ? { uri : this . _options . editor ?. uri . toString ( ) , line : this . _options . editor ?. line }
570+ : undefined ,
542571 } ,
543- file :
544- this . _options . editor != null
545- ? { uri : this . _options . editor ?. uri . toString ( ) , line : this . _options . editor ?. line }
546- : undefined ,
547- } ) } "Show Team Actions")`;
572+ ) } "Show Team Actions")`;
548573 }
549574
550575 const gitUri = this . _item . getGitUri ( ) ;
0 commit comments