WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit c33d18d

Browse files
committed
Implements welcome overlay over Homve View for new users in Cursor
and other IDEs without walkthrough support. Adds a welcome overlay to the home webview for new users to improve the first-time user experience. The overlay is displayed only on the first install and when the walkthrough is not supported. It can be dismissed, and its state is persisted. (#4769, #4773, PLG-138)
1 parent bd9b333 commit c33d18d

File tree

5 files changed

+87
-5
lines changed

5 files changed

+87
-5
lines changed

src/extension.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,11 @@ async function showWhatsNew(
366366
if (previousVersion == null) {
367367
Logger.log(`GitLens first-time install; window.focused=${window.state.focused}`);
368368

369-
// Show welcome webview on first install for IDEs that don't support walkthroughs (e.g., Cursor)
370-
// For IDEs that support walkthroughs, the walkthrough will be shown instead
371-
if (window.state.focused && !container.walkthrough.isWalkthroughSupported) {
372-
void executeCommand('gitlens.showWelcomePage');
373-
}
369+
// // Show welcome webview on first install for IDEs that don't support walkthroughs (e.g., Cursor)
370+
// // For IDEs that support walkthroughs, the walkthrough will be shown instead
371+
// if (window.state.focused && !container.walkthrough.isWalkthroughSupported) {
372+
// void executeCommand('gitlens.showWelcomePage');
373+
// }
374374

375375
return;
376376
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { consume } from '@lit/context';
2+
import { css, html, LitElement, nothing } from 'lit';
3+
import { customElement, state } from 'lit/decorators.js';
4+
import type { State } from '../../../home/protocol';
5+
import { CollapseSectionCommand } from '../../../home/protocol';
6+
import { ipcContext } from '../../shared/contexts/ipc';
7+
import type { HostIpc } from '../../shared/ipc';
8+
import { stateContext } from '../context';
9+
10+
declare global {
11+
interface HTMLElementTagNameMap {
12+
'gl-welcome-overlay': GlWelcomeOverlay;
13+
}
14+
}
15+
16+
@customElement('gl-welcome-overlay')
17+
export class GlWelcomeOverlay extends LitElement {
18+
static override shadowRootOptions: ShadowRootInit = {
19+
...LitElement.shadowRootOptions,
20+
delegatesFocus: true,
21+
};
22+
23+
static override styles = [
24+
css`
25+
.overlay {
26+
position: fixed;
27+
top: 0;
28+
left: 0;
29+
right: 0;
30+
bottom: 0;
31+
z-index: 1000;
32+
display: flex;
33+
align-items: center;
34+
justify-content: center;
35+
background-color: #007acc;
36+
color: white;
37+
}
38+
`,
39+
];
40+
41+
@consume<State>({ context: stateContext, subscribe: true })
42+
@state()
43+
private _state!: State;
44+
45+
@consume<HostIpc>({ context: ipcContext, subscribe: true })
46+
@state()
47+
private _ipc!: HostIpc;
48+
49+
@state()
50+
private closed = false;
51+
52+
override render(): unknown {
53+
const { welcomeOverlayCollapsed, walkthroughSupported, newInstall } = this._state;
54+
if (this.closed || welcomeOverlayCollapsed || walkthroughSupported || !newInstall) {
55+
return nothing;
56+
}
57+
58+
return html`
59+
<div class="overlay">
60+
<h1 class="title">Welcome!!!</h1>
61+
<button class="close-button" @click=${() => this.onClose()}>Dismiss</button>
62+
</div>
63+
`;
64+
}
65+
66+
private onClose() {
67+
this.closed = true;
68+
69+
this._ipc.sendCommand(CollapseSectionCommand, {
70+
section: 'welcomeOverlay',
71+
collapsed: true,
72+
});
73+
}
74+
}

src/webviews/apps/home/home.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import './components/ai-all-access-banner';
2929
import './components/ama-banner';
3030
import './components/integration-banner';
3131
import './components/preview-banner';
32+
import './components/welcome-overlay';
3233
import '../shared/components/mcp-banner';
3334
import './components/repo-alerts';
3435
import '../shared/components/banner/banner';
@@ -111,6 +112,7 @@ export class GlHomeApp extends GlAppHost<State> {
111112
`,
112113
)}
113114
</main>
115+
<gl-welcome-overlay></gl-welcome-overlay>
114116
</div>
115117
`;
116118
}

src/webviews/home/homeWebview.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
803803
return this.container.storage.get('home:walkthrough:dismissed') ?? false;
804804
}
805805

806+
private getWelcomeOverlayCollapsed() {
807+
return this.container.storage.get('home:sections:collapsed')?.includes('welcomeOverlay') ?? false;
808+
}
809+
806810
private getPreviewCollapsed() {
807811
return this.container.storage.get('home:sections:collapsed')?.includes('newHomePreview') ?? false;
808812
}
@@ -922,6 +926,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
922926
amaBannerCollapsed: this.getAmaBannerCollapsed(),
923927
mcpBannerCollapsed: this.getMcpBannerCollapsed(),
924928
mcpCanAutoRegister: this.getMcpCanAutoRegister(),
929+
welcomeOverlayCollapsed: this.getWelcomeOverlayCollapsed(),
925930
};
926931
}
927932

src/webviews/home/protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export interface State extends WebviewState<'gitlens.views.home'> {
5252
previewEnabled: boolean;
5353
newInstall: boolean;
5454
amaBannerCollapsed: boolean;
55+
welcomeOverlayCollapsed: boolean;
5556
}
5657

5758
export interface IntegrationState extends IntegrationDescriptor {

0 commit comments

Comments
 (0)