Feature/agent UI style optimization (#10385)

### What problem does this PR solve?

Hi team,  @ZhenhangTung @KevinHuSh  @cike8899 
About #10384 , I've completed the UI optimization adjustments for the
Agent page according to our previous discussions and the design draft
sketches provided by @Naomi. The main modifications include:

1. Adjusted the style and content of placeholder-node.
2. Adjusted the location of the dropdown (to the right of the
placeholder-node) .
3. Adjusted the tooltip position spacing when the mouse hovers in the
dropdown menu.
4. Hides the thick scroll bar on the dropdown component.
5. Highlight the connection line when dragging to generate a
placeholder-node

<img width="1323" height="509" alt="Image"
src="https://github.com/user-attachments/assets/0d366f7f-477d-4c00-bb58-d5d58b3a745f"
/>

Please review the related code modifications when you have time. Let me
know if further adjustments are needed!
Thanks!

### Type of change

- [x] Other (please describe): UI Enhancement

---------

Co-authored-by: leonlai <leonlai@futurefab.ai>
This commit is contained in:
FatMii
2025-10-09 11:12:12 +08:00
committed by GitHub
parent 4585edc20e
commit f341dc03b8
12 changed files with 174 additions and 38 deletions

View File

@ -2,6 +2,7 @@ import { Connection, Position } from '@xyflow/react';
import { useCallback, useRef } from 'react';
import { useDropdownManager } from '../canvas/context';
import { Operator, PREVENT_CLOSE_DELAY } from '../constant';
import useGraphStore from '../store';
import { useAddNode } from './use-add-node';
interface ConnectionStartParams {
@ -26,6 +27,7 @@ export const useConnectionDrag = (
) => { x: number; y: number },
removePlaceholderNode: () => void,
clearActiveDropdown: () => void,
checkAndRemoveExistingPlaceholder: () => void,
) => {
// Reference for whether connection is established
const isConnectedRef = useRef(false);
@ -38,6 +40,7 @@ export const useConnectionDrag = (
const { addCanvasNode } = useAddNode(reactFlowInstance);
const { setActiveDropdown } = useDropdownManager();
const { setHighlightedPlaceholderEdgeId } = useGraphStore();
/**
* Connection start handler function
@ -81,10 +84,17 @@ export const useConnectionDrag = (
}
if (isHandleClick) {
removePlaceholderNode();
hideModal();
clearActiveDropdown();
connectionStartRef.current = null;
mouseStartPosRef.current = null;
return;
}
// Check and remove existing placeholder-node before creating new one
checkAndRemoveExistingPlaceholder();
// Create placeholder node and establish connection
const mockEvent = { clientX, clientY };
const contextData = {
@ -101,9 +111,13 @@ export const useConnectionDrag = (
contextData,
)(mockEvent);
// Record the created placeholder node ID
if (newNodeId) {
setCreatedPlaceholderRef(newNodeId);
if (connectionStartRef.current) {
const edgeId = `xy-edge__${connectionStartRef.current.nodeId}${connectionStartRef.current.handleId}-${newNodeId}end`;
setHighlightedPlaceholderEdgeId(edgeId);
}
}
// Calculate placeholder node position and display dropdown menu
@ -140,6 +154,11 @@ export const useConnectionDrag = (
calculateDropdownPosition,
setActiveDropdown,
showModal,
setHighlightedPlaceholderEdgeId,
checkAndRemoveExistingPlaceholder,
removePlaceholderNode,
hideModal,
clearActiveDropdown,
],
);
@ -187,7 +206,13 @@ export const useConnectionDrag = (
removePlaceholderNode();
hideModal();
clearActiveDropdown();
}, [removePlaceholderNode, hideModal, clearActiveDropdown]);
setHighlightedPlaceholderEdgeId(null);
}, [
removePlaceholderNode,
hideModal,
clearActiveDropdown,
setHighlightedPlaceholderEdgeId,
]);
return {
onConnectStart,