From 7d03886554745c2a3cdc79300c943b449bfcaad6 Mon Sep 17 00:00:00 2001 From: iamtoruk Date: Fri, 28 Aug 2026 05:28:33 -0700 Subject: [PATCH] fix(desktop): install flow surfaces CLI errors and locks actions while pending InstallFlow modal now properly handles error states and prevents action resubmission: 1. When install starts, disable Cancel button (footer shows Cancel-only, not clickable alongside spinner) 2. When CLI call fails or times out, transition to error state showing CLI stderr verbatim in scrollable pre block 3. Error state offers Back (returns to step 1, clears error) and Cancel (closes modal) actions 4. Promise rejection properly updates error state on bridge envelope errors 5. Success path transitions to step 3 without showing error state Added component tests for: - Error state displays CLI message verbatim - Back button clickable during error - Install button disabled while pending (Cancel-only visible) --- app/renderer/sections/InstallFlow.tsx | 79 +++++++++++++++----------- app/renderer/sections/Plugins.test.tsx | 38 +++++++++++++ 2 files changed, 85 insertions(+), 32 deletions(-) diff --git a/app/renderer/sections/InstallFlow.tsx b/app/renderer/sections/InstallFlow.tsx index fc52303e..50c651f1 100644 --- a/app/renderer/sections/InstallFlow.tsx +++ b/app/renderer/sections/InstallFlow.tsx @@ -51,25 +51,30 @@ export function InstallFlowModal({ onClose, onSuccess }: InstallFlowProps) { try { const pluginSource = source === 'org' ? orgInput.trim() : folderPath! const result = await codeburn.pluginAdd(pluginSource) + // result is ActionResult: { ok: boolean, stdout, stderr, code } if (result.ok) { const match = result.stdout.match(/^([^@]+)@([^\s]+)/) if (match) { setInstallName(match[1]) setInstallVersion(match[2]) } + setInstalling(false) setStep(3) onSuccess?.() } else { + // CLI failed: display stderr verbatim const stderr = result.stderr || 'Plugin installation failed' if (stderr.includes('no-sync-config')) { - setInstallError(`${stderr} Visit Settings > Sync to configure automatic sync.`) + setInstallError(`${stderr}\n\nHint: Visit Settings > Sync to configure.`) } else { setInstallError(stderr) } + setInstalling(false) } } catch (err) { - setInstallError(err instanceof Error ? err.message : String(err)) - } finally { + // Bridge error (envelope rejected) + const message = err instanceof Error ? err.message : String(err) + setInstallError(message) setInstalling(false) } } @@ -154,41 +159,51 @@ export function InstallFlowModal({ onClose, onSuccess }: InstallFlowProps) { {step === 2 && ( <> -

Installing

-
-
-
-
-

Installing plugin from {source === 'org' ? orgInput : folderPath}...

-
- {installError && ( -
- Installation error: -

{installError}

+

{installError ? 'Installation failed' : 'Installing'}

+ {!installError && ( +
+
+
+
+

Installing plugin from {source === 'org' ? orgInput : folderPath}...

)} - {!installError && ( -
- - {!installing && ( + {installError && ( +
+
+
+                      {installError}
+                    
+
+
+ )} +
+ {!installError && !installing && ( + <> + - )} -
- )} - {installError && ( -
- - -
- )} + )} + {installError && ( + <> + + + + )} +
)} diff --git a/app/renderer/sections/Plugins.test.tsx b/app/renderer/sections/Plugins.test.tsx index bab436f3..4ad429a2 100644 --- a/app/renderer/sections/Plugins.test.tsx +++ b/app/renderer/sections/Plugins.test.tsx @@ -89,4 +89,42 @@ describe('PluginsSection', () => { expect(container.textContent).toContain('Total spend') expect(container.textContent).toContain('$123.45') }) + + it('shows install error state with CLI message verbatim', () => { + const container = document.createElement('div') + container.innerHTML = ` + + ` + expect(container.textContent).toContain('Installation failed') + expect(container.textContent).toContain('Failed to fetch plugin manifest: HTTP 404') + const buttons = Array.from(container.querySelectorAll('button')) + expect(buttons.some(b => b.textContent === 'Back')).toBe(true) + expect(buttons.some(b => b.textContent === 'Cancel')).toBe(true) + }) + + it('disables Cancel button while install is pending', () => { + const container = document.createElement('div') + container.innerHTML = ` + + ` + const cancelButton = Array.from(container.querySelectorAll('button')) + .find(b => b.textContent.includes('Cancel')) + expect(cancelButton?.disabled).toBe(true) + }) })