Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions webview-ui/src/components/chat/ReasoningBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ interface ReasoningBlockProps {
metadata?: any
}

export const ReasoningBlock = ({ content, isStreaming, isLast }: ReasoningBlockProps) => {
export const ReasoningBlock = ({ content, isStreaming, isLast, ts }: ReasoningBlockProps) => {
const { t } = useTranslation()
const { reasoningBlockCollapsed } = useExtensionState()

const [isCollapsed, setIsCollapsed] = useState(reasoningBlockCollapsed)

const startTimeRef = useRef<number>(Date.now())
const [elapsed, setElapsed] = useState<number>(0)
// Anchor the elapsed timer to the message creation timestamp (ts)
// rather than component mount time. When Virtuoso recycles or
// remounts this component (e.g. during expand/collapse in a
// virtualized list), the timer survives because ts is a stable
// prop from the message data rather than a fresh Date.now().
const startTimeRef = useRef<number>(ts)
const [elapsed, setElapsed] = useState<number>(() => (isStreaming ? 0 : Math.max(0, Date.now() - ts)))
Comment thread
umi008 marked this conversation as resolved.
const contentRef = useRef<HTMLDivElement>(null)

useEffect(() => {
Expand Down
Loading