Skip to content

Commit a69f523

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 a96e1e4 commit a69f523

File tree

7 files changed

+81
-2
lines changed

7 files changed

+81
-2
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",
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"

docs/telemetry-events.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6147,6 +6147,16 @@
61476147
"category": "GitLens",
61486148
"icon": "$(person-add)"
61496149
},
6150+
{
6151+
"command": "gitlens.ai.aiRebaseBranch:graph",
6152+
"title": "AI Recompose branch commits (Preview)...",
6153+
"icon": "$(sparkle)"
6154+
},
6155+
{
6156+
"command": "gitlens.ai.aiRebaseUnpushed:graph",
6157+
"title": "AI Recompose unpushed commits (Preview)...",
6158+
"icon": "$(sparkle)"
6159+
},
61506160
{
61516161
"command": "gitlens.ai.explainBranch",
61526162
"title": "Explain Branch Changes (Preview)...",
@@ -10796,6 +10806,14 @@
1079610806
"command": "gitlens.addAuthors",
1079710807
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders"
1079810808
},
10809+
{
10810+
"command": "gitlens.ai.aiRebaseBranch:graph",
10811+
"when": "false"
10812+
},
10813+
{
10814+
"command": "gitlens.ai.aiRebaseUnpushed:graph",
10815+
"when": "false"
10816+
},
1079910817
{
1080010818
"command": "gitlens.ai.explainBranch",
1080110819
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"
@@ -22832,6 +22850,16 @@
2283222850
"when": "webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(remote|tracking)\\b)(?!.*?\\b\\+closed\\b)/ && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && gitlens:repos:withRemotes",
2283322851
"group": "1_gitlens_actions@3"
2283422852
},
22853+
{
22854+
"command": "gitlens.ai.aiRebaseBranch:graph",
22855+
"when": "webviewItem =~ /gitlens:branch\\b/ && !listMultiSelection",
22856+
"group": "1_gitlens_actions@6"
22857+
},
22858+
{
22859+
"command": "gitlens.ai.aiRebaseUnpushed:graph",
22860+
"when": "webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+ahead\\b)/ && !listMultiSelection",
22861+
"group": "1_gitlens_actions@7"
22862+
},
2283522863
{
2283622864
"command": "gitlens.graph.mergeBranchInto",
2283722865
"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
@@ -525,6 +525,8 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
525525
this.host.registerWebviewCommand('gitlens.graph.rebaseOntoUpstream', this.rebaseToRemote),
526526
this.host.registerWebviewCommand('gitlens.graph.renameBranch', this.renameBranch),
527527
this.host.registerWebviewCommand('gitlens.graph.associateIssueWithBranch', this.associateIssueWithBranch),
528+
this.host.registerWebviewCommand('gitlens.ai.aiRebaseBranch:graph', this.aiRebaseBranch),
529+
this.host.registerWebviewCommand('gitlens.ai.aiRebaseUnpushed:graph', this.aiRebaseUnpushed),
528530

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

@@ -3242,6 +3244,23 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
32423244
return Promise.resolve();
32433245
}
32443246

3247+
@log()
3248+
private aiRebaseBranch(item?: GraphItemContext) {
3249+
if (isGraphItemRefContext(item, 'branch')) {
3250+
}
3251+
3252+
return Promise.resolve();
3253+
}
3254+
3255+
@log()
3256+
private aiRebaseUnpushed(item?: GraphItemContext) {
3257+
if (isGraphItemRefContext(item, 'branch')) {
3258+
const { ref } = item.webviewItemValue;
3259+
}
3260+
3261+
return Promise.resolve();
3262+
}
3263+
32453264
@log()
32463265
private cherryPick(item?: GraphItemContext) {
32473266
const { selection } = this.getGraphItemRefs(item, 'revision');

0 commit comments

Comments
 (0)