Skip to content

feat: add setting to disable automatic context tracking#230

Open
shaunbuswell wants to merge 4 commits into
stravu:mainfrom
elevanaltd:debug-investigation
Open

feat: add setting to disable automatic context tracking#230
shaunbuswell wants to merge 4 commits into
stravu:mainfrom
elevanaltd:debug-investigation

Conversation

@shaunbuswell

Copy link
Copy Markdown

Summary

Adds a user setting to disable Crystal's automatic context tracking feature, which runs /context after every Claude response.

Problem

Crystal automatically runs /context after each Claude response to track context usage. This:

  • Doubles the wait time after each interaction
  • Uses additional Claude quota
  • Can't be disabled

Solution

This PR adds a checkbox in Settings → AI Integration to disable automatic context tracking.

Changes

  • ✅ Add disableAutoContext setting to config types
  • ✅ Add checkbox UI in Settings under "AI Integration"
  • ✅ Check setting before running auto-context in events.ts
  • ✅ Display "auto-context disabled" in UI when feature is disabled
  • ✅ Clarify checkbox wording to avoid confusion

Testing

  1. Go to Settings → General → AI Integration
  2. Check "Disable automatic context tracking"
  3. Run a Claude session
  4. Verify session completes without additional /context delay
  5. Check console for: [auto-context-debug] Auto-context disabled in settings - skipping
  6. Verify UI shows "auto-context disabled" instead of token count

Future Phases (separate PRs)

  • Phase 2: Force auto-context to use Haiku model (reduce cost/latency)
  • Phase 3: Fix context extraction to show accurate usage

Screenshots

When disabled, the UI shows "auto-context disabled" instead of potentially incorrect token counts.

Fixes the delay issue reported when using Crystal with custom builds.

shaunbuswell and others added 3 commits December 18, 2025 22:15
- Add disableAutoContext setting to config types
- Add isAutoContextDisabled() method to ConfigManager
- Check setting before running auto-context in events.ts
- Add checkbox in Settings UI under AI Integration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changed "When enabled" to "When checked" to avoid confusion
since the checkbox disables the feature when checked.
…e is disabled

Updates the context usage display to reflect when automatic context
tracking is disabled in settings, providing clearer feedback to users.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The node_modules symlink was being tracked in git, which caused CI
failures as pnpm couldn't create the node_modules directory.

ENOTDIR error fix: node_modules should never be committed to git.
@jordan-BAIC

Copy link
Copy Markdown
Collaborator

Are you sure this uses quota?

@shaunbuswell

Copy link
Copy Markdown
Author

Are you sure this uses quota?

From everything I've seen, yes. If you look at main/src/events.ts around line 472, it triggers /context via claudeManager.continuePanel() as a follow-up run, rather than passively parsing metadata from the previous response. That means:

  • A second Claude Code execution occurs
  • Tokens are consumed to process /context and return its output

The token cost is probably small, but non-zero, and the additional run also introduces noticeable latency because Crystal waits for /context to complete before updating the UI.

My concern isn’t really costs but that this always runs, cannot currently be disabled and adds a second model invocation (of same main model chosen) per user interaction.

What I've actually done, if it's of interest, is :

  1. Added this disable option
  2. Created a function that allows me to choose the model (based on same dropdown as main UI) when it's enabled
  3. Added a further fix that ensures that when auto-context runs /context after each Claude response, it will correctly extract and display token usage like "74k/200k tokens (37%)" instead of showing stale or incorrect values.

I've not bombarded you with 2 & 3 in case 1 wasn't of use. But if you see value, I'll add those PRs too.

@shaunbuswell

Copy link
Copy Markdown
Author

After reviewing this further, I think there is an issue that needs looking into. I've raised #233 regarding this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants