mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-10-07 17:08:34 +08:00
* feat: multi-backend support with cloud SaaS proxy routing * feat: route conversation export through cloud proxy on cloud backends * fix: route conversation delete through cloud proxy on cloud backends * fix: forward settings diffs verbatim through cloud proxy save * fix: surface cloud-aware settings sub-pages and gate local-only routes * fix: route secrets settings through cloud proxy on cloud backends * fix: route conversation stop runtime through cloud proxy on cloud backends * fix: re-expose planning agent UI for cloud backends and route plan file reads through cloud proxy * fix: route Display Cost runtime fetch through cloud proxy and ungate local metrics without session API key * fix: handle WAITING_FOR_SANDBOX task status from cloud backends to prevent UI crash * fix: re-expose Public Share in conversation menu for cloud backends * fix: redirect to home when switching backends from a conversation page * fix: hide cloud orgs the API key can't access in backend selector * feat: support running multiple local agent-servers with shared persistence * fix: lint * fix: failing tests
107 lines
3.5 KiB
TypeScript
107 lines
3.5 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import {
|
|
getStatusCode,
|
|
getIndicatorColor,
|
|
IndicatorColor,
|
|
} from "#/utils/status";
|
|
import { AgentState } from "#/types/agent-state";
|
|
import { I18nKey } from "#/i18n/declaration";
|
|
import { V1ExecutionStatus } from "#/types/v1/core";
|
|
import type { V1AppConversationStartTaskStatus } from "#/api/conversation-service/v1-conversation-service.types";
|
|
|
|
describe("getStatusCode", () => {
|
|
it("returns RUNNING_TASK when execution status is running", () => {
|
|
const result = getStatusCode("OPEN", V1ExecutionStatus.RUNNING);
|
|
expect(result).toBe(I18nKey.AGENT_STATUS$RUNNING_TASK);
|
|
});
|
|
|
|
it("returns WAITING_FOR_TASK when execution status is idle", () => {
|
|
const result = getStatusCode("OPEN", V1ExecutionStatus.IDLE);
|
|
expect(result).toBe(I18nKey.AGENT_STATUS$WAITING_FOR_TASK);
|
|
});
|
|
|
|
it("returns STOPPED when execution status is paused", () => {
|
|
const result = getStatusCode("OPEN", V1ExecutionStatus.PAUSED);
|
|
expect(result).toBe(I18nKey.CHAT_INTERFACE$STOPPED);
|
|
});
|
|
|
|
it("returns starting i18n key when task is running setup", () => {
|
|
const result = getStatusCode("OPEN", null, "STARTING_CONVERSATION");
|
|
expect(result).toBe(I18nKey.CONVERSATION$STARTING_CONVERSATION);
|
|
});
|
|
|
|
it("prioritises task ERROR over websocket CONNECTING", () => {
|
|
const result = getStatusCode("CONNECTING", null, "ERROR");
|
|
expect(result).toBe(I18nKey.AGENT_STATUS$ERROR_OCCURRED);
|
|
});
|
|
|
|
it("returns DISCONNECTED when websocket is closed and no task", () => {
|
|
const result = getStatusCode("CLOSED", V1ExecutionStatus.IDLE);
|
|
expect(result).toBe(I18nKey.CHAT_INTERFACE$DISCONNECTED);
|
|
});
|
|
|
|
it("returns COMMON$WAITING_FOR_SANDBOX when task is waiting for sandbox", () => {
|
|
const result = getStatusCode("OPEN", null, "WAITING_FOR_SANDBOX");
|
|
expect(result).toBe(I18nKey.COMMON$WAITING_FOR_SANDBOX);
|
|
});
|
|
|
|
it("falls back to starting i18n key for an unknown task status instead of throwing", () => {
|
|
const unknownStatus =
|
|
"FUTURE_STATUS_FROM_CLOUD" as V1AppConversationStartTaskStatus;
|
|
const result = getStatusCode("OPEN", null, unknownStatus);
|
|
expect(result).toBe(I18nKey.CONVERSATION$STARTING_CONVERSATION);
|
|
});
|
|
});
|
|
|
|
describe("getIndicatorColor", () => {
|
|
it("prioritises agent readiness over stale runtime status for AWAITING_USER_INPUT", () => {
|
|
const result = getIndicatorColor(
|
|
"OPEN",
|
|
"RUNNING",
|
|
"STATUS$STARTING_RUNTIME",
|
|
AgentState.AWAITING_USER_INPUT,
|
|
);
|
|
expect(result).toBe(IndicatorColor.BLUE);
|
|
});
|
|
|
|
it("returns red when websocket is closed", () => {
|
|
const result = getIndicatorColor(
|
|
"CLOSED",
|
|
"STOPPED",
|
|
"STATUS$STOPPED",
|
|
AgentState.RUNNING,
|
|
);
|
|
expect(result).toBe(IndicatorColor.RED);
|
|
});
|
|
|
|
it("returns yellow when agent is loading", () => {
|
|
const result = getIndicatorColor(
|
|
"OPEN",
|
|
"STARTING",
|
|
"STATUS$STARTING_RUNTIME",
|
|
AgentState.LOADING,
|
|
);
|
|
expect(result).toBe(IndicatorColor.YELLOW);
|
|
});
|
|
|
|
it("returns orange for AWAITING_USER_CONFIRMATION", () => {
|
|
const result = getIndicatorColor(
|
|
"OPEN",
|
|
"RUNNING",
|
|
"STATUS$STARTING_RUNTIME",
|
|
AgentState.AWAITING_USER_CONFIRMATION,
|
|
);
|
|
expect(result).toBe(IndicatorColor.ORANGE);
|
|
});
|
|
|
|
it("returns green for FINISHED state", () => {
|
|
const result = getIndicatorColor(
|
|
"OPEN",
|
|
"RUNNING",
|
|
"STATUS$SETTING_UP_WORKSPACE",
|
|
AgentState.FINISHED,
|
|
);
|
|
expect(result).toBe(IndicatorColor.GREEN);
|
|
});
|
|
});
|