Compare commits
9 Commits
6e13b6d207
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea326a10b4 | ||
|
|
f97c5e8ec4 | ||
|
|
4d029d3ebe | ||
|
|
5eba211061 | ||
|
|
f44a0f9c68 | ||
|
|
a99d1dafb2 | ||
|
|
5aa7202abe | ||
|
|
02b835fb13 | ||
|
|
d1336b1fea |
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"version": 1,
|
||||
"lastRunAtMs": 1783196565768,
|
||||
"turnsSinceLastRun": 5,
|
||||
"turnsSinceLastRun": 7,
|
||||
"lastTranscriptMtimeMs": 1783196565691.0437,
|
||||
"lastProcessedGenerationId": "7ac52bd5-5714-460a-9c3b-e4b21907d6d7",
|
||||
"lastProcessedGenerationId": "71df05a3-2a54-46fa-aa10-c8b8357c33fd",
|
||||
"trialStartedAtMs": null
|
||||
}
|
||||
|
||||
@@ -91,24 +91,6 @@ jobs:
|
||||
-d "parse_mode=Markdown" || true
|
||||
fi
|
||||
|
||||
- name: Pack web artifact for deploy
|
||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||
working-directory: memento-note
|
||||
run: |
|
||||
tar czf ../web-artifact.tgz \
|
||||
.next/standalone .next/static public prisma \
|
||||
node_modules/.prisma node_modules/@prisma node_modules/prisma \
|
||||
docker-entrypoint.sh socket-server.ts tsconfig.json
|
||||
ls -lh ../web-artifact.tgz
|
||||
|
||||
- name: Upload web artifact
|
||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: web-artifact
|
||||
path: web-artifact.tgz
|
||||
retention-days: 2
|
||||
|
||||
deploy:
|
||||
name: Deploy production (on server)
|
||||
needs: ci
|
||||
@@ -123,10 +105,32 @@ jobs:
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
|
||||
- name: Download web artifact
|
||||
uses: actions/download-artifact@v3
|
||||
# Build sur docker-host : évite upload-artifact Gitea (souvent cassé en prod).
|
||||
- name: Setup Node 22
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
name: web-artifact
|
||||
node-version: "22"
|
||||
|
||||
- name: Build web artifact on server
|
||||
working-directory: /opt/memento/memento-note
|
||||
run: |
|
||||
set -euo pipefail
|
||||
npm ci --legacy-peer-deps
|
||||
npx prisma generate
|
||||
npm run build
|
||||
for p in .next/standalone .next/static public prisma; do
|
||||
[ -e "$p" ] || { echo "Missing build output: $p"; exit 1; }
|
||||
done
|
||||
tar czf /tmp/web-artifact.tgz \
|
||||
.next/standalone .next/static public prisma \
|
||||
node_modules/.prisma node_modules/@prisma node_modules/prisma \
|
||||
docker-entrypoint.sh socket-server.ts tsconfig.json
|
||||
SIZE=$(stat -c%s /tmp/web-artifact.tgz)
|
||||
if [ "$SIZE" -lt 1048576 ]; then
|
||||
echo "ERROR: artifact too small ($SIZE bytes)"
|
||||
exit 1
|
||||
fi
|
||||
ls -lh /tmp/web-artifact.tgz
|
||||
|
||||
- name: Update .env.docker
|
||||
env:
|
||||
@@ -238,6 +242,6 @@ jobs:
|
||||
|
||||
- name: Deploy on 192.168.1.190
|
||||
env:
|
||||
ARTIFACT_TGZ: ${{ github.workspace }}/web-artifact.tgz
|
||||
ARTIFACT_TGZ: /tmp/web-artifact.tgz
|
||||
EXPECTED_COMMIT: ${{ github.sha }}
|
||||
run: bash /opt/memento/scripts/deploy-prod.sh
|
||||
|
||||
49
.github/workflows/ci.yaml
vendored
49
.github/workflows/ci.yaml
vendored
@@ -91,25 +91,6 @@ jobs:
|
||||
-d "parse_mode=Markdown" || true
|
||||
fi
|
||||
|
||||
- name: Pack web artifact for deploy
|
||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||
working-directory: memento-note
|
||||
run: |
|
||||
tar czf ../web-artifact.tgz \
|
||||
.next/standalone .next/static public prisma \
|
||||
node_modules/.prisma node_modules/@prisma node_modules/prisma \
|
||||
docker-entrypoint.sh socket-server.ts tsconfig.json
|
||||
ls -lh ../web-artifact.tgz
|
||||
|
||||
- name: Upload web artifact
|
||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||
uses: actions/upload-artifact@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: web-artifact
|
||||
path: web-artifact.tgz
|
||||
retention-days: 2
|
||||
|
||||
deploy:
|
||||
name: Deploy production (on server)
|
||||
needs: ci
|
||||
@@ -124,11 +105,31 @@ jobs:
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
|
||||
- name: Download web artifact
|
||||
uses: actions/download-artifact@v3
|
||||
continue-on-error: true
|
||||
- name: Setup Node 22
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
name: web-artifact
|
||||
node-version: "22"
|
||||
|
||||
- name: Build web artifact on server
|
||||
working-directory: /opt/memento/memento-note
|
||||
run: |
|
||||
set -euo pipefail
|
||||
npm ci --legacy-peer-deps
|
||||
npx prisma generate
|
||||
npm run build
|
||||
for p in .next/standalone .next/static public prisma; do
|
||||
[ -e "$p" ] || { echo "Missing build output: $p"; exit 1; }
|
||||
done
|
||||
tar czf /tmp/web-artifact.tgz \
|
||||
.next/standalone .next/static public prisma \
|
||||
node_modules/.prisma node_modules/@prisma node_modules/prisma \
|
||||
docker-entrypoint.sh socket-server.ts tsconfig.json
|
||||
SIZE=$(stat -c%s /tmp/web-artifact.tgz)
|
||||
if [ "$SIZE" -lt 1048576 ]; then
|
||||
echo "ERROR: artifact too small ($SIZE bytes)"
|
||||
exit 1
|
||||
fi
|
||||
ls -lh /tmp/web-artifact.tgz
|
||||
|
||||
- name: Update .env.docker
|
||||
env:
|
||||
@@ -229,6 +230,6 @@ jobs:
|
||||
|
||||
- name: Deploy on 192.168.1.190
|
||||
env:
|
||||
ARTIFACT_TGZ: ${{ github.workspace }}/web-artifact.tgz
|
||||
ARTIFACT_TGZ: /tmp/web-artifact.tgz
|
||||
EXPECTED_COMMIT: ${{ github.sha }}
|
||||
run: bash /opt/memento/scripts/deploy-prod.sh
|
||||
|
||||
@@ -7,6 +7,7 @@ import { detectUserLanguage, parseAcceptLanguage } from "@/lib/i18n/detect-user-
|
||||
import { loadTranslations } from "@/lib/i18n/load-translations";
|
||||
import { getAISettings } from "@/app/actions/ai-settings";
|
||||
import { AIChatLayoutBridge } from "@/components/ai-chat-layout-bridge";
|
||||
import { SidebarResizeClient } from "@/components/sidebar-resize-client";
|
||||
|
||||
|
||||
export default async function MainLayout({
|
||||
@@ -36,8 +37,8 @@ export default async function MainLayout({
|
||||
initialAiProcessingConsent={aiSettings?.aiProcessingConsent === true}
|
||||
>
|
||||
{/* No top-bar header — sidebar-only navigation (architectural-grid design) */}
|
||||
<div className="flex h-screen overflow-hidden bg-memento-desk dark:bg-background">
|
||||
<Suspense fallback={<div className="hidden w-80 md:w-[26rem] 2xl:w-[30rem] shrink-0 md:block h-full self-stretch" />}>
|
||||
<SidebarResizeClient>
|
||||
<Suspense fallback={<div className="hidden w-80 shrink-0 md:block h-full self-stretch" />}>
|
||||
<Sidebar user={session?.user} />
|
||||
</Suspense>
|
||||
|
||||
@@ -47,9 +48,9 @@ export default async function MainLayout({
|
||||
</a>
|
||||
{children}
|
||||
</main>
|
||||
</SidebarResizeClient>
|
||||
|
||||
{showAIAssistant && <AIChatLayoutBridge />}
|
||||
</div>
|
||||
{showAIAssistant && <AIChatLayoutBridge />}
|
||||
</ProvidersWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { emitToSession } from '@/lib/socket-emit'
|
||||
|
||||
const convertSchema = z.object({
|
||||
ideaId: z.string().min(1),
|
||||
notebookId: z.string().min(1).nullable().optional(),
|
||||
})
|
||||
|
||||
export async function POST(
|
||||
@@ -21,7 +22,7 @@ export async function POST(
|
||||
try {
|
||||
const { sessionId } = await params
|
||||
const body = await request.json()
|
||||
const { ideaId } = convertSchema.parse(body)
|
||||
const { ideaId, notebookId: paramNotebookId } = convertSchema.parse(body)
|
||||
|
||||
const brainstormSession = await prisma.brainstormSession.findFirst({
|
||||
where: {
|
||||
@@ -51,7 +52,7 @@ export async function POST(
|
||||
}
|
||||
|
||||
let sourceSection = ''
|
||||
let targetNotebookId: string | null = null
|
||||
let targetNotebookId: string | null = paramNotebookId ?? null
|
||||
|
||||
if (brainstormSession.exportedNoteId) {
|
||||
const exportedNote = await prisma.note.findUnique({
|
||||
|
||||
181
memento-note/components/brainstorm/brainstorm-confirm-dialog.tsx
Normal file
181
memento-note/components/brainstorm/brainstorm-confirm-dialog.tsx
Normal file
@@ -0,0 +1,181 @@
|
||||
'use client'
|
||||
|
||||
import { useState, memo } from 'react'
|
||||
import { motion, AnimatePresence } from 'motion/react'
|
||||
import { Wind, FolderOpen, X, Loader2, ChevronDown } from 'lucide-react'
|
||||
import { useLanguage } from '@/lib/i18n'
|
||||
import { useNotebooks } from '@/context/notebooks-context'
|
||||
import type { Note } from '@/lib/types'
|
||||
|
||||
interface BrainstormConfirmDialogProps {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
onConfirm: (notebookId: string | null) => void
|
||||
note: Note | null
|
||||
}
|
||||
|
||||
function BrainstormConfirmDialogInner({ open, onClose, onConfirm, note }: BrainstormConfirmDialogProps) {
|
||||
const { t } = useLanguage()
|
||||
const { notebooks } = useNotebooks()
|
||||
const [showNotebookSelect, setShowNotebookSelect] = useState(false)
|
||||
|
||||
const noteNotebook = notebooks.find(nb => nb.id === note?.notebookId)
|
||||
const defaultNotebookName = noteNotebook?.name || t('brainstorm.defaultNotebook') || 'Brainstorm'
|
||||
const defaultNotebookId = note?.notebookId ?? null
|
||||
|
||||
const [selectedNotebookId, setSelectedNotebookId] = useState<string | null>(defaultNotebookId)
|
||||
const [selectedNotebookName, setSelectedNotebookName] = useState(defaultNotebookName)
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const handleConfirm = () => {
|
||||
setLoading(true)
|
||||
onConfirm(selectedNotebookId)
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
setLoading(false)
|
||||
setSelectedNotebookId(defaultNotebookId)
|
||||
setSelectedNotebookName(defaultNotebookName)
|
||||
setShowNotebookSelect(false)
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{open && note && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{ duration: 0.2 }}
|
||||
className="fixed inset-0 z-[100] flex items-center justify-center bg-black/40 backdrop-blur-sm p-4"
|
||||
onClick={(e) => { if (e.target === e.currentTarget) handleClose() }}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={t('brainstorm.confirmTitle') || 'Brainstorm this idea'}
|
||||
>
|
||||
<motion.div
|
||||
initial={{ scale: 0.92, y: 20 }}
|
||||
animate={{ scale: 1, y: 0 }}
|
||||
exit={{ scale: 0.92, y: 20 }}
|
||||
transition={{ type: 'spring', stiffness: 340, damping: 30 }}
|
||||
className="bg-memento-paper dark:bg-zinc-900 rounded-3xl shadow-2xl border border-border/40 w-full max-w-md overflow-hidden"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* Header */}
|
||||
<div className="px-6 py-5 border-b border-border/20 flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-9 h-9 rounded-xl bg-brand-accent/10 flex items-center justify-center">
|
||||
<Wind size={16} className="text-brand-accent" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="font-memento-serif text-base font-medium text-ink dark:text-dark-ink">
|
||||
{t('brainstorm.confirmTitle') || 'Brainstorm this idea'}
|
||||
</h3>
|
||||
<p className="text-[10px] text-concrete uppercase tracking-widest font-bold">
|
||||
{t('brainstorm.confirmSubtitle') || 'AI will expand your idea'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleClose}
|
||||
className="p-1.5 rounded-lg text-concrete hover:text-ink hover:bg-black/5 dark:hover:bg-white/5 transition-colors cursor-pointer"
|
||||
aria-label={t('common.close') || 'Close'}
|
||||
>
|
||||
<X size={16} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Body */}
|
||||
<div className="px-6 py-5 space-y-4">
|
||||
{/* Seed preview */}
|
||||
<div className="p-4 rounded-2xl bg-white/60 dark:bg-white/5 border border-border/30">
|
||||
<p className="text-[10px] uppercase tracking-widest font-bold text-concrete mb-2">
|
||||
{t('brainstorm.seedLabel') || 'Seed idea'}
|
||||
</p>
|
||||
<p className="text-sm font-memento-serif text-ink dark:text-dark-ink leading-relaxed line-clamp-3">
|
||||
{note.title || t('notes.untitled')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Destination notebook */}
|
||||
<div>
|
||||
<p className="text-[10px] uppercase tracking-widest font-bold text-concrete mb-2">
|
||||
{t('brainstorm.destinationLabel') || 'Notes will be saved to'}
|
||||
</p>
|
||||
<button
|
||||
onClick={() => setShowNotebookSelect(!showNotebookSelect)}
|
||||
className="w-full flex items-center justify-between p-3 rounded-xl bg-white/60 dark:bg-white/5 border border-border/30 hover:border-brand-accent/40 transition-colors cursor-pointer"
|
||||
>
|
||||
<div className="flex items-center gap-2.5">
|
||||
<div className="w-7 h-7 rounded-lg bg-brand-accent/10 flex items-center justify-center shrink-0">
|
||||
<FolderOpen size={13} className="text-brand-accent" />
|
||||
</div>
|
||||
<span className="text-sm font-medium text-ink dark:text-dark-ink truncate">
|
||||
{selectedNotebookName}
|
||||
</span>
|
||||
</div>
|
||||
<ChevronDown size={14} className={`text-concrete transition-transform ${showNotebookSelect ? 'rotate-180' : ''}`} />
|
||||
</button>
|
||||
<AnimatePresence>
|
||||
{showNotebookSelect && (
|
||||
<motion.div
|
||||
initial={{ height: 0, opacity: 0 }}
|
||||
animate={{ height: 'auto', opacity: 1 }}
|
||||
exit={{ height: 0, opacity: 0 }}
|
||||
transition={{ duration: 0.2 }}
|
||||
className="overflow-hidden"
|
||||
>
|
||||
<div className="mt-1 max-h-48 overflow-y-auto rounded-xl border border-border/30 bg-white dark:bg-zinc-800 shadow-lg">
|
||||
<button
|
||||
onClick={() => { setSelectedNotebookId(null); setSelectedNotebookName(t('brainstorm.noNotebook') || 'No notebook'); setShowNotebookSelect(false) }}
|
||||
className="w-full text-left px-3 py-2.5 hover:bg-brand-accent/5 transition-colors text-sm text-concrete cursor-pointer"
|
||||
>
|
||||
{t('brainstorm.noNotebook') || 'No notebook'}
|
||||
</button>
|
||||
{notebooks.map(nb => (
|
||||
<button
|
||||
key={nb.id}
|
||||
onClick={() => { setSelectedNotebookId(nb.id); setSelectedNotebookName(nb.name); setShowNotebookSelect(false) }}
|
||||
className={`w-full text-left px-3 py-2.5 hover:bg-brand-accent/5 transition-colors text-sm cursor-pointer flex items-center gap-2 ${selectedNotebookId === nb.id ? 'text-brand-accent font-medium' : 'text-ink dark:text-dark-ink'}`}
|
||||
>
|
||||
<FolderOpen size={12} className="shrink-0 opacity-50" />
|
||||
<span className="truncate">{nb.name}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="px-6 py-4 border-t border-border/20 flex items-center justify-end gap-3">
|
||||
<button
|
||||
onClick={handleClose}
|
||||
disabled={loading}
|
||||
className="px-4 py-2.5 rounded-xl text-sm font-medium text-concrete hover:text-ink hover:bg-black/5 dark:hover:bg-white/5 transition-colors cursor-pointer"
|
||||
>
|
||||
{t('common.cancel')}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleConfirm}
|
||||
disabled={loading}
|
||||
className="px-5 py-2.5 rounded-xl bg-brand-accent text-white text-sm font-bold uppercase tracking-wider hover:bg-brand-accent/90 transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-2"
|
||||
>
|
||||
{loading ? (
|
||||
<><Loader2 size={14} className="animate-spin" /> {t('brainstorm.launching') || 'Launching…'}</>
|
||||
) : (
|
||||
<><Wind size={14} /> {t('brainstorm.launch') || 'Brainstorm'}</>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
)
|
||||
}
|
||||
|
||||
export const BrainstormConfirmDialog = memo(BrainstormConfirmDialogInner)
|
||||
@@ -1,4 +1,6 @@
|
||||
'use client'
|
||||
import { toast } from 'sonner'
|
||||
import { useNotebooks } from '@/context/notebooks-context'
|
||||
|
||||
import React, { useState, useMemo, useEffect, useRef, useCallback } from 'react'
|
||||
import { useRouter, useSearchParams } from 'next/navigation'
|
||||
@@ -26,9 +28,11 @@ import {
|
||||
LayoutGrid,
|
||||
X,
|
||||
Edit2,
|
||||
Maximize2,
|
||||
} from 'lucide-react'
|
||||
import dynamic from 'next/dynamic'
|
||||
import { useLanguage } from '@/lib/i18n'
|
||||
import { useNotePeek, NotePeekPanel } from '@/components/note-peek'
|
||||
import {
|
||||
useBrainstormSession,
|
||||
useBrainstormSessions,
|
||||
@@ -50,6 +54,7 @@ import {
|
||||
import { useBrainstormSocket } from '@/hooks/use-brainstorm-socket'
|
||||
import { LiveCursors, PresenceAvatars, useCursorTracking } from '@/components/brainstorm/live-cursors'
|
||||
import { ActivityFeed } from '@/components/brainstorm/activity-feed'
|
||||
import { ConvertNotebookDialog } from './convert-notebook-dialog'
|
||||
import { BrainstormShareDialog } from '@/components/brainstorm/brainstorm-share-dialog'
|
||||
import { GhostCursor } from '@/components/brainstorm/ghost-cursor'
|
||||
import { PlaybackBar } from '@/components/brainstorm/playback-bar'
|
||||
@@ -76,12 +81,15 @@ const WAVE_COLORS: Record<number, { border: string; bg: string; text: string }>
|
||||
|
||||
export function BrainstormPage() {
|
||||
const router = useRouter()
|
||||
const peek = useNotePeek()
|
||||
const { notebooks } = useNotebooks()
|
||||
const searchParams = useSearchParams()
|
||||
const { t, language } = useLanguage()
|
||||
const { data: authSession } = useSession()
|
||||
const urlSessionId = searchParams.get('session')
|
||||
const urlSeed = searchParams.get('seed')
|
||||
const urlSourceNoteId = searchParams.get('sourceNoteId')
|
||||
const urlNotebookId = searchParams.get('notebookId')
|
||||
const urlInviteToken = searchParams.get('invite')
|
||||
|
||||
const [seedInput, setSeedInput] = useState('')
|
||||
@@ -102,8 +110,9 @@ export function BrainstormPage() {
|
||||
|
||||
const { data: sessions, isLoading: sessionsLoading } = useBrainstormSessions()
|
||||
|
||||
// Auto-sélectionner la dernière session si aucune session active
|
||||
// Auto-sélectionner la dernière session si aucune session active ET pas de seed dans l'URL
|
||||
useEffect(() => {
|
||||
if (urlSeed || urlInviteToken) return // Ne pas auto-select si on arrive avec un seed
|
||||
if (!activeSessionId && !urlSessionId && !sessionsLoading && sessions && sessions.length > 0) {
|
||||
const last = sessions[0]
|
||||
setActiveSessionId(last.id)
|
||||
@@ -121,6 +130,7 @@ export function BrainstormPage() {
|
||||
const expandIdea = useExpandIdea(activeSessionId || '')
|
||||
const dismissIdea = useDismissIdea(activeSessionId || '')
|
||||
const convertIdea = useConvertIdea(activeSessionId || '')
|
||||
const [convertConfirm, setConvertConfirm] = useState<BrainstormIdea | null>(null)
|
||||
const exportBrainstorm = useExportBrainstorm(activeSessionId || '')
|
||||
const finalizeBrainstorm = useFinalizeBrainstorm(activeSessionId || '')
|
||||
const deleteBrainstorm = useDeleteBrainstorm()
|
||||
@@ -132,8 +142,7 @@ export function BrainstormPage() {
|
||||
const renameSession = useRenameBrainstormSession(activeSessionId || '')
|
||||
const [impactToast, setImpactToast] = useState<{ notesEnriched: number; notesMarkedDry: number } | null>(null)
|
||||
const [exportError, setExportError] = useState<string | null>(null)
|
||||
const [exportToast, setExportToast] = useState<{ noteTitle: string; notebookName: string } | null>(null)
|
||||
const [convertToast, setConvertToast] = useState<{ noteTitle: string; noteId: string } | null>(null)
|
||||
|
||||
const [remoteMove, setRemoteMove] = useState<{ ideaId: string; x: number; y: number; _seq: number } | null>(null)
|
||||
const [playbackIdeas, setPlaybackIdeas] = useState<any[] | null>(null)
|
||||
const [viewMode, setViewMode] = useState<'canvas' | 'list'>('canvas')
|
||||
@@ -238,15 +247,27 @@ export function BrainstormPage() {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const handleConvert = async (idea: BrainstormIdea) => {
|
||||
const handleConvert = async (idea: BrainstormIdea, targetNotebookId: string | null = urlNotebookId) => {
|
||||
try {
|
||||
const result = await convertIdea.mutateAsync(idea.id)
|
||||
const result = await convertIdea.mutateAsync({ ideaId: idea.id, notebookId: targetNotebookId })
|
||||
if (result?.id) {
|
||||
setConvertToast({ noteTitle: result.title || idea.title, noteId: result.id })
|
||||
setTimeout(() => {
|
||||
setConvertToast(null)
|
||||
router.push(`/home?openNote=${result.id}`)
|
||||
}, 2000)
|
||||
let nbName = 'carnet'
|
||||
if (result.notebookId) {
|
||||
const nb = notebooks.find(n => n.id === result.notebookId)
|
||||
nbName = nb?.name || 'carnet'
|
||||
}
|
||||
toast.success(t('brainstorm.noteCreatedIn') || 'Note created', {
|
||||
description: `${result.title || idea.title} → 📁 ${nbName}`,
|
||||
action: {
|
||||
label: t('brainstorm.openNotebook') || 'Open notebook',
|
||||
onClick: () => {
|
||||
if (result.notebookId) router.push(`/home?notebook=${result.notebookId}`)
|
||||
else router.push('/home')
|
||||
},
|
||||
},
|
||||
duration: 15000,
|
||||
})
|
||||
peek.open(result.id)
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
@@ -287,11 +308,15 @@ export function BrainstormPage() {
|
||||
const result = await exportBrainstorm.mutateAsync()
|
||||
if (result?.id) {
|
||||
const notebookName = result._notebookName || t('brainstorm.exportDefaultNotebookName')
|
||||
setExportToast({ noteTitle: result.title || t('brainstorm.exportDefaultNoteTitle'), notebookName })
|
||||
setTimeout(() => {
|
||||
setExportToast(null)
|
||||
router.push(`/home?openNote=${result.id}`)
|
||||
}, 2000)
|
||||
toast.success(t('brainstorm.noteCreated') || 'Note created', {
|
||||
description: `${result.title || t('brainstorm.exportDefaultNoteTitle')} — ${notebookName}`,
|
||||
action: {
|
||||
label: t('notePeek.openFully') || 'Open',
|
||||
onClick: () => router.push(`/home?openNote=${result.id}`),
|
||||
},
|
||||
duration: 10000,
|
||||
})
|
||||
peek.open(result.id)
|
||||
return
|
||||
}
|
||||
const impact = await finalizeBrainstorm.mutateAsync()
|
||||
@@ -729,9 +754,13 @@ export function BrainstormPage() {
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{selectedIdea.status === 'converted' && (
|
||||
<span className="text-[10px] font-bold text-emerald-500 uppercase tracking-widest bg-emerald-500/10 px-2 py-1 rounded-full">
|
||||
{t('brainstorm.noteCreated') || 'Note Created'}
|
||||
</span>
|
||||
<button
|
||||
onClick={() => selectedIdea.convertedToNoteId && peek.open(selectedIdea.convertedToNoteId)}
|
||||
className="flex items-center gap-1.5 text-[10px] font-bold text-emerald-600 dark:text-emerald-400 uppercase tracking-widest bg-emerald-500/10 hover:bg-emerald-500/20 px-3 py-1.5 rounded-full transition-colors cursor-pointer"
|
||||
>
|
||||
<FileText size={11} />
|
||||
{t('brainstorm.noteCreated') || 'Note Created'} →
|
||||
</button>
|
||||
)}
|
||||
{canEdit && (
|
||||
<button
|
||||
@@ -846,7 +875,7 @@ export function BrainstormPage() {
|
||||
</div>
|
||||
{ref.noteId && (
|
||||
<button
|
||||
onClick={() => router.push(`/home?openNote=${ref.noteId}`)}
|
||||
onClick={() => ref.noteId && peek.open(ref.noteId)}
|
||||
className="shrink-0 px-2 py-1 text-[9px] font-bold uppercase tracking-wider rounded-lg bg-foreground/5 hover:bg-foreground/10 text-muted-foreground hover:text-foreground transition-all"
|
||||
>
|
||||
{t('brainstorm.viewNote') || 'View'}
|
||||
@@ -872,16 +901,28 @@ export function BrainstormPage() {
|
||||
{expandIdea.isPending ? (t('brainstorm.deepening') || 'Generating...') : (t('brainstorm.deepen') || 'Deepen')}
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleConvert(selectedIdea)}
|
||||
disabled={selectedIdea.status === 'converted' || convertIdea.isPending}
|
||||
className="flex flex-col items-center justify-center p-6 border-2 border-dashed border-border rounded-2xl hover:border-emerald-400/40 hover:bg-emerald-500/5 transition-all group disabled:opacity-50"
|
||||
>
|
||||
<FileText size={24} className="text-muted-foreground group-hover:text-emerald-500 mb-2" />
|
||||
<span className="text-[11px] font-bold uppercase tracking-widest text-muted-foreground group-hover:text-foreground">
|
||||
{convertIdea.isPending ? (t('brainstorm.converting') || 'Converting...') : (t('brainstorm.extract') || 'Create Note')}
|
||||
</span>
|
||||
</button>
|
||||
{selectedIdea.status === 'converted' && selectedIdea.convertedToNoteId ? (
|
||||
<button
|
||||
onClick={() => selectedIdea.convertedToNoteId && peek.open(selectedIdea.convertedToNoteId)}
|
||||
className="flex flex-col items-center justify-center p-6 border-2 border-emerald-400/40 bg-emerald-500/5 rounded-2xl hover:bg-emerald-500/10 transition-all group"
|
||||
>
|
||||
<FileText size={24} className="text-emerald-500 mb-2" />
|
||||
<span className="text-[11px] font-bold uppercase tracking-widest text-emerald-600 dark:text-emerald-400">
|
||||
{t('brainstorm.openNote') || 'Open Note'} →
|
||||
</span>
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={() => setConvertConfirm(selectedIdea)}
|
||||
disabled={convertIdea.isPending}
|
||||
className="flex flex-col items-center justify-center p-6 border-2 border-dashed border-border rounded-2xl hover:border-emerald-400/40 hover:bg-emerald-500/5 transition-all group disabled:opacity-50"
|
||||
>
|
||||
<FileText size={24} className="text-muted-foreground group-hover:text-emerald-500 mb-2" />
|
||||
<span className="text-[11px] font-bold uppercase tracking-widest text-muted-foreground group-hover:text-foreground">
|
||||
{convertIdea.isPending ? (t('brainstorm.converting') || 'Converting...') : (t('brainstorm.extract') || 'Create Note')}
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<button
|
||||
@@ -1124,49 +1165,29 @@ export function BrainstormPage() {
|
||||
)}
|
||||
</AnimatePresence>
|
||||
|
||||
<AnimatePresence>
|
||||
{exportToast && (
|
||||
<motion.div
|
||||
initial={{ y: 100, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
exit={{ y: 100, opacity: 0 }}
|
||||
className="fixed bottom-8 left-1/2 -translate-x-1/2 z-50 px-6 py-4 bg-emerald-600 text-white rounded-2xl shadow-2xl flex items-center gap-3 text-sm font-medium"
|
||||
>
|
||||
<Wind size={18} />
|
||||
<div className="flex flex-col">
|
||||
<span className="font-bold">{exportToast.noteTitle}</span>
|
||||
<span className="text-[11px] text-emerald-100">
|
||||
{t('brainstorm.exportNotebookPrefix')} {exportToast.notebookName}
|
||||
</span>
|
||||
</div>
|
||||
<div className="ml-3 flex items-center gap-1.5 text-emerald-200 text-[10px]">
|
||||
<div className="w-1.5 h-1.5 rounded-full bg-emerald-300 animate-pulse" />
|
||||
{t('brainstorm.exportOpening')}
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
{/* Peek panel — drawer latéral pour aperçu note sans quitter le brainstorm */}
|
||||
<NotePeekPanel
|
||||
note={peek.note}
|
||||
blockId={peek.blockId}
|
||||
loading={peek.loading}
|
||||
mode="overlay"
|
||||
onClose={peek.close}
|
||||
onOpenFully={(n) => { router.push(`/home?openNote=${n.id}`); peek.close() }}
|
||||
/>
|
||||
|
||||
<AnimatePresence>
|
||||
{convertToast && (
|
||||
<motion.div
|
||||
initial={{ y: 100, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
exit={{ y: 100, opacity: 0 }}
|
||||
className="fixed bottom-8 left-1/2 -translate-x-1/2 z-50 px-6 py-4 bg-emerald-600 text-white rounded-2xl shadow-2xl flex items-center gap-3 text-sm font-medium"
|
||||
>
|
||||
<FileText size={18} />
|
||||
<div className="flex flex-col">
|
||||
<span className="font-bold">{convertToast.noteTitle}</span>
|
||||
<span className="text-[11px] text-emerald-100">{t('brainstorm.noteCreated') || 'Note Created'}</span>
|
||||
</div>
|
||||
<div className="ml-3 flex items-center gap-1.5 text-emerald-200 text-[10px]">
|
||||
<div className="w-1.5 h-1.5 rounded-full bg-emerald-300 animate-pulse" />
|
||||
{t('brainstorm.exportOpening')}
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
{/* Dialog de sélection de carnet pour la conversion */}
|
||||
<ConvertNotebookDialog
|
||||
open={convertConfirm !== null}
|
||||
idea={convertConfirm}
|
||||
notebooks={notebooks}
|
||||
defaultNotebookId={urlNotebookId}
|
||||
onClose={() => setConvertConfirm(null)}
|
||||
onConfirm={(notebookId) => {
|
||||
if (!convertConfirm) return
|
||||
handleConvert(convertConfirm, notebookId)
|
||||
setConvertConfirm(null)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
157
memento-note/components/brainstorm/convert-notebook-dialog.tsx
Normal file
157
memento-note/components/brainstorm/convert-notebook-dialog.tsx
Normal file
@@ -0,0 +1,157 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { motion, AnimatePresence } from 'motion/react'
|
||||
import { FileText, FolderOpen, ChevronDown, Loader2, X } from 'lucide-react'
|
||||
import { useLanguage } from '@/lib/i18n'
|
||||
import type { Notebook } from '@/lib/types'
|
||||
|
||||
interface ConvertNotebookDialogProps {
|
||||
open: boolean
|
||||
idea: { id: string; title: string } | null
|
||||
notebooks: Notebook[]
|
||||
defaultNotebookId: string | null | undefined
|
||||
onClose: () => void
|
||||
onConfirm: (notebookId: string | null) => void
|
||||
}
|
||||
|
||||
export function ConvertNotebookDialog({ open, idea, notebooks, defaultNotebookId, onClose, onConfirm }: ConvertNotebookDialogProps) {
|
||||
const { t } = useLanguage()
|
||||
const [showNotebookSelect, setShowNotebookSelect] = useState(false)
|
||||
const [selectedNotebookId, setSelectedNotebookId] = useState<string | null>(defaultNotebookId ?? null)
|
||||
const selectedNotebook = notebooks.find(nb => nb.id === selectedNotebookId)
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const handleConfirm = () => {
|
||||
setLoading(true)
|
||||
onConfirm(selectedNotebookId)
|
||||
}
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{open && idea && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{ duration: 0.2 }}
|
||||
className="fixed inset-0 z-[90] flex items-center justify-center bg-black/40 backdrop-blur-sm p-4"
|
||||
onClick={(e) => { if (e.target === e.currentTarget) onClose() }}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={t('brainstorm.convertTitle') || 'Create note from idea'}
|
||||
>
|
||||
<motion.div
|
||||
initial={{ scale: 0.92, y: 20 }}
|
||||
animate={{ scale: 1, y: 0 }}
|
||||
exit={{ scale: 0.92, y: 20 }}
|
||||
transition={{ type: 'spring', stiffness: 340, damping: 30 }}
|
||||
className="bg-memento-paper dark:bg-zinc-900 rounded-3xl shadow-2xl border border-border/40 w-full max-w-md overflow-hidden"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="px-6 py-5 border-b border-border/20 flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-9 h-9 rounded-xl bg-emerald-500/10 flex items-center justify-center">
|
||||
<FileText size={16} className="text-emerald-600 dark:text-emerald-400" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="font-memento-serif text-base font-medium text-ink dark:text-dark-ink">
|
||||
{t('brainstorm.convertTitle') || 'Create note from idea'}
|
||||
</h3>
|
||||
<p className="text-[10px] text-concrete uppercase tracking-widest font-bold">
|
||||
{t('brainstorm.convertSubtitle') || 'Choose where to save this note'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="p-1.5 rounded-lg text-concrete hover:text-ink hover:bg-black/5 dark:hover:bg-white/5 transition-colors cursor-pointer"
|
||||
aria-label={t('common.close') || 'Close'}
|
||||
>
|
||||
<X size={16} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="px-6 py-5 space-y-4">
|
||||
<div className="p-4 rounded-2xl bg-white/60 dark:bg-white/5 border border-border/30">
|
||||
<p className="text-[10px] uppercase tracking-widest font-bold text-concrete mb-2">
|
||||
{t('brainstorm.ideaLabel') || 'Idea'}
|
||||
</p>
|
||||
<p className="text-sm font-memento-serif text-ink dark:text-dark-ink leading-relaxed line-clamp-3">
|
||||
{idea.title}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p className="text-[10px] uppercase tracking-widest font-bold text-concrete mb-2">
|
||||
{t('brainstorm.destinationLabel') || 'Notes will be saved to'}
|
||||
</p>
|
||||
<button
|
||||
onClick={() => setShowNotebookSelect(!showNotebookSelect)}
|
||||
className="w-full flex items-center justify-between p-3 rounded-xl bg-white/60 dark:bg-white/5 border border-border/30 hover:border-emerald-500/40 transition-colors cursor-pointer"
|
||||
>
|
||||
<div className="flex items-center gap-2.5">
|
||||
<div className="w-7 h-7 rounded-lg bg-emerald-500/10 flex items-center justify-center shrink-0">
|
||||
<FolderOpen size={13} className="text-emerald-600" />
|
||||
</div>
|
||||
<span className="text-sm font-medium text-ink dark:text-dark-ink truncate">
|
||||
{selectedNotebook?.name || t('brainstorm.noNotebook') || 'No notebook'}
|
||||
</span>
|
||||
</div>
|
||||
<ChevronDown size={14} className={`text-concrete transition-transform ${showNotebookSelect ? 'rotate-180' : ''}`} />
|
||||
</button>
|
||||
<AnimatePresence>
|
||||
{showNotebookSelect && (
|
||||
<motion.div
|
||||
initial={{ height: 0, opacity: 0 }}
|
||||
animate={{ height: 'auto', opacity: 1 }}
|
||||
exit={{ height: 0, opacity: 0 }}
|
||||
transition={{ duration: 0.2 }}
|
||||
className="overflow-hidden"
|
||||
>
|
||||
<div className="mt-1 max-h-48 overflow-y-auto rounded-xl border border-border/30 bg-white dark:bg-zinc-800 shadow-lg">
|
||||
<button
|
||||
onClick={() => { setSelectedNotebookId(null); setShowNotebookSelect(false) }}
|
||||
className="w-full text-left px-3 py-2.5 hover:bg-emerald-500/5 transition-colors text-sm text-concrete cursor-pointer"
|
||||
>
|
||||
{t('brainstorm.noNotebook') || 'No notebook'}
|
||||
</button>
|
||||
{notebooks.map(nb => (
|
||||
<button
|
||||
key={nb.id}
|
||||
onClick={() => { setSelectedNotebookId(nb.id); setShowNotebookSelect(false) }}
|
||||
className={`w-full text-left px-3 py-2.5 hover:bg-emerald-500/5 transition-colors text-sm cursor-pointer flex items-center gap-2 ${selectedNotebookId === nb.id ? 'text-emerald-600 font-medium' : 'text-ink dark:text-dark-ink'}`}
|
||||
>
|
||||
<FolderOpen size={12} className="shrink-0 opacity-50" />
|
||||
<span className="truncate">{nb.name}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="px-6 py-4 border-t border-border/20 flex items-center justify-end gap-3">
|
||||
<button
|
||||
onClick={onClose}
|
||||
disabled={loading}
|
||||
className="px-4 py-2.5 rounded-xl text-sm font-medium text-concrete hover:text-ink hover:bg-black/5 dark:hover:bg-white/5 transition-colors cursor-pointer"
|
||||
>
|
||||
{t('common.cancel')}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleConfirm}
|
||||
disabled={loading}
|
||||
className="px-5 py-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-700 text-white text-sm font-bold uppercase tracking-wider transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-2"
|
||||
>
|
||||
{loading ? <><Loader2 size={14} className="animate-spin" /> {t('common.creating') || 'Creating…'}</> : <><FileText size={14} /> {t('brainstorm.createNote') || 'Create note'}</>}
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
)
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { type ReactNode } from 'react'
|
||||
import { motion, AnimatePresence, useReducedMotion } from 'motion/react'
|
||||
import { X, Maximize2, Loader2 } from 'lucide-react'
|
||||
import { X, Maximize2, Loader2, FolderOpen } from 'lucide-react'
|
||||
import { useLanguage } from '@/lib/i18n'
|
||||
import type { Note } from '@/lib/types'
|
||||
import { NotePeekContent } from './note-peek-content'
|
||||
@@ -77,6 +77,15 @@ export function NotePeekPanel({
|
||||
renderContent(note, blockId)
|
||||
) : (
|
||||
<>
|
||||
{note.notebookId && (
|
||||
<a
|
||||
href={`/home?notebook=${note.notebookId}`}
|
||||
className="inline-flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-widest text-brand-accent hover:text-brand-accent/70 transition-colors mb-2 cursor-pointer"
|
||||
>
|
||||
<FolderOpen size={11} />
|
||||
{t('brainstorm.openNotebook') || 'Open notebook'}
|
||||
</a>
|
||||
)}
|
||||
<h2 className="text-xl font-serif font-medium text-ink dark:text-dark-ink mb-6">
|
||||
{note.title || t('notePeek.untitled') || 'Untitled'}
|
||||
</h2>
|
||||
|
||||
@@ -50,6 +50,8 @@ import {
|
||||
} from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useHydrated } from '@/lib/use-hydrated'
|
||||
import dynamic from 'next/dynamic'
|
||||
const BrainstormConfirmDialog = dynamic(() => import('@/components/brainstorm/brainstorm-confirm-dialog').then(m => ({ default: m.BrainstormConfirmDialog })), { ssr: false })
|
||||
import { formatDistanceToNow } from 'date-fns'
|
||||
import { fr } from 'date-fns/locale/fr'
|
||||
import { enUS } from 'date-fns/locale/en-US'
|
||||
@@ -715,14 +717,23 @@ const GridCard = memo(function GridCard({
|
||||
aiIllustrationEnabled,
|
||||
onOpen,
|
||||
onTogglePin,
|
||||
onDeleteNote,
|
||||
onMoveToNotebook,
|
||||
onDeleteNote, onMoveToNotebook,
|
||||
onNoteIllustrationGenerated,
|
||||
onNoteIllustrationDeleted,
|
||||
onOpenHistory,
|
||||
isOverlay = false,
|
||||
}: GridCardSharedProps) {
|
||||
const router = useRouter()
|
||||
const [brainstormNote, setBrainstormNote] = useState<Note | null>(null)
|
||||
|
||||
const handleBrainstormConfirm = (notebookId: string | null) => {
|
||||
if (!brainstormNote) return
|
||||
const seed = `${brainstormNote.title || untitled}\n\n${getNotePlainExcerpt(brainstormNote, 200)}`.trim()
|
||||
const params = new URLSearchParams({ seed: seed.slice(0, 300), sourceNoteId: brainstormNote.id })
|
||||
if (notebookId) params.set('notebookId', notebookId)
|
||||
router.push(`/brainstorm?${params.toString()}`)
|
||||
setBrainstormNote(null)
|
||||
}
|
||||
const { t, language } = useLanguage()
|
||||
const hydrated = useHydrated()
|
||||
const title = getNoteDisplayTitle(note, untitled)
|
||||
@@ -741,11 +752,11 @@ const GridCard = memo(function GridCard({
|
||||
|
||||
const handleBrainstormClick = (e: React.MouseEvent) => {
|
||||
e.stopPropagation()
|
||||
const seed = `${title}\n\n${excerpt}`.trim() || title
|
||||
router.push(`/brainstorm?seed=${encodeURIComponent(seed.slice(0, 300))}&sourceNoteId=${note.id}`)
|
||||
setBrainstormNote(note)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<motion.div
|
||||
initial={isOverlay || !hydrated ? false : { opacity: 0, y: 15 }}
|
||||
animate={isOverlay ? undefined : { opacity: 1, y: 0 }}
|
||||
@@ -851,5 +862,13 @@ const GridCard = memo(function GridCard({
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
<BrainstormConfirmDialog
|
||||
open={brainstormNote !== null}
|
||||
onClose={() => setBrainstormNote(null)}
|
||||
onConfirm={(notebookId) => { if (brainstormNote) handleBrainstormConfirm(notebookId) }}
|
||||
note={brainstormNote}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
19
memento-note/components/sidebar-resize-client.tsx
Normal file
19
memento-note/components/sidebar-resize-client.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
'use client'
|
||||
|
||||
import { type ReactNode } from 'react'
|
||||
import { useSidebarResize, SidebarResizeHandle } from '@/components/sidebar-resize'
|
||||
|
||||
export function SidebarResizeClient({ children }: { children: ReactNode }) {
|
||||
const { width, isDragging, onPointerDown } = useSidebarResize()
|
||||
|
||||
return (
|
||||
<div className="flex h-screen overflow-hidden bg-memento-desk dark:bg-background">
|
||||
<div className="contents" style={{ ['--sidebar-width' as string]: `${width}px` }}>
|
||||
<div className="flex h-full" style={{ width: `${width}px` }}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
<SidebarResizeHandle onPointerDown={onPointerDown} isDragging={isDragging} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
81
memento-note/components/sidebar-resize.tsx
Normal file
81
memento-note/components/sidebar-resize.tsx
Normal file
@@ -0,0 +1,81 @@
|
||||
'use client'
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
|
||||
const STORAGE_KEY = 'memento-sidebar-width'
|
||||
const MIN = 280
|
||||
const MAX = 560
|
||||
|
||||
export function useSidebarResize() {
|
||||
const [width, setWidth] = useState(320)
|
||||
const [isDragging, setIsDragging] = useState(false)
|
||||
const startXRef = useRef(0)
|
||||
const startWidthRef = useRef(320)
|
||||
|
||||
useEffect(() => {
|
||||
const stored = localStorage.getItem(STORAGE_KEY)
|
||||
if (stored) {
|
||||
const parsed = parseInt(stored, 10)
|
||||
if (!isNaN(parsed) && parsed >= MIN && parsed <= MAX) {
|
||||
setWidth(parsed)
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const onPointerDown = useCallback((e: React.PointerEvent) => {
|
||||
e.preventDefault()
|
||||
setIsDragging(true)
|
||||
startXRef.current = e.clientX
|
||||
startWidthRef.current = width
|
||||
document.body.style.cursor = 'col-resize'
|
||||
document.body.style.userSelect = 'none'
|
||||
}, [width])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isDragging) return
|
||||
|
||||
const onPointerMove = (e: PointerEvent) => {
|
||||
const delta = e.clientX - startXRef.current
|
||||
const newWidth = Math.max(MIN, Math.min(MAX, startWidthRef.current + delta))
|
||||
setWidth(newWidth)
|
||||
}
|
||||
|
||||
const onPointerUp = () => {
|
||||
setIsDragging(false)
|
||||
document.body.style.cursor = ''
|
||||
document.body.style.userSelect = ''
|
||||
setWidth(prev => {
|
||||
localStorage.setItem(STORAGE_KEY, String(prev))
|
||||
return prev
|
||||
})
|
||||
}
|
||||
|
||||
document.addEventListener('pointermove', onPointerMove)
|
||||
document.addEventListener('pointerup', onPointerUp)
|
||||
return () => {
|
||||
document.removeEventListener('pointermove', onPointerMove)
|
||||
document.removeEventListener('pointerup', onPointerUp)
|
||||
}
|
||||
}, [isDragging])
|
||||
|
||||
return { width, isDragging, onPointerDown }
|
||||
}
|
||||
|
||||
export function SidebarResizeHandle({ onPointerDown, isDragging }: { onPointerDown: (e: React.PointerEvent) => void; isDragging: boolean }) {
|
||||
return (
|
||||
<div
|
||||
onPointerDown={onPointerDown}
|
||||
className={`hidden md:flex items-center justify-center w-1 shrink-0 cursor-col-resize transition-colors z-50 ${
|
||||
isDragging
|
||||
? 'bg-brand-accent w-[3px]'
|
||||
: 'bg-border/40 hover:bg-brand-accent/50 hover:w-[3px]'
|
||||
}`}
|
||||
style={{ touchAction: 'none' }}
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div className={`w-[2px] h-12 rounded-full transition-colors ${isDragging ? 'bg-brand-accent' : 'bg-border/60'}`} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export { MIN as SIDEBAR_MIN_WIDTH, MAX as SIDEBAR_MAX_WIDTH }
|
||||
@@ -154,12 +154,14 @@ export function useConvertIdea(sessionId: string) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (ideaId: string) => {
|
||||
mutationFn: async (args: string | { ideaId: string; notebookId?: string | null }) => {
|
||||
const ideaId = typeof args === 'string' ? args : args.ideaId
|
||||
const notebookId = typeof args === 'string' ? null : args.notebookId
|
||||
const res = await fetch(`/api/brainstorm/${sessionId}/convert`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'include',
|
||||
body: JSON.stringify({ ideaId }),
|
||||
body: JSON.stringify({ ideaId, notebookId }),
|
||||
})
|
||||
const data = await res.json()
|
||||
if (!data.success) throw new Error(data.error || 'Failed to convert idea')
|
||||
|
||||
@@ -2925,7 +2925,7 @@
|
||||
"noSessions": "No brainstorms yet",
|
||||
"startOne": "Start one",
|
||||
"sessions": "Brainstorms",
|
||||
"seedLabel": "Seed Idea",
|
||||
"seedLabel": "Seed idea",
|
||||
"ideaPromptDetailed": "Enter your idea, question, or topic to brainstorm...",
|
||||
"brainstormThisIdea": "Brainstorm this idea",
|
||||
"startBrainstorm": "Start Brainstorm",
|
||||
@@ -3068,7 +3068,19 @@
|
||||
"legendWave1": "Variations",
|
||||
"legendWave2": "Analogies",
|
||||
"legendWave3": "Disruptions",
|
||||
"legendConverted": "Converted"
|
||||
"legendConverted": "Converted",
|
||||
"confirmTitle": "Brainstorm this idea",
|
||||
"confirmSubtitle": "AI will expand your idea",
|
||||
"destinationLabel": "Notes will be saved to",
|
||||
"defaultNotebook": "Brainstorm",
|
||||
"noNotebook": "No notebook",
|
||||
"launching": "Launching…",
|
||||
"launch": "Brainstorm",
|
||||
"noteCreatedIn": "Note created in",
|
||||
"openNotebook": "Open notebook",
|
||||
"convertTitle": "Create note from idea",
|
||||
"convertSubtitle": "Choose where to save this note",
|
||||
"ideaLabel": "Idea"
|
||||
},
|
||||
"byokSettings": {
|
||||
"title": "Your API keys (BYOK)",
|
||||
|
||||
@@ -3072,7 +3072,19 @@
|
||||
"legendWave1": "Variations",
|
||||
"legendWave2": "Analogies",
|
||||
"legendWave3": "Disruptions",
|
||||
"legendConverted": "Convertie"
|
||||
"legendConverted": "Convertie",
|
||||
"confirmTitle": "Brainstormer cette idée",
|
||||
"confirmSubtitle": "L'IA va développer votre idée",
|
||||
"destinationLabel": "Les notes seront sauvegardées dans",
|
||||
"defaultNotebook": "Brainstorm",
|
||||
"noNotebook": "Aucun carnet",
|
||||
"launching": "Lancement…",
|
||||
"launch": "Brainstormer",
|
||||
"noteCreatedIn": "Note créée dans",
|
||||
"openNotebook": "Ouvrir le carnet",
|
||||
"convertTitle": "Créer une note depuis cette idée",
|
||||
"convertSubtitle": "Choisir où sauvegarder cette note",
|
||||
"ideaLabel": "Idée"
|
||||
},
|
||||
"byokSettings": {
|
||||
"title": "Vos clés API (BYOK)",
|
||||
|
||||
Reference in New Issue
Block a user