feat(chat): 完善运行状态与权限交互
This commit is contained in:
@@ -19,12 +19,14 @@ import CloseRounded from "@mui/icons-material/CloseRounded";
|
||||
import EditRounded from "@mui/icons-material/EditRounded";
|
||||
import EditNoteRounded from "@mui/icons-material/EditNoteRounded";
|
||||
import HistoryRounded from "@mui/icons-material/HistoryRounded";
|
||||
import type { AgentRuntimeState } from "@/lib/agentRuntime";
|
||||
|
||||
type AgentHeaderProps = {
|
||||
sessionTitle?: string;
|
||||
canRenameSessionTitle?: boolean;
|
||||
isHydrating?: boolean;
|
||||
isStreaming: boolean;
|
||||
runtimeState?: AgentRuntimeState;
|
||||
isHistoryOpen: boolean;
|
||||
onHistoryToggle: () => void;
|
||||
onRenameSessionTitle?: (title: string) => void;
|
||||
@@ -37,6 +39,7 @@ export const AgentHeader = ({
|
||||
canRenameSessionTitle = false,
|
||||
isHydrating = false,
|
||||
isStreaming,
|
||||
runtimeState = "ready",
|
||||
isHistoryOpen,
|
||||
onHistoryToggle,
|
||||
onRenameSessionTitle,
|
||||
@@ -47,6 +50,14 @@ export const AgentHeader = ({
|
||||
const displayTitle = sessionTitle?.trim() || "新对话";
|
||||
const [isEditingTitle, setIsEditingTitle] = React.useState(false);
|
||||
const [draftTitle, setDraftTitle] = React.useState(sessionTitle?.trim() || "");
|
||||
const runtimeStatus =
|
||||
runtimeState === "unavailable" || runtimeState === "models_unavailable"
|
||||
? { color: "#e53935", label: "Agent 服务未就绪" }
|
||||
: runtimeState === "checking"
|
||||
? { color: "#ffb300", label: "正在连接 Agent 服务" }
|
||||
: isStreaming
|
||||
? { color: "#ff9800", label: "Agent 正在生成" }
|
||||
: { color: "#00e676", label: "Agent 已就绪" };
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!isEditingTitle) {
|
||||
@@ -109,17 +120,19 @@ export const AgentHeader = ({
|
||||
/>
|
||||
</Avatar>
|
||||
<Box
|
||||
role="status"
|
||||
aria-label={runtimeStatus.label}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
bottom: -2,
|
||||
right: -2,
|
||||
width: 14,
|
||||
height: 14,
|
||||
bgcolor: isStreaming ? "#ff9800" : "#00e676",
|
||||
bgcolor: runtimeStatus.color,
|
||||
borderRadius: "50%",
|
||||
border: "2.5px solid #fff",
|
||||
boxShadow: `0 0 10px ${isStreaming ? "#ff9800" : "#00e676"}`,
|
||||
animation: isStreaming ? "pulse 1.5s infinite" : "none",
|
||||
boxShadow: `0 0 10px ${runtimeStatus.color}`,
|
||||
animation: isStreaming && runtimeState === "ready" ? "pulse 1.5s infinite" : "none",
|
||||
"@keyframes pulse": {
|
||||
"0%": { boxShadow: `0 0 0 0 ${alpha("#ff9800", 0.7)}` },
|
||||
"70%": { boxShadow: `0 0 0 6px ${alpha("#ff9800", 0)}` },
|
||||
|
||||
Reference in New Issue
Block a user