fix(md): file streaming patch preview#4465
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Hardens preview session reconciliation by preventing replayed/stale streaming events from overwriting completed sessions ( On preview completion, seeds the workspace file-content query cache with the final preview text and tightens completion success checks before adding/activating the resulting file resource. Updates unit tests to cover renderability and session replacement rules. Reviewed by Cursor Bugbot for commit 6f4bbe6. Configure here. |
Greptile SummaryThis PR guards markdown file preview activation, replay, reconnect, and cache handoff state to eliminate flicker during streamed workspace file edits. The core fix is adding
Confidence Score: 5/5Safe to merge; the change is a targeted guard around preview activation that does not alter the underlying streaming or file-write logic. All activation, cache-seed, and resource-handoff paths gate correctly on The resource event handler in Important Files Changed
Sequence DiagramsequenceDiagram
participant Stream as SSE Stream
participant Chat as use-chat handler
participant Sessions as useFilePreviewSessions
participant Resources as Resources state
participant UI as ResourceContent
Stream->>Chat: file_preview_start
Chat->>Sessions: upsert(pending, v=0, text='')
Note over UI: guard: hasRenderable=false - no activation
Stream->>Chat: file_preview_target
Chat->>Chat: rememberPreviewActivationOwner(session)
Chat->>Sessions: upsert(baseSession)
Chat->>Resources: syncPreviewResourceChrome (activate if autoActivate)
Stream->>Chat: file_preview_content (first)
Note over Chat: prevSession has no renderable content
Chat->>Sessions: upsert(streaming, v=1, text='...')
Chat->>Resources: syncPreviewResourceChrome - activate preview
UI-->>UI: streamingPreviewText defined - render FileViewer
Stream->>Chat: file_preview_content (subsequent)
Note over Chat: prevSession already renderable - skip chrome sync
Chat->>Sessions: upsert(streaming, v=N, text='...')
Stream->>Chat: file_preview_complete (success=true, id matches)
Chat->>Sessions: complete(session)
Chat->>Resources: setResources (add real file, remove streaming-file)
Chat->>Chat: completedPreviewResourceHandoffRef.set(fileId)
Chat->>Chat: seedCompletedPreviewContentCache(fileId, previewText)
Stream->>Chat: resource event (file added)
Chat->>Chat: read completedPreviewHandoff - suppressActivation?
alt suppress activation
Chat->>Resources: setResources (add without activating)
else normal
Chat->>Resources: addResource - activate
end
Chat->>Chat: delete handoff ref (cleanup)
Reviews (2): Last reviewed commit: "address comment" | Re-trigger Greptile |
|
bugbot run |
|
@greptile |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6f4bbe6. Configure here.
Summary
Fixes markdown file preview flicker during streamed workspace file edits by guarding preview activation, replay, reconnect, and cache handoff state.
Type of Change
Testing
Tested manually
Checklist