Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

Extracts hardcoded emoji symbols from UserOutput methods into a configurable Theme struct, enabling support for different output styles (emoji, plain text, ASCII) based on environment or user preferences.

Changes

Theme System

  • Added Theme struct with three predefined themes:
    • emoji() - Unicode symbols (⏳ ✅ ⚠️ ❌) for interactive terminals (default)
    • plain() - Text labels ([INFO] [OK] [WARN] [ERROR]) for CI/CD pipelines
    • ascii() - ASCII characters (=> [+] [!] [x]) for limited terminal support
  • Implements Default trait returning emoji theme for backward compatibility

UserOutput Integration

  • Added theme: Theme field to UserOutput
  • Added UserOutput::with_theme(verbosity, theme) constructor
  • Updated all output methods (progress(), success(), warn(), error()) to use self.theme.X_symbol()
  • Removed hardcoded symbols from method implementations

Testing

  • Added TestUserOutput::with_theme() for theme injection in tests
  • 11 new tests covering theme creation, accessors, and integration

Usage

use torrust_tracker_deployer_lib::presentation::user_output::{UserOutput, VerbosityLevel, Theme};

// Default emoji theme (existing behavior)
let mut output = UserOutput::new(VerbosityLevel::Normal);

// Plain text for CI/CD
let mut output = UserOutput::with_theme(VerbosityLevel::Normal, Theme::plain());
output.success("Deployment complete"); // [OK] Deployment complete

// ASCII for limited terminals
let mut output = UserOutput::with_theme(VerbosityLevel::Normal, Theme::ascii());
output.success("Deployment complete"); // [+] Deployment complete

All existing code continues to work without modifications.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 192.0.2.1
    • Triggering command: ssh -i /nonexistent/key -p 22 -o ConnectTimeout=5 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no testuser@192.0.2.1 echo 'SSH connected' (packet block)
    • Triggering command: ssh -i /nonexistent/key -p 22 -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5 -o StrictHostKeyChecking=no testuser@192.0.2.1 echo 'SSH connected' (packet block)
    • Triggering command: ssh -i /nonexistent/key -p 22 -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null testuser@192.0.2.1 echo 'SSH connected' (packet block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add Theme/Configuration Support for UserOutput</issue_title>
<issue_description>## Overview

Extract emoji symbols from UserOutput methods into a configurable Theme struct. This enables support for different output styles (emoji, plain text, ASCII) based on environment or user preferences, making the application more accessible and CI/CD-friendly.

Specification

See detailed specification: docs/issues/124-add-theme-configuration-support.md

🏗️ Architecture Requirements

DDD Layer: Presentation
Module Path: src/presentation/user_output.rs
Pattern: Configuration/Theme Pattern

Module Structure Requirements

  • Create Theme struct within user_output.rs module
  • Implement predefined theme constructors (emoji(), plain(), ascii())
  • Implement Default trait for Theme (emoji theme)
  • Update UserOutput to use Theme for all symbol formatting
  • Follow module organization conventions (see docs/contributing/module-organization.md)

Architectural Constraints

  • No breaking changes: Existing code using default constructor continues to work
  • Backward compatibility: Default theme uses emoji (current behavior)
  • Extensibility: Easy to add new themes without modifying output methods
  • Type safety: Theme fields are strongly typed
  • Immutability: Theme is set at construction, not modified during runtime

Anti-Patterns to Avoid

  • Global mutable theme - Don't use static mutable for theme configuration
  • Runtime theme switching - Theme is set at construction, not changed afterward
  • Hardcoded symbols in methods - All symbols must come from Theme

Implementation Plan

Phase 1: Create Theme Struct (1-2 hours)

  • Create Theme struct with symbol fields
  • Implement Theme::emoji(), Theme::plain(), Theme::ascii()
  • Implement accessor methods and Default trait
  • Add comprehensive documentation

Phase 2: Add Unit Tests for Theme (1 hour)

  • Test all predefined themes
  • Test accessor methods
  • Test theme cloning and equality

Phase 3: Integrate Theme into UserOutput (2-3 hours)

  • Add theme: Theme field to UserOutput
  • Create UserOutput::with_theme() constructor
  • Update all output methods to use self.theme.X_symbol()
  • Remove hardcoded symbols

Phase 4: Update Tests (2-3 hours)

  • Update test infrastructure to support themes
  • Add tests for each theme variant
  • Verify all existing tests pass

Phase 5: Documentation and Verification (1 hour)

  • Add module documentation
  • Add usage examples
  • Run pre-commit checks: ./scripts/pre-commit.sh

Acceptance Criteria

Note for Contributors: These criteria define what the PR reviewer will check. Use this as your pre-review checklist before submitting the PR to minimize back-and-forth iterations.

Quality Checks:

  • Pre-commit checks pass: ./scripts/pre-commit.sh

Theme Implementation Checks:

  • Theme struct exists with all symbol fields
  • All predefined themes implemented: emoji(), plain(), ascii()
  • Default trait returns emoji theme
  • All accessor methods implemented

Integration Checks:

  • UserOutput has theme: Theme field
  • UserOutput::with_theme() constructor exists
  • All output methods use theme symbols (no hardcoded symbols)

Testing Checks:

  • Theme unit tests cover all variants
  • Test infrastructure supports theme injection
  • All existing tests pass

Backward Compatibility Checks:

  • Default UserOutput::new() uses emoji theme
  • No breaking changes to public API

Documentation Checks:

  • Theme system fully documented
  • Usage examples for each theme
  • Each theme variant documented with use case

Related

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 3, 2025 22:26
Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
Copilot AI changed the title [WIP] Add theme/configuration support for UserOutput Add Theme/Configuration Support for UserOutput Nov 3, 2025
Copilot AI requested a review from josecelano November 3, 2025 22:54
Copilot finished work on behalf of josecelano November 3, 2025 22:54
@josecelano josecelano marked this pull request as ready for review November 4, 2025 06:57
Copy link
Member

@josecelano josecelano left a comment

Choose a reason for hiding this comment

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

ACK 2835384

@josecelano josecelano merged commit 8fe39e7 into main Nov 4, 2025
51 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.

Add Theme/Configuration Support for UserOutput

2 participants