File size: 1,170 Bytes
bdbcdab
 
 
a56db97
 
bdbcdab
 
 
6d4d388
bdbcdab
 
 
a56db97
 
bdbcdab
 
 
 
6d4d388
bdbcdab
 
 
 
 
0bc8e38
bdbcdab
 
 
 
6d4d388
bdbcdab
 
0bc8e38
 
 
bdbcdab
bbfa431
bdbcdab
 
 
 
 
bbfa431
bdbcdab
b1d24de
bdbcdab
a56db97
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import UserMessage from './UserMessage';
import AssistantMessage from './AssistantMessage';
import type { UIMessage } from 'ai';

interface MessageBubbleProps {
  message: UIMessage;
  isLastTurn?: boolean;
  onUndoTurn?: () => void;
  onEditAndRegenerate?: (messageId: string, newText: string) => void | Promise<void>;
  isProcessing?: boolean;
  isStreaming?: boolean;
  approveTools: (approvals: Array<{ tool_call_id: string; approved: boolean; feedback?: string | null }>) => Promise<boolean>;
}

export default function MessageBubble({
  message,
  isLastTurn = false,
  onUndoTurn,
  onEditAndRegenerate,
  isProcessing = false,
  isStreaming = false,
  approveTools,
}: MessageBubbleProps) {
  if (message.role === 'user') {
    return (
      <UserMessage
        message={message}
        isLastTurn={isLastTurn}
        onUndoTurn={onUndoTurn}
        onEditAndRegenerate={onEditAndRegenerate}
        isProcessing={isProcessing}
      />
    );
  }

  if (message.role === 'assistant') {
    return (
      <AssistantMessage
        message={message}
        isStreaming={isStreaming}
        approveTools={approveTools}
      />
    );
  }

  return null;
}