MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / MessageFooter

Function MessageFooter

cli/src/components/message-footer.tsx:38–219  ·  view source on GitHub ↗
({
  messageId,
  blocks,
  content,
  isLoading,
  isComplete,
  completionTime,
  credits,
  timerStartTime,
  onFeedback,
  onCloseFeedback,
})

Source from the content-addressed store, hash-verified

36}
37
38export const MessageFooter: React.FC<MessageFooterProps> = ({
39 messageId,
40 blocks,
41 content,
42 isLoading,
43 isComplete,
44 completionTime,
45 credits,
46 timerStartTime,
47 onFeedback,
48 onCloseFeedback,
49}) => {
50 const theme = useTheme()
51
52 // Memoize selectors to prevent new function references on every render
53 const selectIsFeedbackOpenMemo = useMemo(
54 () => selectIsFeedbackOpenForMessage(messageId),
55 [messageId],
56 )
57 const selectHasSubmittedFeedbackMemo = useMemo(
58 () => selectHasSubmittedFeedback(messageId),
59 [messageId],
60 )
61 const selectMessageFeedbackCategoryMemo = useMemo(
62 () => selectMessageFeedbackCategory(messageId),
63 [messageId],
64 )
65
66 const isFeedbackOpen = useFeedbackStore(selectIsFeedbackOpenMemo)
67 const hasSubmittedFeedback = useFeedbackStore(selectHasSubmittedFeedbackMemo)
68 const selectedFeedbackCategory = useFeedbackStore(
69 selectMessageFeedbackCategoryMemo,
70 )
71
72 const shouldShowLoadingTimer = isLoading && !isComplete
73 const shouldShowCompletionFooter = isComplete
74 const canRequestFeedback = shouldShowCompletionFooter && !hasSubmittedFeedback
75 const isGoodOrBadSelection =
76 selectedFeedbackCategory === 'good_result' ||
77 selectedFeedbackCategory === 'bad_result'
78 const shouldShowSubmittedFeedbackState =
79 shouldShowCompletionFooter && hasSubmittedFeedback && isGoodOrBadSelection
80 const shouldRenderFeedbackButton =
81 Boolean(onFeedback) &&
82 (canRequestFeedback || shouldShowSubmittedFeedbackState)
83
84 const handleFeedbackOpen = useCallback(() => {
85 if (!canRequestFeedback || !onFeedback) return
86 onFeedback(messageId)
87 }, [canRequestFeedback, onFeedback, messageId])
88
89 const handleFeedbackClose = useCallback(() => {
90 if (!canRequestFeedback) return
91 onCloseFeedback?.()
92 }, [canRequestFeedback, onCloseFeedback])
93
94 // Build text from content and text blocks for copy button
95 const textToCopy = [

Callers

nothing calls this directly

Calls 4

useThemeFunction · 0.90

Tested by

no test coverage detected