Skip to content

fix(cli): Converge dev onto the in-TUI error pattern. DevScreen alr... (#1588)#70

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

fix(cli): Converge dev onto the in-TUI error pattern. DevScreen alr... (#1588)#70
aidandaly24 wants to merge 1 commit into
mainfrom
fix/1588

Conversation

@aidandaly24

Copy link
Copy Markdown
Owner

Refs aws#1588

Issues

  • bug: error behavior in TUI is inconsistent aws/agentcore-cli#1588 — In the TUI menu, selecting "dev" in a project that has no agents/harnesses tears down the TUI and dumps the user back to the shell with a bare "Error: No agents or harnesses defined in project." line and exit code 1. Selecting "logs" in the same no-agent state instead shows a clean in-TUI error and lets the user keep navigating. The error content is correct; only the presentation is inconsistent and jarring (full TUI exit vs. in-app message).

Root cause

Verified at v0.20.2: TUI dev menu entry (App.tsx:144-147) does setExitAction({type:'dev'})+exit() with no agent pre-check; render.ts:70-74 then calls launchBrowserDev() (browser-mode.ts:119) which does console.error+process.exit(1) at lines 123-126/131-134 for agent-less projects. loadProjectConfig (config.ts:139-157) returns non-null for an existing-but-empty project so the !project guard misses it. logs instead routes to an in-TUI error screen (App.tsx:156-157 -> LogsScreen.tsx:78-83). The standalone agentcore dev CLI command throws ValidationError (command.tsx:327-331, caught+printed) and never calls launchBrowserDev, so the raw exit is reachable only via the menu exit-action path.

The fix

Converge dev onto the in-TUI error pattern. DevScreen already implements a noAgentsError in-TUI screen (DevScreen.tsx:500-518) mirroring LogsScreen; route the menu dev selection through an in-TUI DevScreen path (the launchTuiDevScreenWithPicker mechanism already used by the standalone command at command.tsx:514) instead of setExitAction+exit, so the error renders in-app. Keep browser-mode.ts:123-134 process.exit(1) as a CLI-only backstop. Add a regression test under src/cli/tui/screens/dev/tests/ paralleling LogsScreen.test.tsx. Precedent: PR aws#1575 fixed the same early-exit class for web-search/no-gateway.

Files touched: src/cli/tui/App.tsx:144-147 (dev menu branch — route to in-TUI DevScreen instead of setExitAction+exit); src/cli/commands/dev/browser-mode.ts:123-134 (process.exit(1) guards demoted to CLI-only backstop) and the existing launchTuiDevScreenWithPicker at browser-mode.ts:328; reuse src/cli/tui/screens/dev/DevScreen.tsx:500-518 noAgentsError branch; pattern reference src/cli/tui/screens/logs/LogsScreen.tsx:78-83; new regression test under src/cli/tui/screens/dev/tests/ mirroring src/cli/tui/screens/logs/tests/LogsScreen.test.tsx

Validation evidence

The fix was verified by reproducing the original symptom and re-running after the change:

BEFORE (buggy build, fix stashed, same no-agent project /tmp/acfix-1588-proj/acfix1588 created via create --no-agent): TUI main menu -> down to "dev" -> Enter tears down the TUI back to the shell. Final screen is the bare line "Error: No agents or harnesses defined in project." with bufferType flipped from "alternate" to "normal" and tui_close reported exitCode: 1. This is exactly the reported symptom (render.ts:70-72 imports+calls launchBrowserDev, which hits console.error+process.exit(1) at browser-mode.ts:123-134 for agent-less projects).

AFTER (fixed build, App.tsx routes dev menu via setRoute({name:'dev'}) -> in-TUI DevScreen): same steps render the in-app DevScreen error screen while the TUI stays alive (bufferType remains "alternate"): title "Dev Server", "No agents or harnesses defined in project.", "Dev mode requires at least one agent with an entrypoint or a harness.", "Run agentcore add agent to create one.", helpText "Esc quit". Pressing Esc returns to the main Commands menu (TUI not exited, navigation continues). Confirmed parity: selecting "logs" in the same project shows its own in-TUI error ("No runtimes defined in agentcore.json", "Esc back") and likewise stays in-TUI. No bare error line and no exit code 1 from the dev menu action. browser-mode.ts:123-134 process.exit(1) CLI backstop guards remain unchanged.

Test suite: green.


Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.

…ects

TUI dev menu path only; converges the no-agent dev flow onto the existing in-TUI DevScreen error pattern (mirroring logs). No change to the standalone `agentcore dev` CLI command, browser-mode.ts exit guards, or the agent-present/harness-only browser-launch behavior.

Refs aws#1588
@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.39% 13680 / 36579
🔵 Statements 36.65% 14542 / 39669
🔵 Functions 31.94% 2344 / 7337
🔵 Branches 31.3% 9058 / 28934
Generated in workflow #124 for commit 61d2566 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