Skip to content

refactor(tui): split MCP header helpers#3333

Draft
cyq1017 wants to merge 2 commits into
Hmbown:mainfrom
cyq1017:codex/codewhale-3310-mcp-headers
Draft

refactor(tui): split MCP header helpers#3333
cyq1017 wants to merge 2 commits into
Hmbown:mainfrom
cyq1017:codex/codewhale-3310-mcp-headers

Conversation

@cyq1017

@cyq1017 cyq1017 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Problem

crates/tui/src/mcp.rs still keeps HTTP header framing and custom-header filtering inline with transport code, which makes the MCP transport split in #3310 harder to review incrementally.

Change

  • Move MCP HTTP default/header filtering helpers into mcp::headers
  • Keep helper visibility scoped to the parent MCP module
  • Preserve existing header behavior and tests

Verification

  • cargo test -p codewhale-tui mcp -- --nocapture
  • cargo fmt --check --all
  • git diff --check
  • cargo clippy -p codewhale-tui --all-targets --locked -- -D warnings -A clippy::uninlined_format_args -A clippy::too_many_arguments -A clippy::unnecessary_map_or -A clippy::assertions_on_constants

Part of #3310.

Signed-off-by: cyq <15000851237@163.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors MCP HTTP header handling by moving related helper functions and constants from crates/tui/src/mcp.rs into a new submodule crates/tui/src/mcp/headers.rs. The feedback suggests using explicit module path qualifiers (self::headers and super::headers) when importing from the new module to avoid potential name resolution conflicts with the external headers crate.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/tui/src/mcp.rs Outdated
use crate::child_env;
use crate::network_policy::{Decision, NetworkPolicyDecider, host_from_url};
use crate::utils::write_atomic;
use headers::{apply_safe_custom_headers, with_default_mcp_http_headers};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using use headers::... can cause ambiguity or compilation errors if an external crate named headers is present in the dependency tree (which is a very common crate in the Rust ecosystem). It is safer and more idiomatic to use self::headers to explicitly refer to the local module.

Suggested change
use headers::{apply_safe_custom_headers, with_default_mcp_http_headers};
use self::headers::{apply_safe_custom_headers, with_default_mcp_http_headers};

Comment thread crates/tui/src/mcp.rs Outdated
#[cfg(test)]
mod tests {
use super::*;
use headers::{MCP_HTTP_ACCEPT, is_safe_custom_header};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Similarly, inside the tests module, use headers::... should be qualified as super::headers::... to avoid name resolution conflicts with any external headers crate.

Suggested change
use headers::{MCP_HTTP_ACCEPT, is_safe_custom_header};
use super::headers::{MCP_HTTP_ACCEPT, is_safe_custom_header};

Signed-off-by: cyq <15000851237@163.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

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