Files
Phillip Tarrant 20cb279793 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
2025-11-25 20:44:24 -06:00

28 lines
918 B
HTML

{#
Job Polling Partial
Shows loading state while waiting for AI response, auto-polls for completion
#}
{% if player_action %}
<div class="player-action-echo">
<span class="player-action-label">Your action:</span>
<span class="player-action-text">{{ player_action }}</span>
</div>
{% endif %}
<div class="loading-state"
hx-get="{{ url_for('game.poll_job', session_id=session_id, job_id=job_id, _hx_target=hx_target, _hx_swap=hx_swap) }}"
hx-trigger="load delay:1s"
hx-swap="{{ hx_swap|default('innerHTML') }}"
hx-target="{{ hx_target|default('#narrative-content') }}">
<div class="loading-spinner-large"></div>
<p class="loading-text">
{% if status == 'queued' %}
Awaiting the Dungeon Master...
{% elif status == 'processing' %}
The Dungeon Master considers your action...
{% else %}
Processing...
{% endif %}
</p>
</div>