From ccdfc0f6e91935f87cec8357c64a300e7344b1d0 Mon Sep 17 00:00:00 2001 From: Gagancreates Date: Mon, 1 Jun 2026 02:35:29 +0530 Subject: [PATCH] feat(google-docs): overwrite-confirm on sync conflict and last-synced indicator --- apps/x/apps/renderer/src/App.tsx | 15 ++++++++++++++- .../renderer/src/components/editor-toolbar.tsx | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/apps/x/apps/renderer/src/App.tsx b/apps/x/apps/renderer/src/App.tsx index fc36df68..1137aabe 100644 --- a/apps/x/apps/renderer/src/App.tsx +++ b/apps/x/apps/renderer/src/App.tsx @@ -1454,7 +1454,19 @@ function App() { setGoogleDocSyncDirection('up') markRecentLocalMarkdownWrite(path) try { - const result = await window.ipc.invoke('google-docs:sync', { path, markdown }) + let result = await window.ipc.invoke('google-docs:sync', { path, markdown }) + if (result.conflict) { + const overwrite = window.confirm( + 'This Google Doc changed since your last sync.\n\n' + + 'Overwrite it with your local version? Cancel to keep the remote copy ' + + '(use “Sync down” to pull it first).', + ) + if (!overwrite) { + toast.info('Sync up cancelled — remote Google Doc is unchanged') + return + } + result = await window.ipc.invoke('google-docs:sync', { path, markdown, force: true }) + } if (!result.synced) { throw new Error(result.error || 'This note is not linked to a Google Doc.') } @@ -5776,6 +5788,7 @@ function App() { googleDoc={linkedGoogleDoc && !isViewingHistory ? { title: linkedGoogleDoc.title, isSyncing: isActive ? googleDocSyncDirection : null, + lastSyncedAt: linkedGoogleDoc.syncedAt, onOpen: () => { if (linkedGoogleDoc.url) { window.open(linkedGoogleDoc.url, '_blank') diff --git a/apps/x/apps/renderer/src/components/editor-toolbar.tsx b/apps/x/apps/renderer/src/components/editor-toolbar.tsx index b7397376..9bacc158 100644 --- a/apps/x/apps/renderer/src/components/editor-toolbar.tsx +++ b/apps/x/apps/renderer/src/components/editor-toolbar.tsx @@ -39,9 +39,11 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, + DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' +import { formatRelativeTime } from '@/lib/relative-time' interface EditorToolbarProps { editor: Editor | null @@ -56,6 +58,7 @@ interface EditorToolbarProps { export interface GoogleDocToolbarState { title: string isSyncing?: 'up' | 'down' | null + lastSyncedAt?: string onOpen: () => void onSyncDown: () => void onSyncUp: () => void @@ -470,6 +473,12 @@ export function EditorToolbar({ + + {googleDoc.lastSyncedAt + ? `Last synced ${formatRelativeTime(googleDoc.lastSyncedAt)}` + : 'Not synced yet'} + + Open Google Doc