feat(tui): add dedicated Logs screen for streaming runtime logs#1274
feat(tui): add dedicated Logs screen for streaming runtime logs#1274notgitika wants to merge 6 commits into
Conversation
Adds a TUI screen for streaming deployed agent CloudWatch logs, replacing the previous CLI-only help page. Users can now select a deployed agent and stream logs in real-time from the TUI menu. Closes aws#565
Package TarballHow to installnpm install https://github.com/aws/agentcore-cli/releases/download/pr-1274-tarball/aws-agentcore-0.13.1.tgz |
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Nice addition — the screen flow (loading → optional agent select → streaming, with full-screen handoff) is clean and the abort-on-unmount logic in useLogsStream looks correct. A couple of things I think should be addressed before merging:
- The inline streaming view advertises arrow-key scrolling in its help text but doesn't actually implement it — only
lis wired up. Either remove the misleading hint or implement scrolling. - No unit tests are included for the new hook or screen, even though comparable code in this repo (e.g.
useInvokeFlow,AddScreen) is covered. The PR description says 663 TUI tests pass, but none of them exercise this new code path.
Details inline.
| const [loadError, setLoadError] = useState<string | undefined>(); | ||
| const [showFullScreen, setShowFullScreen] = useState(false); | ||
|
|
||
| const { logs, isStreaming, error: streamError } = useLogsStream(selectedAgent); |
There was a problem hiding this comment.
Minor robustness note: useLogsStream(selectedAgent) re-runs its effect whenever the selectedAgent reference changes. Since selectedAgent is set once from agents[selectedIndex] (a stable reference from state), this is fine in practice — but if you ever add a "refresh / reconnect" action that constructs a new AgentContext object with the same fields, you'd get an infinite-stream-restart loop. Consider keying the effect on agentContext.agentId (and friends) instead of the object identity, or memoizing the context. Not a blocker.
- Remove misleading "↑↓ scroll" from inline streaming view help text since scrolling is only available in the full-screen view (press l) - Add unit tests for useLogsStream hook (7 tests covering idle state, streaming, error handling, abort cleanup, and buffer cap) - Add unit tests for LogsScreen (5 tests covering all phase transitions)
- Replace manual slice with LogPanel component (built-in ↑↓ scrolling, auto-scroll to bottom, page up/down) - Add level filter shortcuts: 1=all, 2=errors, 3=warn+, 4=info+ - Change full-screen key from l to f (l conflicts with scroll) - Show filter status and count in header
- Set fixed height on LogPanel container to prevent header from being pushed off screen when logs accumulate - Remove redundant info+ filter (same as all), keep 1=all 2=errors 3=warn+
Add overflow="hidden" to the LogPanel container so long wrapped log lines don't overflow past the fixed height and corrupt the help text.
… default Explicitly detect info level (gray/dim) separately from unclassified logs which now render as system level (cyan, readable). Errors stay red, warnings stay yellow.
Summary
logsfrom the CLI-only command list so it's now accessible directly from the TUI menul)Implementation
useLogsStreamhook: manages CloudWatchstreamLogslifecycle with abort/cleanup, auto-detects log levels, caps buffer at 1000 entriesLogsScreencomponent: phases through loading → agent selection (if multiple) → streaming view with error handlingFullScreenLogViewfor scrollable full-screen log viewingTest plan
tsc --noEmit)eslint)Closes #565