Fix: Place the invitation reminder icon in a separate file #9634 (#9662)

### What problem does this PR solve?

Fix: Place the invitation reminder icon in a separate file #9634
Fix: After receiving the agent message, pull the agent data to highlight
the edges passed #9538

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2025-08-22 20:08:55 +08:00
committed by GitHub
parent 3947da10ae
commit adbb038a87
3 changed files with 47 additions and 33 deletions

View File

@ -0,0 +1,28 @@
import { Button } from '@/components/ui/button';
import { useNavigateWithFromState } from '@/hooks/route-hook';
import { useListTenant } from '@/hooks/use-user-setting-request';
import { TenantRole } from '@/pages/user-setting/constants';
import { BellRing } from 'lucide-react';
import { useCallback, useMemo } from 'react';
export function BellButton() {
const { data } = useListTenant();
const navigate = useNavigateWithFromState();
const showBell = useMemo(() => {
return data.some((x) => x.role === TenantRole.Invite);
}, [data]);
const handleBellClick = useCallback(() => {
navigate('/user-setting/team');
}, [navigate]);
return showBell ? (
<Button variant={'ghost'} onClick={handleBellClick}>
<div className="relative">
<BellRing className="size-4 " />
<span className="absolute size-1 rounded -right-1 -top-1 bg-red-600"></span>
</div>
</Button>
) : null;
}

View File

