keyword-node.tsx


Overview

keyword-node.tsx defines a React functional component named KeywordNode that represents a visual node in a flow-based interface (likely a workflow or logic editor). This component is designed to be used within a node graph editor powered by @xyflow/react, facilitating connections between nodes via handles on the left and right sides.

The node visually displays:

The component supports theming (light/dark) and selection highlighting, making it visually consistent within the overall UI theme and interactive node graph.


Detailed Explanation

KeywordNode Component

export function KeywordNode({
  id,
  data,
  isConnectable = true,
  selected,
}: NodeProps<IKeywordNode>)

Purpose

KeywordNode renders a single node element in a flowchart or graph editor. It represents a "keyword" logic node that can be connected to other nodes via handles.

Parameters

Return Value

Returns a React JSX element representing the node UI.

Usage Example

import { KeywordNode } from './keyword-node';

// Inside a flow graph component render method
<KeywordNode
  id="node-1"
  data={{ name: 'Keyword Extractor', label: 'Extractor', form: { llm_id: 'gpt-4' } }}
  isConnectable={true}
  selected={false}
/>

Implementation Details


Interaction with Other Parts of the Application


Summary of the Component Structure

Element

Description

<section>

Container element with conditional theming and selection styles.

<Handle> (Left)

Source handle on the left side for outgoing connections.

<Handle> (Right)

Source handle on the right side for outgoing connections.

<NodeHeader>

Displays node name and label.

<div> (LLMLabel)

Displays the LLM identifier label.


Mermaid Component Diagram

componentDiagram
    component KeywordNode {
      +id: string
      +data: IKeywordNode
      +isConnectable: boolean
      +selected: boolean
      +render(): JSX.Element
    }
    component NodeHeader {
      +id: string
      +name: string
      +label: string
      +render(): JSX.Element
    }
    component LLMLabel {
      +value: string | undefined
      +render(): JSX.Element
    }
    component Handle {
      +id: string
      +type: source | target
      +position: Position
      +isConnectable: boolean
      +style: CSSProperties
      +render(): JSX.Element
    }
    component useTheme {
      +theme: string
    }
    KeywordNode --> NodeHeader : renders
    KeywordNode --> LLMLabel : renders
    KeywordNode --> Handle : renders (left and right)
    KeywordNode --> useTheme : uses

Important Notes


Summary

keyword-node.tsx provides a reusable, themed React component representing a keyword logic node within a flow editor UI. It integrates with flow handles for connectivity, displays node metadata via a header and LLM label, and respects theme and selection states for consistent UX. This file is a key UI building block for constructing and visualizing logic workflows that involve keyword nodes linked to language models or other entities.