-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Summary
This phase focuses on internal improvements that support the UI and interaction upgrades introduced in Phases 1 and 2.
The goal is to modernize formatting utilities, reduce duplication, centralize common patterns, and improve long-term maintainability , without altering existing behavior.
This phase does not introduce new user-facing features. It strengthens the structure behind them.
Problem
After visual and interaction improvements, formatting and feedback logic can become scattered across multiple handlers.
Current challenges:
- Repeated formatting patterns
- Duplicate message-edit logic
- Inconsistent layout generation
- Inline keyboard layouts manually constructed in multiple places
- String-based Telegram constants prone to typos
- Formatting rules embedded directly in feature handlers
This increases maintenance overhead and future refactor cost.
Scope of This Issue
This issue introduces shared utilities and structural cleanup to standardize UI construction and feedback handling.
Included Improvements
1. Centralized Progressive Update Utility
Introduce a reusable function:
async def send_progressive_update(message, new_text, parse_mode=None, reply_markup=None, max_retries=2)Purpose:
- Safely edit messages
- Retry on failure
- Reduce duplicate try/except logic
- Standardize update behavior
Removes repeated edit logic from multiple handlers.
2. Unified Status Message Helper
Introduce:
async def send_status_with_emoji(update, emoji, text, reply_markup=None, delete_after=None)Purpose:
- Standardize status messages
- Optional auto-delete support
- Ensure consistent formatting
- Reduce repetitive boilerplate
3. Auto-Delete Background Utility
Introduce a background-safe helper:
async def _auto_delete_message(message, delay_seconds)Purpose:
- Clean temporary messages
- Avoid repeated sleep/delete patterns
- Centralize safe deletion logic
4. Smart Inline Button Grid Builder
Introduce:
def create_smart_button_grid(items: list, columns: int = 2)Purpose:
- Automatically structure inline keyboards
- Reduce manual row construction
- Improve layout consistency
- Enable easier future scaling
5. Section Header Utility
Introduce:
def create_section_header(title: str, icon: str = "•")Purpose:
- Standardize header formatting
- Avoid duplicated separator strings
- Enforce consistent visual hierarchy
6. Telegram Constant Modernization
Replace string literals with official constants:
ParseMode.MARKDOWNChatAction.TYPING
Benefits:
- Type safety
- IDE autocomplete
- Reduced typo risk
- Cleaner imports
No behavioral change.
7. Formatting Consolidation
Refactor message formatting patterns to:
- Use consistent separators
- Avoid inline hard-coded visual styles
- Reduce string duplication
- Keep layout logic centralized
This improves readability and maintainability.
8. Remove Redundant or Duplicate Blocks
Clean up:
- Duplicate exception blocks
- Repeated inline keyboard definitions
- Redundant string formatting patterns
- Repeated debug prints where unnecessary
No logic removal — only cleanup.
Explicitly Out of Scope
This issue does NOT include:
- UI redesign (Phase 1)
- Interaction flow changes (Phase 2)
- Feature additions
- Command logic modification
- Algorithm changes
- Performance tuning
This is purely structural and maintainability-focused.
Technical Notes
- No new dependencies
- No configuration changes
- No breaking changes
- Backward compatible
- Same public behavior
Estimated changes:
- 4–5 new helper functions
- Reduction in duplicated logic
- Refactoring across multiple handlers
- Cleaner separation of formatting vs execution logic
Acceptance Criteria
- Formatting logic centralized in helper functions
- Progressive update logic reusable
- Inline keyboards built through shared utility
- Telegram constants used consistently
- No regression in behavior
- No visible functionality changes
- Reduced code duplication
Impact
User Experience:
- No visible new features
- More consistent presentation
- Improved reliability
Development:
- Cleaner architecture
- Reduced duplication
- Easier future feature additions
- Lower maintenance cost
- Clear separation of UI utilities from feature logic
This is Phase 3 of the UI modernization roadmap and focuses on internal structure and long-term maintainability.