Skip to content

Commit ce109d9

Browse files
committed
Adds welcome page webview for first-time installs
(#4769, #4773, PLG-138)
1 parent 061c1dc commit ce109d9

16 files changed

+291
-1
lines changed

contributions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5691,6 +5691,11 @@
56915691
"label": "Show Visual File History View",
56925692
"commandPalette": "gitlens:enabled"
56935693
},
5694+
"gitlens.showWelcomePage": {
5695+
"label": "Show Welcome",
5696+
"icon": "$(heart)",
5697+
"commandPalette": "gitlens:enabled"
5698+
},
56945699
"gitlens.showWorkspacesView": {
56955700
"label": "Show Cloud Workspaces View",
56965701
"commandPalette": "gitlens:enabled && !gitlens:hasVirtualFolders"

docs/telemetry-events.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3538,3 +3538,42 @@ or
35383538
}
35393539
```
35403540

3541+
### welcome/closed
3542+
3543+
```typescript
3544+
{
3545+
[`context.${string}`]: string | number | boolean,
3546+
'context.webview.host': 'view' | 'editor',
3547+
'context.webview.id': string,
3548+
'context.webview.instanceId': string,
3549+
'context.webview.type': string
3550+
}
3551+
```
3552+
3553+
### welcome/showAborted
3554+
3555+
```typescript
3556+
{
3557+
'context.webview.host': 'view' | 'editor',
3558+
'context.webview.id': string,
3559+
'context.webview.instanceId': string,
3560+
'context.webview.type': string,
3561+
'duration': number,
3562+
'loading': boolean
3563+
}
3564+
```
3565+
3566+
### welcome/shown
3567+
3568+
```typescript
3569+
{
3570+
[`context.${string}`]: string | number | boolean,
3571+
'context.webview.host': 'view' | 'editor',
3572+
'context.webview.id': string,
3573+
'context.webview.instanceId': string,
3574+
'context.webview.type': string,
3575+
'duration': number,
3576+
'loading': boolean
3577+
}
3578+
```
3579+

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8364,6 +8364,12 @@
83648364
"title": "Show Visual File History View",
83658365
"category": "GitLens"
83668366
},
8367+
{
8368+
"command": "gitlens.showWelcomePage",
8369+
"title": "Show Welcome",
8370+
"category": "GitLens",
8371+
"icon": "$(heart)"
8372+
},
83678373
{
83688374
"command": "gitlens.showWorkspacesView",
83698375
"title": "Show Cloud Workspaces View",
@@ -13208,6 +13214,10 @@
1320813214
"command": "gitlens.showTimelineView",
1320913215
"when": "gitlens:enabled"
1321013216
},
13217+
{
13218+
"command": "gitlens.showWelcomePage",
13219+
"when": "gitlens:enabled"
13220+
},
1321113221
{
1321213222
"command": "gitlens.showWorkspacesView",
1321313223
"when": "gitlens:enabled && !gitlens:hasVirtualFolders"

src/constants.commands.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,7 @@ export type ContributedPaletteCommands =
10021002
| 'gitlens.showTagsView'
10031003
| 'gitlens.showTimelinePage'
10041004
| 'gitlens.showTimelineView'
1005+
| 'gitlens.showWelcomePage'
10051006
| 'gitlens.showWorkspacesView'
10061007
| 'gitlens.showWorktreesView'
10071008
| 'gitlens.startWork'

src/constants.views.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export type GroupableTreeViewTypes = Extract<
4343
>;
4444
export type GroupableTreeViewIds<T extends GroupableTreeViewTypes = GroupableTreeViewTypes> = TreeViewIds<T>;
4545

46-
export type WebviewTypes = 'composer' | 'graph' | 'patchDetails' | 'settings' | 'timeline';
46+
export type WebviewTypes = 'composer' | 'graph' | 'patchDetails' | 'settings' | 'timeline' | 'welcome';
4747
export type WebviewIds = `gitlens.${WebviewTypes}`;
4848

4949
export type WebviewViewTypes = 'commitDetails' | 'graph' | 'graphDetails' | 'home' | 'patchDetails' | 'timeline';

src/container.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import { registerTimelineWebviewCommands, registerTimelineWebviewPanel } from '.
7878
import { RebaseEditorProvider } from './webviews/rebase/rebaseEditor';
7979
import { registerSettingsWebviewCommands, registerSettingsWebviewPanel } from './webviews/settings/registration';
8080
import { WebviewsController } from './webviews/webviewsController';
81+
import { registerWelcomeWebviewPanel } from './webviews/welcome/registration';
8182

8283
export type Environment = 'dev' | 'staging' | 'production';
8384

@@ -257,6 +258,9 @@ export class Container {
257258
this._disposables.push(settingsPanels);
258259
this._disposables.push(registerSettingsWebviewCommands(settingsPanels));
259260

261+
const welcomePanels = registerWelcomeWebviewPanel(webviews);
262+
this._disposables.push(welcomePanels);
263+
260264
this._disposables.push(new ViewFileDecorationProvider());
261265

262266
const patchDetailsPanels = registerPatchDetailsWebviewPanel(webviews);

src/extension.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ 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+
}
374+
369375
return;
370376
}
371377

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createContext } from '@lit/context';
2+
import type { State } from '../../welcome/protocol';
3+
4+
export const stateContext = createContext<State>('state');
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ContextProvider } from '@lit/context';
2+
import type { IpcMessage } from '../../protocol';
3+
import type { State } from '../../welcome/protocol';
4+
import type { ReactiveElementHost } from '../shared/appHost';
5+
import { StateProviderBase } from '../shared/stateProviderBase';
6+
import { stateContext } from './context';
7+
8+
export class WelcomeStateProvider extends StateProviderBase<State['webviewId'], State, typeof stateContext> {
9+
protected override createContextProvider(state: State): ContextProvider<typeof stateContext, ReactiveElementHost> {
10+
return new ContextProvider(this.host, { context: stateContext, initialValue: state });
11+
}
12+
13+
protected override onMessageReceived(_msg: IpcMessage): void {
14+
// Welcome webview doesn't need to handle any messages
15+
}
16+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<style nonce="#{cspNonce}">
6+
@font-face {
7+
font-family: 'codicon';
8+
font-display: block;
9+
src: url('#{webroot}/codicon.ttf?79130123c9d3674a686cf03962523e8a') format('truetype');
10+
}
11+
@font-face {
12+
font-family: 'glicons';
13+
font-display: block;
14+
src: url('#{root}/dist/glicons.woff2?d3b316716ee1329763a193a20834cd0a') format('woff2');
15+
}
16+
</style>
17+
</head>
18+
19+
<body
20+
class="preload"
21+
data-placement="#{placement}"
22+
data-vscode-context='{ "webview": "#{webviewId}", "webviewInstance": "#{webviewInstanceId}" }'
23+
>
24+
<gl-welcome-app name="WelcomeView" placement="#{placement}" bootstrap="#{state}"></gl-welcome-app>
25+
</body>
26+
</html>

0 commit comments

Comments
 (0)