Checkpoitn

This commit is contained in:
Siddharth Ganesan
2026-04-09 11:27:08 -07:00
parent 817833c3a3
commit 2ba4228669
6 changed files with 2848 additions and 4506 deletions

View File

@@ -165,7 +165,9 @@ export const ResourceContent = memo(function ResourceContent({
}
}, [workspaceId, streamFileName])
const streamingFileMode: 'append' | 'replace' = isWriteStream ? 'append' : 'replace'
// workspace_file preview events now carry whole-file snapshots, not deltas.
// Treat every live preview as replace so the viewer shows the latest snapshot.
const streamingFileMode: 'append' | 'replace' = 'replace'
// For existing file resources (not streaming-file), only pass streaming
// content for patch operations where the preview splices new content into

View File

@@ -610,11 +610,34 @@ export function useChat(
const assistantId = generateId()
const reconnect = async () => {
const succeeded = await retryReconnectRef.current({
streamId: activeStreamId,
assistantId,
gen,
})
const initialSnapshot = chatHistory.streamSnapshot
const snapshotEvents = Array.isArray(initialSnapshot?.events)
? (initialSnapshot.events as StreamBatchEvent[])
: []
const reconnectResult =
snapshotEvents.length > 0
? await attachToExistingStream({
streamId: activeStreamId,
assistantId,
expectedGen: gen,
initialBatch: {
success: true,
events: snapshotEvents,
status: initialSnapshot?.status ?? 'unknown',
},
afterCursor: String(snapshotEvents[snapshotEvents.length - 1]?.eventId ?? '0'),
})
: null
const succeeded =
reconnectResult !== null
? !reconnectResult.error || reconnectResult.aborted
: await retryReconnectRef.current({
streamId: activeStreamId,
assistantId,
gen,
})
if (!succeeded && streamGenRef.current === gen) {
try {
finalizeRef.current({ error: true })

View File

@@ -85,7 +85,9 @@ export async function fetchChatHistory(
return {
id: chat.id,
title: chat.title,
messages: Array.isArray(chat.messages) ? chat.messages : [],
messages: Array.isArray(chat.messages)
? chat.messages.map((m: Record<string, unknown>) => normalizeMessage(m))
: [],
activeStreamId: chat.conversationId || null,
resources: Array.isArray(chat.resources) ? chat.resources : [],
streamSnapshot: chat.streamSnapshot || null,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -415,6 +415,7 @@ export async function runStreamLoop(
toolName: 'workspace_file',
previewPhase: 'file_preview_content',
content: streamedContent,
contentMode: 'snapshot',
},
...(streamEvent.scope ? { scope: streamEvent.scope } : {}),
})