@ -12,13 +12,10 @@ import { LanguageList, LanguageMap, ThemeEnum } from '@/constants/common';
import { useChangeLanguage } from '@/hooks/logic-hooks'; import { useChangeLanguage } from '@/hooks/logic-hooks';
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks'; import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
import { useNavigateWithFromState } from '@/hooks/route-hook'; import { useNavigateWithFromState } from '@/hooks/route-hook';
import { useListTenant } from '@/hooks/use-user-setting-request';
import { useFetchUserInfo } from '@/hooks/user-setting-hooks'; import { useFetchUserInfo } from '@/hooks/user-setting-hooks';
import { TenantRole } from '@/pages/user-setting/constants';
import { Routes } from '@/routes'; import { Routes } from '@/routes';
import { camelCase } from 'lodash'; import { camelCase } from 'lodash';
import { import {
BellRing,
ChevronDown, ChevronDown,
CircleHelp, CircleHelp,
Cpu, Cpu,
@ -34,6 +31,7 @@ import {
import React, { useCallback, useMemo } from 'react'; import React, { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useLocation } from 'umi'; import { useLocation } from 'umi';
import { BellButton } from './bell-button';
const handleDocHelpCLick = () => { const handleDocHelpCLick = () => {
window.open('https://ragflow.io/docs/dev/category/guides', 'target'); window.open('https://ragflow.io/docs/dev/category/guides', 'target');
@ -56,12 +54,6 @@ export function Header() {
changeLanguage(key); changeLanguage(key);
}; };
const { data } = useListTenant();
const showBell = useMemo(() => {
return data.some((x) => x.role === TenantRole.Invite);
}, [data]);
const items = LanguageList.map((x) => ({ const items = LanguageList.map((x) => ({
key: x, key: x,
label: <span>{LanguageMap[x as keyof typeof LanguageMap]}</span>, label: <span>{LanguageMap[x as keyof typeof LanguageMap]}</span>,
@ -71,10 +63,6 @@ export function Header() {
setTheme(theme === ThemeEnum.Dark ? ThemeEnum.Light : ThemeEnum.Dark); setTheme(theme === ThemeEnum.Dark ? ThemeEnum.Light : ThemeEnum.Dark);
}, [setTheme, theme]); }, [setTheme, theme]);
const handleBellClick = useCallback(() => {
navigate('/user-setting/team');
}, [navigate]);
const tagsData = useMemo( const tagsData = useMemo(
() => [ () => [
{ path: Routes.Root, name: t('header.Root'), icon: House }, { path: Routes.Root, name: t('header.Root'), icon: House },
@ -163,14 +151,7 @@ export function Header() {
<Button variant={'ghost'} onClick={onThemeClick}> <Button variant={'ghost'} onClick={onThemeClick}>
{theme === 'light' ? <Sun /> : <Moon />} {theme === 'light' ? <Sun /> : <Moon />}
</Button> </Button>
{showBell && ( <BellButton></BellButton>
<Button variant={'ghost'} onClick={handleBellClick}>
<div className="relative">
<BellRing className="size-4 " />
<span className="absolute size-1 rounded -right-1 -top-1 bg-red-600"></span>
</div>
</Button>
)}
<div className="relative"> <div className="relative">
<RAGFlowAvatar <RAGFlowAvatar
name={nickname} name={nickname}

View File

@ -4,6 +4,7 @@ import {
useHandleMessageInputChange, useHandleMessageInputChange,
useSelectDerivedMessages, useSelectDerivedMessages,
} from '@/hooks/logic-hooks'; } from '@/hooks/logic-hooks';
import { useFetchAgent } from '@/hooks/use-agent-request';
import { import {
IEventList, IEventList,
IInputEvent, IInputEvent,
@ -188,11 +189,7 @@ export const useSendAgentMessage = (
return answerList[0]?.message_id; return answerList[0]?.message_id;
}, [answerList]); }, [answerList]);
useEffect(() => { const { refetch } = useFetchAgent();
if (answerList[0]?.session_id) {
setSessionId(answerList[0]?.session_id);
}
}, [answerList]);
const { findReferenceByMessageId } = useFindMessageReference(answerList); const { findReferenceByMessageId } = useFindMessageReference(answerList);
const prologue = useGetBeginNodePrologue(); const prologue = useGetBeginNodePrologue();
@ -250,7 +247,7 @@ export const useSendAgentMessage = (
setValue(message.content); setValue(message.content);
removeLatestMessage(); removeLatestMessage();
} else { } else {
// refetch(); // pull the message list after sending the message successfully refetch(); // pull the message list after sending the message successfully
} }
} catch (error) { } catch (error) {
console.log('🚀 ~ useSendAgentMessage ~ error:', error); console.log('🚀 ~ useSendAgentMessage ~ error:', error);
@ -258,28 +255,30 @@ export const useSendAgentMessage = (
}, },
[ [
agentId, agentId,
sessionId,
send,
clearUploadResponseList,
inputs, inputs,
beginParams, beginParams,
uploadResponseList, uploadResponseList,
sessionId,
send,
clearUploadResponseList,
setValue, setValue,
removeLatestMessage, removeLatestMessage,
refetch,
], ],
); );
const sendFormMessage = useCallback( const sendFormMessage = useCallback(
(body: { id?: string; inputs: Record<string, BeginQuery> }) => { async (body: { id?: string; inputs: Record<string, BeginQuery> }) => {
send({ ...body, session_id: sessionId });
addNewestOneQuestion({ addNewestOneQuestion({
content: Object.entries(body.inputs) content: Object.entries(body.inputs)
.map(([key, val]) => `${key}: ${val.value}`) .map(([key, val]) => `${key}: ${val.value}`)
.join('<br/>'), .join('<br/>'),
role: MessageType.User, role: MessageType.User,
}); });
await send({ ...body, session_id: sessionId });
refetch();
}, },
[addNewestOneQuestion, send, sessionId], [addNewestOneQuestion, refetch, send, sessionId],
); );
// reset session // reset session
@ -346,6 +345,12 @@ export const useSendAgentMessage = (
} }
}, [addEventList, answerList, addEventListFun, messageId]); }, [addEventList, answerList, addEventListFun, messageId]);
useEffect(() => {
if (answerList[0]?.session_id) {
setSessionId(answerList[0]?.session_id);
}
}, [answerList]);
return { return {
value, value,
sendLoading: !done, sendLoading: !done,