From 388ab69a970e7bbd249948f34d7ab3e7ab5ddcb9 Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Fri, 23 Jan 2026 13:20:31 -0500 Subject: [PATCH] fix(cliproxy): complete backend param propagation per code review - Add backend param to checkLatestVersion() - Add backend param to isPinned(), getPinned(), clearPin() wrappers - Use getBackendLabel() consistently in showStatus() Addresses review feedback from PR #359. --- src/cliproxy/services/binary-service.ts | 25 +++++++++++++++++-------- src/commands/cliproxy-command.ts | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/cliproxy/services/binary-service.ts b/src/cliproxy/services/binary-service.ts index 7202c3cb..6ad3f392 100644 --- a/src/cliproxy/services/binary-service.ts +++ b/src/cliproxy/services/binary-service.ts @@ -70,10 +70,13 @@ export function getBinaryStatus(backend?: CLIProxyBackend): BinaryStatusResult { /** * Check for latest version */ -export async function checkLatestVersion(): Promise { +export async function checkLatestVersion(backend?: CLIProxyBackend): Promise { + const effectiveBackend = + backend ?? loadOrCreateUnifiedConfig().cliproxy?.backend ?? DEFAULT_BACKEND; + try { const latestVersion = await fetchLatestCliproxyVersion(); - const currentVersion = getInstalledCliproxyVersion(); + const currentVersion = getInstalledCliproxyVersion(effectiveBackend); const updateAvailable = latestVersion !== currentVersion; return { @@ -177,20 +180,26 @@ export async function installLatest( /** * Check if a version is pinned */ -export function isPinned(): boolean { - return isVersionPinned(); +export function isPinned(backend?: CLIProxyBackend): boolean { + const effectiveBackend = + backend ?? loadOrCreateUnifiedConfig().cliproxy?.backend ?? DEFAULT_BACKEND; + return isVersionPinned(effectiveBackend); } /** * Get pinned version if any */ -export function getPinned(): string | null { - return getPinnedVersion(); +export function getPinned(backend?: CLIProxyBackend): string | null { + const effectiveBackend = + backend ?? loadOrCreateUnifiedConfig().cliproxy?.backend ?? DEFAULT_BACKEND; + return getPinnedVersion(effectiveBackend); } /** * Clear version pin */ -export function clearPin(): void { - clearPinnedVersion(); +export function clearPin(backend?: CLIProxyBackend): void { + const effectiveBackend = + backend ?? loadOrCreateUnifiedConfig().cliproxy?.backend ?? DEFAULT_BACKEND; + clearPinnedVersion(effectiveBackend); } diff --git a/src/commands/cliproxy-command.ts b/src/commands/cliproxy-command.ts index 6a08c32d..ebb20861 100644 --- a/src/commands/cliproxy-command.ts +++ b/src/commands/cliproxy-command.ts @@ -488,7 +488,7 @@ async function showStatus(verbose: boolean, backend: CLIProxyBackend): Promise