From cd81bacd15ef44656a350464c77256dec1f02dc2 Mon Sep 17 00:00:00 2001 From: bahdotsh Date: Thu, 2 Apr 2026 14:25:49 +0530 Subject: [PATCH] refactor(ui): feature-gate models and utils, clean up cfg imports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous commit gated the TUI behind a feature flag but left the models and utils modules unconditionally compiled. It turns out that *every single consumer* of those modules is TUI-gated code — they were compiling to dead code when building with --no-default-features. Gate models and utils behind cfg(feature = "tui") where they belong. While at it, consolidate the five separate #[cfg(feature = "tui")] annotations on imports in workflow.rs into a single grouped use block, because repeating the same attribute five times in a row is not my idea of readability. Also add a cargo check --no-default-features step to CI so this kind of thing doesn't silently regress. --- .github/workflows/build.yml | 6 ++++++ crates/ui/src/handlers/workflow.rs | 18 ++++++++---------- crates/ui/src/lib.rs | 8 +++++--- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d033417..862a842 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,6 +52,12 @@ jobs: command: build args: --target ${{ matrix.target }} + - name: Check no-default-features + uses: actions-rs/cargo@v1 + with: + command: check + args: --no-default-features --target ${{ matrix.target }} + - name: Run tests uses: actions-rs/cargo@v1 with: diff --git a/crates/ui/src/handlers/workflow.rs b/crates/ui/src/handlers/workflow.rs index abf57c2..a6a793b 100644 --- a/crates/ui/src/handlers/workflow.rs +++ b/crates/ui/src/handlers/workflow.rs @@ -1,18 +1,16 @@ // Workflow handlers -#[cfg(feature = "tui")] -use crate::app::App; -#[cfg(feature = "tui")] -use crate::models::{ExecutionResultMsg, WorkflowExecution, WorkflowStatus}; -#[cfg(feature = "tui")] -use chrono::Local; use std::io; use std::path::{Path, PathBuf}; -#[cfg(feature = "tui")] -use std::sync::mpsc; -#[cfg(feature = "tui")] -use std::thread; use wrkflw_evaluator::evaluate_workflow_file; use wrkflw_executor::{self, JobStatus, RuntimeType, StepStatus}; +#[cfg(feature = "tui")] +use { + crate::app::App, + crate::models::{ExecutionResultMsg, WorkflowExecution, WorkflowStatus}, + chrono::Local, + std::sync::mpsc, + std::thread, +}; // Validate a workflow or directory containing workflows pub fn validate_workflow(path: &Path, verbose: bool) -> io::Result<()> { diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index b362c8e..658dffa 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -8,10 +8,8 @@ // - utils: Contains utility functions // - views: Contains UI rendering code -// Re-export public modules +// Always-available modules (CLI validation/execution) pub mod handlers; -pub mod models; -pub mod utils; // TUI-specific modules (require ratatui/crossterm) #[cfg(feature = "tui")] @@ -21,6 +19,10 @@ pub mod components; #[cfg(feature = "tui")] pub mod log_processor; #[cfg(feature = "tui")] +pub mod models; +#[cfg(feature = "tui")] +pub mod utils; +#[cfg(feature = "tui")] pub mod views; // Re-export main entry points