diff --git a/oAI/ViewModels/ChatViewModel.swift b/oAI/ViewModels/ChatViewModel.swift index 5f0420c..c09e892 100644 --- a/oAI/ViewModels/ChatViewModel.swift +++ b/oAI/ViewModels/ChatViewModel.swift @@ -756,6 +756,7 @@ Don't narrate future actions ("Let me...") - just use the tools. savedMessageCount = chatMessages.count notesEnabled = false notesFilename = nil + DraftRecoveryService.shared.clear() showSystemMessage("Saved as \"\(details.name)\"") Task { await GitSyncService.shared.autoSync() } } 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 /// original action (new chat / clear / switch / quit) must not happen. 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() 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 ) savedMessageCount = chatMessages.count + DraftRecoveryService.shared.clear() showSystemMessage("Saved \"\(name)\"") Task { await GitSyncService.shared.autoSync() } return true @@ -2421,6 +2430,7 @@ Don't narrate future actions ("Let me...") - just use the tools. savedMessageCount = chatMessages.count notesEnabled = false notesFilename = nil + DraftRecoveryService.shared.clear() showSystemMessage("Saved as \"\(details.name)\"") Task { await GitSyncService.shared.autoSync() } return true