mirror of
https://github.com/RSSNext/Folo.git
synced 2026-10-28 19:37:57 +08:00
fix: ai chain thought close state
- Replaced the random ID generation for collapseId with React's useId for improved stability and performance. - Updated the effect logic to conditionally close the collapse based on the currentChainReasoningIsFinished state. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
+2
-2
@@ -20,7 +20,7 @@ interface AIChainOfThoughtProps {
|
||||
}
|
||||
export const AIChainOfThought: React.FC<AIChainOfThoughtProps> = React.memo(
|
||||
({ groups, isStreaming, className }) => {
|
||||
const collapseId = React.useMemo(() => `chain-${Math.random().toString(36).slice(2)}`, [])
|
||||
const collapseId = React.useId()
|
||||
|
||||
const collapseRef = React.useRef<CollapseCssRef>(null)
|
||||
|
||||
@@ -58,7 +58,7 @@ export const AIChainOfThought: React.FC<AIChainOfThoughtProps> = React.memo(
|
||||
}, [groups, isStreaming])
|
||||
|
||||
React.useEffect(() => {
|
||||
collapseRef.current?.setIsOpened(!currentChainReasoningIsFinished)
|
||||
if (currentChainReasoningIsFinished) collapseRef.current?.setIsOpened(false)
|
||||
}, [collapseRef, currentChainReasoningIsFinished])
|
||||
|
||||
if (!groups || groups.length === 0) return null
|
||||
|
||||
Reference in New Issue
Block a user