Commit Graph

15 Commits

Author SHA1 Message Date
Zihao Xu
5a82a186a7 chore: add pytest-cov to requirements (#50)
Closes #42
2026-01-19 20:46:09 +08:00
Zihao Xu
a6b8198c3f Merge branch 'main' into xzhseh/sqlite-event-manager 2026-01-07 20:05:02 -08:00
bridge
968625d27b fix git action 2026-01-07 20:33:25 +08:00
Zihao Xu
a1f08dd0ab feat: SQLite event storage with pagination and filtering
Implement SQLite-based event persistence as specified in sqlite-event-manager.md.

## Changes

### Backend
- **EventStorage** (`src/classes/event_storage.py`): New SQLite storage layer
  - Cursor-based pagination with compound cursor `{month_stamp}_{rowid}`
  - Avatar filtering (single and pair queries)
  - Major/minor event separation
  - Cleanup API with `keep_major` and `before_month_stamp` filters

- **EventManager** (`src/classes/event_manager.py`): Refactored to use SQLite
  - Delegates to EventStorage for persistence
  - Memory fallback mode for testing
  - New `get_events_paginated()` method

- **API** (`src/server/main.py`):
  - `GET /api/events` - Paginated event retrieval with filtering
  - `DELETE /api/events/cleanup` - User-triggered cleanup

### Frontend
- **EventPanel.vue**: Scroll-to-load pagination, dual-person filter UI
- **world.ts**: Event state management with pagination
- **game.ts**: New API client methods

### Testing
- 81 new tests for EventStorage, EventManager, and API
- Added `pytest-asyncio` and `httpx` to requirements.txt

## Known Issues: Save/Load is Currently Broken

After loading a saved game, the following issues occur:

1. **Wrong database used**: API returns events from the startup database instead
   of the loaded save's `_events.db` file
2. **Events from wrong time period**: Shows events from year 115 when loaded
   save is at year 114
3. **Pagination broken after load**: `has_more` returns `False` despite hundreds
   of events in the saved database
4. **Filter functionality broken**: Character selection filter stops working
   after loading a game

Root cause: `load_game.py` does not properly switch the EventManager's database
connection to the loaded save's events database.
2026-01-07 00:40:34 -08:00
bridge
f14ea0b92e refactor llm config 2025-12-30 22:27:27 +08:00
bridge
52d953f565 remove litellm when pack 2025-11-22 00:41:13 +08:00
bridge
259d4a3794 update pack 2025-11-21 23:58:36 +08:00
bridge
870037d811 update pack 2025-11-21 23:39:54 +08:00
bridge
bfefb97ea2 temp 2025-11-20 01:21:32 +08:00
bridge
cf210d13e4 remove pack.py 2025-10-28 23:50:37 +08:00
bridge
d2f8205355 update 2025-10-26 22:30:35 +08:00
bridge
c09119a808 fix require 2025-10-15 21:31:30 +08:00
bridge
6e695910d0 update llm 2025-10-12 23:28:49 +08:00
bridge
eb9a727aab update ai prompt 2025-09-02 22:29:42 +08:00
bridge
a826a75312 update 2025-08-30 22:27:18 +08:00