Skip to content

fix(cli): (a) Seed text initialValue from stored state (name || def... (#1590)#62

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

fix(cli): (a) Seed text initialValue from stored state (name || def... (#1590)#62
aidandaly24 wants to merge 1 commit into
mainfrom
fix/1590

Conversation

@aidandaly24

Copy link
Copy Markdown
Owner

Refs aws#1590

Issues

  • bug: inconsistent preference saving in wizards aws/agentcore-cli#1590 — In the TUI wizards, when a user navigates back to a previous step, the on-screen value does not always reflect what they previously typed/selected. Re-entering the agent name step shows the regenerated default (MyAgent) instead of the name the user typed; re-entering a single-select step (e.g. language) shows the cursor on the first option (Python) instead of the previously chosen value. The underlying config is actually retained in state and the final resource is created correctly, so this is a confusing display inconsistency, not data loss.

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:

BUILD: passed first attempt -> OK /local/home/aidandal/workplace/issues/bugfix-run/clusters/1590/repo/dist/cli/index.mjs. Drove the fixed CLI via tui-harness (node dist/cli/index.mjs create in a temp dir, build-type Agent -> AddAgentScreen which embeds GenerateWizardUI).

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.

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
@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.17% 13598 / 36581
🔵 Statements 36.44% 14457 / 39671
🔵 Functions 31.8% 2333 / 7336
🔵 Branches 31.12% 9008 / 28942
Generated in workflow #116 for commit 5ce7847 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