Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
694 changes: 694 additions & 0 deletions .omo/plans/disable-env-master-plan.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions crates/jcode-base/src/config/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ impl Config {

/// Load config from file, with environment variable overrides
pub fn load() -> Self {
// Trigger DisableRegistry initialization early so env vars are read
// before any config-dependent code runs.
let _ = crate::disable::DisableRegistry::global();

let mut config = Self::load_from_file().unwrap_or_default();
config.apply_env_overrides();
config
Expand All @@ -20,6 +24,9 @@ impl Config {
/// Unlike [`Self::load`], this returns TOML/read errors to callers that need
/// to distinguish a malformed config from an absent config.
pub fn load_strict() -> anyhow::Result<Self> {
// Trigger DisableRegistry initialization early.
let _ = crate::disable::DisableRegistry::global();

let mut config = Self::load_from_file_strict()?.unwrap_or_default();
config.apply_env_overrides();
Ok(config)
Expand Down
55 changes: 53 additions & 2 deletions crates/jcode-base/src/config/env_overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ impl Config {
reason = "Environment override parsing is intentionally explicit and grouped by config area"
)]
pub(crate) fn apply_env_overrides(&mut self) {
// Deprecated env vars — still supported but log warning.
#[cfg(not(test))]
{
if std::env::var("JCODE_DISABLED_TOOLS").is_ok() {
crate::logging::warn(
"JCODE_DISABLED_TOOLS is deprecated, use JCODE_DISABLE_TOOL=... instead",
);
}
if std::env::var("JCODE_DISABLE_BASE_TOOLS").is_ok() {
crate::logging::warn(
"JCODE_DISABLE_BASE_TOOLS is deprecated, use JCODE_DISABLE_TOOL=base instead",
);
}
if std::env::var("JCODE_DISABLED_ANIMATIONS").is_ok() {
crate::logging::warn(
"JCODE_DISABLED_ANIMATIONS is deprecated, use JCODE_DISABLE_ANIMATION=... instead",
);
}
}

// Keybindings
if let Ok(v) = std::env::var("JCODE_SCROLL_UP_KEY") {
self.keybindings.scroll_up = v;
Expand Down Expand Up @@ -109,12 +129,30 @@ impl Config {
if let Ok(v) = std::env::var("JCODE_TOOLS") {
self.tools.enabled = parse_env_list(&v);
}
// Disable-related vars are now centralized in DisableRegistry.
// Populate Config fields from the registry for backward compat.
{
let registry = crate::disable::DisableRegistry::global();
let tools: Vec<String> = registry.all_disabled_tools().iter().cloned().collect();
if !tools.is_empty() {
self.tools.disabled = tools;
}
self.tools.disable_base_tools = registry.base_tools_disabled();
}
// Backward compat: also read deprecated env vars directly.
if let Ok(v) = std::env::var("JCODE_DISABLED_TOOLS") {
self.tools.disabled = parse_env_list(&v);
let parsed = parse_env_list(&v);
for tool in parsed {
if !self.tools.disabled.contains(&tool) {
self.tools.disabled.push(tool);
}
}
}
if let Ok(v) = std::env::var("JCODE_DISABLE_BASE_TOOLS")
&& let Some(parsed) = parse_env_bool(&v)
{
// Explicit boolean assignment preserves backward compat:
// `=false` overrides registry to re-enable base tools.
self.tools.disable_base_tools = parsed;
}

Expand Down Expand Up @@ -213,8 +251,21 @@ impl Config {
self.display.prompt_entry_animation = parsed;
}
}
// Animations: populate from DisableRegistry, then merge deprecated env var.
{
let registry = crate::disable::DisableRegistry::global();
let anims: Vec<String> = registry.all_disabled_animations().iter().cloned().collect();
if !anims.is_empty() {
self.display.disabled_animations = anims;
}
}
if let Ok(v) = std::env::var("JCODE_DISABLED_ANIMATIONS") {
self.display.disabled_animations = parse_env_list(&v);
let parsed = parse_env_list(&v);
for anim in parsed {
if !self.display.disabled_animations.contains(&anim) {
self.display.disabled_animations.push(anim);
}
}
}
if let Ok(v) = std::env::var("JCODE_PERFORMANCE") {
let trimmed = v.trim().to_lowercase();
Expand Down
Loading
Loading