forked from Rockachopa/Timmy-time-dashboard
fix: restore real-time chat responses via WebSocket (#98)
The chat WebSocket return path was broken by two bugs that prevented
Timmy's responses from appearing in the live chat feed:
1. Frontend checked msg.type instead of msg.event for 'timmy_response'
events — the WSEvent dataclass uses 'event' as the field name.
2. Frontend accessed msg.response instead of msg.data.response — the
response payload is nested in the data field.
Additional fixes:
- Queue acknowledgment ("Message queued...") no longer logged as an
agent message in chat history; the real response is logged by the
task processor when it completes, eliminating duplicate messages.
- Chat message template now carries data-task-id so the WS handler
can find and replace the placeholder with the actual response.
- appendMessage() uses DOM APIs (textContent) instead of innerHTML
for safer content insertion before markdown rendering.
- Fixed chat_message.html script targeting when queue-status div is
present between the agent message and the inline script.
https://claude.ai/code/session_011cJfexqBBuGhSRQU8qwKcR
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
d4acaefee9
commit
2e92838033
@@ -176,6 +176,15 @@ async def _task_processor_loop() -> None:
|
||||
context = f"[System: Current date/time is {now.strftime('%A, %B %d, %Y at %I:%M %p')}]\n\n"
|
||||
response = timmy_chat(context + task.description)
|
||||
|
||||
# Log the real agent response to chat history
|
||||
try:
|
||||
from dashboard.store import message_log
|
||||
timestamp = now.strftime("%H:%M:%S")
|
||||
message_log.append(role="agent", content=response, timestamp=timestamp)
|
||||
except Exception as e:
|
||||
logger.debug("Failed to log response to message_log: %s", e)
|
||||
|
||||
# Push response to chat UI via WebSocket
|
||||
try:
|
||||
from infrastructure.ws_manager.handler import ws_manager
|
||||
asyncio.create_task(
|
||||
|
||||
Reference in New Issue
Block a user