add-webview
Create new webviews with IPC protocol, Lit app, and registration
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Create new webviews with IPC protocol, Lit app, and registration
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | add-webview |
| description | Create new webviews with IPC protocol, Lit app, and registration |
Scaffold a new webview with all required boilerplate.
/add-webview [name]
myFeature)view (sidebar) or panel (editor panel)src/webviews/{name}/protocol.tsimport type { IpcScope } from '../ipc/models/ipc.js';
import { IpcCommand, IpcNotification, IpcRequest } from '../ipc/models/ipc.js';
import type { WebviewState } from '../protocol.js';
export const scope: IpcScope = '{name}';
export interface State extends WebviewState<'gitlens.views.{name}'> {
loading: boolean;
}
// Commands (fire-and-forget)
export interface DoSomethingParams {
id: string;
}
export const DoSomethingCommand = new IpcCommand<DoSomethingParams>(scope, 'doSomething');
// Requests (with response)
export interface GetDataParams {
filter?: string;
}
export interface GetDataResponse {
items: unknown[];
}
export const GetDataRequest = new IpcRequest<GetDataParams, GetDataResponse>(scope, 'getData');
// Notifications (host → webview)
export interface DidChangeDataParams {
items: unknown[];
}
export const DidChangeDataNotification = new IpcNotification<DidChangeDataParams>(scope, 'data/didChange');
src/webviews/{name}/{name}Webview.tsimport type { Disposable } from 'vscode';
import type { Container } from '../../container.js';
import type { WebviewHost, WebviewProvider } from '../webviewProvider.js';
import { ipcCommand, ipcRequest } from '../ipc/handlerRegistry.js';
import type { IpcParams, IpcResponse } from '../ipc/models/ipc.js';
import type { State } from './protocol.js';
import { DoSomethingCommand, GetDataRequest, DidChangeDataNotification } from './protocol.js';
export class {Name}WebviewProvider implements WebviewProvider<State, State>, Disposable {
constructor(
private readonly container: Container,
private readonly host: WebviewHost<'gitlens.views.{name}'>,
) {}
dispose(): void {}
async includeBootstrap(): Promise<State> {
return {
webviewId: this.host.id,
webviewInstanceId: this.host.instanceId,
loading: false,
};
}
@ipcCommand(DoSomethingCommand)
private async onDoSomething(params: IpcParams<typeof DoSomethingCommand>): Promise<void> {
// Handle command
}
@ipcRequest(GetDataRequest)
private async onGetData(params: IpcParams<typeof GetDataRequest>): Promise<IpcResponse<typeof GetDataRequest>> {
return { items: [] };
}
}
src/webviews/{name}/registration.tsimport type { WebviewsController } from '../webviewsController.js';
import type { WebviewViewProxy } from '../webviewProxy.js';
import type { State } from './protocol.js';
export type {Name}WebviewShowingArgs = [];
export function register{Name}WebviewView(
controller: WebviewsController,
): WebviewViewProxy<'gitlens.views.{name}', {Name}WebviewShowingArgs, State> {
return controller.registerWebviewView<'gitlens.views.{name}', State, State, {Name}WebviewShowingArgs>(
{
id: 'gitlens.views.{name}',
fileName: '{name}.html',
title: '{Title}',
contextKeyPrefix: 'gitlens:webviewView:{name}',
trackingFeature: '{name}View',
type: '{name}',
plusFeature: false,
webviewHostOptions: { retainContextWhenHidden: true },
},
async (container, host) => {
const { {Name}WebviewProvider } = await import(
/* webpackChunkName: "webview-{name}" */ './{name}Webview.js'
);
return new {Name}WebviewProvider(container, host);
},
);
}
src/webviews/apps/{name}/{name}.tsimport { html } from 'lit';
import { customElement } from 'lit/decorators.js';
import { GlAppHost } from '../shared/appHost.js';
import type { HostIpc } from '../shared/ipc.js';
import type { LoggerContext } from '../shared/contexts/logger.js';
import type { State } from '../../{name}/protocol.js';
import { {Name}StateProvider } from './stateProvider.js';
import { styles } from './{name}.css.js';
@customElement('gl-{name}-app')
export class Gl{Name}App extends GlAppHost<State, {Name}StateProvider> {
static override styles = styles;
protected override createStateProvider(
bootstrap: string, ipc: HostIpc, logger: LoggerContext,
): {Name}StateProvider {
return new {Name}StateProvider(this, bootstrap, ipc, logger);
}
override render() {
return html`<div class="{name}"><h1>{Title}</h1></div>`;
}
}
src/webviews/apps/{name}/stateProvider.tsimport type { Disposable } from 'vscode';
import type { StateProvider } from '../shared/stateProviderBase.js';
import type { HostIpc } from '../shared/ipc.js';
import type { LoggerContext } from '../shared/contexts/logger.js';
import type { State } from '../../{name}/protocol.js';
export class {Name}StateProvider implements StateProvider<State>, Disposable {
readonly state: State;
constructor(
private readonly host: Gl{Name}App,
bootstrap: string,
private readonly ipc: HostIpc,
private readonly logger: LoggerContext,
) {
this.state = JSON.parse(bootstrap);
}
dispose(): void {}
}
src/webviews/apps/{name}/{name}.css.tsimport { css } from 'lit';
export const styles = css`
:host { display: block; height: 100%; }
.{name} { padding: 1rem; }
`;
For accessibility requirements when creating or modifying webview components, see docs/accessibility.md.
getWebviewsConfigs() in webpack.config.mjssrc/webviews/webviewsController.tssrc/constants.views.tspnpm run build:webviews| Component | Community | Pro |
|---|---|---|
| Protocol/Provider | src/webviews/{name}/ | src/webviews/plus/{name}/ |
| App | src/webviews/apps/{name}/ | src/webviews/apps/plus/{name}/ |
Use for one-off / single-question inspection of the running GitLens extension — examining UI state, reading logs, checking feature flags, dispatching a command, or asking "what does the live DOM look like right now". Reference for `vscode-inspector` MCP primitives. For iterative debug-and-fix loops on UI bugs (sweep → fix → re-verify), use `/live-exercise` instead.
Use whenever any UI-bearing work touches a running instance — building or fixing a feature, ship-gating, auditing, OR debugging visible bugs (flaky behavior, intermittent rendering, "sometimes does X" reports, hover/focus/animation glitches, layout overflow). Adaptive depth from tactical fix-loop to ship-gate audit. Not for pure-logic diff review.
Use to audit a component, file, or directory for WCAG 2.1 AA accessibility compliance. Detects ARIA anti-patterns, missing semantics, keyboard gaps, and color-only information. Safety-first — refuses to emit fixes that would create a new accessibility bug. Scope is always explicit; do not use for page-level flow or cross-program planning.
Use to audit a page, view, or composed flow for WCAG 2.1 AA compliance at the composition level - landmarks, heading hierarchy, tab order across components, focus handoff on modal open/close, live-region conflicts. Scope is page/view, NOT component internals. Safety-first - refuses to emit fixes that would create a new a11y bug. For single-component audits use /a11y-audit; for cross-program planning use /a11y-remediate.
Use to produce a leader-facing remediation proposal from one or more /a11y-audit outputs plus team and product context. Translates audit findings into sprint plans, staffing asks, customer-facing language, compliance rollups, and critical-path analysis. Refuses to fabricate numbers, owners, or commitments beyond the inputs it has.
Add new icons to the GitLens GL Icons font