Skip to content

Commit 1eb1125

Browse files
committed
Adds welcome page webview for first-time installs
(#4769, PLG-138)
1 parent 36ebc66 commit 1eb1125

16 files changed

+291
-1
lines changed

contributions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5657,6 +5657,11 @@
56575657
"label": "Show Visual File History View",
56585658
"commandPalette": "gitlens:enabled"
56595659
},
5660+
"gitlens.showWelcomePage": {
5661+
"label": "Show Welcome",
5662+
"icon": "$(heart)",
5663+
"commandPalette": "gitlens:enabled"
5664+
},
56605665
"gitlens.showWorkspacesView": {
56615666
"label": "Show Cloud Workspaces View",
56625667
"commandPalette": "gitlens:enabled && !gitlens:hasVirtualFolders"

docs/telemetry-events.md

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

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

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8344,6 +8344,12 @@
83448344
"title": "Show Visual File History View",
83458345
"category": "GitLens"
83468346
},
8347+
{
8348+
"command": "gitlens.showWelcomePage",
8349+
"title": "Show Welcome",
8350+
"category": "GitLens",
8351+
"icon": "$(heart)"
8352+
},
83478353
{
83488354
"command": "gitlens.showWorkspacesView",
83498355
"title": "Show Cloud Workspaces View",
@@ -13156,6 +13162,10 @@
1315613162
"command": "gitlens.showTimelineView",
1315713163
"when": "gitlens:enabled"
1315813164
},
13165+
{
13166+
"command": "gitlens.showWelcomePage",
13167+
"when": "gitlens:enabled"
13168+
},
1315913169
{
1316013170
"command": "gitlens.showWorkspacesView",
1316113171
"when": "gitlens:enabled && !gitlens:hasVirtualFolders"

src/constants.commands.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ export type ContributedPaletteCommands =
999999
| 'gitlens.showTagsView'
10001000
| 'gitlens.showTimelinePage'
10011001
| 'gitlens.showTimelineView'
1002+
| 'gitlens.showWelcomePage'
10021003
| 'gitlens.showWorkspacesView'
10031004
| 'gitlens.showWorktreesView'
10041005
| 'gitlens.startWork'

src/constants.views.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export type GroupableTreeViewTypes = Extract<
3737
>;
3838
export type GroupableTreeViewIds<T extends GroupableTreeViewTypes = GroupableTreeViewTypes> = TreeViewIds<T>;
3939

40-
export type WebviewTypes = 'composer' | 'graph' | 'patchDetails' | 'settings' | 'timeline';
40+
export type WebviewTypes = 'composer' | 'graph' | 'patchDetails' | 'settings' | 'timeline' | 'welcome';
4141
export type WebviewIds = `gitlens.${WebviewTypes}`;
4242

4343
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
@@ -347,6 +347,12 @@ async function showWhatsNew(
347347
if (previousVersion == null) {
348348
Logger.log(`GitLens first-time install; window.focused=${window.state.focused}`);
349349

350+
// Show welcome webview on first install for IDEs that don't support walkthroughs (e.g., Cursor)
351+
// For IDEs that support walkthroughs, the walkthrough will be shown instead
352+
if (window.state.focused && !container.walkthrough.isWalkthroughSupported) {
353+
void executeCommand('gitlens.showWelcomePage');
354+
}
355+
350356
return;
351357
}
352358

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)