Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Duplicate scheduleAutoSave() call — original not removed after "move"

The PR description states scheduleAutoSave() was moved before the guard let coordinator check, but the original call at line 94 was left in place. When the coordinator IS available (the normal path), scheduleAutoSave() is called twice in the same synchronous execution: once at line 83 and again at line 94.

Root Cause and Impact

The second call at line 94 immediately cancels the autoSaveTask created by the first call at line 83 and schedules a brand new one. While this is functionally equivalent to calling it once (due to the cancel-and-reschedule pattern in scheduleAutoSave()), it is clearly unintentional leftover code from an incomplete move.

During rapid streaming updates, each updateDocument call resets the debounce timer twice instead of once per invocation. The practical impact is negligible since both calls happen synchronously, but the redundant call should be removed to match the stated intent of the fix.

(Refers to line 94)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ final class DocumentManager: ObservableObject {
self.sessionId = sessionId
self.title = title
self.initialContent = initialContent
self.currentContent = initialContent
self.wordCount = initialContent.split(whereSeparator: \.isWhitespace).count
self.hasActiveDocument = true

Expand Down Expand Up @@ -85,6 +86,7 @@ final class DocumentManager: ObservableObject {
currentContent = existing + sep + markdown
}

scheduleAutoSave()
guard let coordinator = editorCoordinator else {
log.warning("Cannot update document: editor coordinator not ready, content tracked for later")
print("Cannot update document: editor coordinator not ready, content tracked for later")
Expand Down