Commit Graph

49 Commits

Author SHA1 Message Date
bridge
f33cfab0d5 refactor frontend (not done) 2026-01-11 22:08:01 +08:00
bridge
ff6038b786 fix: incorrect order in event panel 2026-01-11 19:26:05 +08:00
bridge
59824d9cd5 update readme and tips 2026-01-09 00:49:16 +08:00
bridge
d1d7e7d7bd fix conflict with pr-16 2026-01-08 21:23:06 +08:00
Zihao Xu
9485b62cfd feat: add loading screen with progress tracking
- Add async initialization with 6 phases: scanning_assets, loading_map,
  initializing_sects, generating_avatars, checking_llm, generating_initial_events
- Add /api/init-status endpoint for frontend polling
- Add /api/control/reinit endpoint for error recovery
- Add LoadingOverlay.vue component with:
  - Progress ring with gradient
  - Phase text in xianxia style (rotating messages for LLM phase)
  - Tips that rotate every 5 seconds
  - Time-based background transparency (fades to 80% over 20s)
  - Backdrop blur effect
  - Error state with retry button
- Preload map and avatars during LLM initialization for smoother UX
- Add comprehensive tests for init status API
2026-01-08 21:12:18 +08:00
Zihao Xu
8631be501b fix: prevent game from auto-starting to avoid stale initialization events
Problem:
When loading a save (e.g., from year 106), events from year 100 would appear.
This happened because the game auto-started on server startup and client
connection, generating initialization events before the user could load a save.

Solution:
1. Backend: Keep game paused on startup even if LLM check passes
2. Backend: Remove auto-resume on first WebSocket connection
3. Frontend: Start with game paused (isManualPaused = true)

Now the user must explicitly click 'resume' to start a new game, or load a
save first. This prevents the race condition where game_loop generates events
with stale world state.
2026-01-08 21:10:05 +08:00
Zihao Xu
624f697bee fix: pause game during save load to prevent stale events
The game loop could generate events with the old world's timestamp while
loading a save, causing 100年1月 events to appear after loading a 106年
save. Now we pause the game before loading and keep it paused after,
giving the frontend time to refresh state.
2026-01-08 21:06:34 +08:00
Zihao Xu
06d1bed987 fix: integrate SQLite event storage into load/save system
- Fix load_game to use World.create_with_db() for SQLite event storage
- Add get_events_db_path() to compute event database path from save path
- Add JSON to SQLite migration for backward compatibility with old saves
- Close old EventManager before loading new save to prevent connection leaks
- Add events_db metadata to save file
- Add comprehensive tests for database switching bug and save/load cycle
2026-01-07 23:22:17 -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
8a23dc5576 add lode 2026-01-06 23:01:25 +08:00
bridge
b60481c99c fix death bug 2026-01-06 21:23:06 +08:00
bridge
3f980d4593 fix a bug 2026-01-06 20:42:53 +08:00
bridge
276902bca0 refactor effect system 2026-01-04 22:03:05 +08:00
4thfever
f0290af13a Merge pull request #4 from xzhseh/xzhseh/fix-gender-display-chinese
fix: display gender in Chinese for avatar list API
2026-01-04 20:50:40 +08:00
Zihao Xu
233aea47d3 fix: display gender in Chinese for avatar list API
Use str(a.gender) instead of a.gender.value to return Chinese
"男"/"女" instead of English "male"/"female" in the avatar_list
endpoint, consistent with other APIs that use get_structured_info().
2026-01-04 00:59:24 -08:00
Zihao Xu
1a94117607 fix: cross-platform subprocess compatibility for npm dev server
On macOS/Linux, using shell=True with a list argument doesn't work as expected.
Only the first element is passed to the shell, causing npm to print help instead
of running the dev command.

Changes:
- Use shell=False + list on macOS/Linux, shell=True + string on Windows.
- Use terminate() instead of taskkill on macOS/Linux for cleanup.
2026-01-03 23:53:31 -08:00
bridge
f499f63c50 update 2026-01-03 22:05:45 +08:00
bridge
561f1efe21 add emoji to frontend 2026-01-01 15:08:09 +08:00
bridge
7197dd1acb refactor equip 2025-12-31 23:18:47 +08:00
bridge
d55ada7d66 refactor llm config 2025-12-30 22:20:30 +08:00
bridge
b8a4850e80 add llm config panel 2025-12-30 21:23:30 +08:00
bridge
9ed511aafb add protagonist 2025-12-13 20:48:03 +08:00
bridge
b094032eb2 add cloud 2025-12-06 15:52:28 +08:00
bridge
31ab56251b refactor map 2025-12-02 23:00:09 +08:00
bridge
39f158bbe8 update death 2025-12-01 02:05:11 +08:00
bridge
1aaa4d4094 add relationship in front 2025-12-01 01:16:02 +08:00
bridge
36ef26344f fail fast 2025-11-29 22:56:46 +08:00
bridge
b3e62b8c22 fail fast 2025-11-29 22:53:09 +08:00
bridge
d7549d7d32 update celestial phenon 2025-11-29 13:30:06 +08:00
bridge
796f48315f refactor sect in vue 2025-11-27 21:46:42 +08:00
bridge
8f3f095c27 refactor new avatars 2025-11-25 01:06:56 +08:00
bridge
ebd4f8be18 add new avatar button and func 2025-11-25 00:17:12 +08:00
bridge
9295d71a90 add pngs 2025-11-24 23:02:57 +08:00
bridge
c41285603b add celestrial phenon to front 2025-11-22 17:50:12 +08:00
bridge
45faba9990 fix bug 2025-11-22 17:26:54 +08:00
bridge
a65a23726e refactor 2025-11-22 15:57:59 +08:00
bridge
99e4871a5d update web, add clickable parts 2025-11-22 15:07:09 +08:00
bridge
460984e5ab update server 2025-11-22 14:05:56 +08:00
bridge
dfba5fda28 update 2025-11-22 12:29:28 +08:00
bridge
077cb5978f update ai.txt 2025-11-22 01:41:34 +08:00
bridge
85764cfa2e fix pack 2025-11-22 00:10:21 +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
6ab05edab2 update map 2025-11-21 23:11:35 +08:00
bridge
a234e621b7 add long objective setting func 2025-11-21 22:14:27 +08:00
bridge
5a51b6638d fix bug 2025-11-20 23:55:22 +08:00
bridge
0713881b71 fix web bugs 2025-11-20 22:55:56 +08:00
bridge
10d571e6bb refactor web 2025-11-20 22:16:27 +08:00
bridge
bfefb97ea2 temp 2025-11-20 01:21:32 +08:00