Skip to content

Commit 55dbfc8

Browse files
nickwesselmanclaude
andcommitted
Fix progress bars not clearing on completion after React 19 upgrade
The Ink 6 / React 19 upgrade (269f3aa) deferred unmountInk() in ConcurrentOutput to let React 19 flush batched state updates, but missed the same pattern in useAsyncAndUnmount (used by Tasks) and SingleTask. Without the deferral, unmountInk() fires before the setState that triggers `return null` is flushed, so the final render still contains the LoadingBar and it is never erased. Wrap unmountInk() in setImmediate() in both places, matching the existing fix in ConcurrentOutput. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a4d95bf commit 55dbfc8

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/cli-kit/src/private/node/ui/components/SingleTask.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ const SingleTask = <T,>({task, title, onComplete, onAbort, noColor}: SingleTaskP
3535
.then((result) => {
3636
setIsDone(true)
3737
onComplete?.(result)
38-
unmountInk()
38+
// Defer unmount so React 19 can flush batched state updates
39+
// before the component tree is torn down.
40+
setImmediate(() => unmountInk())
3941
})
4042
.catch((error) => {
4143
setIsDone(true)
42-
unmountInk(error)
44+
setImmediate(() => unmountInk(error))
4345
})
4446
}, [task, unmountInk, onComplete])
4547

packages/cli-kit/src/private/node/ui/hooks/use-async-and-unmount.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ export default function useAsyncAndUnmount(
1616
asyncFunction()
1717
.then(() => {
1818
onFulfilled()
19-
unmountInk()
19+
// Defer unmount so React 19 can flush batched state updates
20+
// before the component tree is torn down.
21+
setImmediate(() => unmountInk())
2022
})
2123
.catch((error) => {
2224
onRejected(error)
23-
unmountInk(error)
25+
setImmediate(() => unmountInk(error))
2426
})
2527
}, [])
2628
}

0 commit comments

Comments
 (0)