({
followup,
index,
isClicked,
isHovered,
onSendFollowup,
onHover,
disabled,
labelColumnWidth,
}: FollowupLineProps)
| 31 | } |
| 32 | |
| 33 | const FollowupLine = ({ |
| 34 | followup, |
| 35 | index, |
| 36 | isClicked, |
| 37 | isHovered, |
| 38 | onSendFollowup, |
| 39 | onHover, |
| 40 | disabled, |
| 41 | labelColumnWidth, |
| 42 | }: FollowupLineProps) => { |
| 43 | const theme = useTheme() |
| 44 | const { terminalWidth } = useTerminalDimensions() |
| 45 | |
| 46 | const handleClick = useCallback(() => { |
| 47 | if (!disabled) { |
| 48 | onSendFollowup(followup.prompt, index) |
| 49 | } |
| 50 | }, [followup.prompt, index, onSendFollowup, disabled]) |
| 51 | |
| 52 | const handleMouseOver = useCallback(() => onHover(index), [onHover, index]) |
| 53 | const handleMouseOut = useCallback(() => onHover(null), [onHover]) |
| 54 | |
| 55 | // Compute effective hover state declaratively |
| 56 | // Show hover effects if actually hovered AND not disabled AND not already clicked |
| 57 | const showHoverState = isHovered && !disabled && !isClicked |
| 58 | |
| 59 | const hasLabel = Boolean(followup.label) |
| 60 | const displayText = hasLabel ? followup.label : followup.prompt |
| 61 | |
| 62 | // Show description when hovered, has a label, and terminal is wide enough |
| 63 | const showDescription = |
| 64 | showHoverState && hasLabel && terminalWidth >= MIN_WIDTH_FOR_DESCRIPTION |
| 65 | |
| 66 | // Calculate truncated prompt with ellipsis only when needed |
| 67 | const truncatedPrompt = showDescription |
| 68 | ? (() => { |
| 69 | const availableWidth = Math.max(0, terminalWidth - labelColumnWidth - 4) |
| 70 | return followup.prompt.length > availableWidth |
| 71 | ? followup.prompt.slice(0, availableWidth - 1) + '…' |
| 72 | : followup.prompt |
| 73 | })() |
| 74 | : '' |
| 75 | |
| 76 | // Determine colors based on state |
| 77 | // When hovered, use primary color (acid green) for both arrow and title |
| 78 | const iconColor = isClicked |
| 79 | ? theme.success |
| 80 | : showHoverState |
| 81 | ? theme.primary |
| 82 | : theme.muted |
| 83 | const labelColor = isClicked |
| 84 | ? theme.muted |
| 85 | : showHoverState |
| 86 | ? theme.primary |
| 87 | : theme.foreground |
| 88 | |
| 89 | // Calculate padding spaces needed to align descriptions (only when showing description) |
| 90 | const labelLength = (displayText ?? '').length |
nothing calls this directly
no test coverage detected