Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/chat/application/chat_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def on_message(self, message: Message):
if message.room_id != self.page.session.get("current_room"):
return

should_render_chat_message = message.message_type == "chat_message"

if message.message_type == "chat_message":
control = self.create_chat_message(message)
self.append_chat_control(control)
Expand Down Expand Up @@ -172,7 +174,15 @@ def on_message(self, message: Message):
self.append_chat_control(control)
self.update_page()

if message.room_id == "programador" and message.message_type == "chat_message":
assistant_name = getattr(self.assistant_responder, "nome", "").strip().lower()
should_process_assistant_response = (
should_render_chat_message
and message.room_id == "programador"
and message.message_type not in {"login_message", "file_message"}
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should_render_chat_message já garante message.message_type == "chat_message", então o predicado and message.message_type not in {"login_message", "file_message"} é redundante e não tem efeito. Remover essa condição (ou remover should_render_chat_message e manter apenas uma checagem de tipo) deixa a regra mais clara e evita confusão em futuras refatorações.

Suggested change
and message.message_type not in {"login_message", "file_message"}

Copilot uses AI. Check for mistakes.
and message.user_name.strip().lower() != assistant_name
Comment on lines +177 to +182
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comparação message.user_name.strip().lower() != assistant_name impede o assistente de responder a qualquer usuário humano que escolha o mesmo nome do bot (ex.: "Programador"), já que não existe validação/"nome reservado" no fluxo de login. Isso muda o comportamento de forma silenciosa e pode quebrar o uso do assistente para esses usuários. Considere (a) bloquear nomes reservados no join_chat_click (p.ex. impedir user_id == assistant_name), ou (b) identificar mensagens do assistente por um atributo dedicado (ex.: user_id/flag is_assistant) em vez de inferir pelo user_name.

Suggested change
assistant_name = getattr(self.assistant_responder, "nome", "").strip().lower()
should_process_assistant_response = (
should_render_chat_message
and message.room_id == "programador"
and message.message_type not in {"login_message", "file_message"}
and message.user_name.strip().lower() != assistant_name
is_assistant_message = getattr(message, "is_assistant", False)
should_process_assistant_response = (
should_render_chat_message
and message.room_id == "programador"
and message.message_type not in {"login_message", "file_message"}
and not is_assistant_message

Copilot uses AI. Check for mistakes.
)

if should_process_assistant_response:
assistant_response = self.assistant_responder.process_message(message)
if assistant_response:
self.append_chat_control(self.create_chat_message(assistant_response))
Expand Down