diff --git a/src/dashboard/app.py b/src/dashboard/app.py index b007ef6..0eb083c 100644 --- a/src/dashboard/app.py +++ b/src/dashboard/app.py @@ -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( diff --git a/src/dashboard/routes/agents.py b/src/dashboard/routes/agents.py index fad0a7d..7988bd2 100644 --- a/src/dashboard/routes/agents.py +++ b/src/dashboard/routes/agents.py @@ -316,13 +316,16 @@ async def chat_timmy(request: Request, message: str = Form(...)): logger.error("Failed to queue chat message: %s", exc) error_text = f"Failed to queue message: {exc}" - # Log to message history (for context, even though async) + # Log user message to history. For chat_response tasks the real agent + # reply is logged by the task processor when it completes, so we only + # log the queue acknowledgment for explicit task_request commands. message_log.append(role="user", content=message, timestamp=timestamp) - if response_text is not None: + if task_info and response_text is not None: + # Explicit task queue command — the acknowledgment IS the response message_log.append(role="agent", content=response_text, timestamp=timestamp) - else: + elif error_text: message_log.append( - role="error", content=error_text or "Unknown error", timestamp=timestamp + role="error", content=error_text, timestamp=timestamp ) return templates.TemplateResponse( diff --git a/src/dashboard/templates/partials/chat_message.html b/src/dashboard/templates/partials/chat_message.html index 54a8a0e..b52f5e5 100644 --- a/src/dashboard/templates/partials/chat_message.html +++ b/src/dashboard/templates/partials/chat_message.html @@ -3,7 +3,7 @@