Skip to content

feat(cli): user-facing warning registry + startup banner#196

Merged
emal-avala merged 1 commit intomainfrom
feat/warning-banner
Apr 23, 2026
Merged

feat(cli): user-facing warning registry + startup banner#196
emal-avala merged 1 commit intomainfrom
feat/warning-banner

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

Non-fatal warnings (dangerous flags, missing dependencies, deprecations) previously went to tracing::warn! which routes to logs — users rarely look at logs. Added a process-wide services::warnings registry that the REPL renders as a bannered block at startup and an easy API for any code path to enqueue a warning.

───────────────────────────────────────────────────────────────
 [WARN]  All permission checks disabled (--dangerously-skip-permissions).
         The agent can run any tool without confirmation.
 [WARN]  Process-level sandbox disabled for this session (--no-sandbox).
         Tool calls are not isolated.
───────────────────────────────────────────────────────────────

API

use agent_code_lib::services::warnings;

warnings::warn("--no-sandbox disables process isolation");   // severity WARN
warnings::info("Using experimental feature X");              // severity INFO
warnings::snapshot();                                         // read without clearing
warnings::clear();                                            // user-dismiss or test-reset

The registry de-duplicates on push (by level + message) so callers can re-push on every check without flooding the banner.

Wiring

Initial sources in main.rs:

Condition Severity Message
--dangerously-skip-permissions WARN permission bypass notice
--no-sandbox (sandbox disabled) WARN isolation-off notice
--no-sandbox ignored by security gate WARN ignored-notice

The banner renders to stderr so it doesn't contaminate stdout when the REPL output is piped.

Why stderr and not the existing tracing::warn! path?

tracing::warn! writes with a log-formatter prefix and is invisible unless RUST_LOG=warn is set. Users expect dangerous-flag warnings to be visible by default without opting in to logging. Both sources fire together (tracing keeps the log entry for telemetry, banner surfaces the user-facing message).

Test plan

  • cargo fmt --all — clean
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo test -p agent-code-lib --lib services::warnings — 5/5 pass
    • push_and_snapshot_roundtrip
    • duplicate_push_is_ignored
    • different_levels_same_message_are_distinct
    • clear_empties_registry
    • snapshot_does_not_drain
  • cargo test -p agent-code --test smoke — 4/4 pass
  • Manual: agent --dangerously-skip-permissions → banner renders at REPL startup; normal startup → no banner

Non-fatal warnings (dangerous flags, missing binaries, deprecations)
previously went to `tracing::warn!` → logs, which users rarely look
at. Added a process-wide `services::warnings` registry that the REPL
renders as a bannered block at startup.

  services::warnings::warn(msg)  — severity "WARN"
  services::warnings::info(msg)  — severity "INFO"
  services::warnings::snapshot() — read without clearing

The registry de-duplicates on push (by level + message) so callers
can be noisy without flooding the banner.

Rendered as a bordered eprintln! block via ratatui, stderr so it
doesn't contaminate stdout when piped. No-op when no warnings are
registered, so the banner is invisible in the happy path.

Initial sources wired up in main.rs:

  --dangerously-skip-permissions → warn (permission bypass)
  --no-sandbox                   → warn (sandbox disabled)
  --no-sandbox + security.disable_bypass_permissions → warn (ignored)

Tests: 5 unit tests using a serialized Mutex to survive cargo's
parallel test runner against the singleton.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@emal-avala emal-avala merged commit b6964ff into main Apr 23, 2026
14 checks passed
@emal-avala emal-avala deleted the feat/warning-banner branch April 23, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant