feat(api,web): tier-based session limits and daily turn usage display
Backend Changes:
- Add tier-based max_sessions config (free: 1, basic: 2, premium: 3, elite: 5)
- Add DELETE /api/v1/sessions/{id} endpoint for hard session deletion
- Cascade delete chat messages when session is deleted
- Add GET /api/v1/usage endpoint for daily turn limit info
- Replace hardcoded TIER_LIMITS with config-based ai_calls_per_day
- Handle unlimited (-1) tier in rate limiter service
Frontend Changes:
- Add inline session delete buttons with HTMX on character list
- Add usage_display.html component showing remaining daily turns
- Display usage indicator on character list and game play pages
- Page refresh after session deletion to update UI state
Documentation:
- Update API_REFERENCE.md with new endpoints and tier limits
- Update API_TESTING.md with session endpoint examples
- Update SESSION_MANAGEMENT.md with tier-based limits
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -126,13 +126,21 @@ session = service.create_solo_session(
|
||||
|
||||
**Validations:**
|
||||
- User must own the character
|
||||
- User cannot exceed 5 active sessions
|
||||
- User cannot exceed their tier's session limit
|
||||
|
||||
**Session Limits by Tier:**
|
||||
| Tier | Max Sessions |
|
||||
|------|--------------|
|
||||
| FREE | 1 |
|
||||
| BASIC | 2 |
|
||||
| PREMIUM | 3 |
|
||||
| ELITE | 5 |
|
||||
|
||||
**Returns:** `GameSession` instance
|
||||
|
||||
**Raises:**
|
||||
- `CharacterNotFound` - Character doesn't exist or user doesn't own it
|
||||
- `SessionLimitExceeded` - User has 5+ active sessions
|
||||
- `SessionLimitExceeded` - User has reached their tier's session limit
|
||||
|
||||
### Retrieving Sessions
|
||||
|
||||
@@ -284,10 +292,18 @@ session = service.add_world_event(
|
||||
|
||||
| Limit | Value | Notes |
|
||||
|-------|-------|-------|
|
||||
| Active sessions per user | 5 | End existing sessions to create new |
|
||||
| Active sessions per user | Tier-based (1-5) | See tier limits below |
|
||||
| Active quests per session | 2 | Complete or abandon to accept new |
|
||||
| Conversation history | Unlimited | Consider archiving for very long sessions |
|
||||
|
||||
**Session Limits by Tier:**
|
||||
| Tier | Max Sessions |
|
||||
|------|--------------|
|
||||
| FREE | 1 |
|
||||
| BASIC | 2 |
|
||||
| PREMIUM | 3 |
|
||||
| ELITE | 5 |
|
||||
|
||||
---
|
||||
|
||||
## Database Schema
|
||||
@@ -400,7 +416,7 @@ except SessionNotFound:
|
||||
try:
|
||||
service.create_solo_session(user_id, char_id)
|
||||
except SessionLimitExceeded:
|
||||
# User has 5+ active sessions
|
||||
# User has reached their tier's session limit
|
||||
pass
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user