Skip to content

Conversation

@linw1995
Copy link
Owner

Overview

Refactor src/agent.rs by splitting it into focused submodules to improve code maintainability and testability.

Main Changes

Module Extraction

  • src/agent/message.rs (301 lines) - Message type definitions
  • src/agent/provider_selection.rs (220 lines) - Provider selection logic
  • src/agent/streaming.rs (386 lines) - Streaming processing implementation
  • src/prompt_reply.rs (119 lines) - Prompt reply handling
  • src/agent.rs - Reduced from 924 to 86 lines

New TUI State Types

  • crates/coco-tui/src/components/chat/state.rs (186 lines) - Chat component state management
    • ChatState - Session state (Ready/Processing)
    • Focus - UI focus management
    • ViewMode - View mode switching
    • CancellationGuard - Double-key exit protection

Impact

  • Clearer code structure with single responsibility per module
  • Better unit testing and future extensibility
  • Centralized TUI state management for improved UI maintainability

@linw1995 linw1995 added the enhancement New feature or request label Jan 30, 2026
@linw1995 linw1995 merged commit 00f07ed into dev Jan 30, 2026
3 checks passed
@linw1995 linw1995 deleted the refactor/glm-auto branch January 30, 2026 12:58
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 65.76087% with 252 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.82%. Comparing base (c3970cb) to head (20a1acd).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
src/agent/streaming.rs 55.83% 125 Missing ⚠️
src/agent/message.rs 76.60% 51 Missing ⚠️
src/agent/provider_selection.rs 72.78% 40 Missing ⚠️
src/prompt_reply.rs 67.60% 23 Missing ⚠️
src/agent.rs 23.52% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #163      +/-   ##
==========================================
+ Coverage   47.59%   47.82%   +0.23%     
==========================================
  Files         100      104       +4     
  Lines       27316    27421     +105     
==========================================
+ Hits        13000    13115     +115     
+ Misses      14316    14306      -10     

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants