mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
Merge branch 'dev' of github.com:simstudioai/sim into dev
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 })
|
||||
|
||||
@@ -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
@@ -415,6 +415,7 @@ export async function runStreamLoop(
|
||||
toolName: 'workspace_file',
|
||||
previewPhase: 'file_preview_content',
|
||||
content: streamedContent,
|
||||
contentMode: 'snapshot',
|
||||
},
|
||||
...(streamEvent.scope ? { scope: streamEvent.scope } : {}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user