Skip to content

fix: fix infinite loop between source type and add another KB TUI screens#1699

Merged
nborges-aws merged 1 commit into
mainfrom
KB-TUI-screen-fix
Jul 7, 2026
Merged

fix: fix infinite loop between source type and add another KB TUI screens#1699
nborges-aws merged 1 commit into
mainfrom
KB-TUI-screen-fix

Conversation

@nborges-aws

@nborges-aws nborges-aws commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

Fix a bug which caused TUI screen to infinitely loop between "source type" and "add another?" when atleast one source was configured on a KB.

The previous cycle was caused by:

  1. add-another Esc → data-source-type
  2. data-source-type Esc (with existing sources) → add-another

The solution in this PR updates the logic in the following ways:

  • source-type always returns to description
  • description advances conditionally to source-type or add-another, based on at least one data source already being configured
  • sources always returns to data source type

New flow is as follows:

  • First time through (no sources): description → data-source-type → sources → add-another
  • Esc from add-another → data-source-type (reconsider)
  • Esc from data-source-type → description
  • Submit from description (with existing sources) → add-another (skip type picker, go straight to decide)

Related Issue

Closes #

Documentation PR

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@nborges-aws nborges-aws requested a review from a team July 7, 2026 16:31
@github-actions github-actions Bot added the size/xs PR size: XS label Jul 7, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label Jul 7, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jul 7, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.22.0.tgz

How to install

gh release download pr-1699-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.22.0.tgz

@nborges-aws nborges-aws changed the title fix: fix infinite loop between source type and add another KB TUI scr… fix: fix infinite loop between source type and add another KB TUI screens Jul 7, 2026

@agentcore-cli-automation agentcore-cli-automation left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix eliminates the infinite loop cleanly — my trace of the new state machine agrees with the description, and I don't see any new cycle introduced.

One thing worth adding before merging: a regression test for the loop scenario. The existing AddKnowledgeBaseScreen.test.tsx already drives the wizard with ink-testing-library (see walkToGatewayStep), so a test that reproduces "add one source → land on add-another → Esc → Esc" and asserts the screen doesn't oscillate would be inexpensive to add and would prevent this exact regression from returning. Without it, someone could easily re-introduce the loop by tweaking one of these onExit/onCancel handlers.

Minor observation (non-blocking, pre-existing): the description TextInput doesn't pass initialValue={description}, so on any Esc-round-trip that returns to the description step the field renders empty, and hitting Enter clears the previously entered description. This PR widens the set of paths that reach the description step a second time (Esc from data-source-type now works even when sources exist), so users are more likely to hit it. Worth a follow-up — probably as simple as initialValue={description} on the description input, or gating setDescription(value) on non-empty input.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 38.72% 14400 / 37181
🔵 Statements 38.03% 15347 / 40352
🔵 Functions 33.29% 2476 / 7436
🔵 Branches 32.51% 9608 / 29550
Generated in workflow #3996 for commit b1bc05f by the Vitest Coverage Report Action

@nborges-aws nborges-aws merged commit 08a9ae5 into main Jul 7, 2026
35 of 36 checks passed
@nborges-aws nborges-aws deleted the KB-TUI-screen-fix branch July 7, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xs PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants