1. Update suggestionGeneratorAgent.ts - Match the suggestions to user's language 2. Add incognito mode - Allow user to switch on / off incognito mode by webpage toggle or url parameter - URL Parameter Control - Accessing `/?incognito=true` automatically enables incognito mode - Accessing `/?incognito=false` or without parameters will use normal mode 3. Add the history retention feature - Allow users to set history retention days through config.toml or API endpoints, as well as on the settings page. 4. Add layout mode: Default / Tabs - Allow users to change default layout mode through config.toml - Allow users to customize layout mode for each browser through setting page 5. Allow users to change webpage theme by system detection
3.4 KiB
3.4 KiB
History Retention Feature Test Guide
This document outlines how to test the history retention feature that has been implemented.
Features Implemented
- Config.toml Setting: Added
RETENTION_DAYSsetting under[HISTORY]section - Settings Page: Added UI control to set history retention days when incognito mode is off
- API Endpoints:
- Updated
/api/configto handle history retention settings - Created
/api/cleanup-historyfor manual cleanup
- Updated
- Automatic Cleanup: History cleanup runs automatically when new chats are created (non-incognito mode)
Configuration
config.toml
[HISTORY]
RETENTION_DAYS = 30 # Number of days to keep chat history when incognito mode is off (0 = keep forever)
Settings Page
- Navigate to Settings page
- Find "History Settings" section
- Set "History Retention (Days)" value
- 0 = keep forever
- Any positive number = days to retain history
How It Works
-
When Incognito Mode is OFF:
- Chat history is saved to database
- History cleanup runs automatically when creating new chats
- Old chats (older than retention period) are automatically deleted
-
When Incognito Mode is ON:
- Chat history is NOT saved to database
- No cleanup needed as nothing is stored
-
Cleanup Logic:
- Runs automatically in background when new chats are created
- Deletes chats older than the configured retention period
- Also deletes all messages associated with old chats
- If retention is set to 0, keeps all history forever
Testing Steps
-
Set Retention Period:
- Go to Settings page
- Set "History Retention (Days)" to a small number (e.g., 1 day for testing)
- Save the setting
-
Create Test Chats:
- Make sure incognito mode is OFF
- Create several test chats
- Verify they appear in chat history
-
Test Manual Cleanup:
- Call POST
/api/cleanup-historyendpoint - Check response for cleanup results
- Call POST
-
Test Automatic Cleanup:
- Wait for retention period to pass (or modify database dates for testing)
- Create a new chat (triggers automatic cleanup)
- Verify old chats are removed
-
Test Incognito Mode:
- Turn ON incognito mode
- Create chats - they should not be saved to history
- Turn OFF incognito mode
- Create chats - they should be saved and cleanup should work
API Endpoints
GET /api/config
Returns current configuration including historyRetentionDays
POST /api/config
Updates configuration including historyRetentionDays
POST /api/cleanup-history
Manually triggers history cleanup and returns results:
{
"message": "Cleaned up X old chats and their messages",
"deletedChats": X
}
Files Modified
config.toml- Added HISTORY sectionsrc/lib/config.ts- Added history retention getter/settersrc/app/api/config/route.ts- Added history retention to APIsrc/app/settings/page.tsx- Added UI control for history retentionsrc/app/api/cleanup-history/route.ts- New cleanup endpointsrc/lib/utils/historyCleanup.ts- Cleanup utility functionssrc/app/api/chat/route.ts- Integrated automatic cleanup
Notes
- History retention only applies when incognito mode is OFF
- Cleanup runs automatically in background to avoid blocking chat creation
- Setting retention to 0 disables cleanup (keeps all history)
- Cleanup is based on chat creation date (
createdAtfield)