Skip to content

fix: handle ESC properly on policy generate selection screen - #2225

Merged
nborges-aws merged 1 commit into
refactorfrom
fix/esc-policy-generation
Sep 4, 2026
Merged

fix: handle ESC properly on policy generate selection screen#2225
nborges-aws merged 1 commit into
refactorfrom
fix/esc-policy-generation

Conversation

@nborges-aws

Copy link
Copy Markdown
Contributor

Description

Fix an issue in agentcore -> gateway -> policy -> generate TUI flow. ESC on the "choose gateway to generate policy for screen" caused an infinite redirection back to the gateway selection table. Solution changes onEscape to direct you back to gateway management screen.

Before:

Screen.Recording.2026-09-04.at.2.02.39.PM.mov

After

Screen.Recording.2026-09-04.at.2.03.55.PM.mov

Type of Change

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

Testing

How have you tested the change?

  • bun run test (2988 pass, 0 fail)
  • 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.

@github-actions github-actions Bot added the size/xs PR size: XS label Sep 4, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Sep 4, 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 Sep 4, 2026

@agentcore-devx-automation agentcore-devx-automation Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AgentCore Harness Review

Verdict: Looks good

This is a small, correct fix. The GatewayPolicyGenerateScreen picker has breadcrumb ["agentcore", "gateway", "policy", "generate"], so GatewayPicker's default onBack would navigate to /agentcore/gateway/policy, which in Root.tsx (lines 479–482) is just a <Navigate to="/agentcore/gateway/policy/generate" replace /> — i.e., it bounces right back to the picker. Explicitly wiring onEscape to /agentcore/gateway correctly skips the redirect-only route and lands on the Gateway menu.

The new test in generate.screen.test.tsx exercises the full picker → menu path and uses the standard TestCoreClient — no excessive mocking. Nothing to change here.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Sep 4, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.05%. Comparing base (9175ad4) to head (e6fd546).

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #2225   +/-   ##
=========================================
  Coverage     97.05%   97.05%           
=========================================
  Files           555      555           
  Lines         38385    38386    +1     
=========================================
+ Hits          37253    37254    +1     
  Misses         1132     1132           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nborges-aws
nborges-aws merged commit 3fcf406 into refactor Sep 4, 2026
20 of 21 checks passed
@nborges-aws
nborges-aws deleted the fix/esc-policy-generation branch September 4, 2026 18:24
aidandaly24 added a commit that referenced this pull request Sep 4, 2026
…2234)

* fix(tui): esc from a deep-linked harness wizard returns to the menu

`agentcore harness create` with no flags opens the TUI directly on the
wizard, so the wizard is the only history entry. Its first-step back was
navigate(-1), which had nothing to pop, and esc did nothing. The wizard
now takes an explicit onExit: create returns to the harness menu, update
returns to the update picker.

* test(tui): cover esc from every command with a screen

Walk the compiled command tree, mount every screen-backed command through
the real route table, press esc, and assert the header belongs to a menu
above it. This is the counterpart to the command-line-only walk in
CliOnlyScreen.test, so a screen added later is covered without a new
test. It catches both the policy picker redirect loop (#2225) and the
deep-linked wizard. compiledRootCommand() is extracted from the harness
so tests can enumerate the tree the same way the app does.

* fix(tui): keep the update wizard's escape as a history pop

The update wizard is only reached from the update picker or the detail
screen's update action, never as the first history entry, so a pop returns
to whichever the user came from. Only the create wizard can be deep-linked
and needs an explicit target. Note the same invariant at EndpointWizard's
pop, which the route walk cannot reach because every route into it passes
a picker first.

* test(tui): reuse compiledRootCommand and note what the walk tolerates

Drop the two inline root compiles now that the harness exports one, and
record that the walk accepts any ancestor menu, so it catches a no-op or a
loop but not an escape that jumps too far up.
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