Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(frontend): display confirmation buttons for explandable messages (#6426)

Xiaohua Zhangaa0cd5196721
diff --git a/frontend/src/components/features/chat/messages.tsx b/frontend/src/components/features/chat/messages.tsx
index 74439e17a6..03321d14c9 100644
--- a/frontend/src/components/features/chat/messages.tsx
+++ b/frontend/src/components/features/chat/messages.tsx
@@ -12,15 +12,22 @@ interface MessagesProps {
export const Messages: React.FC<MessagesProps> = React.memo(
({ messages, isAwaitingUserConfirmation }) =>
messages.map((message, index) => {
+ const shouldShowConfirmationButtons =
+ messages.length - 1 === index &&
+ message.sender === "assistant" &&
+ isAwaitingUserConfirmation;
+
if (message.type === "error" || message.type === "action") {
return (
- <ExpandableMessage
- key={index}
- type={message.type}
- id={message.translationID}
- message={message.content}
- success={message.success}
- />
+ <div key={index}>
+ <ExpandableMessage
+ type={message.type}
+ id={message.translationID}
+ message={message.content}
+ success={message.success}
+ />
+ {shouldShowConfirmationButtons && <ConfirmationButtons />}
+ </div>
);
}
@@ -33,9 +40,7 @@ export const Messages: React.FC<MessagesProps> = React.memo(
{message.imageUrls && message.imageUrls.length > 0 && (
<ImageCarousel size="small" images={message.imageUrls} />
)}
- {messages.length - 1 === index &&
- message.sender === "assistant" &&
- isAwaitingUserConfirmation && <ConfirmationButtons />}
+ {shouldShowConfirmationButtons && <ConfirmationButtons />}
</ChatMessage>
);
}),