From baeb64de559b6c5037c4e7dc9c193af24a17a95d Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 22:04:52 -0700 Subject: [PATCH] refactor(windows): use the shared pause filter Both read_commands_uds and read_commands_tcp now ask komorebi_transport::allowed_while_paused instead of listing TogglePause, State, GlobalState and Stop. The one token that differed between the two copies (process_command(message, stream) in the TCP reader, where stream is already a &mut TcpStream, against &mut stream in the UDS reader) is only how the reply stream is passed: each call site keeps its own form, so TCP behaviour is unchanged. A paused connection still ends after the first message. komorebi-transport becomes a dependency of the Windows daemon. Verified: nix develop --command cargo clippy --workspace --locked --all-targets -- -D warnings: finished, no warnings or errors (tier 2). Not run: Windows unit tests or scenarios. --- Cargo.lock | 1 + komorebi/Cargo.toml | 1 + komorebi/src/process_command.rs | 29 +++++++++++------------------ 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f131762f..1f02fe2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3342,6 +3342,7 @@ dependencies = [ "komorebi-protocol", "komorebi-scrolling", "komorebi-themes", + "komorebi-transport", "lazy_static", "miow", "nanoid", diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 9c6aa4c9..90d806c5 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -13,6 +13,7 @@ komorebi-layouts = { path = "../komorebi-layouts", features = ["win32"] } komorebi-scrolling = { path = "../komorebi-scrolling" } komorebi-themes = { path = "../komorebi-themes" } komorebi-protocol = { path = "../crates/komorebi-protocol", default-features = false } +komorebi-transport = { path = "../crates/komorebi-transport" } base64 = "0.22" bitflags = { version = "2", features = ["serde"] } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 67f16398..6226f373 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -2,6 +2,7 @@ use color_eyre::eyre; use color_eyre::eyre::OptionExt; use color_eyre::eyre::WrapErr; use komorebi_themes::colour::Rgb; +use komorebi_transport::allowed_while_paused; use miow::pipe::connect; use parking_lot::Mutex; use std::collections::HashMap; @@ -2291,15 +2292,11 @@ pub fn read_commands_uds( } Some(mut wm) => { if wm.is_paused { - return match message { - SocketMessage::TogglePause - | SocketMessage::State - | SocketMessage::GlobalState - | SocketMessage::Stop => Ok(wm.process_command(message, &mut stream)?), - _ => { - tracing::trace!("ignoring while paused"); - Ok(()) - } + return if allowed_while_paused(&message) { + Ok(wm.process_command(message, &mut stream)?) + } else { + tracing::trace!("ignoring while paused"); + Ok(()) }; } @@ -2339,15 +2336,11 @@ pub fn read_commands_tcp( let mut wm = wm.lock(); if wm.is_paused { - return match message { - SocketMessage::TogglePause - | SocketMessage::State - | SocketMessage::GlobalState - | SocketMessage::Stop => Ok(wm.process_command(message, stream)?), - _ => { - tracing::trace!("ignoring while paused"); - Ok(()) - } + return if allowed_while_paused(&message) { + Ok(wm.process_command(message, stream)?) + } else { + tracing::trace!("ignoring while paused"); + Ok(()) }; }