From 82db722735970a4c61b070ab3d0178e58405cc14 Mon Sep 17 00:00:00 2001 From: sepehr Date: Sun, 3 May 2026 01:05:23 +0200 Subject: [PATCH] fix(chat): inject preview inline in chat tab + resizable note list panel --- .../components/contextual-ai-chat.tsx | 50 ++++++++++++++++ memento-note/components/notes-tabs-view.tsx | 34 ++++++++++- memento-note/scripts/add-resize.js | 60 +++++++++++++++++++ 3 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 memento-note/scripts/add-resize.js diff --git a/memento-note/components/contextual-ai-chat.tsx b/memento-note/components/contextual-ai-chat.tsx index 85ca171..3e539a7 100644 --- a/memento-note/components/contextual-ai-chat.tsx +++ b/memento-note/components/contextual-ai-chat.tsx @@ -507,6 +507,56 @@ export function ContextualAIChat({ )} + + {/* Enrich-in-progress indicator */} + {resourceEnriching && !isLoading && ( +
+
+ +
+
+ + {t('ai.resource.enriching') || 'Traitement IA...'} +
+
+ )} + + {/* Inline preview from inject buttons */} + {resourcePreview && !resourceEnriching && ( +
+
+ + {resourcePreview.source === 'chat' ? (t('ai.resource.fromChat') || 'Remplacement') + : resourcePreview.source === 'replace' ? (t('ai.resource.replacement') || 'Remplacement') + : resourcePreview.source === 'complete' ? (t('ai.resource.completedByAI') || 'Complété par IA') + : (t('ai.resource.mergedByAI') || 'Fusionné par IA')} + + +
+
+ +
+
+ + +
+
+ )} +
diff --git a/memento-note/components/notes-tabs-view.tsx b/memento-note/components/notes-tabs-view.tsx index 8cae071..a086956 100644 --- a/memento-note/components/notes-tabs-view.tsx +++ b/memento-note/components/notes-tabs-view.tsx @@ -756,6 +756,27 @@ export function NotesTabsView({ const selected = items.find((n) => n.id === selectedId) ?? null const colorKey = selected ? getColorKey(selected) : 'default' + // Resizable left panel (180px min, 420px max, default 256px) + const [listPanelWidth, setListPanelWidth] = useState(256) + const isDraggingRef = useRef(false) + const handleResizeStart = (e: React.MouseEvent) => { + e.preventDefault() + isDraggingRef.current = true + const startX = e.clientX + const startW = listPanelWidth + const onMove = (ev: MouseEvent) => { + if (!isDraggingRef.current) return + setListPanelWidth(Math.min(420, Math.max(180, startW + (ev.clientX - startX)))) + } + const onUp = () => { + isDraggingRef.current = false + window.removeEventListener('mousemove', onMove) + window.removeEventListener('mouseup', onUp) + } + window.addEventListener('mousemove', onMove) + window.addEventListener('mouseup', onUp) + } + const handleCreateNote = (noteType: NoteType = 'richtext') => { startCreating(async () => { try { @@ -815,8 +836,8 @@ export function NotesTabsView({ style={{ height: 'max(360px, min(85vh, calc(100vh - 9rem)))' }} data-testid="notes-grid-tabs" > - {/* ── Left panel: note list ── */} -
+ {/* ── Left panel: note list — resizable ── */} +
{/* Header */}
@@ -941,6 +962,15 @@ export function NotesTabsView({
+ {/* Resize handle */} +
+
+
+ {/* ── Right content panel ── */} {selected ? (
diff --git a/memento-note/scripts/add-resize.js b/memento-note/scripts/add-resize.js new file mode 100644 index 0000000..a26c06f --- /dev/null +++ b/memento-note/scripts/add-resize.js @@ -0,0 +1,60 @@ +const fs = require('fs'); +const path = require('path'); + +const filePath = path.join(__dirname, '..', 'components', 'notes-tabs-view.tsx'); +let src = fs.readFileSync(filePath, 'utf8'); + +const insertCode = ` + // Resizable left panel + const [listPanelWidth, setListPanelWidth] = useState(256) + const isDraggingRef = useRef(false) + + const handleResizeStart = (e) => { + e.preventDefault() + isDraggingRef.current = true + const startX = e.clientX + const startW = listPanelWidth + const onMove = (ev) => { + if (!isDraggingRef.current) return + setListPanelWidth(Math.min(420, Math.max(180, startW + (ev.clientX - startX)))) + } + const onUp = () => { + isDraggingRef.current = false + window.removeEventListener('mousemove', onMove) + window.removeEventListener('mouseup', onUp) + } + window.addEventListener('mousemove', onMove) + window.addEventListener('mouseup', onUp) + } + +`; + +// Insert before the return statement +const MARKER = ' return (\r\n