增加会话标题支持,优化聊天头部展示
Build Push and Deploy / docker-image (push) Successful in 1m1s
Build Push and Deploy / deploy-fallback-log (push) Has been skipped

This commit is contained in:
2026-05-15 17:32:38 +08:00
parent 8058b7b859
commit 570d2c7de1
3 changed files with 17 additions and 3 deletions
+14 -3
View File
@@ -18,6 +18,7 @@ import CloseRounded from "@mui/icons-material/CloseRounded";
import HistoryRounded from "@mui/icons-material/HistoryRounded"; import HistoryRounded from "@mui/icons-material/HistoryRounded";
type AgentHeaderProps = { type AgentHeaderProps = {
sessionTitle?: string;
isStreaming: boolean; isStreaming: boolean;
isHistoryOpen: boolean; isHistoryOpen: boolean;
onHistoryToggle: () => void; onHistoryToggle: () => void;
@@ -26,6 +27,7 @@ type AgentHeaderProps = {
}; };
export const AgentHeader = ({ export const AgentHeader = ({
sessionTitle,
isStreaming, isStreaming,
isHistoryOpen, isHistoryOpen,
onHistoryToggle, onHistoryToggle,
@@ -33,6 +35,7 @@ export const AgentHeader = ({
onClose, onClose,
}: AgentHeaderProps) => { }: AgentHeaderProps) => {
const theme = useTheme(); const theme = useTheme();
const displayTitle = sessionTitle?.trim() || "TJWater Agent";
return ( return (
<Box <Box
@@ -91,7 +94,7 @@ export const AgentHeader = ({
/> />
</Box> </Box>
</motion.div> </motion.div>
<Box> <Box sx={{ minWidth: 0 }}>
<Typography <Typography
variant="h6" variant="h6"
fontWeight={800} fontWeight={800}
@@ -100,12 +103,20 @@ export const AgentHeader = ({
backgroundClip: "text", backgroundClip: "text",
color: "transparent", color: "transparent",
letterSpacing: -0.3, letterSpacing: -0.3,
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
maxWidth: { xs: "calc(100vw - 220px)", sm: 320 },
}} }}
> >
TJWater Agent {displayTitle}
</Typography> </Typography>
<Typography variant="caption" color="text.secondary" fontWeight={500}> <Typography variant="caption" color="text.secondary" fontWeight={500}>
{isStreaming ? "正在思考分析任务..." : "基于大模型的水力分析引擎"} {isStreaming
? "正在思考分析任务..."
: displayTitle === "TJWater Agent"
? "基于大模型的水力分析引擎"
: "当前会话标题"}
</Typography> </Typography>
</Box> </Box>
</Stack> </Stack>
+2
View File
@@ -58,6 +58,7 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
branchTransition, branchTransition,
isHydrating, isHydrating,
isStreaming, isStreaming,
sessionTitle,
sendPrompt, sendPrompt,
regenerate, regenerate,
editAndResubmit, editAndResubmit,
@@ -220,6 +221,7 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
<Blob color={alpha(theme.palette.success.light, 0.18)} size={200} top="80%" left="-10%" delay={4} /> <Blob color={alpha(theme.palette.success.light, 0.18)} size={200} top="80%" left="-10%" delay={4} />
<AgentHeader <AgentHeader
sessionTitle={sessionTitle}
isStreaming={isStreaming} isStreaming={isStreaming}
isHistoryOpen={isHistoryOpen} isHistoryOpen={isHistoryOpen}
onHistoryToggle={handleHistoryToggle} onHistoryToggle={handleHistoryToggle}
@@ -767,6 +767,7 @@ export const useAgentChatSession = ({
branchTransition, branchTransition,
isHydrating, isHydrating,
isStreaming, isStreaming,
sessionTitle,
sessionId, sessionId,
sendPrompt, sendPrompt,
regenerate, regenerate,