From f0367443c7c8691d1b602c1fa60f95d53cae0db7 Mon Sep 17 00:00:00 2001 From: kevinkim-ogp Date: Wed, 12 Nov 2025 09:05:09 +0800 Subject: [PATCH 1/2] chore: expand ai test result --- .../src/components/VariablesList/index.tsx | 63 ++++++++++++++----- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/packages/frontend/src/components/VariablesList/index.tsx b/packages/frontend/src/components/VariablesList/index.tsx index 87e63c2d30..56430933f5 100644 --- a/packages/frontend/src/components/VariablesList/index.tsx +++ b/packages/frontend/src/components/VariablesList/index.tsx @@ -1,6 +1,6 @@ import { TDataOutMetadatumType } from '@plumber/types' -import { useMemo, useRef } from 'react' +import { useMemo, useRef, useState } from 'react' import { IconType } from 'react-icons/lib' import { Accordion, @@ -25,6 +25,7 @@ import TableVariableItem from './TableVariableItem' const VARIABLE_ITEM_HEIGHT = 77 const SUGGESTION_VARIABLE_ITEM_HEIGHT = 61 +const CHARACTER_LIMIT = 100 function VariableTag({ type, @@ -92,12 +93,17 @@ export function VariableItem({ isLast?: boolean withIcon?: IconType }): JSX.Element { + const [isExpanded, setIsExpanded] = useState(false) const shouldShowBottomBorder = !withIcon && (onClick || isLast) const displayValue = variable.displayedValue ?? variable.value?.toString() ?? '' const isSuggestionVariable = onClick && !withIcon + + const shouldShowToggle = + variable.type === 'ai_response' && displayValue.length > CHARACTER_LIMIT + return ( {variable.label ?? variable.name} - - - {displayValue.length ? ( - displayValue - ) : ( - empty - )} - - {withIcon && } + + + + {displayValue.length ? ( + displayValue + ) : ( + empty + )} + + {withIcon && } + + {shouldShowToggle && ( + { + e.stopPropagation() + setIsExpanded(!isExpanded) + }} + onMouseDown={(e) => { + e.stopPropagation() + }} + > + {isExpanded ? 'Show less' : 'Show more'} + + )} ) From e139f1961534d8ac4c2e3dfc2f56ba84ce95bd65 Mon Sep 17 00:00:00 2001 From: kevinkim-ogp Date: Tue, 18 Nov 2025 18:20:53 +0800 Subject: [PATCH 2/2] minor refactor, fix display on expand --- .../src/components/VariablesList/index.tsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/frontend/src/components/VariablesList/index.tsx b/packages/frontend/src/components/VariablesList/index.tsx index 56430933f5..0021fc5de5 100644 --- a/packages/frontend/src/components/VariablesList/index.tsx +++ b/packages/frontend/src/components/VariablesList/index.tsx @@ -1,6 +1,6 @@ import { TDataOutMetadatumType } from '@plumber/types' -import { useMemo, useRef, useState } from 'react' +import { useEffect, useMemo, useRef, useState } from 'react' import { IconType } from 'react-icons/lib' import { Accordion, @@ -25,7 +25,6 @@ import TableVariableItem from './TableVariableItem' const VARIABLE_ITEM_HEIGHT = 77 const SUGGESTION_VARIABLE_ITEM_HEIGHT = 61 -const CHARACTER_LIMIT = 100 function VariableTag({ type, @@ -94,6 +93,8 @@ export function VariableItem({ withIcon?: IconType }): JSX.Element { const [isExpanded, setIsExpanded] = useState(false) + const [isOverflowing, setIsOverflowing] = useState(false) + const textRef = useRef(null) const shouldShowBottomBorder = !withIcon && (onClick || isLast) const displayValue = @@ -101,8 +102,18 @@ export function VariableItem({ const isSuggestionVariable = onClick && !withIcon - const shouldShowToggle = - variable.type === 'ai_response' && displayValue.length > CHARACTER_LIMIT + // Check if text is overflowing after render + useEffect(() => { + if (variable.type === 'ai_response' && textRef.current && !isExpanded) { + const element = textRef.current + const isTextOverflowing = + element.scrollHeight > element.clientHeight || + element.scrollWidth > element.clientWidth + setIsOverflowing(isTextOverflowing) + } + }, [variable.type, isExpanded]) + + const shouldShowToggle = variable.type === 'ai_response' && isOverflowing return ( parentRef.current, estimateSize: () => onClick ? SUGGESTION_VARIABLE_ITEM_HEIGHT : VARIABLE_ITEM_HEIGHT, + measureElement: (element) => element.getBoundingClientRect().height, overscan: 50, }) @@ -261,6 +274,7 @@ export default function VariablesList(props: VariablesListProps) {