diff --git a/desktop/src/components/ButlerPanel/index.tsx b/desktop/src/components/ButlerPanel/index.tsx index 0052b0d..7a12932 100644 --- a/desktop/src/components/ButlerPanel/index.tsx +++ b/desktop/src/components/ButlerPanel/index.tsx @@ -1,4 +1,6 @@ +import { useState } from 'react'; import { useButlerInsights } from '../../hooks/useButlerInsights'; +import { useChatStore } from '../../store/chatStore'; import { InsightsSection } from './InsightsSection'; import { ProposalsSection } from './ProposalsSection'; import { MemorySection } from './MemorySection'; @@ -9,6 +11,21 @@ interface ButlerPanelProps { export function ButlerPanel({ agentId }: ButlerPanelProps) { const { painPoints, proposals, loading, error, refresh } = useButlerInsights(agentId); + const messageCount = useChatStore((s) => s.messages.length); + const [analyzing, setAnalyzing] = useState(false); + + const hasData = (painPoints?.length ?? 0) > 0 || (proposals?.length ?? 0) > 0; + const canAnalyze = messageCount >= 2; + + const handleAnalyze = async () => { + if (!canAnalyze || analyzing) return; + setAnalyzing(true); + try { + await refresh(); + } finally { + setAnalyzing(false); + } + }; if (!agentId) { return ( @@ -32,23 +49,51 @@ export function ButlerPanel({ agentId }: ButlerPanelProps) { )} - {/* Insights section */} -
-

- 我最近在关注 -

- -
+ {!loading && !hasData && ( +
+
+ + + +
+

+ 管家正在了解您,多轮对话后会自动发现您的需求 +

+ +
+ )} - {/* Proposals section */} -
-

- 我提出的方案 -

- -
+ {(hasData || loading) && ( + <> + {/* Insights section */} +
+

+ 我最近在关注 +

+ +
- {/* Memory section */} + {/* Proposals section */} +
+

+ 我提出的方案 +

+ +
+ + )} + + {/* Memory section (always show) */}

我记得关于您