@npc-chat Feature: NPC Companion Chat Background: Given the Fellowship SUT is running And I am logged in as "gandalf" And I am on the dashboard And I open the NPC chat panel Scenario: User can start a chat with Frodo When I select "Frodo" from the character selector Then the chat should initialize with "Frodo" And an opening message should appear from "Frodo" Scenario: NPC initiates conversation with random opener style When I select "Sam" from the character selector Then the opening message from "Sam" should be one of: | A question about my current task | | A reflection on my progress | | A directive for what to do next | Scenario: User can carry on multi-turn conversation When I select "Gandalf" from the character selector And I send a message "What should I do next?" Then I should receive a reply from "Gandalf" When I send another message "How long will it take?" Then I should receive another reply from "Gandalf" And the conversation should flow coherently across multiple turns Scenario: NPC responses include contextual nudge-to-action When I chat with Sam And I send a message "I need guidance" Then the NPC response should include a suggested action And the suggested action should point to a valid in-app route Scenario: User can reset conversation When I chat with Frodo And I send a message "Hello" And I click the reset conversation button Then a fresh opening message should appear And the previous conversation history should be cleared Scenario: NPC personas are consistent When Frodo responds to my message, the tone should be: | uncertain, reflective, clarifying | When Sam responds to my message, the tone should be: | practical, loyal, action-oriented | When Gandalf responds to my message, the tone should be: | wise, directive, mentor | @azure-fallback Scenario: Chat works with Azure fallback when service is unavailable Given the Azure AI service is unavailable When I chat with any companion Then the chat should still function And responses should be deterministic in-character fallbacks And feature remains usable without Azure credentials Scenario: Out-of-character responses trigger retry and fallback Given the Azure service returns an out-of-character response When I send a message Then the system should attempt one strict retry And if the second response is also out-of-character, provide an in-character fallback # TODO: Implement business logic to handle session-scoped memory in NPC chat # Current Issue: Backend does not extract and persist user-stated names (e.g., "My name is Aragorn") # Solution: Add name extraction logic to npc_chat_service.py to: # 1. Detect when user states their name in chat message # 2. Store name in conversation context/session memory # 3. Include stored name in future LLM prompts for context awareness # 4. NPCs will then be able to reference the user's stated name naturally @skip Scenario: Chat session memory persists within login session When I chat with Gandalf And I send a message "My name is Aragorn" And I send another message "Do you remember who I am?" Then Gandalf should reference "Aragorn" in the response And the conversation should demonstrate session-scoped memory