Skip to content

feat: gate heavy dependencies behind Cargo features#53

Merged
tzero86 merged 6 commits into
mainfrom
feat/feature-gating
May 13, 2026
Merged

feat: gate heavy dependencies behind Cargo features#53
tzero86 merged 6 commits into
mainfrom
feat/feature-gating

Conversation

@tzero86

@tzero86 tzero86 commented May 12, 2026

Copy link
Copy Markdown
Owner

Summary

Makes heavy dependencies optional via Cargo features to reduce binary size and build time. All features are enabled by default for backward compatibility.

New Features

Feature Dependencies ~Size Impact
syntax-highlight syntect, two-face ~5-8 MB
image-preview image, ratatui-image ~3-5 MB
sftp ssh2 ~1-2 MB
terminal-panel vt100, portable-pty, conpty ~500 KB-1 MB
auto-update ureq ~500 KB

Binary Size Results

Build Size
Full (default features) 5.67 MB
Minimal (--no-default-features) 1.52 MB
Savings ~4.15 MB (73% smaller)

What's Changed

  • Cargo.toml: new features + optional deps
  • src/highlight.rs: stub highlight_text() when disabled
  • src/fs/sftp.rs: module-level cfg gate
  • src/update.rs: stub check_latest_release() when disabled
  • src/pty.rs, state/terminal.rs, ui/terminal.rs: stub terminal panel
  • src/preview.rs, ui/preview.rs: stub image preview
  • src/jobs.rs: conditional workers and request types
  • src/app.rs: conditional imports and startup code
  • src/state/mod.rs: stub Picker type when image-preview disabled
  • .github/workflows/test.yml: CI matrix for default + minimal builds on Linux/Windows

Validation

  • cargo fmt --all
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace ✅ (630+ tests passed)
  • cargo check --no-default-features
  • cargo build --release --no-default-features

Usage

# Full build (default — all features)
cargo install zeta

# Minimal build (core file manager only)
cargo install zeta --no-default-features

# Pick and choose
cargo install zeta --no-default-features --features syntax-highlight,auto-update

tzero86 added 3 commits May 12, 2026 20:43
Adds optional features to reduce binary size and build time:
- syntax-highlight (syntect + two-face)
- image-preview (image + ratatui-image)
- sftp (ssh2)
- terminal-panel (vt100 + portable-pty/conpty)
- auto-update (ureq)

All features are enabled by default for backward compatibility.
A minimal build (--no-default-features) compiles and runs core
file manager functionality without the heavy deps.

Files changed:
- Cargo.toml: new features + optional deps
- src/highlight.rs: stub highlight_text() when disabled
- src/fs/sftp.rs: module-level cfg gate
- src/update.rs: stub check_latest_release() when disabled
- src/pty.rs, state/terminal.rs, ui/terminal.rs: stub terminal
  panel when disabled
- src/preview.rs, ui/preview.rs: stub image preview when disabled
- src/jobs.rs: conditional workers and request types
- src/app.rs: conditional imports and startup code
- src/state/mod.rs: stub Picker type when image-preview disabled
Tests both default and --no-default-features builds on
Linux and Windows. Runs fmt, clippy, build, and test for
each combination.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f582fece7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Cargo.toml Outdated
Comment thread src/app.rs
tzero86 added 3 commits May 12, 2026 21:06
Run clippy with the same feature set as build/test instead of
--all-features, avoiding pre-existing warnings in code paths that
aren't part of the tested configuration.
Gated unused stub imports/variables behind feature flags to satisfy
-D warnings on minimal builds:

- terminal.rs/ui: Arc/Mutex/Color/terminal param only when terminal-panel
- highlight.rs: MAX_HIGHLIGHT_BYTES only when syntax-highlight
- update.rs: is_newer_version, parse_version_tag, Ordering, and their
tests only when auto-update
- preview_enhancements.rs: image/ratatui_image tests only when image-preview
1. Cargo.toml: make conpty/portable-pty optional and tie them to the
   terminal-panel feature so --no-default-features skips them entirely.

2. src/app.rs: add explicit fallback for CheckForUpdates when auto-update
   is disabled (shows error status instead of silently ignoring).

3. src/state/menu.rs: gate Check for Updates / Apply Update menu items
   behind the auto-update feature so they don't appear in minimal builds.
@tzero86 tzero86 merged commit 8423019 into main May 13, 2026
6 checks passed
@tzero86 tzero86 deleted the feat/feature-gating branch May 13, 2026 00:48
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