Skip to content

Commit 4f2b92c

Browse files
committed
fix(tui): prevent screen flicker in policy creation flow
handleSelectEngine and handleAddPolicyToNewEngine perform async gateway lookups without transitioning to a loading state first, leaving the select screen interactive during the await. This causes a visible flicker when the promise resolves and the flow jumps to the policy wizard. Set flow to loading before the async calls so the UI shows a clean loading indicator during the transition.
1 parent a5c2da9 commit 4f2b92c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/cli/tui/screens/policy/AddPolicyFlow.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export function AddPolicyFlow({ isInteractive = true, onExit, onBack, onDev, onD
112112
if (item.id === '__create_new__') {
113113
setFlow({ name: 'engine-wizard' });
114114
} else {
115+
setFlow({ name: 'loading' });
115116
const [deployedId, deployedGateways] = await Promise.all([
116117
policyEnginePrimitive.getDeployedEngineId(item.id),
117118
policyEnginePrimitive.getDeployedGateways(),
@@ -161,6 +162,7 @@ export function AddPolicyFlow({ isInteractive = true, onExit, onBack, onDev, onD
161162
}, []);
162163

163164
const handleAddPolicyToNewEngine = useCallback(async (engineName: string) => {
165+
setFlow({ name: 'loading' });
164166
const [deployedId, deployedGateways] = await Promise.all([
165167
policyEnginePrimitive.getDeployedEngineId(engineName),
166168
policyEnginePrimitive.getDeployedGateways(),
@@ -177,7 +179,7 @@ export function AddPolicyFlow({ isInteractive = true, onExit, onBack, onDev, onD
177179
if (flow.name === 'loading') {
178180
return (
179181
<Box>
180-
<Text dimColor>Loading policy engines...</Text>
182+
<Text dimColor>Loading...</Text>
181183
</Box>
182184
);
183185
}

0 commit comments

Comments
 (0)