tool-timeline-item.tsx


Overview

tool-timeline-item.tsx is a React functional component file designed to render a timeline view of various tools' operations or results within a workflow UI. It visually represents each tool invocation as a timeline item, displaying tool icons, execution duration, results, and optionally, arguments passed to those tools.

This component integrates with a timeline UI component library and an accordion UI to show/hide details about each tool's execution in a collapsible manner. It is tailored for scenarios where multiple tools are executed sequentially, and users need an intuitive interface to track the progress and results.


Detailed Explanation

Component: ToolTimelineItem

Purpose

ToolTimelineItem renders a list of tool executions on a timeline. Each tool's data is shown as an individual timeline item with an icon, name, execution time, and expandable details. It supports both a full view and a share-friendly compact view.

Props

Prop

Type

Default

Description

tools

Record<string, any>[]

An array of tool execution objects. Each object contains information about a tool invocation.

sendLoading

boolean

false

Indicates if the tools are currently loading/sending results; used to display loading states.

isShare

boolean

false

When true, adjusts rendering for a shareable view (e.g., hides some icons/details).

Usage Example

import ToolTimelineItem from './tool-timeline-item';

const toolsData = [
  {
    tool_name: 'github',
    result: { stars: 1000 },
    elapsed_time: 2.45,
    path: 'root-->search',
    arguments: { repo: 'originai' },
  },
  {
    tool_name: 'google_scholar',
    result: { papers: [] },
    elapsed_time: 1.2,
    path: 'root-->search',
    arguments: {},
  },
];

<ToolTimelineItem tools={toolsData} sendLoading={false} isShare={false} />;

Internal Functions

capitalizeWords(str: string, separator: string = '_'): string[]

capitalizeWords('google_scholar'); // ['Google', 'Scholar']
capitalizeWords('some_tool_name', '_'); // ['Some', 'Tool', 'Name']

changeToolName(toolName: any): string

changeToolName('google_scholar'); // "Agent Google Scholar"

parentName(str: string, separator: string = '-->'): string

parentName('root-->search-->tool'); // "tool"
parentName('tool'); // "tool"

Component Structure and Behavior


Important Implementation Details


Interactions with Other Parts of the System

This file is intended for use in a larger workflow or agent UI visualization system where multiple tools or operators execute in sequence, and the user needs to inspect the timeline of these executions.


Mermaid Diagram: Component Structure and Props

componentDiagram
    direction TB
    ToolTimelineItem <|-- TimelineItem
    TimelineItem --> TimelineHeader
    TimelineHeader --> TimelineSeparator
    TimelineHeader --> TimelineIndicator
    TimelineItem --> TimelineContent
    TimelineContent --> Accordion
    Accordion --> AccordionItem
    AccordionItem --> AccordionTrigger
    AccordionItem --> AccordionContent
    AccordionContent --> JsonViewer
    TimelineIndicator --> OperatorIcon

    ToolTimelineItem : props
    ToolTimelineItem : - tools: Record<string, any>[]
    ToolTimelineItem : - sendLoading: boolean
    ToolTimelineItem : - isShare?: boolean

Summary

tool-timeline-item.tsx is a React component that visualizes a sequence of tool operations in a timeline format. It filters out unnecessary tools, capitalizes tool names, and represents each tool with its icon, execution time, and expandable details. The component adapts its display for shareable views and loading states, making it a versatile UI element in workflow monitoring and debugging tools.


End of Documentation