11"use client" ;
22
3- import React , { useState } from "react" ;
3+ import React , { useState , useEffect } from "react" ;
44import { useTranslation } from "react-i18next" ;
55import { Button , Col , Flex , Tooltip , Divider , Table , theme , App } from "antd" ;
66import { ExclamationCircleOutlined } from "@ant-design/icons" ;
@@ -17,7 +17,9 @@ import {
1717 exportAgent ,
1818 updateToolConfig ,
1919} from "@/services/agentConfigService" ;
20+ import { clearAgentNewMark } from "@/services/agentConfigService" ;
2021import log from "@/lib/logger" ;
22+ import { clearAgentAndSync } from "@/lib/agentNewUtils" ;
2123
2224interface AgentListProps {
2325 agentList : Agent [ ] ;
@@ -40,6 +42,27 @@ export default function AgentList({
4042 const confirm = useConfirmModal ( ) ;
4143 const queryClient = useQueryClient ( ) ;
4244
45+ // Note: rely on agent.is_new from agentList (single source of truth).
46+ // Clear NEW mark when agent is selected (sync with selection visual feedback)
47+ useEffect ( ( ) => {
48+ if ( currentAgentId ) {
49+ const agentId = String ( currentAgentId ) ;
50+ const agent = agentList . find ( a => String ( a . id ) === agentId ) ;
51+ if ( agent ?. is_new ) {
52+ ( async ( ) => {
53+ try {
54+ const res = await clearAgentAndSync ( agentId , queryClient ) ;
55+ if ( ! res ?. success ) {
56+ log . warn ( "Failed to clear NEW mark for agent:" , agentId , res ) ;
57+ }
58+ } catch ( err ) {
59+ log . error ( "Error clearing NEW mark:" , err ) ;
60+ }
61+ } ) ( ) ;
62+ }
63+ }
64+ } , [ currentAgentId , agentList ] ) ;
65+
4366 // Call relationship modal state
4467 const [ callRelationshipModalVisible , setCallRelationshipModalVisible ] =
4568 useState ( false ) ;
@@ -279,6 +302,8 @@ export default function AgentList({
279302 onClick : ( e : any ) => {
280303 e . preventDefault ( ) ;
281304 e . stopPropagation ( ) ;
305+
306+ // Call onSelectAgent - NEW mark clearing is handled by useEffect
282307 onSelectAgent ( agent ) ;
283308 } ,
284309 } ) }
@@ -292,6 +317,7 @@ export default function AgentList({
292317 const isSelected =
293318 currentAgentId !== null &&
294319 String ( currentAgentId ) === String ( agent . id ) ;
320+ const isNew = agent . is_new || false ;
295321
296322 return (
297323 < Flex
@@ -332,6 +358,13 @@ export default function AgentList({
332358 < ExclamationCircleOutlined className = "text-amber-500 text-sm flex-shrink-0 cursor-pointer" />
333359 </ Tooltip >
334360 ) }
361+ { isNew && (
362+ < Tooltip title = { t ( "space.new" , "New imported agent" ) } >
363+ < span className = "inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400 flex-shrink-0" >
364+ NEW
365+ </ span >
366+ </ Tooltip >
367+ ) }
335368 { displayName && (
336369 < span className = "text-base leading-normal max-w-[220px] truncate break-all" >
337370 { displayName }
0 commit comments