feat: gate heavy dependencies behind Cargo features#53
Merged
Conversation
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.
There was a problem hiding this comment.
💡 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".
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
syntax-highlightsyntect,two-faceimage-previewimage,ratatui-imagesftpssh2terminal-panelvt100,portable-pty,conptyauto-updateureqBinary Size Results
--no-default-features)What's Changed
Cargo.toml: new features + optional depssrc/highlight.rs: stubhighlight_text()when disabledsrc/fs/sftp.rs: module-level cfg gatesrc/update.rs: stubcheck_latest_release()when disabledsrc/pty.rs,state/terminal.rs,ui/terminal.rs: stub terminal panelsrc/preview.rs,ui/preview.rs: stub image previewsrc/jobs.rs: conditional workers and request typessrc/app.rs: conditional imports and startup codesrc/state/mod.rs: stubPickertype when image-preview disabled.github/workflows/test.yml: CI matrix for default + minimal builds on Linux/WindowsValidation
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