generated from nhcarrigan/template
feat: add disable_1m_context toggle to settings UI
Adds a new config option to expose the CLAUDE_CODE_DISABLE_1M_CONTEXT environment variable through the settings sidebar, allowing users to opt out of the extended 1M context window without manually setting environment variables. Closes #154
This commit is contained in:
@@ -28,6 +28,9 @@ pub struct ClaudeStartOptions {
|
||||
|
||||
#[serde(default)]
|
||||
pub use_worktree: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub disable_1m_context: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -119,6 +122,9 @@ pub struct HikariConfig {
|
||||
|
||||
#[serde(default)]
|
||||
pub use_worktree: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub disable_1m_context: bool,
|
||||
}
|
||||
|
||||
impl Default for HikariConfig {
|
||||
@@ -152,6 +158,7 @@ impl Default for HikariConfig {
|
||||
budget_warning_threshold: 0.8,
|
||||
discord_rpc_enabled: true,
|
||||
use_worktree: false,
|
||||
disable_1m_context: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,6 +266,8 @@ mod tests {
|
||||
assert_eq!(config.budget_action, BudgetAction::Warn);
|
||||
assert!((config.budget_warning_threshold - 0.8).abs() < f32::EPSILON);
|
||||
assert!(config.discord_rpc_enabled);
|
||||
assert!(!config.use_worktree);
|
||||
assert!(!config.disable_1m_context);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -292,6 +301,7 @@ mod tests {
|
||||
budget_warning_threshold: 0.75,
|
||||
discord_rpc_enabled: true,
|
||||
use_worktree: true,
|
||||
disable_1m_context: false,
|
||||
};
|
||||
|
||||
let json = serde_json::to_string(&config).unwrap();
|
||||
|
||||
@@ -279,6 +279,11 @@ impl WslBridge {
|
||||
}
|
||||
}
|
||||
|
||||
// Disable 1M context window if requested
|
||||
if options.disable_1m_context {
|
||||
cmd.env("CLAUDE_CODE_DISABLE_1M_CONTEXT", "1");
|
||||
}
|
||||
|
||||
cmd
|
||||
} else {
|
||||
// Running on Windows - use wsl with bash login shell to ensure PATH is loaded
|
||||
@@ -319,6 +324,11 @@ impl WslBridge {
|
||||
}
|
||||
}
|
||||
|
||||
// Disable 1M context window if requested
|
||||
if options.disable_1m_context {
|
||||
claude_cmd.push_str("CLAUDE_CODE_DISABLE_1M_CONTEXT=1 ");
|
||||
}
|
||||
|
||||
claude_cmd.push_str(
|
||||
"claude --output-format stream-json --input-format stream-json --verbose",
|
||||
);
|
||||
|
||||
@@ -62,6 +62,7 @@ async function changeDirectory(path: string): Promise<void> {
|
||||
mcp_servers_json: config.mcp_servers_json || null,
|
||||
allowed_tools: allAllowedTools,
|
||||
use_worktree: config.use_worktree ?? false,
|
||||
disable_1m_context: config.disable_1m_context ?? false,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -137,6 +138,7 @@ async function startNewConversation(): Promise<void> {
|
||||
mcp_servers_json: config.mcp_servers_json || null,
|
||||
allowed_tools: allAllowedTools,
|
||||
use_worktree: config.use_worktree ?? false,
|
||||
disable_1m_context: config.disable_1m_context ?? false,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
discord_rpc_enabled: true,
|
||||
show_thinking_blocks: true,
|
||||
use_worktree: false,
|
||||
disable_1m_context: false,
|
||||
});
|
||||
|
||||
let showCustomThemeEditor = $state(false);
|
||||
@@ -489,6 +490,22 @@
|
||||
Launch sessions with <code class="font-mono">--worktree</code> for isolated git worktree environments
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Disable 1M Context Window -->
|
||||
<div class="mb-4">
|
||||
<label class="flex items-center gap-3 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={config.disable_1m_context}
|
||||
class="w-4 h-4 rounded border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--accent-primary)] focus:ring-[var(--accent-primary)]"
|
||||
/>
|
||||
<span class="text-sm text-[var(--text-primary)]">Disable 1M context window</span>
|
||||
</label>
|
||||
<p class="text-xs text-[var(--text-tertiary)] mt-1 ml-7">
|
||||
Sets <code class="font-mono">CLAUDE_CODE_DISABLE_1M_CONTEXT=1</code> to opt out of the extended
|
||||
context window
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Greeting Section -->
|
||||
|
||||
@@ -363,6 +363,7 @@ User: ${formattedMessage}`;
|
||||
mcp_servers_json: config.mcp_servers_json || null,
|
||||
allowed_tools: allAllowedTools,
|
||||
use_worktree: config.use_worktree ?? false,
|
||||
disable_1m_context: config.disable_1m_context ?? false,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
mcp_servers_json: config.mcp_servers_json || null,
|
||||
allowed_tools: newGrantedTools,
|
||||
use_worktree: config.use_worktree ?? false,
|
||||
disable_1m_context: config.disable_1m_context ?? false,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
discord_rpc_enabled: true,
|
||||
show_thinking_blocks: true,
|
||||
use_worktree: false,
|
||||
disable_1m_context: false,
|
||||
});
|
||||
|
||||
let streamerModeActive = $state(false);
|
||||
@@ -180,6 +181,7 @@
|
||||
mcp_servers_json: currentConfig.mcp_servers_json || null,
|
||||
allowed_tools: allAllowedTools,
|
||||
use_worktree: currentConfig.use_worktree ?? false,
|
||||
disable_1m_context: currentConfig.disable_1m_context ?? false,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -292,6 +294,7 @@
|
||||
mcp_servers_json: currentConfig.mcp_servers_json || null,
|
||||
allowed_tools: allAllowedTools,
|
||||
use_worktree: currentConfig.use_worktree ?? false,
|
||||
disable_1m_context: currentConfig.disable_1m_context ?? false,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
mcp_servers_json: config.mcp_servers_json || null,
|
||||
allowed_tools: grantedToolsList,
|
||||
use_worktree: config.use_worktree ?? false,
|
||||
disable_1m_context: config.disable_1m_context ?? false,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -195,6 +195,7 @@ describe("config store", () => {
|
||||
discord_rpc_enabled: true,
|
||||
show_thinking_blocks: true,
|
||||
use_worktree: false,
|
||||
disable_1m_context: false,
|
||||
};
|
||||
|
||||
expect(config.model).toBe("claude-sonnet-4");
|
||||
@@ -242,6 +243,7 @@ describe("config store", () => {
|
||||
discord_rpc_enabled: true,
|
||||
show_thinking_blocks: true,
|
||||
use_worktree: false,
|
||||
disable_1m_context: false,
|
||||
};
|
||||
|
||||
expect(config.model).toBeNull();
|
||||
@@ -788,6 +790,7 @@ describe("config store", () => {
|
||||
discord_rpc_enabled: false,
|
||||
show_thinking_blocks: true,
|
||||
use_worktree: false,
|
||||
disable_1m_context: false,
|
||||
};
|
||||
|
||||
const mockInvokeImpl = vi.mocked(invoke);
|
||||
|
||||
@@ -49,6 +49,8 @@ export interface HikariConfig {
|
||||
show_thinking_blocks: boolean;
|
||||
// Worktree isolation
|
||||
use_worktree: boolean;
|
||||
// Disable 1M context window
|
||||
disable_1m_context: boolean;
|
||||
}
|
||||
|
||||
const defaultConfig: HikariConfig = {
|
||||
@@ -90,6 +92,7 @@ const defaultConfig: HikariConfig = {
|
||||
discord_rpc_enabled: true,
|
||||
show_thinking_blocks: true,
|
||||
use_worktree: false,
|
||||
disable_1m_context: false,
|
||||
};
|
||||
|
||||
function createConfigStore() {
|
||||
|
||||
Reference in New Issue
Block a user