/ src / components / binary-feedback / BinaryFeedback.tsx
BinaryFeedback.tsx
 1  import { default as React, useCallback } from 'react'
 2  import { useNotifyAfterTimeout } from '../../hooks/useNotifyAfterTimeout.js'
 3  import { AssistantMessage, BinaryFeedbackResult } from '../../query.js'
 4  import type { Tool } from '../../Tool.js'
 5  import type { NormalizedMessage } from '../../utils/messages.js'
 6  import { BinaryFeedbackView } from './BinaryFeedbackView.js'
 7  import {
 8    type BinaryFeedbackChoose,
 9    getBinaryFeedbackResultForChoice,
10    logBinaryFeedbackEvent,
11  } from './utils.js'
12  
13  type Props = {
14    m1: AssistantMessage
15    m2: AssistantMessage
16    resolve: (result: BinaryFeedbackResult) => void
17    debug: boolean
18    erroredToolUseIDs: Set<string>
19    inProgressToolUseIDs: Set<string>
20    normalizedMessages: NormalizedMessage[]
21    tools: Tool[]
22    unresolvedToolUseIDs: Set<string>
23    verbose: boolean
24  }
25  
26  export function BinaryFeedback({
27    m1,
28    m2,
29    resolve,
30    debug,
31    erroredToolUseIDs,
32    inProgressToolUseIDs,
33    normalizedMessages,
34    tools,
35    unresolvedToolUseIDs,
36    verbose,
37  }: Props): React.ReactNode {
38    const onChoose = useCallback<BinaryFeedbackChoose>(
39      choice => {
40        logBinaryFeedbackEvent(m1, m2, choice)
41        resolve(getBinaryFeedbackResultForChoice(m1, m2, choice))
42      },
43      [m1, m2, resolve],
44    )
45    useNotifyAfterTimeout('Claude needs your input on a response comparison')
46    return (
47      <BinaryFeedbackView
48        debug={debug}
49        erroredToolUseIDs={erroredToolUseIDs}
50        inProgressToolUseIDs={inProgressToolUseIDs}
51        m1={m1}
52        m2={m2}
53        normalizedMessages={normalizedMessages}
54        tools={tools}
55        unresolvedToolUseIDs={unresolvedToolUseIDs}
56        verbose={verbose}
57        onChoose={onChoose}
58      />
59    )
60  }