fix: prevent infinite loop on Escape from policy generation error#9
Merged
jesseturner21 merged 1 commit intomainfrom Mar 20, 2026
Merged
Conversation
Coverage Report
|
Package Tarballaws-agentcore-0.3.0-preview.6.1.tgz How to installnpm install https://github.com/jesseturner21/agentcore-cli/releases/download/pr-9-tarball/aws-agentcore-0.3.0-preview.6.1.tgz |
187fda2 to
ea35977
Compare
…error When the policy generation API returned an error, pressing Escape on the review step would loop back to the loading step and re-trigger the API call, creating an infinite loop. The root cause was the double goBack() pattern (one immediate, one via setTimeout) suffering from stale closures — both calls saw the same step, so the second never reached the description step, while the first landed on loading and re-fired the useEffect. The fix uses a skipGeneration ref: when navigating back from review, the ref is set to true and a single goBack() moves to the loading step. The useEffect detects the ref, resets it, and calls goBack() again (now with the correct step in scope) to reach the description step — without ever starting generation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ea35977 to
cd44505
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
goBack()pattern (immediate +setTimeout) suffered from stale closures — both calls saw the same step, so the loading step'suseEffectwould re-fire generationskipGenerationref to let theuseEffectdetect back-navigation and callgoBack()with the correct step in scope, reaching the description step without re-triggering generationTest plan
Evidence
Generation error on the review step
After Escape from error — lands on description step with text pre-filled
Successful generation result before pressing Escape
🤖 Generated with Claude Code