Skip to content

Commit a9a155c

Browse files
committed
Updates banner when gk mcp can be auto registered
1 parent e880637 commit a9a155c

File tree

7 files changed

+49
-10
lines changed

7 files changed

+49
-10
lines changed

src/plus/gk/utils/-webview/mcp.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import type { Container } from '../../../../container';
44
import { getHostAppName } from '../../../../system/-webview/vscode';
55
import { satisfies } from '../../../../system/version';
66

7-
export async function isMcpBannerEnabled(container: Container): Promise<boolean> {
7+
export async function isMcpBannerEnabled(container: Container, showAutoRegistration = false): Promise<boolean> {
88
// Check if running on web or automatically registrable
9-
if (isWeb || supportsMcpExtensionRegistration()) {
9+
if (isWeb || (!showAutoRegistration && supportsMcpExtensionRegistration())) {
1010
return false;
1111
}
1212

src/webviews/apps/home/home.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export class GlHomeApp extends GlAppHost<State> {
9292
<gl-mcp-banner
9393
.layout=${'responsive'}
9494
.source=${'home'}
95+
.canAutoRegister=${this.state?.mcpCanAutoRegister ?? false}
9596
.collapsed=${this.state?.mcpBannerCollapsed ?? true}
9697
></gl-mcp-banner>
9798
<gl-active-work></gl-active-work>

src/webviews/apps/home/stateProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ export class HomeStateProvider implements StateProvider<State> {
9797
host.requestUpdate();
9898
break;
9999
case DidChangeMcpBanner.is(msg):
100-
this._state.mcpBannerCollapsed = msg.params;
100+
this._state.mcpBannerCollapsed = msg.params.mcpBannerCollapsed;
101+
this._state.mcpCanAutoRegister = msg.params.mcpCanAutoRegister;
101102
this._state.timestamp = Date.now();
102103

103104
this.provider.setValue(this._state, true);

src/webviews/apps/shared/components/banner/banner.css.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,15 @@ export const bannerStyles = css`
212212
font-weight: bold;
213213
color: var(--gl-banner-text-color);
214214
margin: 0;
215+
text-wrap: pretty;
215216
}
216217
217218
.banner__body {
218219
font-size: 1em;
219220
color: var(--gl-banner-text-color);
220221
margin: 0;
221222
line-height: 1.4;
223+
text-wrap: pretty;
222224
}
223225
224226
.banner__buttons {

src/webviews/apps/shared/components/mcp-banner.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css, html, LitElement, nothing } from 'lit';
2-
import { customElement, property, state } from 'lit/decorators.js';
2+
import { customElement, property } from 'lit/decorators.js';
33
import { urls } from '../../../../constants';
44
import { createCommandLink } from '../../../../system/commands';
55
import './banner/banner';
@@ -40,14 +40,36 @@ export class GlMcpBanner extends LitElement {
4040
@property()
4141
layout: 'default' | 'responsive' = 'default';
4242

43-
@state()
44-
private collapsed: boolean = false;
43+
@property({ type: Boolean })
44+
collapsed: boolean = false;
45+
46+
@property({ type: Boolean })
47+
private canAutoRegister: boolean = false;
4548

4649
override render(): unknown {
4750
if (this.collapsed) {
4851
return nothing;
4952
}
5053

54+
if (this.canAutoRegister) {
55+
const bodyHtml = `GitKraken MCP is now active in Copilot chat. Ask Copilot to "start work on issue PROJ-123" or "create a PR for my commits" to see Git workflows powered by AI. <a href="${urls.helpCenterMCP}">Learn more</a>`;
56+
57+
return html`
58+
<gl-banner
59+
exportparts="base"
60+
display="gradient-purple"
61+
layout="${this.layout}"
62+
banner-title="GitKraken MCP for GitLens is Here!"
63+
body="${bodyHtml}"
64+
dismissible
65+
dismiss-href="${createCommandLink('gitlens.storage.store', {
66+
key: 'mcp:banner:dismissed',
67+
value: true,
68+
})}"
69+
></gl-banner>
70+
`;
71+
}
72+
5173
const bodyHtml = `Leverage Git and Integration information from GitLens in AI chat. <a href="${urls.helpCenterMCP}">Learn more</a>`;
5274

5375
return html`

src/webviews/home/homeWebview.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import type { AIModelChangeEvent } from '../../plus/ai/aiProviderService';
5151
import { showPatchesView } from '../../plus/drafts/actions';
5252
import type { Subscription } from '../../plus/gk/models/subscription';
5353
import type { SubscriptionChangeEvent } from '../../plus/gk/subscriptionService';
54-
import { isMcpBannerEnabled } from '../../plus/gk/utils/-webview/mcp.utils';
54+
import { isMcpBannerEnabled, supportsMcpExtensionRegistration } from '../../plus/gk/utils/-webview/mcp.utils';
5555
import { isAiAllAccessPromotionActive } from '../../plus/gk/utils/-webview/promo.utils';
5656
import { isSubscriptionTrialOrPaidFromState } from '../../plus/gk/utils/subscription.utils';
5757
import type { ConfiguredIntegrationsChangeEvent } from '../../plus/integrations/authentication/configuredIntegrationService';
@@ -803,7 +803,11 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
803803
}
804804

805805
private async getMcpBannerCollapsed() {
806-
return !(await isMcpBannerEnabled(this.container));
806+
return !(await isMcpBannerEnabled(this.container, true));
807+
}
808+
809+
private getMcpCanAutoRegister() {
810+
return supportsMcpExtensionRegistration();
807811
}
808812

809813
private getIntegrationBannerCollapsed() {
@@ -898,6 +902,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
898902
newInstall: getContext('gitlens:install:new', false),
899903
amaBannerCollapsed: this.getAmaBannerCollapsed(),
900904
mcpBannerCollapsed: await this.getMcpBannerCollapsed(),
905+
mcpCanAutoRegister: this.getMcpCanAutoRegister(),
901906
};
902907
}
903908

