@@ -122,7 +122,30 @@ export const ResourceContent = memo(function ResourceContent({
122122
123123 // #region agent log
124124 if ( streamingFile ) {
125- fetch ( 'http://127.0.0.1:7774/ingest/b056eec6-a1ee-457f-8556-85f94314ca06' , { method :'POST' , headers :{ 'Content-Type' :'application/json' , 'X-Debug-Session-Id' :'6f10b0' } , body :JSON . stringify ( { sessionId :'6f10b0' , location :'resource-content.tsx:streaming-context' , message :'streaming state' , data :{ resourceId :resource . id , resourceType :resource . type , streamOp :streamOperation , isPatch :isPatchStream , isWrite :isWriteStream , isUpdate :isUpdateStream , hasActiveFileRecord :! ! activeFileRecord , hasFetchedContent :! ! fetchedFileContent , fetchedContentLen :fetchedFileContent ?. length , streamingFileContentLen :streamingFile . content . length , streamingFileName :streamingFile . fileName , streamingFileMode :isWriteStream ?'append' :'replace' } , timestamp :Date . now ( ) } ) } ) . catch ( ( ) => { } ) ;
125+ fetch ( 'http://127.0.0.1:7774/ingest/b056eec6-a1ee-457f-8556-85f94314ca06' , {
126+ method : 'POST' ,
127+ headers : { 'Content-Type' : 'application/json' , 'X-Debug-Session-Id' : '6f10b0' } ,
128+ body : JSON . stringify ( {
129+ sessionId : '6f10b0' ,
130+ location : 'resource-content.tsx:streaming-context' ,
131+ message : 'streaming state' ,
132+ data : {
133+ resourceId : resource . id ,
134+ resourceType : resource . type ,
135+ streamOp : streamOperation ,
136+ isPatch : isPatchStream ,
137+ isWrite : isWriteStream ,
138+ isUpdate : isUpdateStream ,
139+ hasActiveFileRecord : ! ! activeFileRecord ,
140+ hasFetchedContent : ! ! fetchedFileContent ,
141+ fetchedContentLen : fetchedFileContent ?. length ,
142+ streamingFileContentLen : streamingFile . content . length ,
143+ streamingFileName : streamingFile . fileName ,
144+ streamingFileMode : isWriteStream ? 'append' : 'replace' ,
145+ } ,
146+ timestamp : Date . now ( ) ,
147+ } ) ,
148+ } ) . catch ( ( ) => { } )
126149 }
127150 // #endregion
128151 const streamingExtractedContent = useMemo ( ( ) => {
@@ -132,13 +155,41 @@ export const ResourceContent = memo(function ResourceContent({
132155 if ( isPatchStream ) {
133156 if ( ! fetchedFileContent ) {
134157 // #region agent log
135- fetch ( 'http://127.0.0.1:7774/ingest/b056eec6-a1ee-457f-8556-85f94314ca06' , { method :'POST' , headers :{ 'Content-Type' :'application/json' , 'X-Debug-Session-Id' :'6f10b0' } , body :JSON . stringify ( { sessionId :'6f10b0' , location :'resource-content.tsx:patch-no-fetched' , message :'patch but no fetchedFileContent' , data :{ resourceId :resource . id , activeFileRecordId :activeFileRecord ?. id } , timestamp :Date . now ( ) , hypothesisId :'H1' } ) } ) . catch ( ( ) => { } ) ;
158+ fetch ( 'http://127.0.0.1:7774/ingest/b056eec6-a1ee-457f-8556-85f94314ca06' , {
159+ method : 'POST' ,
160+ headers : { 'Content-Type' : 'application/json' , 'X-Debug-Session-Id' : '6f10b0' } ,
161+ body : JSON . stringify ( {
162+ sessionId : '6f10b0' ,
163+ location : 'resource-content.tsx:patch-no-fetched' ,
164+ message : 'patch but no fetchedFileContent' ,
165+ data : { resourceId : resource . id , activeFileRecordId : activeFileRecord ?. id } ,
166+ timestamp : Date . now ( ) ,
167+ hypothesisId : 'H1' ,
168+ } ) ,
169+ } ) . catch ( ( ) => { } )
136170 // #endregion
137171 return undefined
138172 }
139173 const patchResult = extractPatchPreview ( streamingFile , fetchedFileContent )
140174 // #region agent log
141- fetch ( 'http://127.0.0.1:7774/ingest/b056eec6-a1ee-457f-8556-85f94314ca06' , { method :'POST' , headers :{ 'Content-Type' :'application/json' , 'X-Debug-Session-Id' :'6f10b0' } , body :JSON . stringify ( { sessionId :'6f10b0' , location :'resource-content.tsx:patch-result' , message :'extractPatchPreview result' , data :{ hasPatchResult :! ! patchResult , patchResultLen :patchResult ?. length , fetchedLen :fetchedFileContent . length , contentPreview :streamingFile . content . slice ( 0 , 200 ) , edit :streamingFile . edit } , timestamp :Date . now ( ) , hypothesisId :'H4' } ) } ) . catch ( ( ) => { } ) ;
175+ fetch ( 'http://127.0.0.1:7774/ingest/b056eec6-a1ee-457f-8556-85f94314ca06' , {
176+ method : 'POST' ,
177+ headers : { 'Content-Type' : 'application/json' , 'X-Debug-Session-Id' : '6f10b0' } ,
178+ body : JSON . stringify ( {
179+ sessionId : '6f10b0' ,
180+ location : 'resource-content.tsx:patch-result' ,
181+ message : 'extractPatchPreview result' ,
182+ data : {
183+ hasPatchResult : ! ! patchResult ,
184+ patchResultLen : patchResult ?. length ,
185+ fetchedLen : fetchedFileContent . length ,
186+ contentPreview : streamingFile . content . slice ( 0 , 200 ) ,
187+ edit : streamingFile . edit ,
188+ } ,
189+ timestamp : Date . now ( ) ,
190+ hypothesisId : 'H4' ,
191+ } ) ,
192+ } ) . catch ( ( ) => { } )
142193 // #endregion
143194 return patchResult
144195 }
@@ -147,14 +198,36 @@ export const ResourceContent = memo(function ResourceContent({
147198 if ( extracted . length === 0 ) return undefined
148199
149200 // #region agent log
150- fetch ( 'http://127.0.0.1:7774/ingest/b056eec6-a1ee-457f-8556-85f94314ca06' , { method :'POST' , headers :{ 'Content-Type' :'application/json' , 'X-Debug-Session-Id' :'6f10b0' } , body :JSON . stringify ( { sessionId :'6f10b0' , location :'resource-content.tsx:write-update-content' , message :'extracted content for write/update' , data :{ streamOp :streamOperation , extractedLen :extracted . length , extractedPreview :extracted . slice ( 0 , 150 ) } , timestamp :Date . now ( ) , hypothesisId :'H2' } ) } ) . catch ( ( ) => { } ) ;
201+ fetch ( 'http://127.0.0.1:7774/ingest/b056eec6-a1ee-457f-8556-85f94314ca06' , {
202+ method : 'POST' ,
203+ headers : { 'Content-Type' : 'application/json' , 'X-Debug-Session-Id' : '6f10b0' } ,
204+ body : JSON . stringify ( {
205+ sessionId : '6f10b0' ,
206+ location : 'resource-content.tsx:write-update-content' ,
207+ message : 'extracted content for write/update' ,
208+ data : {
209+ streamOp : streamOperation ,
210+ extractedLen : extracted . length ,
211+ extractedPreview : extracted . slice ( 0 , 150 ) ,
212+ } ,
213+ timestamp : Date . now ( ) ,
214+ hypothesisId : 'H2' ,
215+ } ) ,
216+ } ) . catch ( ( ) => { } )
151217 // #endregion
152218
153219 if ( isUpdateStream ) return extracted
154220 if ( isWriteStream ) return extracted
155221
156222 return undefined
157- } , [ streamingFile , streamOperation , isWriteStream , isPatchStream , isUpdateStream , fetchedFileContent ] )
223+ } , [
224+ streamingFile ,
225+ streamOperation ,
226+ isWriteStream ,
227+ isPatchStream ,
228+ isUpdateStream ,
229+ fetchedFileContent ,
230+ ] )
158231 const syntheticFile = useMemo ( ( ) => {
159232 const ext = getFileExtension ( streamFileName )
160233 const SOURCE_MIME_MAP : Record < string , string > = {
@@ -176,17 +249,14 @@ export const ResourceContent = memo(function ResourceContent({
176249 }
177250 } , [ workspaceId , streamFileName ] )
178251
179- const streamingFileMode : 'append' | 'replace' =
180- isWriteStream ? 'append' : 'replace'
252+ const streamingFileMode : 'append' | 'replace' = isWriteStream ? 'append' : 'replace'
181253
182254 // For existing file resources (not streaming-file), only pass streaming
183255 // content for patch operations where the preview splices new content into
184256 // the displayed file. Update operations re-stream the entire file from
185257 // scratch which causes visual duplication of already-visible content.
186258 const embeddedStreamingContent =
187- resource . id !== 'streaming-file' && isUpdateStream
188- ? undefined
189- : streamingExtractedContent
259+ resource . id !== 'streaming-file' && isUpdateStream ? undefined : streamingExtractedContent
190260
191261 if ( streamingFile && resource . id === 'streaming-file' ) {
192262 return (
@@ -513,7 +583,13 @@ interface EmbeddedFileProps {
513583 streamingMode ?: 'append' | 'replace'
514584}
515585
516- function EmbeddedFile ( { workspaceId, fileId, previewMode, streamingContent, streamingMode } : EmbeddedFileProps ) {
586+ function EmbeddedFile ( {
587+ workspaceId,
588+ fileId,
589+ previewMode,
590+ streamingContent,
591+ streamingMode,
592+ } : EmbeddedFileProps ) {
517593 const { canEdit } = useUserPermissionsContext ( )
518594 const { data : files = [ ] , isLoading, isFetching } = useWorkspaceFiles ( workspaceId )
519595 const file = useMemo ( ( ) => files . find ( ( f ) => f . id === fileId ) , [ files , fileId ] )
@@ -638,9 +714,7 @@ function extractPatchPreview(
638714 const strategy = typeof edit . strategy === 'string' ? edit . strategy : undefined
639715 const lines = existingContent . split ( '\n' )
640716 const occurrence =
641- typeof edit . occurrence === 'number' && Number . isFinite ( edit . occurrence )
642- ? edit . occurrence
643- : 1
717+ typeof edit . occurrence === 'number' && Number . isFinite ( edit . occurrence ) ? edit . occurrence : 1
644718
645719 if ( strategy === 'search_replace' ) {
646720 const search = typeof edit . search === 'string' ? edit . search : ''
@@ -651,7 +725,9 @@ function extractPatchPreview(
651725 }
652726 const firstIdx = existingContent . indexOf ( search )
653727 if ( firstIdx === - 1 ) return undefined
654- return existingContent . slice ( 0 , firstIdx ) + replace + existingContent . slice ( firstIdx + search . length )
728+ return (
729+ existingContent . slice ( 0 , firstIdx ) + replace + existingContent . slice ( firstIdx + search . length )
730+ )
655731 }
656732
657733 const mode = typeof edit . mode === 'string' ? edit . mode : undefined
0 commit comments