fix: resolve NPC chat database persistence and modal targeting
Fixed two critical bugs in NPC chat functionality:
1. Database Persistence - Metadata serialization bug
- Empty dict {} was falsy, preventing JSON conversion
- Changed to unconditional serialization in ChatMessageService
- Messages now successfully save to chat_messages collection
2. Modal Targeting - HTMX targeting lost during polling
- poll_job() wasn't preserving hx-target/hx-swap parameters
- Pass targeting params through query string in polling cycle
- Responses now correctly load in modal instead of main panel
Files modified:
- api/app/services/chat_message_service.py
- public_web/templates/game/partials/job_polling.html
- public_web/app/views/game_views.py
This commit is contained in:
@@ -108,9 +108,9 @@ class ChatMessageService:
|
||||
|
||||
# Save to database
|
||||
message_data = chat_message.to_dict()
|
||||
# Convert metadata dict to JSON string for storage
|
||||
if message_data.get('metadata'):
|
||||
message_data['metadata'] = json.dumps(message_data['metadata'])
|
||||
# Convert metadata dict to JSON string for storage (Appwrite requires string type)
|
||||
# Always convert, even if empty dict (empty dict {} is falsy in Python!)
|
||||
message_data['metadata'] = json.dumps(message_data.get('metadata') or {})
|
||||
|
||||
self.db.create_row(
|
||||
table_id='chat_messages',
|
||||
|
||||
Reference in New Issue
Block a user