Skip to content
Closed
Show file tree
Hide file tree
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export const useMessageHandling = () => {
const streamingMessageIndexRef = useRef<number | null>(null);
// Track the index of the current aggregated thinking message
const thinkingMessageIndexRef = useRef<number | null>(null);
// Preserve one stable timestamp for all message segments in the same turn.
const currentStreamTimestampRef = useRef<number | null>(null);

/**
* Add message
Expand All @@ -56,9 +54,6 @@ export const useMessageHandling = () => {
* Start streaming response
*/
const startStreaming = useCallback((timestamp?: number) => {
const resolvedTimestamp =
typeof timestamp === 'number' ? timestamp : Date.now();
currentStreamTimestampRef.current = resolvedTimestamp;
// Create an assistant placeholder message immediately so tool calls won't jump before it
setMessages((prev) => {
// Record index of the placeholder to update on chunks
Expand All @@ -68,8 +63,8 @@ export const useMessageHandling = () => {
{
role: 'assistant',
content: '',
// Use one stable turn timestamp so later split segments sort correctly.
timestamp: resolvedTimestamp,
// Use provided timestamp (from extension) to keep ordering stable
timestamp: typeof timestamp === 'number' ? timestamp : Date.now(),
},
];
});
Expand All @@ -94,11 +89,7 @@ export const useMessageHandling = () => {
if (idx === null) {
idx = next.length;
streamingMessageIndexRef.current = idx;
next.push({
role: 'assistant',
content: '',
timestamp: currentStreamTimestampRef.current ?? Date.now(),
});
next.push({ role: 'assistant', content: '', timestamp: Date.now() });
}

if (idx < 0 || idx >= next.length) {
Expand Down Expand Up @@ -131,7 +122,6 @@ export const useMessageHandling = () => {
setIsStreaming(false);
streamingMessageIndexRef.current = null;
thinkingMessageIndexRef.current = null;
currentStreamTimestampRef.current = null;
}, []);

/**
Expand Down Expand Up @@ -183,7 +173,7 @@ export const useMessageHandling = () => {
assistantIdx >= 0 &&
assistantIdx < next.length
? next[assistantIdx].timestamp
: (currentStreamTimestampRef.current ?? Date.now());
: Date.now();
next.push({
role: 'thinking',
content: '',
Expand Down
Loading