Skip to content

fix(tui): prevent screen flicker in policy creation flow#730

Merged
jesseturner21 merged 1 commit intomainfrom
fix/policy-flow-flicker
Mar 30, 2026
Merged

fix(tui): prevent screen flicker in policy creation flow#730
jesseturner21 merged 1 commit intomainfrom
fix/policy-flow-flicker

Conversation

@jesseturner21
Copy link
Copy Markdown
Contributor

@jesseturner21 jesseturner21 commented Mar 30, 2026

Description

Fixes a UI flicker in the policy creation flow where, after selecting a policy engine, the gateway selection step briefly shows "No items available" before the actual gateways appear.

Root cause: handleSelectEngine and handleAddPolicyToNewEngine perform async gateway lookups (getDeployedEngineId + getDeployedGateways) without transitioning to a loading state first. This leaves the select screen interactive during the await, which can cause the handler to fire multiple times (race condition). When both resolve, the flow state is set twice in quick succession, remounting AddPolicyScreen — causing the gateway list to briefly render as empty before being populated.

Fix: Set the flow state to loading before the async calls. This replaces the interactive select screen with a loading indicator, preventing duplicate firings and ensuring a clean single transition to the policy wizard with gateway data already resolved.

Also updated the loading message from "Loading policy engines..." to the generic "Loading..." since it is now reused for both initial load and engine-to-policy transitions.

Related Issue

Closes #

Documentation PR

N/A — no user-facing docs changes needed.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Additionally, manually tested the policy creation flow end-to-end by running the CLI, selecting an engine, choosing the Generate source method, and verifying that the gateway selection step renders cleanly without briefly showing "No items available" before the gateways appear.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

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.
@jesseturner21 jesseturner21 requested a review from a team March 30, 2026 19:20
@github-actions github-actions bot added the size/xs PR size: XS label Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.4.0.tgz

How to install

npm install https://github.com/aws/agentcore-cli/releases/download/pr-730-tarball/aws-agentcore-0.4.0.tgz

@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 46.01% 6555 / 14246
🔵 Statements 45.58% 6965 / 15280
🔵 Functions 44.71% 1176 / 2630
🔵 Branches 46.11% 4334 / 9399
Generated in workflow #1523 for commit 4f2b92c by the Vitest Coverage Report Action

Copy link
Copy Markdown
Contributor

@Hweinstock Hweinstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice find!

@jesseturner21 jesseturner21 merged commit dbb9c00 into main Mar 30, 2026
23 checks passed
@jesseturner21 jesseturner21 deleted the fix/policy-flow-flicker branch March 30, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xs PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants