Skip to content

Commit a725d12

Browse files
authored
fix: show 'Computing diff changes...' step during deploy diff phase (#952)
The deploy TUI appeared frozen for 5-15 seconds between preflight completion and 'Publish assets' while cdkToolkitWrapper.diff() ran silently with no step marked as running. Add a dedicated pre-deploy diff step that transitions running -> success around the diff call so StepProgress always has something to highlight. Closes #781
1 parent 343fedc commit a725d12

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/cli/tui/screens/deploy/useDeployFlow.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ export function useDeployFlow(options: DeployFlowOptions = {}): DeployFlowState
122122
const identityKmsKeyArn = preSynthesized?.identityKmsKeyArn ?? preflight.identityKmsKeyArn;
123123
const allCredentials = preSynthesized?.allCredentials ?? preflight.allCredentials;
124124

125+
const [preDeployDiffStep, setPreDeployDiffStep] = useState<Step>({
126+
label: 'Computing diff changes...',
127+
status: 'pending',
128+
});
125129
const [publishAssetsStep, setPublishAssetsStep] = useState<Step>({ label: 'Publish assets', status: 'pending' });
126130
const [deployStep, setDeployStep] = useState<Step>({ label: 'Deploy to AWS', status: 'pending' });
127131
const [diffStep, setDiffStep] = useState<Step>({ label: 'Run CDK diff', status: 'pending' });
@@ -144,6 +148,7 @@ export function useDeployFlow(options: DeployFlowOptions = {}): DeployFlowState
144148
const streamOutputsRef = useRef<Record<string, string> | null>(null);
145149

146150
const startDeploy = useCallback(() => {
151+
setPreDeployDiffStep({ label: 'Computing diff changes...', status: 'pending' });
147152
setPublishAssetsStep({ label: 'Publish assets', status: 'pending' });
148153
setDeployStep({ label: 'Deploy to AWS', status: 'pending' });
149154
setDeployOutput(null);
@@ -327,6 +332,8 @@ export function useDeployFlow(options: DeployFlowOptions = {}): DeployFlowState
327332
if (!isDiffRunningRef.current) {
328333
isDiffRunningRef.current = true;
329334
setIsDiffLoading(true);
335+
setPreDeployDiffStep(prev => ({ ...prev, status: 'running' }));
336+
logger.startStep('Computing diff changes...');
330337
switchableIoHost?.setOnRawMessage((code, _level, message, data) => {
331338
logger.logDiff(code, message);
332339
if (code === 'CDK_TOOLKIT_I4002') {
@@ -345,6 +352,8 @@ export function useDeployFlow(options: DeployFlowOptions = {}): DeployFlowState
345352
switchableIoHost?.setOnRawMessage(null);
346353
isDiffRunningRef.current = false;
347354
setIsDiffLoading(false);
355+
logger.endStep('success');
356+
setPreDeployDiffStep(prev => ({ ...prev, status: 'success' }));
348357
}
349358
}
350359

@@ -569,8 +578,10 @@ export function useDeployFlow(options: DeployFlowOptions = {}): DeployFlowState
569578
if (diffMode) {
570579
return skipPreflight ? [diffStep] : [...preflight.steps, diffStep];
571580
}
572-
return skipPreflight ? [publishAssetsStep, deployStep] : [...preflight.steps, publishAssetsStep, deployStep];
573-
}, [preflight.steps, publishAssetsStep, deployStep, diffStep, skipPreflight, diffMode]);
581+
return skipPreflight
582+
? [preDeployDiffStep, publishAssetsStep, deployStep]
583+
: [...preflight.steps, preDeployDiffStep, publishAssetsStep, deployStep];
584+
}, [preflight.steps, preDeployDiffStep, publishAssetsStep, deployStep, diffStep, skipPreflight, diffMode]);
574585

575586
const phase: DeployPhase = useMemo(() => {
576587
const activeStep = diffMode ? diffStep : deployStep;

0 commit comments

Comments
 (0)