fix(brainstorm): notebookId URL param + lookup carnet + bouton 'Open notebook'
Some checks failed
CI / Lint, Unit Tests & Build (push) Failing after 4m13s
CI / Deploy production (on server) (push) Has been skipped

- brainstorm-page.tsx: lit urlNotebookId depuis URL params
- useConvertIdea accepte targetNotebookId (hook mis à jour)
- handleConvert prend le carnet ciblé en paramètre
- URL notebookId propage via router.push depuis le modal de confirmation
- toast inclut le nom du carnet et un bouton 'Open notebook' qui redirige vers /home?notebook=X
- peek panel affiche un lien vers le carnet source en haut du titre
- useNotebooks pour le lookup du nom depuis notebooks

Vrai fix: les notes vont maintenant là où l'utilisateur a choisi,
pas dans un carnet auto-créé sans qu'il s'en aperçoive.
This commit is contained in:
Antigravity
2026-07-05 20:01:12 +00:00
parent 02b835fb13
commit 5aa7202abe
4 changed files with 31 additions and 9 deletions

View File

@@ -1,5 +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'
@@ -80,12 +81,14 @@ 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('')
@@ -242,17 +245,25 @@ export function BrainstormPage() {
} catch {}
}
const handleConvert = async (idea: BrainstormIdea) => {
const handleConvert = async (idea: BrainstormIdea, targetNotebookId: string | null = urlNotebookId) => {
try {
const result = await convertIdea.mutateAsync({ ideaId: idea.id, notebookId: null })
const result = await convertIdea.mutateAsync({ ideaId: idea.id, notebookId: targetNotebookId })
if (result?.id) {
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,
description: `${result.title || idea.title} → 📁 ${nbName}`,
action: {
label: t('notePeek.openFully') || 'Open',
onClick: () => router.push(`/home?openNote=${result.id}`),
label: t('brainstorm.openNotebook') || 'Open notebook',
onClick: () => {
if (result.notebookId) router.push(`/home?notebook=${result.notebookId}`)
else router.push('/home')
},
},
duration: 10000,
duration: 15000,
})
peek.open(result.id)
}

View File

@@ -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>

View File

@@ -3076,7 +3076,8 @@
"noNotebook": "No notebook",
"launching": "Launching…",
"launch": "Brainstorm",
"noteCreatedIn": "Note created in"
"noteCreatedIn": "Note created in",
"openNotebook": "Open notebook"
},
"byokSettings": {
"title": "Your API keys (BYOK)",

View File

@@ -3080,7 +3080,8 @@
"noNotebook": "Aucun carnet",
"launching": "Lancement…",
"launch": "Brainstormer",
"noteCreatedIn": "Note créée dans"
"noteCreatedIn": "Note créée dans",
"openNotebook": "Ouvrir le carnet"
},
"byokSettings": {
"title": "Vos clés API (BYOK)",