Skip to content

fix(cli): Add useCreateFlow.goBackToInput() (setPhase('input')) and... (#602)#47

Draft
aidandaly24 wants to merge 1 commit into
mainfrom
fix/602
Draft

fix(cli): Add useCreateFlow.goBackToInput() (setPhase('input')) and... (#602)#47
aidandaly24 wants to merge 1 commit into
mainfrom
fix/602

Conversation

@aidandaly24

Copy link
Copy Markdown
Owner

Refs aws#602

Issues

  • UI: esc on add agent screen exits CLI instead of going back aws/agentcore-cli#602 — On the screen reached after typing a project name in interactive agentcore 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 rerun agentcore 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:

BEFORE (unfixed source restored via git stash, provided unit test run): test FAILED. After submitting project name 'MyProject' and pressing Esc on the create-type-prompt, lastFrame() still rendered "What would you like to build?" with footer "↑↓ navigate · Enter select · Esc back · Ctrl+C quit" — the screen never returned to the "Create a new AgentCore project" input phase. Confirmed unfixed CreateScreen.tsx:290 wires create-type-prompt useListNavigation onExit=handleExit (top-level exit) with no back handler; no goBackToInput/handleBack present. This is the exact reported symptom (Esc on build-type select does not go back to name input). AFTER (fix in working tree): same test PASSES 1/1 — Esc returns to phase 'input' ("Create a new AgentCore project" reappears) and onExit mock is NOT called. Fix adds useCreateFlow.goBackToInput() (setPhase('input')) and a CreateScreen handleBack callback that calls flow.goBackToInput() only when phase==='create-type-prompt' else handleExit; both the create-type useListNavigation onExit and Screen onExit are rewired to handleBack. Adversarial temp tests (since removed) also confirmed: (1) Esc on the name input itself still fires top-level onExit (single cancel point preserved); (2) Esc-back then Esc-again cancels via onExit. Both passed.

Test suite: green.


Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.

…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
@github-actions github-actions Bot added the size/s PR size: S label Jun 25, 2026
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 37.32% 13655 / 36583
🔵 Statements 36.59% 14518 / 39673
🔵 Functions 32.01% 2349 / 7338
🔵 Branches 31.21% 9031 / 28934
Generated in workflow #101 for commit c6e32e0 by the Vitest Coverage Report Action

@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant