From 0d3e92cfdaf5f9dec2c1cec7ec42f512fcdc2090 Mon Sep 17 00:00:00 2001 From: nntrivi2001 Date: Tue, 3 Nov 2026 09:43:09 +0700 Subject: [PATCH] feat(chat): a new message shows on the pet; chat panels scroll one way only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A message from someone else in a room not on screen raises a card on the pet (sender · group, the text or its files; click opens the room, gone after 10 s), plays the notification sound when notifications are on, and while the tab is hidden shows a local system notification — never through the server's push relay, which would reach other users' devices. Group settings scrolled both ways (the name field and Rename overflowed, the add-people list scrolled inside the panel): one vertical scroll now, the field shrinks, the list grows in place. Every chat list hides horizontal overflow and a long word or link wraps. --- client/src/components/Sagi/ChatHub.tsx | 74 +++++++++++--- client/src/components/Sagi/Sagi.tsx | 23 ++++- .../Sagi/__tests__/ChatHub.test.tsx | 36 ++++++- .../components/Sagi/__tests__/Pets.test.tsx | 8 +- .../Sagi/__tests__/useChat.test.tsx | 98 +++++++++++++++++++ client/src/components/Sagi/useChat.ts | 84 +++++++++++++++- client/src/i18n/locales/en/settings.json | 3 +- client/src/i18n/locales/vi/settings.json | 3 +- 8 files changed, 306 insertions(+), 23 deletions(-) create mode 100644 client/src/components/Sagi/__tests__/useChat.test.tsx diff --git a/client/src/components/Sagi/ChatHub.tsx b/client/src/components/Sagi/ChatHub.tsx index be6d641d..80c40eae 100644 --- a/client/src/components/Sagi/ChatHub.tsx +++ b/client/src/components/Sagi/ChatHub.tsx @@ -9,7 +9,8 @@ * demand, text with links, pasted / dropped / attached files (images shown * inline, anything else a download, all served only to the room's members), * and for a group its settings — the creator renames it and adds or removes - * people; anyone may leave. `NewChat` picks people: one person opens the + * people; anyone may leave. `ChatNotice` is the card a new message raises on + * the pet while its window is closed. `NewChat` picks people: one person opens the * direct chat with them, more (or a name) makes a group. Only a room's members * ever see it; an admin has no view of other people's chats. * @author Nguyễn Ngọc Trí Vĩ @@ -112,6 +113,47 @@ const Badge = ({ n }: { n: number }) => ) : null; +/** A new message from someone, on the pet while its window is closed: opens the room. */ +export function ChatNotice({ + notice, + onOpen, + onDismiss, +}: { + notice: NonNullable; + onOpen: (roomId: number) => void; + onDismiss: () => void; +}) { + const { t } = useTranslation("settings"); + return ( +
+ + +
+ ); +} + /** The column beside the window: the pet, the rooms, and New chat. */ export function ChatRail({ chat, @@ -131,7 +173,7 @@ export function ChatRail({ on ? "ring-2 ring-accent ring-offset-2 ring-offset-surface-2" : "opacity-80 hover:opacity-100"; return (