Skip to content

Commit f612147

Browse files
committed
Fixes ai enabled setting checks
1 parent 97e900d commit f612147

File tree

5 files changed

+49
-40
lines changed

5 files changed

+49
-40
lines changed

contributions.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"gitlens.ai.explainBranch": {
2727
"label": "Explain Branch (Preview)...",
28-
"commandPalette": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"
28+
"commandPalette": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled && config.gitlens.ai.enabled"
2929
},
3030
"gitlens.ai.explainBranch:graph": {
3131
"label": "Explain Branch (Preview)",
@@ -115,7 +115,7 @@
115115
},
116116
"gitlens.ai.explainWip": {
117117
"label": "Explain Working Changes (Preview)...",
118-
"commandPalette": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"
118+
"commandPalette": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled && config.gitlens.ai.enabled"
119119
},
120120
"gitlens.ai.explainWip:graph": {
121121
"label": "Explain Working Changes (Preview)",
@@ -136,7 +136,7 @@
136136
"menus": {
137137
"view/item/context": [
138138
{
139-
"when": "viewItem =~ /gitlens:(worktree|uncommitted)\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
139+
"when": "viewItem =~ /gitlens:(worktree|uncommitted)\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled && config.gitlens.ai.enabled",
140140
"group": "3_gitlens_ai",
141141
"order": 1
142142
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10469,7 +10469,7 @@
1046910469
},
1047010470
{
1047110471
"command": "gitlens.ai.explainBranch",
10472-
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"
10472+
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled && config.gitlens.ai.enabled"
1047310473
},
1047410474
{
1047510475
"command": "gitlens.ai.explainBranch:graph",
@@ -10505,7 +10505,7 @@
1050510505
},
1050610506
{
1050710507
"command": "gitlens.ai.explainWip",
10508-
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"
10508+
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled && config.gitlens.ai.enabled"
1050910509
},
1051010510
{
1051110511
"command": "gitlens.ai.explainWip:graph",
@@ -17976,7 +17976,7 @@
1797617976
},
1797717977
{
1797817978
"command": "gitlens.ai.explainWip:views",
17979-
"when": "viewItem =~ /gitlens:(worktree|uncommitted)\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
17979+
"when": "viewItem =~ /gitlens:(worktree|uncommitted)\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled && config.gitlens.ai.enabled",
1798017980
"group": "3_gitlens_ai@1"
1798117981
},
1798217982
{

src/commands/git/stash.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type { AIModel } from '../../plus/ai/models/model';
1414
import type { QuickPickItemOfT } from '../../quickpicks/items/common';
1515
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
1616
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
17+
import { configuration } from '../../system/-webview/configuration';
1718
import { getContext } from '../../system/-webview/context';
1819
import { formatPath } from '../../system/-webview/formatPath';
1920
import { getLoggableName, Logger } from '../../system/logger';
@@ -638,9 +639,10 @@ export class StashGitCommand extends QuickCommand<State> {
638639
placeholder: 'Please provide a stash message',
639640
value: state.message,
640641
prompt: 'Enter stash message',
641-
buttons: getContext('gitlens:gk:organization:ai:enabled')
642-
? [QuickInputButtons.Back, generateMessageButton]
643-
: [QuickInputButtons.Back],
642+
buttons:
643+
getContext('gitlens:gk:organization:ai:enabled') && configuration.get('ai.enabled')
644+
? [QuickInputButtons.Back, generateMessageButton]
645+
: [QuickInputButtons.Back],
644646
// Needed to clear any validation errors because of AI generation
645647
validate: (_value: string | undefined): [boolean, string | undefined] => [true, undefined],
646648
onDidClickButton: async (input, button) => {

src/webviews/apps/plus/home/components/branch-card.ts

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,8 @@ export class GlBranchCard extends GlBranchCardBase {
993993
protected getBranchActions(): TemplateResult[] {
994994
const actions = [];
995995

996+
const aiEnabled = this._homeState.orgSettings.ai && this._homeState.aiEnabled;
997+
996998
if (this.branch.worktree) {
997999
actions.push(
9981000
html`<action-item
@@ -1002,29 +1004,31 @@ export class GlBranchCard extends GlBranchCardBase {
10021004
></action-item>`,
10031005
);
10041006

1005-
const hasWip =
1006-
this.wip?.workingTreeState != null
1007-
? this.wip.workingTreeState.added +
1008-
this.wip.workingTreeState.changed +
1009-
this.wip.workingTreeState.deleted >
1010-
0
1011-
: false;
1012-
if (hasWip) {
1013-
actions.push(
1014-
html`<action-item
1015-
label="Explain Working Changes (Preview)"
1016-
icon="sparkle"
1017-
href=${this.createCommandLink('gitlens.ai.explainWip:home')}
1018-
></action-item>`,
1019-
);
1020-
} else {
1021-
actions.push(
1022-
html`<action-item
1023-
label="Explain Branch (Preview)"
1024-
icon="sparkle"
1025-
href=${this.createCommandLink('gitlens.ai.explainBranch:home')}
1026-
></action-item>`,
1027-
);
1007+
if (aiEnabled) {
1008+
const hasWip =
1009+
this.wip?.workingTreeState != null
1010+
? this.wip.workingTreeState.added +
1011+
this.wip.workingTreeState.changed +
1012+
this.wip.workingTreeState.deleted >
1013+
0
1014+
: false;
1015+
if (hasWip) {
1016+
actions.push(
1017+
html`<action-item
1018+
label="Explain Working Changes (Preview)"
1019+
icon="sparkle"
1020+
href=${this.createCommandLink('gitlens.ai.explainWip:home')}
1021+
></action-item>`,
1022+
);
1023+
} else {
1024+
actions.push(
1025+
html`<action-item
1026+
label="Explain Branch (Preview)"
1027+
icon="sparkle"
1028+
href=${this.createCommandLink('gitlens.ai.explainBranch:home')}
1029+
></action-item>`,
1030+
);
1031+
}
10281032
}
10291033
} else {
10301034
actions.push(
@@ -1034,13 +1038,16 @@ export class GlBranchCard extends GlBranchCardBase {
10341038
href=${this.createCommandLink('gitlens.home.switchToBranch')}
10351039
></action-item>`,
10361040
);
1037-
actions.push(
1038-
html`<action-item
1039-
label="Explain Branch (Preview)"
1040-
icon="sparkle"
1041-
href=${this.createCommandLink('gitlens.ai.explainBranch:home')}
1042-
></action-item>`,
1043-
);
1041+
1042+
if (aiEnabled) {
1043+
actions.push(
1044+
html`<action-item
1045+
label="Explain Branch (Preview)"
1046+
icon="sparkle"
1047+
href=${this.createCommandLink('gitlens.ai.explainBranch:home')}
1048+
></action-item>`,
1049+
);
1050+
}
10441051
}
10451052

10461053
// branch actions

src/webviews/home/homeWebview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
736736
}
737737

738738
private onContextChanged(key: keyof ContextKeys) {
739-
if (key === 'gitlens:gk:organization:drafts:enabled') {
739+
if (['gitlens:gk:organization:ai:enabled', 'gitlens:gk:organization:drafts:enabled'].includes(key)) {
740740
this.notifyDidChangeOrgSettings();
741741
}
742742
}

0 commit comments

Comments
 (0)