fix(cli): Add useCreateFlow.goBackToInput() (setPhase('input')) and... (#602)#47
Draft
aidandaly24 wants to merge 1 commit into
Draft
fix(cli): Add useCreateFlow.goBackToInput() (setPhase('input')) and... (#602)#47aidandaly24 wants to merge 1 commit into
aidandaly24 wants to merge 1 commit into
Conversation
…quitting (aws#602) On the interactive `agentcore create` create-type-prompt screen, the footer says "Esc back" but pressing Esc quit the whole CLI. Add useCreateFlow.goBackToInput() and a CreateScreen handleBack that returns to the project-name input when phase==='create-type-prompt', else falls through to the top-level exit. Rewire the create-type useListNavigation onExit and the Screen onExit to handleBack so Esc matches the footer. Refs aws#602
Coverage Report
|
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.
Refs aws#602
Issues
add agentscreen exits CLI instead of going back aws/agentcore-cli#602 — On the screen reached after typing a project name in interactiveagentcore create(the "Would you like to add an agent now?" create-prompt in GA, or "What would you like to build?" create-type-prompt in preview), the footer says "Esc back" but pressing Esc quits the whole CLI and discards the in-progress create. No back navigation to the name input is possible. No data loss (nothing is written before this point) and the user can simply rerunagentcore create, so impact is a confusing UX papercut, not a functional failure.Root cause
Verified at v0.20.2 (commit e92c79a) by reading every link in the chain myself. Esc on the create-prompt/create-type-prompt phase quits the CLI instead of going back: useListNavigation.ts:111-114 fires onExit on Esc; CreateScreen.tsx:297,307 set that onExit=handleExit; handleExit (CreateScreen.tsx:265-282) calls props.onExit when not in success; App.tsx:305-308 wires onExit=handleBack which (App.tsx:111-117) calls exit() because command.tsx:42-49 sets actionOnBack:'exit'. The footer for these phases is NAVIGATE_SELECT "...Esc back..." (constants.ts:16, CreateScreen.tsx:355). useCreateFlow has no create-prompt→input back handler (confirmProjectName useCreateFlow.ts:186-188 only moves forward; goBackFromAddAgent at 222-224 only goes wizard→create-prompt), so Esc falls through to exit, contradicting the footer.
The fix
Add a goBackToInput action to useCreateFlow (e.g. const goBackToInput = useCallback(() => setPhase('input'), []); expose it on CreateFlowState) and use it as the onExit for the two useListNavigation hooks driving the create-prompt and create-type-prompt phases in CreateScreen.tsx, replacing handleExit. Esc then returns to the project-name input, matching the "Esc back" footer and the user's stated expectation, consistent with the wizard layer's existing Esc-back behavior. The name input's own Esc (TextInput onCancel={handleExit}, CreateScreen.tsx:390) then becomes the single top-level cancel point, which is correct. Lower-quality alternative: relabel only these phases' footer to an "Esc cancel" constant, but going-back is the expected UX given every other list screen treats Esc as back. Pure CLI TUI wiring — no SDK/CDK/service involvement.
Files touched: src/cli/tui/screens/create/CreateScreen.tsx — the two useListNavigation onExit handlers for create-prompt (line 297) and create-type-prompt (line 307), change onExit from handleExit to the new goBackToInput. src/cli/tui/screens/create/useCreateFlow.ts — add goBackToInput = useCallback(() => setPhase('input'), []) near confirmProjectName (~line 186-188), declare it on the CreateFlowState interface (~line 74-76), and return it in the hook's return object (~line 776-792).
Validation evidence
The fix was verified by reproducing the original symptom and re-running after the change:
Test suite: green.
Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.