Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 16 additions & 9 deletions src/commands/managedInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { resolvePatchloomStatus, PATCHLOOM_RELEASES_URL, clearPatchloomStatusInf
import { decideManagedUpdate, resolveManagedBinaryVersion } from "../binary/managedUpdate.js";
import {
detectManagedInstallTarget,
unsupportedManagedInstallNotice,
fetchLatestReleaseVersion,
getManagedInstallRoot,
ManagedInstallStage,
Expand Down Expand Up @@ -61,9 +62,11 @@ export async function installPatchloom(): Promise<void> {

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;
}

Expand Down Expand Up @@ -106,9 +109,11 @@ export async function updatePatchloom(): Promise<void> {

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;
}

Expand Down Expand Up @@ -181,9 +186,11 @@ export async function reinstallPatchloom(): Promise<void> {

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;
}

Expand Down
11 changes: 11 additions & 0 deletions src/install/managed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<NodeJS.Architecture, string>> = {
x64: "x86_64",
arm64: "aarch64"
Expand Down
11 changes: 9 additions & 2 deletions src/status/details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down
12 changes: 12 additions & 0 deletions test/unit/binary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
clearManagedInstallFailure,
clearManagedInstallFailureRecord,
detectManagedInstallTarget,
unsupportedManagedInstallNotice,
inspectManagedInstallStatus,
loadManagedInstallFailure,
ManagedInstallVerificationError,
Expand Down Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions test/unit/initializeProject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
2 changes: 1 addition & 1 deletion walkthrough/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading