import * as vscode from 'vscode'; import { getThemeKindName } from './theme'; import type { ConnectionStatus } from './opencode'; export type PanelType = 'chat' | 'agentManager'; export interface WebviewHtmlOptions { webview: vscode.Webview; extensionUri: vscode.Uri; workspaceFolder: string; initialStatus: ConnectionStatus; cliAvailable: boolean; panelType?: PanelType; initialSessionId?: string; viewMode?: 'sidebar' | 'editor'; } export function getWebviewHtml(options: WebviewHtmlOptions): string { const { webview, extensionUri, workspaceFolder, initialStatus, cliAvailable, panelType = 'chat', initialSessionId, viewMode = 'sidebar', } = options; const scriptPath = vscode.Uri.joinPath(extensionUri, 'dist', 'webview', 'assets', 'index.js'); const scriptUri = webview.asWebviewUri(scriptPath); const themeKind = getThemeKindName(vscode.window.activeColorTheme.kind); // Use VS Code CSS variables for proper theme integration // These variables are automatically provided by VS Code to webviews // // Logo geometry matches OpenChamberLogo.tsx: // edge=48, cos30=0.866, sin30=0.5, centerY=50 // top=(50, 2), left=(8.432, 26), right=(91.568, 26), center=(50, 50) // bottomLeft=(8.432, 74), bottomRight=(91.568, 74), bottom=(50, 98) // topFaceCenterY = (2 + 26 + 50 + 26) / 4 = 26 return ` OpenChamber
${initialStatus === 'connecting' ? 'Starting OpenCode API…' : initialStatus === 'connected' ? 'Initializing…' : 'Connecting…'}
${!cliAvailable ? `
OpenCode CLI not found. Please install it first.
` : ''}
`; }