Skip to content

fix(run-insights): TUI wizard state, inline name validation, job history#1602

Open
notgitika wants to merge 1 commit into
aws:mainfrom
notgitika:fix/run-insights-tui
Open

fix(run-insights): TUI wizard state, inline name validation, job history#1602
notgitika wants to merge 1 commit into
aws:mainfrom
notgitika:fix/run-insights-tui

Conversation

@notgitika

@notgitika notgitika commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Four fixes to the agentcore run insights interactive wizard, from the Lens-in-CLI bug bash:

  • Single-agent flow leaves Confirm blank. When the project has exactly one agent, the wizard skipped the agent step but never populated config.agent, so the Confirm screen showed an empty Agent: line. The default config now pre-populates the sole agent so it threads through to confirm and the API call.

  • Inline name validation. The Name step accepted spaces / hyphens / leading digits and only blew up after submit with a service 400. We now validate inline using the service-side BatchEvaluationName shape (^[a-zA-Z][a-zA-Z0-9_]{0,47}$) from AgentCoreEvaluationCommonModel. Lookback days also validate inline (1-90, integer only) instead of silently coercing 0 → 7.

  • Preserve config on error. Hitting "Go back" from a launch error reset the entire wizard. The failed config is now stashed in flow state and the wizard re-opens at the Name step with all prior selections intact.

  • Post-launch "No insights runs found". The wizard wrote to the job-engine store, but the post-launch "View Insights Jobs" screen reads from the legacy .cli/insights/*.json store. We now mirror successful starts to the legacy store after launch so the new job appears immediately.

…inline, surface job in history

Multiple fixes to the `agentcore run insights` interactive wizard:

- **Single-agent flow** (#4): when the project has exactly one agent, the
  wizard skipped the agent step but never set `config.agent`, so the
  Confirm screen showed a blank "Agent:" line. Pre-populate the sole
  agent in the default config so it's threaded through to confirm and
  the API call.

- **Inline name validation** (aws#6): the Name step accepted invalid values
  (spaces, hyphens, leading digits) and only failed at submit time when
  the API returned a 400. Validate inline against the service-side
  `BatchEvaluationName` pattern (`^[a-zA-Z][a-zA-Z0-9_]{0,47}$`).
  Lookback days now also validate inline (1-90, integer only) instead of
  silently coercing 0 to 7.

- **Preserve config on error** (aws#16): when the launch failed, hitting
  "Go back" reset the wizard to the Source step and discarded all
  selections. Now the failed config is stashed in flow state and the
  wizard re-opens at the Name step with everything pre-populated.

- **Post-launch history** (aws#17): the wizard wrote to the job-engine store
  but `view insights` reads from the legacy `.cli/insights/*.json`
  store, so the brand-new job rendered as "No insights runs found".
  Mirror successful starts to the legacy store after launch.

Bug bash items #4, aws#6, aws#16, aws#17 (mix of P1/P2).
@notgitika notgitika requested a review from a team June 22, 2026 03:06
@github-actions github-actions Bot added the size/m PR size: M label Jun 22, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jun 22, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.20.2.tgz

How to install

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

@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 Jun 22, 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.

Nice, focused fixes for the bug bash items. Two things I'd like addressed before merge:

  1. The new forwardRef / useImperativeHandle / jumpToStep surface on RunInsightsScreen appears to be dead code — nothing in the tree passes a ref, and resume-on-error works entirely through the new initialConfig / initialStep props (the screen re-mounts when RunInsightsFlow transitions from error back to wizard). Either wire it up to a caller or drop it; otherwise it adds an API contract that's unused, untested, and (in React 19) unnecessary.
  2. The two new pure validators are good candidates for a small unit test. There are no tests under src/cli/tui/screens/run-insights/ at all, and three of the four fixes here (single-agent default, inline name validation, resume-on-error) are reachable via the wizard hook + pure helpers without any TUI rendering. A small validateJobName / validateLookbackInput / useRunInsightsWizard test file would lock these in cheaply.

One smaller suggestion inline about the silent catch in persistToLegacyStore.

ref
) {
const wizard = useRunInsightsWizard(agentNames, initialConfig, initialStep);
useImperativeHandle(ref, () => ({ jumpToStep: wizard.jumpToStep }), [wizard.jumpToStep]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This forwardRef + useImperativeHandle plumbing (and the exported RunInsightsScreenHandle / jumpToStep on the wizard hook) doesn't appear to be consumed anywhere — RunInsightsFlow mounts the screen without a ref, and resume-on-error works purely through initialConfig / initialStep. I'd suggest one of:

  • Drop it — remove the forwardRef wrapper, the RunInsightsScreenHandle interface, the useImperativeHandle call, and the jumpToStep exposure from useRunInsightsWizard. The component goes back to a plain function and the public API stays minimal.
  • Wire it up — if there's a follow-up use case (e.g. surfacing field-specific errors and jumping to that step from RunInsightsFlow), pass a ref from the flow and call jumpToStep there so the path is exercised.

Note that with React 19, even if you do want imperative access, forwardRef is no longer needed — ref can be a regular prop.

}
},
[allSteps]
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

jumpToStep here only exists to be threaded through useImperativeHandle in RunInsightsScreen.tsx — and nothing calls the resulting handle. Consider removing it (and the forwardRef wrapper) unless there's a planned consumer.

// shows "No insights runs found" right after creating the job.
await persistToLegacyStore(startResult.record).catch(() => {
// Non-fatal — the job started successfully; storage failures shouldn't surface.
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Silently swallowing the error here makes it hard to diagnose a future regression where the legacy store stops being written (the user sees "No insights runs found" again and there's no breadcrumb). At minimum, log via the same mechanism the rest of the flow uses (e.g. ExecLogger or a console.warn). Since the comment already says "storage failures shouldn't surface," the goal is debuggability, not user-visible errors.

Minor: per the comment, this is a workaround until the post-launch screen reads from the job-engine store. A follow-up issue/TODO referencing that migration would help avoid leaving two stores diverging indefinitely (the engine store gets refresh updates, the legacy store doesn't — so statuses written here will stay frozen forever).

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

@jariy17 jariy17 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.

I have one blocking comment.

// Mirror the new job to the legacy insights store so `view insights`
// (InsightsJobsScreen) finds it. Without this, the post-launch screen
// shows "No insights runs found" right after creating the job.
await persistToLegacyStore(startResult.record).catch(() => {

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.

If ViewInsights is looking in the wrong directory shouldn't we change what directory it's looking at. By duplicate the job in two locations, the customer has two "sources of truth" which means we have to maintain both locations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants