---
name: "Add configurable chat history pruning"
---

# Story 179: Add configurable chat history pruning

## User Story

As a user, I want chat history to be automatically pruned to a configurable limit, so that long sessions don't bloat localStorage and degrade performance.

## Acceptance Criteria

- [ ] Default limit of 200 messages is applied when saving to localStorage
- [ ] Messages are pruned from the front (oldest removed first) via messages.slice(-limit)
- [ ] Limit is configurable via localStorage key storykit-chat-history-limit:{projectPath}
- [ ] A limit of 0 means unlimited (no pruning)
- [ ] useChatHistory returns maxMessages and setMaxMessages for future UI use
- [ ] Existing useChatHistory tests continue to pass
- [ ] New tests cover: pruning at limit, custom limit, unlimited mode

## Out of Scope

- TBD
