diff --git a/frontend/src/features/workspace/DocumentEditor.tsx b/frontend/src/features/workspace/DocumentEditor.tsx index 6e40574..80d9f44 100644 --- a/frontend/src/features/workspace/DocumentEditor.tsx +++ b/frontend/src/features/workspace/DocumentEditor.tsx @@ -5,7 +5,6 @@ import { Trash2, Download, FileText, - Radio, Loader2, ArrowLeft, Hash, @@ -18,7 +17,7 @@ import { } from 'lucide-react'; import { Document, DocumentBlock, User } from '../../lib/types'; import { api } from '../../lib/api'; -import { useDocumentSync, DocSyncEvent, RemoteCursor } from '../../lib/useDocumentSync'; +import { useDocumentSync, DocSyncEvent, RemoteCursor, DocSyncStatus } from '../../lib/useDocumentSync'; import { OutlinerTree } from './OutlinerTree'; export interface DocumentEditorProps { @@ -34,6 +33,7 @@ export interface DocumentEditorProps { onSelectTag: (tag: string) => void; onWikiLinkClick?: (pageTitle: string) => void; onBackMobile?: () => void; + onSyncStatusChange?: (status: DocSyncStatus) => void; } const EMOJI_PALETTE = ['📝', '📄', '💡', '🚀', '📌', '📂', '🧠', '⚡', '🎯', '🛠️', '📊', '🔒']; @@ -153,6 +153,7 @@ export const DocumentEditor: React.FC = ({ onSelectTag, onWikiLinkClick, onBackMobile, + onSyncStatusChange, }) => { const [doc, setDoc] = useState(initialDoc || null); const [title, setTitle] = useState(initialDoc?.title || ''); @@ -344,6 +345,10 @@ export const DocumentEditor: React.FC = ({ sendTitleUpdated, } = useDocumentSync(docId, handleRemoteEvent, canEdit, currentUser); + useEffect(() => { + onSyncStatusChange?.(syncStatus); + }, [syncStatus, onSyncStatusChange]); + // Fetch isolated document state on mount useEffect(() => { let isCancelled = false; @@ -750,34 +755,6 @@ export const DocumentEditor: React.FC = ({ ); })()} - {/* Live Sync Status (1:1 styling from SharedListsView) */} -
- -
- + + {/* Right Header Section: Live Sync Status (identical to SharedListsView) */} +
+ {(() => { + const isDocActive = subView === 'editor' && Boolean(selectedDocId); + const isConnected = isDocActive + ? activeDocSyncStatus === 'connected' + : realtimeConnected; + const isConnecting = isDocActive && (activeDocSyncStatus === 'connecting' || activeDocSyncStatus === 'reconnecting'); + const isSSE = !isDocActive && realtimeTransport === 'sse'; + + return ( +
+ +
+ ); + })()} +
{/* Main Workspace Split Pane */} @@ -1336,6 +1400,7 @@ export const WorkspaceView: React.FC = ({ onSelectTag={handleSelectTag} onWikiLinkClick={handleWikiLinkClick} onBackMobile={() => setMobileShowDetail(false)} + onSyncStatusChange={setActiveDocSyncStatus} /> ) : subView === 'tags' ? ( /* =========================================================================