Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Overview

Makes the /compact -m <model> preference sticky globally. When users specify a compaction model, it becomes their default for all future compactions across all workspaces and sessions.

Changes

  • Storage: Added PREFERRED_COMPACTION_MODEL_KEY for localStorage persistence
  • Utility: Created getEffectiveCompactionModel() to manage the sticky preference
    • Saves model to localStorage when -m flag is used
    • Retrieves saved preference when no model specified
    • Falls back to workspace model when no preference exists
  • Integration: Updated prepareCompactionMessage() in ChatInput to use new utility
  • Tests: Added 6 comprehensive test cases with localStorage mocking
  • Docs: Updated docs/context-management.md with sticky behavior explanation

Usage Example

# Set preference to haiku - becomes default
/compact -m haiku

# Future compactions automatically use haiku
/compact
/compact -t 5000

# Change preference to opus
/compact -m opus

# Now opus is the new default
/compact

Testing

✅ 6 new tests for preference management
✅ 34 existing compact command tests passing
✅ 7 compaction options tests passing
✅ TypeScript checks passing

Design Notes

  • Global scope: Preference applies across all workspaces (matches UX expectation)
  • Frontend-only: Uses localStorage pattern, not backend config (per project guidelines)
  • Testable: Logic extracted to pure utility function with comprehensive tests
  • Backwards compatible: No model specified still works (uses workspace default)

Generated with cmux

@ammar-agent ammar-agent force-pushed the compact-model-persist branch 2 times, most recently from 971b76f to 10abb83 Compare October 18, 2025 02:21
@ammario ammario enabled auto-merge October 18, 2025 02:22
When a user specifies a model with `/compact -m <model>`, that model now
becomes their default for all future compactions across all workspaces and
sessions. This preference is stored in localStorage and persists until changed.

## Changes

- **Storage**: Added `PREFERRED_COMPACTION_MODEL_KEY` constant for localStorage
- **Utility**: Created `getEffectiveCompactionModel()` to manage preference
  - Saves model when `-m` flag is used
  - Retrieves saved preference when no model specified
  - Falls back to workspace model when no preference saved
- **Integration**: Updated `prepareCompactionMessage()` to use new utility
- **Tests**: Added 6 test cases for preference management with localStorage mocking
- **Docs**: Updated context-management.md with sticky behavior explanation and examples

## Usage

```bash
# Set preference to haiku
/compact -m haiku

# Future compactions automatically use haiku
/compact
/compact -t 5000

# Change preference to opus
/compact -m opus

# Now opus is the default
/compact
```

## Testing

✅ 6 new tests for model preference management
✅ All existing compact command tests passing (34 tests)
✅ All compaction options tests passing (7 tests)
✅ TypeScript compilation successful

_Generated with `cmux`_
@ammar-agent ammar-agent force-pushed the compact-model-persist branch from 10abb83 to 51a15d9 Compare October 18, 2025 02:25
@ammario ammario added this pull request to the merge queue Oct 18, 2025
Merged via the queue into main with commit d90a90b Oct 18, 2025
10 checks passed
@ammario ammario deleted the compact-model-persist branch October 18, 2025 02:39
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