File tree Expand file tree Collapse file tree 6 files changed +2819
-4477
lines changed
app/workspace/[workspaceId]/home
components/mothership-view/components/resource-content Expand file tree Collapse file tree 6 files changed +2819
-4477
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,9 @@ export const ResourceContent = memo(function ResourceContent({
165165 }
166166 } , [ workspaceId , streamFileName ] )
167167
168- const streamingFileMode : 'append' | 'replace' = isWriteStream ? 'append' : 'replace'
168+ // workspace_file preview events now carry whole-file snapshots, not deltas.
169+ // Treat every live preview as replace so the viewer shows the latest snapshot.
170+ const streamingFileMode : 'append' | 'replace' = 'replace'
169171
170172 // For existing file resources (not streaming-file), only pass streaming
171173 // content for patch operations where the preview splices new content into
Original file line number Diff line number Diff line change @@ -610,11 +610,34 @@ export function useChat(
610610 const assistantId = generateId ( )
611611
612612 const reconnect = async ( ) => {
613- const succeeded = await retryReconnectRef . current ( {
614- streamId : activeStreamId ,
615- assistantId,
616- gen,
617- } )
613+ const initialSnapshot = chatHistory . streamSnapshot
614+ const snapshotEvents = Array . isArray ( initialSnapshot ?. events )
615+ ? ( initialSnapshot . events as StreamBatchEvent [ ] )
616+ : [ ]
617+
618+ const reconnectResult =
619+ snapshotEvents . length > 0
620+ ? await attachToExistingStream ( {
621+ streamId : activeStreamId ,
622+ assistantId,
623+ expectedGen : gen ,
624+ initialBatch : {
625+ success : true ,
626+ events : snapshotEvents ,
627+ status : initialSnapshot ?. status ?? 'unknown' ,
628+ } ,
629+ afterCursor : String ( snapshotEvents [ snapshotEvents . length - 1 ] ?. eventId ?? '0' ) ,
630+ } )
631+ : null
632+
633+ const succeeded =
634+ reconnectResult !== null
635+ ? ! reconnectResult . error || reconnectResult . aborted
636+ : await retryReconnectRef . current ( {
637+ streamId : activeStreamId ,
638+ assistantId,
639+ gen,
640+ } )
618641 if ( ! succeeded && streamGenRef . current === gen ) {
619642 try {
620643 finalizeRef . current ( { error : true } )
Original file line number Diff line number Diff line change @@ -85,7 +85,9 @@ export async function fetchChatHistory(
8585 return {
8686 id : chat . id ,
8787 title : chat . title ,
88- messages : Array . isArray ( chat . messages ) ? chat . messages : [ ] ,
88+ messages : Array . isArray ( chat . messages )
89+ ? chat . messages . map ( ( m : Record < string , unknown > ) => normalizeMessage ( m ) )
90+ : [ ] ,
8991 activeStreamId : chat . conversationId || null ,
9092 resources : Array . isArray ( chat . resources ) ? chat . resources : [ ] ,
9193 streamSnapshot : chat . streamSnapshot || null ,
You can’t perform that action at this time.
0 commit comments