Clear crash-recovery draft on save, not just on discard
attemptSaveCurrentConversation() (Save/Save As) and confirmDiscardIfNeeded's no-unsaved-changes early return both left the on-disk draft_conversation.json untouched, so a stale snapshot from before the save lingered and triggered "Restore unsaved conversation?" on next launch even though everything had already been saved with no changes since.
This commit is contained in:
@@ -756,6 +756,7 @@ Don't narrate future actions ("Let me...") - just use the tools.
|
|||||||
savedMessageCount = chatMessages.count
|
savedMessageCount = chatMessages.count
|
||||||
notesEnabled = false
|
notesEnabled = false
|
||||||
notesFilename = nil
|
notesFilename = nil
|
||||||
|
DraftRecoveryService.shared.clear()
|
||||||
showSystemMessage("Saved as \"\(details.name)\"")
|
showSystemMessage("Saved as \"\(details.name)\"")
|
||||||
Task { await GitSyncService.shared.autoSync() }
|
Task { await GitSyncService.shared.autoSync() }
|
||||||
} catch {
|
} catch {
|
||||||
@@ -2359,7 +2360,14 @@ Don't narrate future actions ("Let me...") - just use the tools.
|
|||||||
/// discards the crash-recovery draft and proceeds; Cancel calls `onCancel()` — the caller's
|
/// discards the crash-recovery draft and proceeds; Cancel calls `onCancel()` — the caller's
|
||||||
/// original action (new chat / clear / switch / quit) must not happen.
|
/// original action (new chat / clear / switch / quit) must not happen.
|
||||||
func confirmDiscardIfNeeded(then proceed: @escaping () -> Void, onCancel: @escaping () -> Void = {}) {
|
func confirmDiscardIfNeeded(then proceed: @escaping () -> Void, onCancel: @escaping () -> Void = {}) {
|
||||||
guard hasUnsavedChanges else { proceed(); return }
|
guard hasUnsavedChanges else {
|
||||||
|
// Nothing unsaved means any on-disk crash-recovery draft is now stale (either a
|
||||||
|
// save already covered it, or there was nothing worth mirroring) — clear it so the
|
||||||
|
// next launch doesn't offer to "restore" a conversation that's already saved intact.
|
||||||
|
DraftRecoveryService.shared.clear()
|
||||||
|
proceed()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let alert = NSAlert()
|
let alert = NSAlert()
|
||||||
alert.alertStyle = .warning
|
alert.alertStyle = .warning
|
||||||
@@ -2401,6 +2409,7 @@ Don't narrate future actions ("Let me...") - just use the tools.
|
|||||||
id: id, name: name, messages: chatMessages, primaryModel: selectedModel?.id
|
id: id, name: name, messages: chatMessages, primaryModel: selectedModel?.id
|
||||||
)
|
)
|
||||||
savedMessageCount = chatMessages.count
|
savedMessageCount = chatMessages.count
|
||||||
|
DraftRecoveryService.shared.clear()
|
||||||
showSystemMessage("Saved \"\(name)\"")
|
showSystemMessage("Saved \"\(name)\"")
|
||||||
Task { await GitSyncService.shared.autoSync() }
|
Task { await GitSyncService.shared.autoSync() }
|
||||||
return true
|
return true
|
||||||
@@ -2421,6 +2430,7 @@ Don't narrate future actions ("Let me...") - just use the tools.
|
|||||||
savedMessageCount = chatMessages.count
|
savedMessageCount = chatMessages.count
|
||||||
notesEnabled = false
|
notesEnabled = false
|
||||||
notesFilename = nil
|
notesFilename = nil
|
||||||
|
DraftRecoveryService.shared.clear()
|
||||||
showSystemMessage("Saved as \"\(details.name)\"")
|
showSystemMessage("Saved as \"\(details.name)\"")
|
||||||
Task { await GitSyncService.shared.autoSync() }
|
Task { await GitSyncService.shared.autoSync() }
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user