({
isPausing = false,
isTask,
taskStatus,
taskDetail,
isStartingStatus,
isStopStatus,
curAgentState,
errorMessage,
t,
}: GetStatusTextArgs)
| 685 | * }) // Returns "Waiting for sandbox" |
| 686 | */ |
| 687 | export function getStatusText({ |
| 688 | isPausing = false, |
| 689 | isTask, |
| 690 | taskStatus, |
| 691 | taskDetail, |
| 692 | isStartingStatus, |
| 693 | isStopStatus, |
| 694 | curAgentState, |
| 695 | errorMessage, |
| 696 | t, |
| 697 | }: GetStatusTextArgs): string { |
| 698 | // Show pausing status |
| 699 | if (isPausing) { |
| 700 | return t(I18nKey.COMMON$STOPPING); |
| 701 | } |
| 702 | |
| 703 | // Show task status if we're polling a task |
| 704 | if (isTask && taskStatus) { |
| 705 | if (taskStatus === "ERROR") { |
| 706 | return taskDetail || t(I18nKey.CONVERSATION$ERROR_STARTING_CONVERSATION); |
| 707 | } |
| 708 | |
| 709 | if (taskStatus === "READY") { |
| 710 | return t(I18nKey.CONVERSATION$READY); |
| 711 | } |
| 712 | |
| 713 | // Format status text with sentence case: "WAITING_FOR_SANDBOX" -> "Waiting for sandbox" |
| 714 | return ( |
| 715 | taskDetail || |
| 716 | taskStatus |
| 717 | .toLowerCase() |
| 718 | .replace(/_/g, " ") |
| 719 | .replace(/^\w/, (c) => c.toUpperCase()) |
| 720 | ); |
| 721 | } |
| 722 | |
| 723 | if (isStartingStatus) { |
| 724 | return t(I18nKey.COMMON$STARTING); |
| 725 | } |
| 726 | |
| 727 | if (isStopStatus) { |
| 728 | return t(I18nKey.COMMON$SERVER_STOPPED); |
| 729 | } |
| 730 | |
| 731 | if (curAgentState === AgentState.ERROR) { |
| 732 | return errorMessage || t(I18nKey.COMMON$ERROR); |
| 733 | } |
| 734 | |
| 735 | return t(I18nKey.COMMON$RUNNING); |
| 736 | } |
no test coverage detected