fix(sidebar): eliminate full page reloads and fix notebook actions visibility

- Fix createNotebookOptimistic to call loadNotebooks() + triggerRefresh()
  after POST, so new notebooks appear immediately without page reload
- Remove window.location.reload() from delete-notebook-dialog (context
  already handles state refresh)
- Rewrite edit-notebook-dialog to use updateNotebook() from context
  instead of raw fetch + full page reload
- Fix NoteRefreshContext: remove refreshKey from useCallback deps to
  prevent unstable triggerRefresh callback cascade
- Fix notebook actions menu visibility: consolidate NotebookActions and
  expand button into single positioned container with proper z-index
- Add actions menu to active/selected notebook (was previously missing)
- Use proper Notebook type instead of any in sidebar components
- Increase button pr-20 to pr-24 to reserve space for actions
- Remove redundant router.refresh() from create-notebook-dialog

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Sepehr Ramezani
2026-03-29 22:23:25 +02:00
parent 8daf50ac3f
commit 806f4c4eeb
7 changed files with 106 additions and 114 deletions

View File

@@ -1,7 +1,6 @@
'use client'
import { useState } from 'react'
import { useRouter } from 'next/navigation'
import { Plus, X, Folder, Briefcase, FileText, Zap, BarChart3, Globe, Sparkles, Book, Heart, Crown, Music, Building2 } from 'lucide-react'
import { Button } from '@/components/ui/button'
import {
@@ -47,7 +46,6 @@ interface CreateNotebookDialogProps {
}
export function CreateNotebookDialog({ open, onOpenChange }: CreateNotebookDialogProps) {
const router = useRouter()
const { t } = useLanguage()
const { createNotebookOptimistic } = useNotebooks()
const [name, setName] = useState('')
@@ -68,9 +66,8 @@ export function CreateNotebookDialog({ open, onOpenChange }: CreateNotebookDialo
icon: selectedIcon,
color: selectedColor,
})
// Close dialog — no full page reload needed
// Close dialog — context already updated sidebar state
onOpenChange?.(false)
router.refresh()
} catch (error) {
console.error('Failed to create notebook:', error)
} finally {