@@ -1134,7 +1139,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
11341139
private async onMcpBannerChanged() {
11351140
if (!this.host.visible) return;
11361141

1137-
void this.host.notify(DidChangeMcpBanner, await this.getMcpBannerCollapsed());
1142+
void this.host.notify(DidChangeMcpBanner, {
1143+
mcpBannerCollapsed: await this.getMcpBannerCollapsed(),
1144+
mcpCanAutoRegister: this.getMcpCanAutoRegister(),
1145+
});
11381146
}
11391147

11401148
private getSelectedRepository() {

src/webviews/home/protocol.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface State extends WebviewState {
3636
integrationBannerCollapsed: boolean;
3737
aiAllAccessBannerCollapsed: boolean;
3838
mcpBannerCollapsed: boolean;
39+
mcpCanAutoRegister: boolean;
3940
hasAnyIntegrationConnected: boolean;
4041
integrations: IntegrationState[];
4142
ai: { model: AIModel | undefined };
@@ -253,7 +254,11 @@ export const CollapseSectionCommand = new IpcCommand<CollapseSectionParams>(scop
253254
export const DismissWalkthroughSection = new IpcCommand<void>(scope, 'walkthrough/dismiss');
254255

255256
export const DidChangeAiAllAccessBanner = new IpcNotification<boolean>(scope, 'ai/allAccess/didChange');
256-
export const DidChangeMcpBanner = new IpcNotification<boolean>(scope, 'mcp/didChange');
257+
export interface DidChangeMcpBannerParams {
258+
mcpBannerCollapsed: boolean;
259+
mcpCanAutoRegister: boolean;
260+
}
261+
export const DidChangeMcpBanner = new IpcNotification<DidChangeMcpBannerParams>(scope, 'mcp/didChange');
257262
export const DismissAiAllAccessBannerCommand = new IpcCommand<void>(scope, 'ai/allAccess/dismiss');
258263

259264
export const SetOverviewFilter = new IpcCommand<OverviewFilters>(scope, 'overview/filter/set');

0 commit comments

Comments
 (0)