Skip to content

Conversation

@linw1995
Copy link
Owner

Summary

Refactor code to improve maintainability by extracting common helper functions and simplifying complex logic.

Main Changes

  • Unified error handling: Extract helper functions like invalid_error(), reply_validation_error(), reply_validation_success() to reduce boilerplate
  • Extract common logic:
    • agent.rs: Extract build_chat_response_from_blocks() method to reduce duplication between chat() and chat_with_history()
    • tools.rs: Add parse_relative_path() helper with unit tests
    • mcp.rs: Extract serialize_to_json_value(), parse_call_tool_payload(), require_server_for_action() helpers
    • combo/runner.rs: Extract emit_prompt_stream_update() to simplify stream update handling
    • combo/starter.rs: Extract helper functions for reply validation
  • Retry mechanism improvement: provider.rs uses complete_with_retry_status() wrapper for consistent retry status handling
  • Code organization: Move sanitize_log_stem() to logging module for better reusability

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 22.35529% with 389 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.53%. Comparing base (55394f6) to head (521582e).
⚠️ Report is 4 commits behind head on dev.

Files with missing lines Patch % Lines
src/provider.rs 0.00% 161 Missing ⚠️
src/combo/runner.rs 0.00% 77 Missing ⚠️
src/combo/starter.rs 20.83% 76 Missing ⚠️
src/agent.rs 0.00% 35 Missing ⚠️
src/agent/prompt.rs 20.68% 23 Missing ⚠️
src/mcp.rs 85.71% 7 Missing ⚠️
crates/coco-tui/src/components/chat.rs 0.00% 6 Missing ⚠️
src/tools.rs 90.47% 2 Missing ⚠️
src/config/env.rs 75.00% 1 Missing ⚠️
src/logging.rs 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #180      +/-   ##
==========================================
- Coverage   48.12%   47.53%   -0.59%     
==========================================
  Files         105      108       +3     
  Lines       27916    30135    +2219     
==========================================
+ Hits        13435    14326     +891     
- Misses      14481    15809    +1328     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@linw1995 linw1995 merged commit 535ba5a into dev Feb 11, 2026
3 checks passed
@linw1995 linw1995 deleted the refactor/codex-auto branch February 11, 2026 03:30
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