From dff1b7b8e09732ba59be2d4faa77c823dc2376ef Mon Sep 17 00:00:00 2001 From: Bereket Terefe Date: Mon, 15 Jun 2026 17:24:13 +0300 Subject: [PATCH] feat(chat): add text to refresh recommendations button and update translations --- backend/app/conversations/service.py | 9 ++-- backend/app/conversations/test_routes.py | 3 +- frontend-new/src/chat/Chat.tsx | 48 +++++++++++++------ .../src/i18n/locales/en-GB/translation.json | 2 +- .../src/i18n/locales/en-US/translation.json | 2 +- .../src/i18n/locales/es-AR/translation.json | 2 +- .../src/i18n/locales/es-ES/translation.json | 2 +- .../src/i18n/locales/sw-KE/translation.json | 2 +- 8 files changed, 47 insertions(+), 23 deletions(-) diff --git a/backend/app/conversations/service.py b/backend/app/conversations/service.py index 7e68e8b55..1526d7c14 100644 --- a/backend/app/conversations/service.py +++ b/backend/app/conversations/service.py @@ -56,7 +56,8 @@ async def send(self, user_id: str, session_id: int, user_input: str, clear_memor filter_pii: bool, city: str | None = None, province: str | None = None, - discuss_recommendations: bool = True) -> ConversationResponse: + discuss_recommendations: bool = True, + is_artificial: bool = False) -> ConversationResponse: # TODO: discuss filter pii and clear_memory """ Get a message from the user and return a response from Compass, save the message and response into the application state @@ -151,14 +152,15 @@ async def send(self, user_id: str, session_id: int, user_input: str, clear_memor filter_pii: bool, city: str | None = None, province: str | None = None, - discuss_recommendations: bool = True) -> ConversationResponse: + discuss_recommendations: bool = True, + is_artificial: bool = False) -> ConversationResponse: if clear_memory: await self._application_state_metrics_recorder.delete_state(session_id) if filter_pii: user_input = await sensitive_filter.obfuscate(user_input) # set the sent_at for the user input - user_input = AgentInput(message=user_input, sent_at=datetime.now(timezone.utc)) + user_input = AgentInput(message=user_input, sent_at=datetime.now(timezone.utc), is_artificial=is_artificial) state = await self._application_state_metrics_recorder.get_state(session_id, city=city, province=province) @@ -306,6 +308,7 @@ async def refresh_recommendations(self, user_id: str, session_id: int, filter_pii=False, city=city, province=province, + is_artificial=True, ) def _should_save_preference_vector(self, state: ApplicationState) -> bool: diff --git a/backend/app/conversations/test_routes.py b/backend/app/conversations/test_routes.py index dc0d80657..9d618a1df 100644 --- a/backend/app/conversations/test_routes.py +++ b/backend/app/conversations/test_routes.py @@ -43,7 +43,8 @@ def _create_test_client_with_mocks(auth) -> TestClientWithMocks: # mock the conversation service class MockConversationService(IConversationService): async def send(self, user_id: str, session_id: int, user_input: str, clear_memory: bool, filter_pii: bool, - city: str | None = None, province: str | None = None, discuss_recommendations: bool = True): + city: str | None = None, province: str | None = None, discuss_recommendations: bool = True, + is_artificial: bool = False): raise NotImplementedError async def get_history_by_session_id(self, user_id: str, session_id: int): diff --git a/frontend-new/src/chat/Chat.tsx b/frontend-new/src/chat/Chat.tsx index 738ef73fb..c4663aaa5 100644 --- a/frontend-new/src/chat/Chat.tsx +++ b/frontend-new/src/chat/Chat.tsx @@ -16,7 +16,7 @@ import { parseConversationPhase, } from "./util"; import { useSnackbar } from "src/theme/SnackbarProvider/SnackbarProvider"; -import { Box, Fab, Tooltip, useTheme } from "@mui/material"; +import { Box, Fab, useTheme } from "@mui/material"; import AutorenewIcon from "@mui/icons-material/Autorenew"; import debounce from "lodash.debounce"; import ChatHeader from "./ChatHeader/ChatHeader"; @@ -1185,19 +1185,39 @@ export const Chat: React.FC> = ({ > {currentPhase.phase === ConversationPhase.RECOMMENDATION && ( - - - activeSessionId && handleRefreshRecommendations(activeSessionId)} - aria-label={t("chat.chat.refreshRecommendations.tooltip")} - > - - - - + + activeSessionId && handleRefreshRecommendations(activeSessionId)} + aria-label={t("chat.chat.refreshRecommendations.label")} + sx={{ + pointerEvents: "auto", + textTransform: "none", + fontWeight: 500, + fontSize: { xs: "0.75rem", md: "0.8125rem" }, + paddingX: { xs: 1.25, md: 1.5 }, + height: { xs: 32, md: 34 }, + minHeight: 0, + }} + > + + {t("chat.chat.refreshRecommendations.label")} + + )} {showBackdrop && } diff --git a/frontend-new/src/i18n/locales/en-GB/translation.json b/frontend-new/src/i18n/locales/en-GB/translation.json index 0b5b07376..77e0e820a 100644 --- a/frontend-new/src/i18n/locales/en-GB/translation.json +++ b/frontend-new/src/i18n/locales/en-GB/translation.json @@ -164,7 +164,7 @@ "confirmation": "Are you sure you want to start a new conversation?" }, "refreshRecommendations": { - "tooltip": "Get new recommendations" + "label": "Refresh recommendations" }, "refreshConfirmationDialog": { "title": "Are you sure you would like to refresh?", diff --git a/frontend-new/src/i18n/locales/en-US/translation.json b/frontend-new/src/i18n/locales/en-US/translation.json index 1f8bdb3ac..24a511259 100644 --- a/frontend-new/src/i18n/locales/en-US/translation.json +++ b/frontend-new/src/i18n/locales/en-US/translation.json @@ -205,7 +205,7 @@ "confirmation": "Are you sure you want to start a new conversation?" }, "refreshRecommendations": { - "tooltip": "Get new recommendations" + "label": "Refresh recommendations" }, "refreshConfirmationDialog": { "title": "Are you sure you would like to refresh?", diff --git a/frontend-new/src/i18n/locales/es-AR/translation.json b/frontend-new/src/i18n/locales/es-AR/translation.json index 418c26112..9c00d3911 100644 --- a/frontend-new/src/i18n/locales/es-AR/translation.json +++ b/frontend-new/src/i18n/locales/es-AR/translation.json @@ -164,7 +164,7 @@ "confirmation": "¿Estás seguro de que deseas iniciar una nueva conversación?" }, "refreshRecommendations": { - "tooltip": "Obtener nuevas recomendaciones" + "label": "Actualizar recomendaciones" }, "refreshConfirmationDialog": { "title": "¿Estás seguro de que querés actualizar?", diff --git a/frontend-new/src/i18n/locales/es-ES/translation.json b/frontend-new/src/i18n/locales/es-ES/translation.json index 21a4d2c72..ee992e174 100644 --- a/frontend-new/src/i18n/locales/es-ES/translation.json +++ b/frontend-new/src/i18n/locales/es-ES/translation.json @@ -164,7 +164,7 @@ "confirmation": "¿Estás seguro de que deseas iniciar una nueva conversación?" }, "refreshRecommendations": { - "tooltip": "Obtener nuevas recomendaciones" + "label": "Actualizar recomendaciones" }, "refreshConfirmationDialog": { "title": "¿Estás seguro de que quieres actualizar?", diff --git a/frontend-new/src/i18n/locales/sw-KE/translation.json b/frontend-new/src/i18n/locales/sw-KE/translation.json index eecdcb3d3..a7baad719 100644 --- a/frontend-new/src/i18n/locales/sw-KE/translation.json +++ b/frontend-new/src/i18n/locales/sw-KE/translation.json @@ -205,7 +205,7 @@ "confirmation": "Una uhakika unataka kuanza mazungumzo mapya?" }, "refreshRecommendations": { - "tooltip": "Pata mapendekezo mapya" + "label": "Onyesha mapendekezo upya" }, "refreshConfirmationDialog": { "title": "Una uhakika ungependa kupaisha upya?",