Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix WebSocket timeout messages in chat window (#7405)

Robert Brennan032eb152bf2d
diff --git a/frontend/src/components/agent-status-map.constant.ts b/frontend/src/components/agent-status-map.constant.ts
index ca5524e772..346186bb1a 100644
--- a/frontend/src/components/agent-status-map.constant.ts
+++ b/frontend/src/components/agent-status-map.constant.ts
@@ -1,7 +1,7 @@
import { I18nKey } from "#/i18n/declaration";
import { AgentState } from "#/types/agent-state";
-enum IndicatorColor {
+export enum IndicatorColor {
BLUE = "bg-blue-500",
GREEN = "bg-green-500",
ORANGE = "bg-orange-500",
diff --git a/frontend/src/components/features/controls/agent-status-bar.tsx b/frontend/src/components/features/controls/agent-status-bar.tsx
index 91622075e4..ab9f29573f 100644
--- a/frontend/src/components/features/controls/agent-status-bar.tsx
+++ b/frontend/src/components/features/controls/agent-status-bar.tsx
@@ -4,7 +4,10 @@ import { useSelector } from "react-redux";
import { showErrorToast } from "#/utils/error-handler";
import { RootState } from "#/store";
import { AgentState } from "#/types/agent-state";
-import { AGENT_STATUS_MAP } from "../../agent-status-map.constant";
+import {
+ AGENT_STATUS_MAP,
+ IndicatorColor,
+} from "../../agent-status-map.constant";
import {
useWsClient,
WsClientProviderStatus,
@@ -69,11 +72,17 @@ export function AgentStatusBar() {
};
}, []);
+ const [indicatorColor, setIndicatorColor] = React.useState<string>(
+ AGENT_STATUS_MAP[curAgentState].indicator,
+ );
+
React.useEffect(() => {
if (status === WsClientProviderStatus.DISCONNECTED) {
setStatusMessage("Connecting...");
+ setIndicatorColor(IndicatorColor.RED);
} else {
setStatusMessage(AGENT_STATUS_MAP[curAgentState].message);
+ setIndicatorColor(AGENT_STATUS_MAP[curAgentState].indicator);
if (notificationStates.includes(curAgentState)) {
const message = t(AGENT_STATUS_MAP[curAgentState].message);
notify(t(AGENT_STATUS_MAP[curAgentState].message), {
@@ -87,13 +96,13 @@ export function AgentStatusBar() {
}
}
}
- }, [curAgentState, notify, t]);
+ }, [curAgentState, status, notify, t]);
return (
<div className="flex flex-col items-center">
<div className="flex items-center bg-base-secondary px-2 py-1 text-gray-400 rounded-[100px] text-sm gap-[6px]">
<div
- className={`w-2 h-2 rounded-full animate-pulse ${AGENT_STATUS_MAP[curAgentState].indicator}`}
+ className={`w-2 h-2 rounded-full animate-pulse ${indicatorColor}`}
/>
<span className="text-sm text-stone-400">{t(statusMessage)}</span>
</div>
diff --git a/frontend/src/context/ws-client-provider.tsx b/frontend/src/context/ws-client-provider.tsx
index 4113f2064c..15209549c1 100644
--- a/frontend/src/context/ws-client-provider.tsx
+++ b/frontend/src/context/ws-client-provider.tsx
@@ -78,7 +78,7 @@ export function updateStatusWhenErrorMessagePresent(data: ErrorArg | unknown) {
!!val && typeof val === "object";
const isString = (val: unknown): val is string => typeof val === "string";
if (isObject(data) && "message" in data && isString(data.message)) {
- if (data.message === "websocket error") {
+ if (data.message === "websocket error" || data.message === "timeout") {
return;
}
let msgId: string | undefined;