fix(cliproxy): consolidate download ui to single spinner

Use single spinner with update() instead of multiple spinners.
Prevents UI jumping during download/verify/extract phases.
This commit is contained in:
kaitranntt
2025-12-05 17:24:12 -05:00
parent 47700474a4
commit ace5ba8750
+7 -12
View File
@@ -383,6 +383,7 @@ export class BinaryManager {
// Download archive // Download archive
const archivePath = path.join(this.config.binPath, `cliproxy-archive.${platform.extension}`); const archivePath = path.join(this.config.binPath, `cliproxy-archive.${platform.extension}`);
// Use single spinner and update text as we progress (avoids UI jumping)
const spinner = new ProgressIndicator(`Downloading CLIProxyAPI v${this.config.version}`); const spinner = new ProgressIndicator(`Downloading CLIProxyAPI v${this.config.version}`);
spinner.start(); spinner.start();
@@ -394,11 +395,8 @@ export class BinaryManager {
throw new Error(result.error || 'Download failed after retries'); throw new Error(result.error || 'Download failed after retries');
} }
spinner.succeed('Download complete'); // Verify checksum (update spinner text instead of creating new one)
spinner.update('Verifying checksum');
// Verify checksum
const verifySpinner = new ProgressIndicator('Verifying checksum');
verifySpinner.start();
const checksumResult = await this.verifyChecksum( const checksumResult = await this.verifyChecksum(
archivePath, archivePath,
@@ -407,7 +405,7 @@ export class BinaryManager {
); );
if (!checksumResult.valid) { if (!checksumResult.valid) {
verifySpinner.fail('Checksum mismatch'); spinner.fail('Checksum mismatch');
fs.unlinkSync(archivePath); fs.unlinkSync(archivePath);
throw new Error( throw new Error(
`Checksum mismatch for ${platform.binaryName}\n` + `Checksum mismatch for ${platform.binaryName}\n` +
@@ -417,15 +415,12 @@ export class BinaryManager {
); );
} }
verifySpinner.succeed('Checksum verified'); // Extract archive (update spinner text)
spinner.update('Extracting binary');
// Extract archive
const extractSpinner = new ProgressIndicator('Extracting binary');
extractSpinner.start();
await this.extractArchive(archivePath, platform.extension); await this.extractArchive(archivePath, platform.extension);
extractSpinner.succeed('Extraction complete'); spinner.succeed('CLIProxyAPI ready');
// Cleanup archive // Cleanup archive
fs.unlinkSync(archivePath); fs.unlinkSync(archivePath);