From cd2b563be411964bc14c17d0275d3b759c1e0df4 Mon Sep 17 00:00:00 2001 From: andrepimenta Date: Tue, 24 Jun 2025 01:59:24 +0100 Subject: [PATCH] Show WSL alert for windows users --- src/extension.ts | 31 ++++++++++++++++++++++ src/ui-styles.ts | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ui.ts | 53 +++++++++++++++++++++++++++++++++++++ 3 files changed, 152 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index 36ce367..855a4e4 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -228,6 +228,9 @@ class ClaudeChatProvider { case 'executeSlashCommand': this._executeSlashCommand(message.command); return; + case 'dismissWSLAlert': + this._dismissWSLAlert(); + return; } }, null, @@ -265,6 +268,10 @@ class ClaudeChatProvider { type: 'modelSelected', model: this._selectedModel }); + + + // Send platform information to webview + this._sendPlatformInfo(); }, 100); } @@ -917,6 +924,7 @@ class ClaudeChatProvider { private async _saveCurrentConversation(): Promise { if (!this._conversationsPath || this._currentConversation.length === 0) {return;} + if(!this._currentSessionId) {return;} try { // Create filename from first user message and timestamp @@ -1340,6 +1348,29 @@ class ClaudeChatProvider { }); } + private _sendPlatformInfo() { + const platform = process.platform; + const dismissed = this._context.globalState.get('wslAlertDismissed', false); + + // Get WSL configuration + const config = vscode.workspace.getConfiguration('claudeCodeChat'); + const wslEnabled = config.get('wsl.enabled', false); + + this._panel?.webview.postMessage({ + type: 'platformInfo', + data: { + platform: platform, + isWindows: platform === 'win32', + wslAlertDismissed: dismissed, + wslEnabled: wslEnabled + } + }); + } + + private _dismissWSLAlert() { + this._context.globalState.update('wslAlertDismissed', true); + } + public dispose() { if (this._panel) { this._panel.dispose(); diff --git a/src/ui-styles.ts b/src/ui-styles.ts index 650e225..e09f381 100644 --- a/src/ui-styles.ts +++ b/src/ui-styles.ts @@ -83,6 +83,74 @@ const styles = ` opacity: 1; } + /* WSL Alert */ + .wsl-alert { + margin: 8px 12px; + background-color: rgba(135, 206, 235, 0.1); + border: 2px solid rgba(135, 206, 235, 0.3); + border-radius: 8px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); + backdrop-filter: blur(4px); + animation: slideUp 0.3s ease; + } + + @keyframes slideUp { + from { + opacity: 0; + transform: translateY(10px); + } + to { + opacity: 1; + transform: translateY(0); + } + } + + .wsl-alert-content { + display: flex; + align-items: center; + padding: 14px 18px; + gap: 14px; + } + + .wsl-alert-icon { + font-size: 22px; + flex-shrink: 0; + } + + .wsl-alert-text { + flex: 1; + font-size: 13px; + line-height: 1.4; + color: var(--vscode-foreground); + } + + .wsl-alert-text strong { + font-weight: 600; + color: var(--vscode-foreground); + } + + .wsl-alert-actions { + display: flex; + gap: 10px; + flex-shrink: 0; + } + + .wsl-alert-actions .btn { + padding: 6px 14px; + font-size: 12px; + border-radius: 6px; + } + + .wsl-alert-actions .btn:first-child { + background-color: rgba(135, 206, 235, 0.2); + border-color: rgba(135, 206, 235, 0.4); + } + + .wsl-alert-actions .btn:first-child:hover { + background-color: rgba(135, 206, 235, 0.3); + border-color: rgba(135, 206, 235, 0.6); + } + .chat-container { flex: 1; display: flex; diff --git a/src/ui.ts b/src/ui.ts index aa534d4..786974a 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -37,6 +37,22 @@ const html = `
+ + + +
@@ -1132,6 +1148,33 @@ const html = ` hideThinkingIntensityModal(); } + // WSL Alert functions + function showWSLAlert() { + const alert = document.getElementById('wslAlert'); + if (alert) { + alert.style.display = 'block'; + } + } + + function dismissWSLAlert() { + const alert = document.getElementById('wslAlert'); + if (alert) { + alert.style.display = 'none'; + } + // Send dismiss message to extension to store in globalState + vscode.postMessage({ + type: 'dismissWSLAlert' + }); + } + + function openWSLSettings() { + // Dismiss the alert + dismissWSLAlert(); + + // Open settings modal + toggleSettings(); + } + function executeSlashCommand(command) { // Hide the modal hideSlashCommandsModal(); @@ -1978,6 +2021,16 @@ const html = ` // Show/hide WSL options document.getElementById('wslOptions').style.display = message.data['wsl.enabled'] ? 'block' : 'none'; } + + if (message.type === 'platformInfo') { + // Check if user is on Windows and show WSL alert if not dismissed and WSL not already enabled + if (message.data.isWindows && !message.data.wslAlertDismissed && !message.data.wslEnabled) { + // Small delay to ensure UI is ready + setTimeout(() => { + showWSLAlert(); + }, 1000); + } + } });