|
|
@@ -5,46 +5,56 @@ import { I18nKey } from "#/i18n/declaration";
|
|
|
import { RootState } from "#/store";
|
|
|
import AgentState from "#/types/AgentState";
|
|
|
|
|
|
-const AgentStatusMap: { [k: string]: { message: string; indicator: string } } =
|
|
|
- {
|
|
|
+enum IndicatorColor {
|
|
|
+ BLUE = "bg-blue-500",
|
|
|
+ GREEN = "bg-green-500",
|
|
|
+ ORANGE = "bg-orange-500",
|
|
|
+ YELLOW = "bg-yellow-500",
|
|
|
+ RED = "bg-red-500",
|
|
|
+ DARK_ORANGE = "bg-orange-800",
|
|
|
+}
|
|
|
+
|
|
|
+function AgentStatusBar() {
|
|
|
+ const { t } = useTranslation();
|
|
|
+ const { curAgentState } = useSelector((state: RootState) => state.agent);
|
|
|
+
|
|
|
+ const AgentStatusMap: {
|
|
|
+ [k: string]: { message: string; indicator: IndicatorColor };
|
|
|
+ } = {
|
|
|
[AgentState.INIT]: {
|
|
|
- message: "Agent is initialized, waiting for task...",
|
|
|
- indicator: "bg-blue-500",
|
|
|
+ message: t(I18nKey.CHAT_INTERFACE$AGENT_INIT_MESSAGE),
|
|
|
+ indicator: IndicatorColor.BLUE,
|
|
|
},
|
|
|
[AgentState.RUNNING]: {
|
|
|
- message: "Agent is running task...",
|
|
|
- indicator: "bg-green-500",
|
|
|
+ message: t(I18nKey.CHAT_INTERFACE$AGENT_RUNNING_MESSAGE),
|
|
|
+ indicator: IndicatorColor.GREEN,
|
|
|
},
|
|
|
[AgentState.AWAITING_USER_INPUT]: {
|
|
|
- message: "Agent is awaiting user input...",
|
|
|
- indicator: "bg-orange-500",
|
|
|
+ message: t(I18nKey.CHAT_INTERFACE$AGENT_AWAITING_USER_INPUT_MESSAGE),
|
|
|
+ indicator: IndicatorColor.ORANGE,
|
|
|
},
|
|
|
[AgentState.PAUSED]: {
|
|
|
- message: "Agent has paused.",
|
|
|
- indicator: "bg-yellow-500",
|
|
|
+ message: t(I18nKey.CHAT_INTERFACE$AGENT_PAUSED_MESSAGE),
|
|
|
+ indicator: IndicatorColor.YELLOW,
|
|
|
},
|
|
|
[AgentState.LOADING]: {
|
|
|
- message: "Agent is initializing...",
|
|
|
- indicator: "bg-yellow-500",
|
|
|
+ message: t(I18nKey.CHAT_INTERFACE$INITIALIZING_AGENT_LOADING_MESSAGE),
|
|
|
+ indicator: IndicatorColor.DARK_ORANGE,
|
|
|
},
|
|
|
[AgentState.STOPPED]: {
|
|
|
- message: "Agent has stopped.",
|
|
|
- indicator: "bg-red-500",
|
|
|
+ message: t(I18nKey.CHAT_INTERFACE$AGENT_STOPPED_MESSAGE),
|
|
|
+ indicator: IndicatorColor.RED,
|
|
|
},
|
|
|
[AgentState.FINISHED]: {
|
|
|
- message: "Agent has finished the task.",
|
|
|
- indicator: "bg-green-500",
|
|
|
+ message: t(I18nKey.CHAT_INTERFACE$AGENT_FINISHED_MESSAGE),
|
|
|
+ indicator: IndicatorColor.GREEN,
|
|
|
},
|
|
|
[AgentState.ERROR]: {
|
|
|
- message: "Agent encountered an error.",
|
|
|
- indicator: "bg-red-500",
|
|
|
+ message: t(I18nKey.CHAT_INTERFACE$AGENT_ERROR_MESSAGE),
|
|
|
+ indicator: IndicatorColor.RED,
|
|
|
},
|
|
|
};
|
|
|
|
|
|
-function AgentStatusBar() {
|
|
|
- const { t } = useTranslation();
|
|
|
- const { curAgentState } = useSelector((state: RootState) => state.agent);
|
|
|
-
|
|
|
// TODO: Extend the agent status, e.g.:
|
|
|
// - Agent is typing
|
|
|
// - Agent is initializing
|
|
|
@@ -53,23 +63,12 @@ function AgentStatusBar() {
|
|
|
// - Agent is not available
|
|
|
return (
|
|
|
<div className="flex items-center">
|
|
|
- {curAgentState !== AgentState.LOADING ? (
|
|
|
- <>
|
|
|
- <div
|
|
|
- className={`w-3 h-3 mr-2 rounded-full animate-pulse ${AgentStatusMap[curAgentState].indicator}`}
|
|
|
- />
|
|
|
- <span className="text-sm text-stone-400">
|
|
|
- {AgentStatusMap[curAgentState].message}
|
|
|
- </span>
|
|
|
- </>
|
|
|
- ) : (
|
|
|
- <>
|
|
|
- <div className="w-3 h-3 mr-3 bg-orange-800 rounded-full animate-pulse" />
|
|
|
- <span className="text-sm text-stone-400">
|
|
|
- {t(I18nKey.CHAT_INTERFACE$INITIALZING_AGENT_LOADING_MESSAGE)}
|
|
|
- </span>
|
|
|
- </>
|
|
|
- )}
|
|
|
+ <div
|
|
|
+ className={`w-3 h-3 mr-2 rounded-full animate-pulse ${AgentStatusMap[curAgentState].indicator}`}
|
|
|
+ />
|
|
|
+ <span className="text-sm text-stone-400">
|
|
|
+ {AgentStatusMap[curAgentState].message}
|
|
|
+ </span>
|
|
|
</div>
|
|
|
);
|
|
|
}
|