Skip to content

fix(companion): mutable Windows pipe listener and cfg-gated Deserialize import - #1816

Open
akushonkamen wants to merge 1 commit into
1jehuang:masterfrom
akushonkamen:fix/1803-windows-mut-macos-unused-import
Open

akushonkamen wants to merge 1 commit into
1jehuang:masterfrom
akushonkamen:fix/1803-windows-mut-macos-unused-import

Conversation

@akushonkamen

Copy link
Copy Markdown
Contributor

Fixes #1803

根因

两个独立编译错误/警告:

  1. Windows E0596:crates/jcode-companion/src/server.rs:168 的 listener 未声明 mut,而 Windows pipe 后端的 accept(&mut self)(crates/jcode-transport/src/windows.rs:69)要求 &mut;unix 后端 accept(&self) 下直接加 mut 又会触发 unused_mut。
  2. macOS unused import:crates/jcode-desktop-open/src/lib.rs:8 的 serde::Deserialize 唯一使用点 NiriWindow(:308)/NiriTimestamp(:318) 均被 #[cfg(any(test, all(unix, not(target_os="macos"))))] 门住,macOS 非 test 构建下该 import 未用,超出仓库 0 warning 预算。

修法

  • 根因一:按 issue 建议的最小修法,server.rs:168 改为 #[allow(unused_mut)] let mut listener = bind(...),并附注释说明双后端差异(Windows 下 mut 实际使用,unix 下允许未用)。
  • 根因二:给 lib.rs:8 的 use serde::Deserialize; 加同一 cfg 门 #[cfg(any(test, all(unix, not(target_os = "macos"))))]。

核验

测试

红(stash 修复杂交实跑):

  • timeout 600 cargo check -p jcode-desktop-open → warning: unused import serde::Deserialize @ lib.rs:8,1 warning。

绿(本机 macOS,全部复跑确认):

Windows(交叉检查):

  • rustup target add x86_64-pc-windows-msvc 成功。
  • cargo check -p jcode-transport --target x86_64-pc-windows-msvc → Finished 通过。
  • cargo check -p jcode-companion --target x86_64-pc-windows-msvc 无法在本机完成——aws-lc-sys 0.45.0 native build 需要 MSVC/Windows SDK 头文件(windows.h/stdlib.h not found)。故 jcode-companion 的 E0596 修复为文本级核验(与 issue 建议的最小修法一致),待 CI Windows job 最终确认。

AI 披露

本修复由 AI coding agent(GLM)辅助完成,经 akushonkamen 复核与测试(commit 中已含 Assisted-by trailer)。

The Windows pipe listener's accept takes &mut self
(crates/jcode-transport/src/windows.rs:69) while the unix listener's takes
&self, so the companion server's listener must be mut on Windows only;
bind it with #[allow(unused_mut)] to satisfy both backends (fixes E0596 in
crates/jcode-companion/src/server.rs:209).

In crates/jcode-desktop-open, the serde::Deserialize import is only needed
by structs gated #[cfg(any(test, all(unix, not(target_os = "macos"))))],
so gate the import the same way and stop tripping the macOS warning budget.

Closes 1jehuang#1803

Assisted-by: AI coding agent (GLM); reviewed and tested by akushonkamen
Signed-off-by: akushonkamen <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low impact] Safe to merge based on the verified compilation fixes and unchanged Unix connection behavior; Windows CI should confirm the full companion build.

T-Rex evidence

Executed validation script

  • The executed Python script extracts both revisions, runs companion checks, and compiles and runs the focused harnesses, making the validation reproducible.

Full companion Windows check blocked by native dependencies

  • Attempted the full companion Windows cross-check and native dependency builds failed, preventing a full Windows build claim.

Evidence from the check

  • The executed Python script extracts both revisions, runs companion checks, and compiles and runs the focused harnesses, making the validation reproducible.

Evidence from the check

  • Generated Rust source preserves the base binding and accept block while using the actual transport, exposing the immutable Windows binding failure.

Evidence from the check

  • Generated Rust source preserves the head binding and accept block while using the actual transport, testing the mutable binding and Unix warning suppression.

Command output from the check

  • Ran the narrow companion server tests on the host and all five passed, including real socket request handling.

Command output from the check

  • Checked the companion crate on Linux and the command exited successfully, with only existing Cargo profile warnings.

Command output from the check

  • Attempted the full companion Windows cross-check and native dependency builds failed, preventing a full Windows build claim.

Command output from the check

  • Built jcode-transport with Tokio runtime support for the executable harnesses, providing real Unix transport dependencies.

Command output from the check

  • Cross-checked jcode-transport for Windows with Tokio runtime support, providing the actual named-pipe Listener for the focused compile comparison.

Command output from the check

  • Compiled the base listener pattern under deny(unused_mut) and compilation succeeded without diagnostics.

Command output from the check

  • Compiled the head listener pattern under deny(unused_mut) and compilation succeeded without diagnostics, confirming the local allowance works.

Command output from the check

  • Executed the base accept-loop harness over three separate Unix socket connections and every echoed byte matched.

Command output from the check

  • Executed the head accept-loop harness over the same three-connection flow and every echoed byte matched, showing no observed accept regression.

Command output from the check

  • Cross-compiled the base pattern against the actual Windows Listener and received E0596 because accept requires a mutable listener.

Command output from the check

  • Cross-compiled the head pattern against the same Windows Listener and compilation succeeded without diagnostics, resolving the binding-contract failure.

Evidence from the check

  • The executed Python script runs the identical desktop-open test and cross-target compile matrix at base and head with separate build caches, making the comparison reproducible.

Command output from the check

  • Captured Git diff, numbered source, toolchain and target inspection show that the import and both derived structs have exactly matching cfg guards.

Command output from the check

  • Executed the base revision's unit tests and macOS/Windows compilation matrix, showing passing tests but a non-test serde unused-import failure under the strict lint.

Command output from the check

  • Executed the head revision's identical matrix, showing passing tests and cross-target test checks while both strict non-test builds pass.

Command output from the check

  • Captured the script invocation and every matrix command's status, showing exit 0 with no unexpected results.

View artifacts

Summary

This PR fixes two platform-specific build problems without changing request behavior.

  • The companion can accept connections through both platform listeners.
  • The desktop-open crate imports Deserialize only on builds that use it.

No actionable issues were found. The verified changes are safe to merge, with full Windows companion compilation still requiring confirmation in Windows CI.

T-Rex validation blocked

The full Windows companion build could not complete because native dependencies require an unavailable MSVC/Windows SDK toolchain. The focused Windows listener compilation passed. Native Windows execution was not tested, and macOS and Windows desktop-open tests were compiled rather than executed.

Reviews (1) · Last reviewed commit: "fix(companion): mutable Windows listener..." · Reviewed by Greptile

This branch has not been deployed

No deployments
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.

master is red past formatting since 089947b02: Windows E0596 in jcode-companion and a macOS warning-budget overrun

1 participant