Skip to content

refactor: show beta notices whenever stderr is a terminal - #336

Open
socksy wants to merge 1 commit into
developfrom
refactor/simplify-beta-notice
Open

refactor: show beta notices whenever stderr is a terminal#336
socksy wants to merge 1 commit into
developfrom
refactor/simplify-beta-notice

Conversation

@socksy

@socksy socksy commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

In keeping with #322 this refactors the beta code to not use stdout/stderr stuff directly from non-output.rs related code

Summary by CodeRabbit

  • Improvements
    • Beta feature notices are now displayed consistently across storage and knowledge commands.
    • Notices appear only when appropriate and are shown no more than once, reducing repeated messages.
    • Beta notices continue to include relevant labels and documentation links when available.

@socksy
socksy requested a review from konstantinoscs July 30, 2026 15:37
@github-actions

This comment was marked as resolved.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Storage beta notifications now use a BetaFeature::notify_once method and a shared output helper that performs terminal and persistence gating. Catalog and knowledge commands call the Storage feature method at their existing notification points.

Changes

Beta notice flow

Layer / File(s) Summary
Centralized notice gating
crates/tower-cmd/src/output.rs
output::notice_once checks stderr terminal status, claims the notice through configuration, and emits it once through notice_to_stderr.
BetaFeature notification API
crates/tower-cmd/src/beta.rs
BetaFeature::notify_once delegates notice emission to the output helper; tests now cover notice formatting.
Catalog command integration
crates/tower-cmd/src/catalogs.rs
Catalog and knowledge handlers call beta::STORAGE.notify_once() for storage operations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CatalogCommand
  participant BetaFeature
  participant output_notice_once
  participant config_claim_notice
  CatalogCommand->>BetaFeature: notify_once()
  BetaFeature->>output_notice_once: pass feature id and notice
  output_notice_once->>config_claim_notice: claim_notice(id)
  config_claim_notice-->>output_notice_once: claim result
  output_notice_once-->>CatalogCommand: emit notice when eligible
Loading

Possibly related PRs

Suggested reviewers: konstantinoscs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main refactor: beta notices are now emitted through terminal-aware stderr handling.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/simplify-beta-notice

Comment @coderabbitai help to get the list of available commands.

match config::claim_notice(id) {
Ok(true) => notice_to_stderr(label, msg),
Ok(false) => {}
Err(err) => debug!("Failed to persist CLI notice {}: {}", id, err),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not realllly sure we need this, but wanted to keep the diff here clean as a move

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.

This writes locally (similar to session persistence). Keep it

@socksy
socksy changed the base branch from main to develop July 30, 2026 15:38
match config::claim_notice(id) {
Ok(true) => notice_to_stderr(label, msg),
Ok(false) => {}
Err(err) => debug!("Failed to persist CLI notice {}: {}", id, err),

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.

This writes locally (similar to session persistence). Keep it

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
crates/tower-cmd/src/beta.rs (1)

34-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Retain coverage for the new notice-gating path.

The refactor removes the existing terminal/claiming test while introducing output::notice_once as the central behavior. Add tests for non-terminal stderr, first claim, already-claimed notices, and persistence failures—ideally in output.rs—so regressions in the dispatch contract are caught.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/tower-cmd/src/beta.rs` around lines 34 - 67, Add coverage around
output::notice_once for the notice-gating dispatch contract: test non-terminal
stderr behavior, successful first claiming, suppression of already-claimed
notices, and persistence failures. Place these tests in output.rs where
possible, and retain the existing BetaFeature notice formatting tests in
beta.rs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/tower-cmd/src/beta.rs`:
- Around line 34-67: Add coverage around output::notice_once for the
notice-gating dispatch contract: test non-terminal stderr behavior, successful
first claiming, suppression of already-claimed notices, and persistence
failures. Place these tests in output.rs where possible, and retain the existing
BetaFeature notice formatting tests in beta.rs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6a5701b3-e208-4e79-9121-29a82b59477f

📥 Commits

Reviewing files that changed from the base of the PR and between 8d5ef43 and 7d58f19.

📒 Files selected for processing (3)
  • crates/tower-cmd/src/beta.rs
  • crates/tower-cmd/src/catalogs.rs
  • crates/tower-cmd/src/output.rs

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.

2 participants