Skip to content

refactor: code health improvements for core modules#11

Merged
aroff merged 2 commits intomainfrom
feature/ailoop-code-health-improvement-1739474400planmd
Feb 17, 2026
Merged

refactor: code health improvements for core modules#11
aroff merged 2 commits intomainfrom
feature/ailoop-code-health-improvement-1739474400planmd

Conversation

@aroff
Copy link
Copy Markdown
Collaborator

@aroff aroff commented Feb 16, 2026

Summary

  • Extract helper functions to reduce complexity in handlers.rs, server.rs, terminal.rs, and websocket.rs
  • Consolidate error handling and response formatting patterns
  • Separate data preparation from rendering logic
  • Improve code organization and testability

Key Improvements

handlers.rs

  • Consolidate error handling with print_ask_error and print_auth_result helpers
  • Add generic prompt_with_validation helper for config prompts
  • Extract parse_log_level function
  • Reduce code duplication across authorization handlers

server.rs

  • Extract process_websocket_message and handle_text_message methods
  • Create dedicated message handler methods for questions, authorization, and navigation
  • Improve separation of concerns in WebSocket message processing

terminal.rs

  • Extract draw_terminal, fetch_channel_messages, and calculate_scroll_offset methods
  • Separate data preparation from rendering with dedicated methods
  • Improve modularity with build_message_line helper

websocket.rs

  • Split buffer flushing into ensure_connection and send_buffered_messages
  • Extract send_websocket_message and calculate_timeout helpers
  • Create await_response_or_timeout with ResponseAwaitResult enum for clearer async flow

Test plan

  • All existing tests pass
  • Code formatting passes (cargo fmt)
  • Linting passes (cargo check)
  • No behavior changes - pure refactoring

🤖 Generated with Claude Code

aroff and others added 2 commits February 16, 2026 09:16
Extract helper functions and simplify complex methods to improve maintainability:

- handlers.rs: consolidate error handling, add generic validation helper
- server.rs: extract WebSocket and message handling logic into focused methods
- terminal.rs: separate data preparation from rendering logic
- websocket.rs: split buffer management and extract timeout/send helpers

Reduces complexity, improves readability, and makes code easier to test.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@aroff aroff merged commit 32597e1 into main Feb 17, 2026
10 checks passed
@aroff aroff deleted the feature/ailoop-code-health-improvement-1739474400planmd branch February 17, 2026 10:02
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