agent-log-nav.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { RiArrowLeftLine } from '@remixicon/react'
  2. import { useTranslation } from 'react-i18next'
  3. import AgentLogNavMore from './agent-log-nav-more'
  4. import Button from '@/app/components/base/button'
  5. import type { AgentLogItemWithChildren } from '@/types/workflow'
  6. type AgentLogNavProps = {
  7. agentOrToolLogItemStack: AgentLogItemWithChildren[]
  8. onShowAgentOrToolLog: (detail?: AgentLogItemWithChildren) => void
  9. }
  10. const AgentLogNav = ({
  11. agentOrToolLogItemStack,
  12. onShowAgentOrToolLog,
  13. }: AgentLogNavProps) => {
  14. const { t } = useTranslation()
  15. const agentOrToolLogItemStackLength = agentOrToolLogItemStack.length
  16. const first = agentOrToolLogItemStack[0]
  17. const mid = agentOrToolLogItemStack.slice(1, -1)
  18. const end = agentOrToolLogItemStack.at(-1)
  19. return (
  20. <div className='flex h-8 items-center bg-components-panel-bg p-1 pr-3'>
  21. <Button
  22. className='shrink-0 px-[5px]'
  23. size='small'
  24. variant='ghost-accent'
  25. onClick={() => {
  26. onShowAgentOrToolLog()
  27. }}
  28. >
  29. <RiArrowLeftLine className='mr-1 h-3.5 w-3.5' />
  30. AGENT
  31. </Button>
  32. <div className='system-xs-regular mx-0.5 shrink-0 text-divider-deep'>/</div>
  33. {
  34. agentOrToolLogItemStackLength > 1
  35. ? (
  36. <Button
  37. className='shrink-0 px-[5px]'
  38. size='small'
  39. variant='ghost-accent'
  40. onClick={() => onShowAgentOrToolLog(first)}
  41. >
  42. {t('workflow.nodes.agent.strategy.label')}
  43. </Button>
  44. )
  45. : (
  46. <div className='system-xs-medium-uppercase flex items-center px-[5px] text-text-tertiary'>
  47. {t('workflow.nodes.agent.strategy.label')}
  48. </div>
  49. )
  50. }
  51. {
  52. !!mid.length && (
  53. <>
  54. <div className='system-xs-regular mx-0.5 shrink-0 text-divider-deep'>/</div>
  55. <AgentLogNavMore
  56. options={mid}
  57. onShowAgentOrToolLog={onShowAgentOrToolLog}
  58. />
  59. </>
  60. )
  61. }
  62. {
  63. !!end && agentOrToolLogItemStackLength > 1 && (
  64. <>
  65. <div className='system-xs-regular mx-0.5 shrink-0 text-divider-deep'>/</div>
  66. <div className='system-xs-medium-uppercase flex items-center px-[5px] text-text-tertiary'>
  67. {end.label}
  68. </div>
  69. </>
  70. )
  71. }
  72. </div>
  73. )
  74. }
  75. export default AgentLogNav