Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(frontend): Ensure error and status messages wrap correctly within containers (#13522)

Jathin Sreenivas1581b95ab93d
diff --git a/frontend/__tests__/utils/custom-toast-handlers.test.ts b/frontend/__tests__/utils/custom-toast-handlers.test.ts
index 404bc1d4dd..f8deebd6f6 100644
--- a/frontend/__tests__/utils/custom-toast-handlers.test.ts
+++ b/frontend/__tests__/utils/custom-toast-handlers.test.ts
@@ -24,11 +24,14 @@ describe("custom-toast-handlers", () => {
displaySuccessToast(shortMessage);
expect(toast.success).toHaveBeenCalledWith(
- shortMessage,
+ expect.anything(),
expect.objectContaining({
duration: 5000, // Should use minimum duration of 5000ms
position: "top-right",
- style: expect.any(Object),
+ style: expect.objectContaining({
+ width: "400px",
+ wordBreak: "break-word",
+ }),
}),
);
});
@@ -39,11 +42,14 @@ describe("custom-toast-handlers", () => {
displaySuccessToast(longMessage);
expect(toast.success).toHaveBeenCalledWith(
- longMessage,
+ expect.anything(),
expect.objectContaining({
duration: expect.any(Number),
position: "top-right",
- style: expect.any(Object),
+ style: expect.objectContaining({
+ width: "400px",
+ wordBreak: "break-word",
+ }),
}),
);
@@ -66,11 +72,14 @@ describe("custom-toast-handlers", () => {
displayErrorToast(shortMessage);
expect(toast.error).toHaveBeenCalledWith(
- shortMessage,
+ expect.anything(),
expect.objectContaining({
duration: 4000, // Should use minimum duration of 4000ms for errors
position: "top-right",
- style: expect.any(Object),
+ style: expect.objectContaining({
+ width: "400px",
+ wordBreak: "break-word",
+ }),
}),
);
});
@@ -81,11 +90,14 @@ describe("custom-toast-handlers", () => {
displayErrorToast(longMessage);
expect(toast.error).toHaveBeenCalledWith(
- longMessage,
+ expect.anything(),
expect.objectContaining({
duration: expect.any(Number),
position: "top-right",
- style: expect.any(Object),
+ style: expect.objectContaining({
+ width: "400px",
+ wordBreak: "break-word",
+ }),
}),
);
diff --git a/frontend/src/components/features/chat/chat-status-indicator.tsx b/frontend/src/components/features/chat/chat-status-indicator.tsx
index 0f74bad850..10299ed1e7 100644
--- a/frontend/src/components/features/chat/chat-status-indicator.tsx
+++ b/frontend/src/components/features/chat/chat-status-indicator.tsx
@@ -15,23 +15,20 @@ function ChatStatusIndicator({
<div
data-testid="chat-status-indicator"
className={cn(
- "h-[31px] w-fit rounded-[100px] pt-[20px] pr-[16px] pb-[20px] pl-[5px] bg-[#25272D] flex items-center",
+ "min-h-[31px] w-full max-w-full rounded-[100px] px-4 py-1.5 bg-[#25272D] flex items-center gap-1.5",
)}
>
<AnimatePresence mode="wait">
{/* Dot */}
<motion.span
key={`dot-${status}`}
- className="animate-[pulse_1.2s_ease-in-out_infinite]"
+ className="flex-shrink-0 animate-[pulse_1.2s_ease-in-out_infinite]"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.3 }}
>
- <DebugStackframeDot
- className="w-6 h-6 shrink-0"
- color={statusColor}
- />
+ <DebugStackframeDot className="w-6 h-6" color={statusColor} />
</motion.span>
{/* Text */}
@@ -41,7 +38,7 @@ function ChatStatusIndicator({
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 2 }}
transition={{ duration: 0.3 }}
- className="font-normal text-[11px] leading-[20px] normal-case"
+ className="font-normal text-[11px] leading-[16px] normal-case break-words whitespace-normal"
>
{status}
</motion.span>
diff --git a/frontend/src/components/features/chat/error-message-banner.tsx b/frontend/src/components/features/chat/error-message-banner.tsx
index 85086791d2..7699230978 100644
--- a/frontend/src/components/features/chat/error-message-banner.tsx
+++ b/frontend/src/components/features/chat/error-message-banner.tsx
@@ -34,7 +34,7 @@ export function ErrorMessageBanner({
<div className="min-w-0 flex-1">
<div
className={cn(
- "whitespace-pre-wrap wrap-break-words",
+ "whitespace-pre-wrap break-words",
isCollapsed && "line-clamp-3",
)}
data-testid="error-message-banner-content"
diff --git a/frontend/src/utils/custom-toast-handlers.tsx b/frontend/src/utils/custom-toast-handlers.tsx
index 64f5ee4e37..ece6212b6b 100644
--- a/frontend/src/utils/custom-toast-handlers.tsx
+++ b/frontend/src/utils/custom-toast-handlers.tsx
@@ -7,6 +7,10 @@ const TOAST_STYLE: CSSProperties = {
border: "1px solid #717888",
color: "#fff",
borderRadius: "4px",
+ width: "400px",
+ wordBreak: "break-word",
+ overflowWrap: "anywhere",
+ whiteSpace: "pre-wrap",
};
export const TOAST_OPTIONS: ToastOptions = {
@@ -16,10 +20,20 @@ export const TOAST_OPTIONS: ToastOptions = {
export const displayErrorToast = (error: string) => {
const duration = calculateToastDuration(error, 4000);
- toast.error(error, { ...TOAST_OPTIONS, duration });
+ toast.error(
+ <span style={{ wordBreak: "break-word", overflowWrap: "anywhere" }}>
+ {error}
+ </span>,
+ { ...TOAST_OPTIONS, duration },
+ );
};
export const displaySuccessToast = (message: string) => {
const duration = calculateToastDuration(message, 5000);
- toast.success(message, { ...TOAST_OPTIONS, duration });
+ toast.success(
+ <span style={{ wordBreak: "break-word", overflowWrap: "anywhere" }}>
+ {message}
+ </span>,
+ { ...TOAST_OPTIONS, duration },
+ );
};