fix(cli): (a) Seed text initialValue from stored state (name || def... (#1590)#62
Draft
aidandaly24 wants to merge 1 commit into
Draft
fix(cli): (a) Seed text initialValue from stored state (name || def... (#1590)#62aidandaly24 wants to merge 1 commit into
aidandaly24 wants to merge 1 commit into
Conversation
Seed text inputs and single-select cursors from retained wizard config so navigating back to a step shows the previously typed/selected value instead of regenerated defaults or the first option. - useListNavigation: add initialSelectedIndex, honored on mount and on resetKey change, defaults to 0/first-enabled when unset or invalid - AddAgentScreen: name step initialValue = name || generateUniqueName(...) - GenerateWizardUI: seed select cursors and idle-timeout/max-lifetime text inputs from wizard.config Refs aws#1590
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#1590
Issues
Root cause
Two TUI mechanisms verified at v0.20.2: useTextInput.ts:73 reads initialValue only at mount + AddAgentScreen.tsx:1000 doesn't seed from stored name; useListNavigation.ts:90-102 always inits/resets cursor to 0 + GenerateWizardUI.tsx:170 resetKey: wizard.step never seeds from config. Config IS retained, only display drops.
The fix
(a) Seed text initialValue from stored state (name || default) at AddAgentScreen.tsx:1000 and GenerateWizardUI idleTimeout/maxLifetime; (b) add initialSelectedIndex to useListNavigation and compute it from wizard.config (findIndex by id) for all select steps. Design decision: centralize cursor-restore in useListNavigation vs. patch each call site.
Files touched: src/cli/tui/hooks/useListNavigation.ts (add initialSelectedIndex seeding in the useState initializer lines 90-94 and the resetKey branch lines 98-102); src/cli/tui/screens/agent/AddAgentScreen.tsx (name step initialValue at line 1000 -> name || generateUniqueName(...)); src/cli/tui/screens/generate/GenerateWizardUI.tsx (seed selectedIndex from config in the useListNavigation call at lines 164-171; seed idleTimeout initialValue at line 393 and maxLifetime initialValue at line 417 from wizard.config). src/cli/tui/hooks/useTextInput.ts:73 is the underlying mount-only behavior (no change needed; callers fix initialValue). Optional shared WizardSelect/wizard-step helper for consistency.
Validation evidence
The fix was verified by reproducing the original symptom and re-running after the change:
BEFORE (original symptom, per cluster description): name step re-rendered initialValue=generateUniqueName('MyAgent',...) so back-nav showed 'MyAgent'; single-select steps had no initialSelectedIndex (useState init / resetKey branch always -> first-enabled) so back-nav put the cursor on index 0 (e.g. Python); idle-timeout & max-lifetime text steps used initialValue="" so back-nav showed empty.
AFTER (observed on branch fix/1590):
(1) NAME: typed 'PaymentBot', advanced to Type step (Name shows checkmark), pressed Esc back -> name field re-displayed '> PaymentBot' (NOT a regenerated MyAgent). Matches AddAgentScreen.tsx:1000 initialValue={name || generateUniqueName(...)}.
(2) SINGLE-SELECT: Language step picked 'TypeScript' (down+Enter), advanced to Build, Esc back -> cursor (the ❯ marker) landed on 'TypeScript', NOT 'Python' (index 0). Repeated for Framework step: picked 'Vercel AI SDK', went to Model, Esc back -> cursor on 'Vercel AI SDK'. Matches GenerateWizardUI.tsx:166-176 (initialSelectedIndex = items.findIndex(id===wizard.config[step]) passed to useListNavigation).
(3) TEXT STEPS: entered Idle Timeout=900, Max Lifetime=7200, reached Confirm (review showed Name: PaymentBot, Language: TypeScript, Framewo
Test suite: green.
Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.