feat(variable-inspect): improve listening description resolution in Listening component

This commit is contained in:
zhsama 2025-10-17 18:11:16 +08:00
parent 32731c4622
commit 3f116dc74b
1 changed files with 19 additions and 2 deletions

View File

@ -1,12 +1,28 @@
import type { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { useStoreApi } from 'reactflow'
import { type Node, useStoreApi } from 'reactflow'
import Button from '@/app/components/base/button'
import BlockIcon from '@/app/components/workflow/block-icon'
import { BlockEnum } from '@/app/components/workflow/types'
import { StopCircle } from '@/app/components/base/icons/src/vender/line/mediaAndDevices'
import { useStore } from '../store'
import { useToolIcon } from '@/app/components/workflow/hooks/use-tool-icon'
import type { TFunction } from 'i18next'
const resolveListeningDescription = (
message: string | undefined,
triggerNode: Node | undefined,
t: TFunction,
): string => {
if (message)
return message
const nodeDescription = (triggerNode?.data as { desc?: string })?.desc
if (nodeDescription)
return nodeDescription
return t('workflow.debug.variableInspect.listening.tip')
}
export type ListeningProps = {
onStop: () => void
@ -34,13 +50,14 @@ const Listening: FC<ListeningProps> = ({
// Use the useToolIcon hook to get the icon for plugin/datasource triggers
const toolIcon = useToolIcon(triggerNode?.data)
const description = resolveListeningDescription(message, triggerNode, t)
return (
<div className='flex h-full flex-col gap-4 rounded-xl bg-background-section p-8'>
<BlockIcon type={triggerType} toolIcon={toolIcon} size="md" className="!h-10 !w-10 !rounded-xl [&_svg]:!h-7 [&_svg]:!w-7" />
<div className='flex flex-col gap-1'>
<div className='system-sm-semibold text-text-secondary'>{t('workflow.debug.variableInspect.listening.title')}</div>
<div className='system-xs-regular text-text-tertiary'>{message ?? t('workflow.debug.variableInspect.listening.tip')}</div>
<div className='system-xs-regular text-text-tertiary'>{description}</div>
</div>
<div>
<Button