Skip to content

Conversation

@leonace924
Copy link
Contributor

@leonace924 leonace924 commented Dec 22, 2025

Refactor: Standardize Success Message Printing with print_success

Summary

This PR refactors success message printing across the codebase to use the centralized print_success utility function from bittensor_cli/src/bittensor/utils.py. This ensures consistent formatting, behavior, and maintainability of success messages throughout the CLI.

Changes

Core Functionality

The print_success function provides a standardized way to display success messages:

  • Automatically prefixes messages with a checkmark emoji (:white_check_mark:)
  • Handles status spinner management (pauses/resumes if a spinner is active)
  • Uses consistent green color formatting via the print_console utility
  • Supports optional status spinner parameter for better UX during long-running operations

Files Modified

Success message printing has been standardized across the following command modules:

Command Modules

  • Staking Commands (bittensor_cli/src/commands/stake/)

    • add.py - Stake addition success messages
    • remove.py - Stake removal finalization messages
    • move.py - Stake movement confirmation messages
    • claim.py - Stake claim success messages
    • children_hotkeys.py - Child hotkey operations success messages
    • auto_staking.py - Auto-staking configuration messages
  • Crowdloan Commands (bittensor_cli/src/commands/crowd/)

    • contribute.py - Contribution success messages
    • create.py - Crowdloan creation success messages
  • Subnet Commands (bittensor_cli/src/commands/subnets/)

    • subnets.py - Subnet registration and operation success messages
    • mechanisms.py - Subnet mechanism updates success messages
  • Wallet Commands (bittensor_cli/src/commands/)

    • wallets.py - Wallet operation success messages
    • proxy.py - Proxy operation success messages
  • Sudo Commands (bittensor_cli/src/commands/)

    • sudo.py - Sudo operation success messages
  • Extrinsic Modules (bittensor_cli/src/bittensor/extrinsics/)

    • transfer.py - Transfer operation success messages
    • serving.py - Serving operation success messages
    • root.py - Root operation success messages
    • registration.py - Registration success messages
  • Other Modules

    • cli.py - CLI-level success messages
    • weights.py - Weight operation success messages

Benefits

  1. Consistency: All success messages now follow the same format and styling
  2. Maintainability: Centralized function makes it easier to update success message behavior across the entire codebase
  3. UX Improvements: Proper status spinner handling prevents visual glitches during long-running operations
  4. Code Quality: Reduces code duplication and ensures DRY (Don't Repeat Yourself) principles

Technical Details

Function Signature

def print_success(message: str, status=None):
    """Print success messages while temporarily pausing the status spinner."""

Usage Pattern

from bittensor_cli.src.bittensor.utils import print_success

# Simple usage
print_success("Operation completed successfully!")

### Migration Pattern

**Before:**
```python
console.print("[green]Success![/green]")
# or
console.print(":white_check_mark: Operation completed")

After:

print_success("Success!")
# or
print_success("Operation completed")

Impact

  • Breaking Changes: None - this is a refactoring that maintains backward compatibility
  • User-Facing Changes: Success messages now have consistent formatting with checkmark icons
  • Performance: No performance impact - function is lightweight and efficient

Related Issues

  • Standardizes success message display across the CLI
  • Improves code maintainability and reduces duplication
  • Enhances user experience with consistent visual feedback

Contribution by Gittensor, learn more at https://gittensor.io/

@leonace924
Copy link
Contributor Author

@thewhaleking would you include this PR for the release?
this is similar as print_error

Copy link
Contributor

@ibraheem-abe ibraheem-abe left a comment

Choose a reason for hiding this comment

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

Looks good at first glance.
I think we should use white_heavy_check_mark instead of white_check_mark for the success messages.

And also need to check why the e2e tests broke for the wallet - probably the success assertion need to be looked at - it might be fixed when you change to the heavy mark

@leonace924
Copy link
Contributor Author

Looks good at first glance. I think we should use white_heavy_check_mark instead of white_check_mark for the success messages.

And also need to check why the e2e tests broke for the wallet - probably the success assertion need to be looked at - it might be fixed when you change to the heavy mark

@ibraheem-abe it seems testing is failed at very first stage when download linux environment

@leonace924
Copy link
Contributor Author

@ibraheem-abe this is ready to go

@ibraheem-abe ibraheem-abe merged commit 095a935 into opentensor:staging Dec 23, 2025
87 checks passed
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