Skip to content
Open
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
21 changes: 20 additions & 1 deletion frontend/src/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
RefreshCw,
FileText,
Eye,
BarChart3
BarChart3,
Activity
} from 'lucide-react';
import { Input, Textarea, Checkbox } from './ui/Input';
import { Button } from './ui/Button';
Expand All @@ -42,6 +43,7 @@ export function Settings({ isOpen, onClose }: SettingsProps) {
const [additionalPathsText, setAdditionalPathsText] = useState('');
const [platform, setPlatform] = useState<string>('darwin');
const [enableCrystalFooter, setEnableCrystalFooter] = useState(true);
const [disableAutoContext, setDisableAutoContext] = useState(false);
const [notificationSettings, setNotificationSettings] = useState({
enabled: true,
playSound: true,
Expand Down Expand Up @@ -80,6 +82,7 @@ export function Settings({ isOpen, onClose }: SettingsProps) {
setAutoCheckUpdates(data.autoCheckUpdates !== false); // Default to true
setDevMode(data.devMode || false);
setEnableCrystalFooter(data.enableCrystalFooter !== false); // Default to true
setDisableAutoContext(data.disableAutoContext || false);

// Load additional paths
const paths = data.additionalPaths || [];
Expand Down Expand Up @@ -142,6 +145,7 @@ export function Settings({ isOpen, onClose }: SettingsProps) {
devMode,
enableCrystalFooter,
additionalPaths: parsedPaths,
disableAutoContext,
notifications: notificationSettings,
analytics: {
enabled: analyticsEnabled
Expand Down Expand Up @@ -359,6 +363,21 @@ export function Settings({ isOpen, onClose }: SettingsProps) {
When enabled, commits made through Crystal will include a footer crediting Crystal. This helps others know you're using Crystal for AI-powered development.
</p>
</SettingsSection>

<SettingsSection
title="Automatic Context Tracking"
description="Control whether Claude automatically runs /context after responses"
icon={<Activity className="w-4 h-4" />}
>
<Checkbox
label="Disable automatic context tracking"
checked={disableAutoContext}
onChange={(e) => setDisableAutoContext(e.target.checked)}
/>
<p className="text-xs text-text-tertiary mt-1">
When checked, Crystal will not automatically run /context after each Claude response. This reduces wait time and Claude quota usage.
</p>
</SettingsSection>
</CollapsibleCard>

{/* System Updates */}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/panels/claude/ClaudePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ export const ClaudePanel: React.FC<AIPanelProps> = React.memo(({ panel, isActive
const transformer = React.useMemo(() => new ClaudeMessageTransformer(), []);
const activeSession = hook.activeSession;
const devModeEnabled = useConfigStore((state) => state.config?.devMode ?? false);
const autoContextDisabled = useConfigStore((state) => state.config?.disableAutoContext ?? false);
const showDebugTabs = devModeEnabled;

const claudePanelState = (panel.state.customState as ClaudePanelState | undefined) ?? {};
const contextUsage = claudePanelState.contextUsage ?? null;
const autoContextRunState = claudePanelState.autoContextRunState ?? 'idle';
const isContextUpdating = autoContextRunState === 'running';
const contextDisplay = contextUsage ?? '-- tokens (--%)';
const contextDisplay = autoContextDisabled
? 'auto-context disabled'
: (contextUsage ?? '-- tokens (--%)');

// Extract and store slash commands when we get JSON messages with init
useEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ export interface AppConfig {
posthogApiKey?: string;
posthogHost?: string;
};
// Auto-context tracking setting (enabled by default)
disableAutoContext?: boolean;
}
5 changes: 5 additions & 0 deletions main/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type { GitStatus } from './types/session';

export function setupEventListeners(services: AppServices, getMainWindow: () => BrowserWindow | null): void {
const {
configManager,
sessionManager,
claudeCodeManager,
executionTracker,
Expand Down Expand Up @@ -997,8 +998,12 @@ export function setupEventListeners(services: AppServices, getMainWindow: () =>
skipSessionSummary = true;
await finalizeAutoContextRun(panelId);
} else if (exitCode === 0) {
if (configManager.isAutoContextDisabled()) {
console.log(`[auto-context-debug] Auto-context disabled in settings - skipping`);
} else {
console.log(`[auto-context-debug] Starting auto context run for panel ${panelId}`);
await startAutoContextRun(panelId, sessionId);
}
} else {
console.log(`[auto-context-debug] Skipping auto context - exitCode is ${exitCode}, not 0`);
}
Expand Down
4 changes: 4 additions & 0 deletions main/src/services/configManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ export class ConfigManager extends EventEmitter {
return this.config.analytics?.distinctId;
}


isAutoContextDisabled(): boolean {
return this.config.disableAutoContext === true;
}
async setAnalyticsDistinctId(distinctId: string): Promise<void> {
if (!this.config.analytics) {
this.config.analytics = {
Expand Down
3 changes: 3 additions & 0 deletions main/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export interface AppConfig {
defaultModel?: string;
// Auto-check for updates
autoCheckUpdates?: boolean;
// Disable automatic context tracking after Claude responses
disableAutoContext?: boolean;
// Stravu MCP integration
stravuApiKey?: string;
stravuServerUrl?: string;
Expand Down Expand Up @@ -81,6 +83,7 @@ export interface UpdateConfigRequest {
defaultPermissionMode?: 'approve' | 'ignore';
defaultModel?: string;
autoCheckUpdates?: boolean;
disableAutoContext?: boolean;
stravuApiKey?: string;
stravuServerUrl?: string;
theme?: 'light' | 'dark';
Expand Down