Skip to content

Commit e2fb2e9

Browse files
committed
Prepares space for future AI-powered recompose actions for a branch
Introduces new AI-assisted commands to recompose all branch commits and specifically unpushed commits via the graph webview. (#4443, #4522)
1 parent 2a53a42 commit e2fb2e9

File tree

6 files changed

+80
-1
lines changed

6 files changed

+80
-1
lines changed

contributions.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,32 @@
2323
]
2424
}
2525
},
26+
"gitlens.ai.aiRebaseBranch:graph": {
27+
"label": "AI Recompose branch commits (Preview)...",
28+
"icon": "$(sparkle)",
29+
"menus": {
30+
"webview/context": [
31+
{
32+
"when": "webviewItem =~ /gitlens:branch\\b/ && !listMultiSelection",
33+
"group": "1_gitlens_actions",
34+
"order": 6
35+
}
36+
]
37+
}
38+
},
39+
"gitlens.ai.aiRebaseUnpushed:graph": {
40+
"label": "AI Recompose unpushed commits (Preview)...",
41+
"icon": "$(sparkle)",
42+
"menus": {
43+
"webview/context": [
44+
{
45+
"when": "webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+ahead\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
46+
"group": "1_gitlens_actions",
47+
"order": 7
48+
}
49+
]
50+
}
51+
},
2652
"gitlens.ai.explainBranch": {
2753
"label": "Explain Branch Changes (Preview)...",
2854
"commandPalette": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6176,6 +6176,16 @@
61766176
"category": "GitLens",
61776177
"icon": "$(person-add)"
61786178
},
6179+
{
6180+
"command": "gitlens.ai.aiRebaseBranch:graph",
6181+
"title": "AI Recompose branch commits (Preview)...",
6182+
"icon": "$(sparkle)"
6183+
},
6184+
{
6185+
"command": "gitlens.ai.aiRebaseUnpushed:graph",
6186+
"title": "AI Recompose unpushed commits (Preview)...",
6187+
"icon": "$(sparkle)"
6188+
},
61796189
{
61806190
"command": "gitlens.ai.explainBranch",
61816191
"title": "Explain Branch Changes (Preview)...",
@@ -10959,6 +10969,14 @@
1095910969
"command": "gitlens.addAuthors",
1096010970
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders"
1096110971
},
10972+
{
10973+
"command": "gitlens.ai.aiRebaseBranch:graph",
10974+
"when": "false"
10975+
},
10976+
{
10977+
"command": "gitlens.ai.aiRebaseUnpushed:graph",
10978+
"when": "false"
10979+
},
1096210980
{
1096310981
"command": "gitlens.ai.explainBranch",
1096410982
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"
@@ -23185,6 +23203,16 @@
2318523203
"when": "webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(remote|tracking)\\b)(?!.*?\\b\\+closed\\b)/ && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && gitlens:repos:withRemotes",
2318623204
"group": "1_gitlens_actions@3"
2318723205
},
23206+
{
23207+
"command": "gitlens.ai.aiRebaseBranch:graph",
23208+
"when": "webviewItem =~ /gitlens:branch\\b/ && !listMultiSelection",
23209+
"group": "1_gitlens_actions@6"
23210+
},
23211+
{
23212+
"command": "gitlens.ai.aiRebaseUnpushed:graph",
23213+
"when": "webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+ahead\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
23214+
"group": "1_gitlens_actions@7"
23215+
},
2318823216
{
2318923217
"command": "gitlens.graph.mergeBranchInto",
2319023218
"when": "webviewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/ && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",

src/constants.commands.generated.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
export type ContributedCommands =
55
| ContributedKeybindingCommands
66
| ContributedPaletteCommands
7+
| 'gitlens.ai.aiRebaseBranch:graph'
8+
| 'gitlens.ai.aiRebaseUnpushed:graph'
79
| 'gitlens.ai.explainBranch:graph'
810
| 'gitlens.ai.explainBranch:views'
911
| 'gitlens.ai.explainCommit:graph'

src/constants.commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export type GlCommandsDeprecated =
3131
| 'gitlens.showFileHistoryInView';
3232

3333
type InternalGraphWebviewCommands =
34+
| 'gitlens.ai.aiRebaseBranch:graph'
35+
| 'gitlens.ai.aiRebaseUnpushed:graph'
3436
| 'gitlens.graph.abortPausedOperation'
3537
| 'gitlens.graph.continuePausedOperation'
3638
| 'gitlens.graph.openRebaseEditor'

src/env/node/git/sub-providers/graph.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ export class GraphGitSubProvider implements GitGraphSubProvider {
356356
: branchIdOfMainWorktree === branchId
357357
? '+checkedout'
358358
: ''
359-
}${branch?.starred ? '+starred' : ''}`,
359+
}${branch?.starred ? '+starred' : ''}${branch?.upstream?.state.ahead ? '+ahead' : ''}${
360+
branch?.upstream?.state.behind ? '+behind' : ''
361+
}`,
360362
webviewItemValue: {
361363
type: 'branch',
362364
ref: createReference(tip, repoPath, {

src/webviews/plus/graph/graphWebview.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
526526
this.host.registerWebviewCommand('gitlens.graph.rebaseOntoUpstream', this.rebaseToRemote),
527527
this.host.registerWebviewCommand('gitlens.graph.renameBranch', this.renameBranch),
528528
this.host.registerWebviewCommand('gitlens.graph.associateIssueWithBranch', this.associateIssueWithBranch),
529+
this.host.registerWebviewCommand('gitlens.ai.aiRebaseBranch:graph', this.aiRebaseBranch),
530+
this.host.registerWebviewCommand('gitlens.ai.aiRebaseUnpushed:graph', this.aiRebaseUnpushed),
529531

530532
this.host.registerWebviewCommand('gitlens.graph.switchToBranch', this.switchTo),
531533

@@ -3245,6 +3247,23 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
32453247
return Promise.resolve();
32463248
}
32473249

3250+
@log()
3251+
private aiRebaseBranch(item?: GraphItemContext) {
3252+
if (isGraphItemRefContext(item, 'branch')) {
3253+
}
3254+
3255+
return Promise.resolve();
3256+
}
3257+
3258+
@log()
3259+
private aiRebaseUnpushed(item?: GraphItemContext) {
3260+
if (isGraphItemRefContext(item, 'branch')) {
3261+
const { ref } = item.webviewItemValue;
3262+
}
3263+
3264+
return Promise.resolve();
3265+
}
3266+
32483267
@log()
32493268
private cherryPick(item?: GraphItemContext) {
32503269
const { selection } = this.getGraphItemRefs(item, 'revision');

0 commit comments

Comments
 (0)