with one click
add-feature-flag
// Add a new feature flag to gate code changes in the Warp codebase.
// Add a new feature flag to gate code changes in the Warp codebase.
| name | add-feature-flag |
| description | Add a new feature flag to gate code changes in the Warp codebase. |
Add a new feature flag to gate code changes in the Warp codebase.
Feature flags in Warp are compile-time flags that allow features to be selectively enabled for different channels (e.g.: Dev, Stable). They use a small runtime plumbing layer that checks if a flag is enabled.
Add the feature to app/Cargo.toml under the [features] section, but NOT under the default nested stanza:
[features]
your_feature_name = []
Add a new variant to the FeatureFlag enum in warp_core/src/features.rs:
#[derive(Sequence)]
pub enum FeatureFlag {
YourFeatureName,
}
Add the feature to app/src/lib.rs with a corresponding #[cfg(feature = "...")] attribute to ensure it's only included when enabled:
#[cfg(feature = "your_feature_name")]
YourFeatureName,
In your code, use the runtime check to conditionally execute feature-gated code:
if FeatureFlag::YourFeatureName.is_enabled() {
// feature-gated behavior
}
To enable the feature by default for Dev/dogfood builds, add it to the DOGFOOD_FLAGS array in features.rs:
pub const DOGFOOD_FLAGS: &[FeatureFlag] = &[
FeatureFlag::YourFeatureName,
];
To test locally with the feature enabled:
cargo run --features your_feature_name
# Multiple features:
cargo run --features your_feature_name,another_feature
If adding an EditableBinding or FixedBinding that's part of a gated feature, include an enabled predicate that checks the feature flag. This prevents the keybinding from appearing in keyboard settings when the feature is disabled.
Example:
EditableBinding::new(
"action:name",
"Action description",
YourAction::Variant
)
.with_enabled(|| FeatureFlag::YourFeatureName.is_enabled())
.with_key_binding("cmdorctrl-key")
When ready to enable the feature for all Warp Stable users, add it to the default array in app/Cargo.toml:
[features]
default = [
"your_feature_name",
# other default features...
]
FeatureFlag::YourFeatureName.is_enabled() instead of #[cfg(...)] when possible, so flags can be toggled without recompilation and are easier to clean up later#[cfg(...)] only when code cannot compile without the flag (e.g., platform-specific code or missing dependencies)