Skip to content

Conversation

@ssmath
Copy link
Contributor

@ssmath ssmath commented Oct 25, 2025

This commit refactors and modularizes the source directory structure by splitting large files into smaller modules. Specifically:

  • Moved message-related types and utilities into their own submodules under src/message/.
  • Created separate submodules for configuration (src/config/*) and connection handling (src/connection/*).
  • Introduced protocol-specific submodules (src/protocol/*) to handle ACP protocol logic.
  • Updated imports across the project to reflect these changes.

Additionally, some files were renamed or moved around within tests directories to better align with their respective feature areas.

These changes aim to improve readability, maintainability, and ease of navigation through the codebase.

This commit refactors and modularizes the source directory structure by splitting large files into smaller modules. Specifically:

- Moved message-related types and utilities into their own submodules under `src/message/`.
- Created separate submodules for configuration (`src/config/*`) and connection handling (`src/connection/*`).
- Introduced protocol-specific submodules (`src/protocol/*`) to handle ACP protocol logic.
- Updated imports across the project to reflect these changes.

Additionally, some files were renamed or moved around within tests directories to better align with their respective feature areas.

These changes aim to improve readability, maintainability, and ease of navigation through the codebase.
@codecov
Copy link

codecov bot commented Oct 25, 2025

Copy link

@llamapreview llamapreview bot left a comment

Choose a reason for hiding this comment

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

AI Code Review by LlamaPReview

🎯 TL;DR & Recommendation

Recommendation: Request Changes

This PR introduces a significant architectural refactoring that improves modularity but contains breaking changes to public APIs and import paths that could impact external consumers.

📄 Documentation Diagram

This diagram documents the new modular client architecture and workflow introduced by the refactoring.

sequenceDiagram
    participant EC as External Consumer
    participant IC as IFlowClient
    participant CH as ConnectionHandler
    participant SC as StdioConnection
    participant WC as WebSocketConnection
    participant AP as ACPProtocol
    note over IC: PR #35;12: New modular structure
    EC->>IC: connect()
    IC->>CH: initialize(options)
    alt Stdio Mode
        CH->>SC: handle_connection()
        SC->>AP: process_messages()
    else WebSocket Mode
        CH->>WC: handle_connection()
        WC->>AP: process_messages()
    end
    AP-->>IC: send_message()
    IC-->>EC: messages() stream
    note over AP: Handles ACP protocol logic
Loading

🌟 Strengths

  • Solid modularization that enhances code maintainability and organization
  • Systematic updates to examples demonstrating proper integration
Priority File Category Impact Summary Anchors
P1 src/acp_protocol.rs Architecture Import restructuring breaks public interface path:examples/advanced/mcp_example.rs
P1 src/client.rs Architecture Complete removal breaks external API consumers path:examples/explore_api.rs
P2 src/acp_protocol.rs Maintainability Code readability improvement with let-chains
P2 src/acp_protocol.rs Architecture Type path updates reflect new module structure
P2 Cargo.toml Architecture New dependency futures-util added for async
P2 examples/advanced/logging_example.rs Testing Inconsistent import patterns in examples
P2 src/client/acp_handler.rs Architecture Well-structured new modular code

🔍 Notable Themes

  • Architectural Breaking Changes: Multiple P1 findings highlight risks to external API consumers due to module restructuring and removal of key files.
  • Improved Code Organization: The refactoring successfully modularizes the codebase, enhancing maintainability and aligning with Rust best practices.

📈 Risk Diagram

This diagram illustrates the risk of breaking changes to external API consumers due to module restructuring.

sequenceDiagram
    participant EC as External Consumer
    participant IC as IFlowClient
    participant MS as Module System
    note over EC,MS: R1(P1): Breaking change risk
    EC->>IC: call API (old import)
    IC->>MS: resolve import
    MS-->>IC: import not found
    IC-->>EC: compilation error
    note over EC: External code breaks due to
    note over EC: restructured module paths
Loading
⚠️ **Unanchored Suggestions (Manual Review Recommended)**

The following suggestions could not be precisely anchored to a specific line in the diff. This can happen if the code is outside the changed lines, has been significantly refactored, or if the suggestion is a general observation. Please review them carefully in the context of the full file.


📁 File: src/client.rs

The complete removal of src/client.rs (905 lines) and replacement with a new modular structure under src/client/ represents a significant architectural change. The related_context shows multiple examples (explore_api.rs, mcp_example.rs, websocket_client.rs) that import and use IFlowClient. While the examples appear to have been updated, this change could break external consumers who rely on the previous client implementation. The new modular structure improves maintainability but requires careful verification that all public APIs remain compatible.

Related Code:

[Snippet not available]


💡 Have feedback? We'd love to hear it in our GitHub Discussions.
✨ This review was generated by LlamaPReview Advanced, which is free for all open-source projects. Learn more.

Comment on lines +8 to +9
use crate::config::options::IFlowOptions;
use crate::message::types::{Message, PermissionMode};
Copy link

Choose a reason for hiding this comment

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

P1 | Confidence: High

The import restructuring in acp_protocol.rs reflects the new modular architecture but introduces a breaking change to the module's public interface. The related_context shows examples like mcp_example.rs and permission_modes.rs that use these types. While the examples appear updated, any external code relying on the old import paths will break. This change affects core protocol handling and requires thorough testing to ensure all type references are correctly updated.

Code Suggestion:

use crate::config::options::IFlowOptions;
use crate::message::types::{Message, PermissionMode};

Evidence: path:examples/advanced/mcp_example.rs, path:examples/advanced/permission_modes.rs

Comment on lines +544 to 547
if let Some(id) = data.get("id").and_then(|v| v.as_u64())
&& id == request_id as u64 {
return Ok(data);
}
Copy link

Choose a reason for hiding this comment

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

P2 | Confidence: High

This change converts nested if-let statements to the more concise && pattern, which is a Rust 1.56+ feature. While this improves code readability, it requires a minimum Rust version that supports let-chains. The change is syntactically correct and maintains the same logic flow, but should be verified to work with the project's supported Rust version.

"plan" => {
if let Some(entries) = update.get("entries").and_then(|v| v.as_array()) {
let entries: Vec<super::types::PlanEntry> = entries
let entries: Vec<crate::message::types::PlanEntry> = entries
Copy link

Choose a reason for hiding this comment

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

P2 | Confidence: High

This change updates the type path from super::types::PlanEntry to crate::message::types::PlanEntry, reflecting the new module structure. While this is correct for the new architecture, it demonstrates the pervasive nature of the refactoring. All such path updates should be verified to ensure they point to the correct locations in the new module hierarchy.

Comment on lines +15 to +16
use crate::logger::MessageLogger;
use crate::message::types::{Message, PlanEntry, PlanPriority, PlanStatus};
Copy link

Choose a reason for hiding this comment

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

P2 | Confidence: High

The new acp_handler.rs module properly uses the updated import paths, demonstrating good adherence to the new architecture. This suggests the refactoring was systematically applied. The separation of ACP protocol handling from the main client logic improves modularity and testability.

uuid = { version = "1.18", features = ["v4"] }
url = "2.5"
tokio-tungstenite = "0.28"
futures-util = { version = "0.3.31", features = ["compat"] }
Copy link

Choose a reason for hiding this comment

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

P2 | Confidence: Medium

The addition of futures-util dependency suggests the new modular architecture may be using more advanced async patterns. This is a new direct dependency that wasn't present before. While likely necessary for the refactored code, it should be verified that this dependency is actually used and that its version aligns with the project's other async dependencies (tokio, async-trait).

Comment on lines +3 to 4
use iflow_cli_sdk_rust::message::types::{PlanEntry, PlanPriority, PlanStatus};
use iflow_cli_sdk_rust::{LoggerConfig, Message, MessageLogger};
Copy link

Choose a reason for hiding this comment

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

P2 | Confidence: Medium

The example updates show the new import structure is being used, which is positive. However, the mixing of direct imports (LoggerConfig, Message, MessageLogger) and module-qualified imports (message::types::{...}) suggests some inconsistency in the public API structure. All examples should consistently use either direct exports or module-qualified imports.

Code Suggestion:

// Either all direct
use iflow_cli_sdk_rust::{LoggerConfig, Message, MessageLogger, PlanEntry, PlanPriority, PlanStatus};
// Or all module-qualified  
use iflow_cli_sdk_rust::message::types::{PlanEntry, PlanPriority, PlanStatus};
use iflow_cli_sdk_rust::logger::{LoggerConfig, MessageLogger};
use iflow_cli_sdk_rust::Message;

Added a new section in `Cargo.toml` to include end-to-end tests located in `tests/e2e/e2e_tests.rs`. This addition aims to improve the testing coverage by including high-level integration scenarios.
This change adds functionality to send a `TaskFinish` message that includes the actual stop reason after processing a prompt response. This provides more detailed information about why a task has finished, which can be useful for debugging and logging purposes.
Added configurations for new examples in `Cargo.toml`:
- explore_api
- query_with_config
- test_response
- websocket_mcp

This allows these examples to be run using cargo commands directly.
This change upgrades the `agent-client-protocol` dependency from version `0.5.0` to `0.7.0`. Additionally, code adjustments were made to align with changes in the new version, particularly in handling content blocks and session updates. These modifications ensure compatibility and leverage any improvements or fixes introduced in the newer version.
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.

3 participants