From 79c9b0d0f4e3cfcacc79af804b5049b09f40d52b Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 7 Jul 2025 19:37:40 +0530 Subject: [PATCH] improve: show notification for unsupported platform --- extensions/vscode/src/activation/activate.ts | 30 +++++++++++++- extensions/vscode/src/util/util.ts | 41 +++++++++++++++++++- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts index 21f7fcb3f..3fc5aa24b 100644 --- a/extensions/vscode/src/activation/activate.ts +++ b/extensions/vscode/src/activation/activate.ts @@ -6,12 +6,40 @@ import * as vscode from "vscode"; import { VsCodeExtension } from "../extension/VsCodeExtension"; import registerQuickFixProvider from "../lang-server/codeActions"; -import { getExtensionVersion } from "../util/util"; +import { + getArchitecture, + getExtensionVersion, + getPlatform, + isUnsupportedPlatform, +} from "../util/util"; import { VsCodeContinueApi } from "./api"; import setupInlineTips from "./InlineTipManager"; export async function activateExtension(context: vscode.ExtensionContext) { + const platformCheck = isUnsupportedPlatform(); + if (platformCheck.isUnsupported) { + const platformTarget = `${getPlatform()}-${getArchitecture()}`; + void vscode.window.showErrorMessage( + `Continue extension cannot activate on ${platformTarget}: ${platformCheck.reason}`, + ); + const error = new Error( + `Continue extension cannot activate on ${platformTarget}: ${platformCheck.reason}`, + ); + + void Telemetry.capture( + "unsupported_platform_activation_attempt", + { + platform: platformTarget, + extensionVersion: getExtensionVersion(), + reason: platformCheck.reason, + }, + true, + ); + + throw error; + } + // Add necessary files getTsConfigPath(); getContinueRcPath(); diff --git a/extensions/vscode/src/util/util.ts b/extensions/vscode/src/util/util.ts index a7c125ff1..949843fc4 100644 --- a/extensions/vscode/src/util/util.ts +++ b/extensions/vscode/src/util/util.ts @@ -1,6 +1,6 @@ -import * as vscode from "vscode"; +import * as os from "node:os"; -const os = require("node:os"); +import * as vscode from "vscode"; function charIsEscapedAtIndex(index: number, str: string): boolean { if (index === 0) { @@ -70,6 +70,7 @@ export function debounced(delay: number, fn: (...args: any[]) => void) { } type Platform = "mac" | "linux" | "windows" | "unknown"; +type Architecture = "x64" | "arm64" | "unknown"; export function getPlatform(): Platform { const platform = os.platform(); @@ -84,6 +85,42 @@ export function getPlatform(): Platform { } } +export function getArchitecture(): Architecture { + const arch = os.arch(); + if (arch === "x64" || arch === "ia32") { + return "x64"; + } else if (arch === "arm64" || arch === "arm") { + return "arm64"; + } else { + return "unknown"; + } +} + +export function isUnsupportedPlatform(): { + isUnsupported: boolean; + reason?: string; +} { + const platform = getPlatform(); + const arch = getArchitecture(); + + if (platform === "mac" && arch === "arm64") { + return { + isUnsupported: true, + reason: + "Windows ARM64 is not currently supported due to missing native dependencies (sqlite3, onnxruntime). Please use the extension on Windows x64, macOS, or Linux instead.", + }; + } + + if (platform === "unknown" || arch === "unknown") { + return { + isUnsupported: true, + reason: `Unsupported platform combination: ${os.platform()}-${os.arch()}. Continue extension supports Windows x64, macOS (Intel/Apple Silicon), and Linux (x64/ARM64).`, + }; + } + + return { isUnsupported: false }; +} + export function getAltOrOption() { if (getPlatform() === "mac") { return "⌥";