diff --git a/package-lock.json b/package-lock.json index 4f41a71..05445af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3126,9 +3126,9 @@ } }, "node_modules/fast-check": { - "version": "4.10.3", - "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.10.3.tgz", - "integrity": "sha512-SBaU6nhh+sXxb05r2IHAKfxnR/1Pu6MqtHYaewM1BY6V5xzOxOk+4yoWO7WfeeyZG1iArFE6/DO/7iLYMUuOJg==", + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.11.0.tgz", + "integrity": "sha512-V4Uc238rhQOdQlc+Gz7JG6SGBtrWnWL8d/6RyiBeCMcNKMhF6DZ0KkAVHJSyNV5r4lA0PmIpZ6iRpTVoz4qjoA==", "dev": true, "funding": [ { diff --git a/src/commands/managedInstall.ts b/src/commands/managedInstall.ts index 2aa8dad..1874af4 100644 --- a/src/commands/managedInstall.ts +++ b/src/commands/managedInstall.ts @@ -4,6 +4,7 @@ import { resolvePatchloomStatus, PATCHLOOM_RELEASES_URL, clearPatchloomStatusInf import { decideManagedUpdate, resolveManagedBinaryVersion } from "../binary/managedUpdate.js"; import { detectManagedInstallTarget, + unsupportedManagedInstallNotice, fetchLatestReleaseVersion, getManagedInstallRoot, ManagedInstallStage, @@ -61,9 +62,11 @@ export async function installPatchloom(): Promise { const target = detectManagedInstallTarget(); if (!target) { - await vscode.window.showErrorMessage( - `Managed install is not supported on this platform (${process.platform}/${process.arch}).` - ); + const notice = unsupportedManagedInstallNotice(process.platform, process.arch); + const choice = await vscode.window.showErrorMessage(notice.message, notice.actionTitle); + if (choice === notice.actionTitle) { + await vscode.commands.executeCommand(notice.actionCommand); + } return; } @@ -106,9 +109,11 @@ export async function updatePatchloom(): Promise { const target = detectManagedInstallTarget(); if (!target) { - await vscode.window.showErrorMessage( - `Managed install is not supported on this platform (${process.platform}/${process.arch}).` - ); + const notice = unsupportedManagedInstallNotice(process.platform, process.arch); + const choice = await vscode.window.showErrorMessage(notice.message, notice.actionTitle); + if (choice === notice.actionTitle) { + await vscode.commands.executeCommand(notice.actionCommand); + } return; } @@ -181,9 +186,11 @@ export async function reinstallPatchloom(): Promise { const target = detectManagedInstallTarget(); if (!target) { - await vscode.window.showErrorMessage( - `Managed install is not supported on this platform (${process.platform}/${process.arch}).` - ); + const notice = unsupportedManagedInstallNotice(process.platform, process.arch); + const choice = await vscode.window.showErrorMessage(notice.message, notice.actionTitle); + if (choice === notice.actionTitle) { + await vscode.commands.executeCommand(notice.actionCommand); + } return; } diff --git a/src/install/managed.ts b/src/install/managed.ts index d4f3631..5cf7ef6 100644 --- a/src/install/managed.ts +++ b/src/install/managed.ts @@ -268,6 +268,17 @@ export function detectManagedInstallTarget( return undefined; } +export function unsupportedManagedInstallNotice( + platform: string, + arch: string +): { message: string; actionTitle: string; actionCommand: string } { + return { + message: `Managed install is not supported on this platform (${platform}/${arch}). Set patchloom.path to a Patchloom binary you already have.`, + actionTitle: "Open Settings", + actionCommand: "patchloom.openPatchloomSettings" + }; +} + const MUSL_ARCH_MAP: Partial> = { x64: "x86_64", arm64: "aarch64" diff --git a/src/status/details.ts b/src/status/details.ts index 1597b64..b343549 100644 --- a/src/status/details.ts +++ b/src/status/details.ts @@ -14,8 +14,13 @@ export interface SetupAction { } export function buildStatusDetails(status: PatchloomStatus, workspaceReadiness?: WorkspaceReadiness): string { + const headline = !status.ready + ? "Patchloom is not ready." + : patchloomNeedsUpgrade(status) + ? "Patchloom CLI is older than this extension expects." + : "Patchloom is ready."; return [ - status.ready ? "Patchloom is ready." : "Patchloom is not ready.", + headline, status.message, `Source: ${describePatchloomSource(status.source)}`, status.version ? `Version: ${status.version}` : undefined, @@ -55,7 +60,9 @@ export function statusNotificationSummary(ready: boolean, needsUpgrade: boolean) } export function preferredStatusAction(status: PatchloomStatus, workspaceReadiness?: WorkspaceReadiness): SetupAction | undefined { - // Missing or outdated CLI: shared remediation (managed install preferred). + // Missing or outdated CLI. Install or Update only when the managed + // binary is the one in use. A setting or PATH binary opens Settings + // or Releases, because those still win resolution order. if (!status.ready || patchloomNeedsUpgrade(status)) { return preferredBinaryRemediationAction(status); } diff --git a/test/unit/binary.test.ts b/test/unit/binary.test.ts index 81f90c9..a212f69 100644 --- a/test/unit/binary.test.ts +++ b/test/unit/binary.test.ts @@ -30,6 +30,7 @@ import { clearManagedInstallFailure, clearManagedInstallFailureRecord, detectManagedInstallTarget, + unsupportedManagedInstallNotice, inspectManagedInstallStatus, loadManagedInstallFailure, ManagedInstallVerificationError, @@ -456,6 +457,17 @@ test("detectManagedInstallTarget maps supported platforms to release targets", ( assert.equal(detectManagedInstallTarget("linux", "arm"), undefined); }); +test("unsupportedManagedInstallNotice names linux/arm and opens settings", () => { + const notice = unsupportedManagedInstallNotice("linux", "arm"); + assert.equal( + notice.message, + "Managed install is not supported on this platform (linux/arm). Set patchloom.path to a Patchloom binary you already have." + ); + assert.match(notice.message, /linux\/arm/); + assert.equal(notice.actionTitle, "Open Settings"); + assert.equal(notice.actionCommand, "patchloom.openPatchloomSettings"); +}); + test("detectManagedInstallTarget selects musl target when isMusl is true", () => { assert.deepEqual(detectManagedInstallTarget("linux", "x64", true), { platform: "linux", diff --git a/test/unit/initializeProject.test.ts b/test/unit/initializeProject.test.ts index 8d5cba2..1bf89db 100644 --- a/test/unit/initializeProject.test.ts +++ b/test/unit/initializeProject.test.ts @@ -512,6 +512,21 @@ test("buildStatusDetails includes workspace readiness context", () => { assert.match(details, /AGENTS\.md: missing/); }); +test("buildStatusDetails opens with the upgrade warning when the CLI is unsupported", () => { + const details = buildStatusDetails({ + ready: true, + source: "path", + message: "Using Patchloom from PATH.", + binaryPath: "/usr/local/bin/patchloom", + version: "patchloom 0.0.9", + compatibility: "unsupported" + }); + + const firstLine = details.split("\n")[0]; + assert.equal(firstLine, "Patchloom CLI is older than this extension expects."); + assert.notEqual(firstLine, "Patchloom is ready."); +}); + test("preferredStatusAction points missing binary users to settings", () => { const action = preferredStatusAction( { diff --git a/walkthrough/install.md b/walkthrough/install.md index 77e0183..4644b99 100644 --- a/walkthrough/install.md +++ b/walkthrough/install.md @@ -3,7 +3,7 @@ Patchloom needs the CLI binary to work. Prefer channels that track GitHub Releases promptly (same day as the tag). -## Managed Install (Recommended on all platforms) +## Managed Install (Recommended download when a build exists) Click **Install Patchloom** above to download and install the CLI automatically. The extension handles download, checksum verification,