fix(cli): Add requireTTY() before each unguarded interactive TUI la... (#982)#41
Draft
aidandaly24 wants to merge 4 commits into
Draft
fix(cli): Add requireTTY() before each unguarded interactive TUI la... (#982)#41aidandaly24 wants to merge 4 commits into
aidandaly24 wants to merge 4 commits into
Conversation
) Non-TTY interactive TUI commands crashed with Ink's 'Raw mode is not supported on the current process.stdin' and, for import (no --source), exited 0 so CI/scripts could not detect the failure. deploy was already guarded by requireTTY (PR aws#949); import/view/export were not. Add requireTTY() before each unguarded interactive launch: - export/index.ts: before renderTUI for export-harness - import/command.ts: in the no-source branch before render(ImportFlow) - view/command.tsx: at the top of launchTuiList and launchTuiDetail requireProject()/--json paths untouched. Adds unit tests covering the three command suites. Refs aws#982
Coverage Report
|
- centralize the interactive-terminal guard at the top of renderTUI() so every TUI entrypoint (export-harness and any future renderTUI caller) is covered by default; keep inline guards only on the raw render() sites (import, view) - rewrite the three tty-guard tests to exercise the real requireTTY by toggling process.stdin.isTTY/process.stdout.isTTY and spying on process.exit + console.error, mocking only the I/O boundaries (mirrors feedback/consent-prompt.test.ts) instead of mocking requireTTY - parameterize the view list guard over all four job types - make requireTTY-vs-requireProject ordering consistent: requireProject() first in import (matches view)
launchTuiDevScreenWithPicker called render() without a requireTTY() guard, so in a non-TTY context it threw Ink's "Raw mode is not supported" stack trace plus a partial alt-screen paint — a counterexample to the centralized guard PR aws#1640 added. Call requireTTY() at the top of the picker (before the alt-screen write and render) and add a tty-guard test that drives the real guard for this path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs aws#982
Issues
agentcore import(no --source) the process then exits 0, so CI/scripts cannot detect the failure (the exit-0 variant in the issue). Foragentcore view <type>andagentcore export harnessthe same launch is unguarded. The literal title reproducer (agentcore deploy) is already fixed at v0.20.2, but the underlying bug class persists in import/view/export.Root cause
Interactive Ink TUIs render screens whose useInput hook calls setRawMode(true), which throws on non-TTY stdin (ink App.js:117, exact match to the issue text). requireTTY() (src/cli/tui/guards/tty.ts:8-13, added PR aws#949 / commit c30ed54) guards deploy/create/add/remove/invoke/dev/exec/run/feedback but NOT import/view/export. Verified at v0.20.2: deploy/command.tsx:218,221 are guarded (the original claim that deploy is the gap is wrong); the unguarded interactive launches are import/command.ts:67 (raw render of ImportFlow), view/command.tsx:97-121 (launchTuiList/launchTuiDetail render history screens that use useListNavigation->useInput), export/index.ts:32 (renderTUI export-harness). Import's render() is never awaited via waitUntilExit(), so Ink's ErrorBoundary (App.js:347) swallows the throw and the process exits 0; export awaits renderTUI->waitUntilExit() so its rejection propagates to exit 1 but with the ugly Ink stack trace. index.ts:9-16 only catches uncaughtException/unhandledRejection, neither of which fires for the import no-op rejectExitPromise path.
The fix
Add requireTTY() before each unguarded interactive launch, mirroring PR aws#949: import (src/cli/commands/import/command.ts no-source branch before requireProject()/render), view (src/cli/commands/view/command.tsx before launchTuiList/launchTuiDetail), and export (src/cli/commands/export/index.ts before renderTUI at :32). Open PR aws#1170 is OPEN and "Closes aws#982" but only patches import/command.ts (7 lines) plus tty/import/deploy tests — its own "Out of scope" section confirms it does NOT cover view or export, so merging it would close the issue while leaving two sites with the identical bug. Recommend expanding aws#1170 to also guard view and export, or more robustly centralizing the guard: call requireTTY() at the top of renderTUI() (src/cli/tui/render.ts:35) AND at the raw render() interactive sites so any future interactive launch is covered by default.
Files touched: src/cli/commands/import/command.ts:26-29,67-73 (no-source interactive branch; partially addressed by open PR aws#1170); src/cli/commands/view/command.tsx:97-121 (NOT covered by aws#1170); src/cli/commands/export/index.ts:32 (NOT covered by aws#1170); guard def src/cli/tui/guards/tty.ts:8-13; ideal central fix point src/cli/tui/render.ts:35. Deploy already guarded at src/cli/commands/deploy/command.tsx:218,221 (no change needed).
Validation evidence
The fix was verified by reproducing the original symptom and re-running after the change:
Test suite: green.
Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.