mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: The operator added by clicking the plus sign will overlap with the original operator. #9886 (#9887)
### What problem does this PR solve? Fix: The operator added by clicking the plus sign will overlap with the original operator. #9886 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -24,3 +24,5 @@ export enum AgentGlobals {
|
|||||||
SysConversationTurns = 'sys.conversation_turns',
|
SysConversationTurns = 'sys.conversation_turns',
|
||||||
SysFiles = 'sys.files',
|
SysFiles = 'sys.files',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const AgentGlobalsSysQueryWithBrace = `{${AgentGlobals.SysQuery}}`;
|
||||||
|
|||||||
@ -225,6 +225,14 @@ function AgentCanvas({ drawerVisible, hideDrawer }: IProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const OnConnectEnd = (event: MouseEvent | TouchEvent) => {
|
const OnConnectEnd = (event: MouseEvent | TouchEvent) => {
|
||||||
|
const target = event.target as HTMLElement;
|
||||||
|
// Clicking Handle will also trigger OnConnectEnd.
|
||||||
|
// To solve the problem that the operator on the right side added by clicking Handle will overlap with the original operator, this event is blocked here.
|
||||||
|
// TODO: However, a better way is to add both operators in the same way as OnConnectEnd.
|
||||||
|
if (target?.classList.contains('react-flow__handle')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ('clientX' in event && 'clientY' in event) {
|
if ('clientX' in event && 'clientY' in event) {
|
||||||
const { clientX, clientY } = event;
|
const { clientX, clientY } = event;
|
||||||
setDropdownPosition({ x: clientX, y: clientY });
|
setDropdownPosition({ x: clientX, y: clientY });
|
||||||
|
|||||||
@ -55,31 +55,33 @@ function OperatorItemList({
|
|||||||
const onNodeCreated = useContext(OnNodeCreatedContext);
|
const onNodeCreated = useContext(OnNodeCreatedContext);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleClick = (operator: Operator) => {
|
const handleClick =
|
||||||
const contextData = handleContext || {
|
(operator: Operator): React.MouseEventHandler<HTMLElement> =>
|
||||||
nodeId: '',
|
(e) => {
|
||||||
id: '',
|
const contextData = handleContext || {
|
||||||
type: 'source' as const,
|
nodeId: '',
|
||||||
position: Position.Right,
|
id: '',
|
||||||
isFromConnectionDrag: true,
|
type: 'source' as const,
|
||||||
|
position: Position.Right,
|
||||||
|
isFromConnectionDrag: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockEvent = mousePosition
|
||||||
|
? {
|
||||||
|
clientX: mousePosition.x,
|
||||||
|
clientY: mousePosition.y,
|
||||||
|
}
|
||||||
|
: e;
|
||||||
|
|
||||||
|
const newNodeId = addCanvasNode(operator, contextData)(mockEvent);
|
||||||
|
|
||||||
|
if (onNodeCreated && newNodeId) {
|
||||||
|
onNodeCreated(newNodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
hideModal?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockEvent = mousePosition
|
|
||||||
? {
|
|
||||||
clientX: mousePosition.x,
|
|
||||||
clientY: mousePosition.y,
|
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const newNodeId = addCanvasNode(operator, contextData)(mockEvent);
|
|
||||||
|
|
||||||
if (onNodeCreated && newNodeId) {
|
|
||||||
onNodeCreated(newNodeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
hideModal?.();
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderOperatorItem = (operator: Operator) => {
|
const renderOperatorItem = (operator: Operator) => {
|
||||||
const commonContent = (
|
const commonContent = (
|
||||||
<div className="hover:bg-background-card py-1 px-3 cursor-pointer rounded-sm flex gap-2 items-center justify-start">
|
<div className="hover:bg-background-card py-1 px-3 cursor-pointer rounded-sm flex gap-2 items-center justify-start">
|
||||||
@ -92,12 +94,12 @@ function OperatorItemList({
|
|||||||
<Tooltip key={operator}>
|
<Tooltip key={operator}>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
{isCustomDropdown ? (
|
{isCustomDropdown ? (
|
||||||
<li onClick={() => handleClick(operator)}>{commonContent}</li>
|
<li onClick={handleClick(operator)}>{commonContent}</li>
|
||||||
) : (
|
) : (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
key={operator}
|
key={operator}
|
||||||
className="hover:bg-background-card py-1 px-3 cursor-pointer rounded-sm flex gap-2 items-center justify-start"
|
className="hover:bg-background-card py-1 px-3 cursor-pointer rounded-sm flex gap-2 items-center justify-start"
|
||||||
onClick={() => handleClick(operator)}
|
onClick={handleClick(operator)}
|
||||||
onSelect={() => hideModal?.()}
|
onSelect={() => hideModal?.()}
|
||||||
>
|
>
|
||||||
<OperatorIcon name={operator} />
|
<OperatorIcon name={operator} />
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import {
|
|||||||
} from '@/components/similarity-slider';
|
} from '@/components/similarity-slider';
|
||||||
import {
|
import {
|
||||||
AgentGlobals,
|
AgentGlobals,
|
||||||
|
AgentGlobalsSysQueryWithBrace,
|
||||||
CodeTemplateStrMap,
|
CodeTemplateStrMap,
|
||||||
ProgrammingLanguage,
|
ProgrammingLanguage,
|
||||||
} from '@/constants/agent';
|
} from '@/constants/agent';
|
||||||
@ -247,7 +248,7 @@ const initialQueryBaseValues = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const initialRetrievalValues = {
|
export const initialRetrievalValues = {
|
||||||
query: AgentGlobals.SysQuery,
|
query: AgentGlobalsSysQueryWithBrace,
|
||||||
top_n: 8,
|
top_n: 8,
|
||||||
top_k: 1024,
|
top_k: 1024,
|
||||||
kb_ids: [],
|
kb_ids: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user