diff --git a/scripts/regressions.mjs b/scripts/regressions.mjs index de04e5b..3ca1f2f 100644 --- a/scripts/regressions.mjs +++ b/scripts/regressions.mjs @@ -439,24 +439,24 @@ try { await inboxColumn.locator('[data-bookmark-id="bookmark-3"]').waitFor() console.log('PASS: kanban drag reorders within a column and moves cards between columns') - // Page tabs share the persisted position with the sidebar; dragging a tab - // issues the complete order permutation and both surfaces reload. Reset the - // pin from the earlier metadata test so both pages are in one reorder group. + // The sidebar persists the complete order permutation (PUT /api/pages); + // drag b above a. Reset the pin from the earlier metadata test so both + // pages are in one reorder group. pages.get('a').pinned = false await page.goto(`${base}/pages`) - await page.locator('[data-page-tab="a"]').waitFor() - await page.locator('[data-page-tab="b"] [data-page-tab-drag]').dragTo( - page.locator('[data-page-tab="a"]'), - { targetPosition: { x: 5, y: 5 } }, + await page.locator('[data-page-id="a"]').waitFor() + await page.locator('[data-page-id="b"] [data-page-drag-handle]').dragTo( + page.locator('[data-page-id="a"]'), + { targetPosition: { x: 10, y: 5 } }, ) - await eventually(() => pages.get('b')?.position === 0 && pages.get('a')?.position === 1, 'Page tab drag did not reorder') - // The sidebar uses the same complete order permutation; drag a back above b. + await eventually(() => pages.get('b')?.position === 0 && pages.get('a')?.position === 1, 'Sidebar page drag did not reorder') + // And drag a back above b. await page.locator('[data-page-id="a"] [data-page-drag-handle]').dragTo( page.locator('[data-page-id="b"]'), { targetPosition: { x: 10, y: 5 } }, ) await eventually(() => pages.get('a')?.position === 0 && pages.get('b')?.position === 1, 'Sidebar page drag did not reorder') - console.log('PASS: page tabs and sidebar persist drag reordering') + console.log('PASS: sidebar persists drag reordering') // Revocation failure path (review CR-02): when Go's revocation fails, the // local sign-out still completes, but the UI must say so — local cookie diff --git a/web/app/(app)/pages/client.tsx b/web/app/(app)/pages/client.tsx index 49b3f17..b052b77 100644 --- a/web/app/(app)/pages/client.tsx +++ b/web/app/(app)/pages/client.tsx @@ -7,9 +7,9 @@ import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import { toast } from 'sonner' import { - ChevronLeft, ChevronRight, Code, CornerUpLeft, Download, Eye, FileText, GripVertical, + Code, CornerUpLeft, Download, Eye, FileText, Heading1, Heading2, Heading3, History, Layers, Link2, List, ListOrdered, ListTodo, Minus, Pencil, - Pin, PinOff, Plus, Quote, RotateCcw, Search, Trash2, Type, X, + Pin, PinOff, Plus, Quote, RotateCcw, Trash2, Type, X, } from 'lucide-react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' @@ -23,7 +23,6 @@ import { PAGES_CHANGED, collectionEmbedMarkdown, descendantPageIds, internalPageId, nextUntitledTitle, notifyActivePage, notifyPagesChanged, pageLinkMarkdown, parsePageEmbed, type PageSummary, } from '@/lib/pages' -import { reorderPages } from '@/lib/page-order' import { fetchLinkPreview } from '@/lib/link-preview' import { LinkPreviewCard } from '@/components/link-preview-card' import type { Element, ElementContent } from 'hast' @@ -184,7 +183,6 @@ export function PagesClient({ initialId }: { initialId: string | null }) { const [pages, setPages] = useState([]) const [activeId, setActiveId] = useState(initialId) const [page, setPage] = useState(null) - const [filter, setFilter] = useState('') const [mode, setMode] = useState<'edit' | 'preview'>('preview') const [title, setTitle] = useState('') const [content, setContent] = useState('') @@ -202,11 +200,8 @@ export function PagesClient({ initialId }: { initialId: string | null }) { const [historyBusy, setHistoryBusy] = useState(null) const [slash, setSlash] = useState<{ query: string; start: number } | null>(null) const [slashIndex, setSlashIndex] = useState(0) - const [tabDrop, setTabDrop] = useState<{ id: string; after: boolean } | null>(null) const textareaRef = useRef(null) const pendingCaret = useRef(null) - const suppressTabClick = useRef(false) - const draggedTabRef = useRef(null) const activePage = useRef(initialId) const loadSequence = useRef(0) const selectionSequence = useRef(0) @@ -504,34 +499,6 @@ export function PagesClient({ initialId }: { initialId: string | null }) { } } - const move = async (dir: -1 | 1) => { - if (!activeId) return - const idx = pages.findIndex((p) => p.id === activeId) - const target = pages[idx + dir] - if (idx < 0 || !target) return - const next = reorderPages(pages, activeId, target.id, dir > 0) - if (next === 'blocked') { toast.error('Pinned and unpinned pages keep separate groups'); return } - if (next) await savePageOrder(next) - } - - const savePageOrder = async (next: PageSummary[]) => { - setPages(next) - const res = await fetch('/api/pages', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ order: next.map((p) => p.id) }) }) - if (!res.ok) { toast.error('Could not reorder pages'); await loadPages(); return } - await loadPages() - notify() - } - - const dropTab = (target: PageSummary, after: boolean) => { - const source = draggedTabRef.current - draggedTabRef.current = null - setTabDrop(null) - if (!source) return - const next = reorderPages(pages, source, target.id, after) - if (next === 'blocked') { toast.error('Pinned and unpinned pages keep separate groups'); return } - if (next) void savePageOrder(next) - } - const download = async () => { if (!activeId) return // A paused conflict can never flush; exporting the server copy is still @@ -658,7 +625,6 @@ export function PagesClient({ initialId }: { initialId: string | null }) { if (/^https?:\/\/\S+$/i.test(text)) offerTitleForPastedUrl(text) } - const visible = pages.filter((p) => p.title.toLowerCase().includes(filter.toLowerCase())) const looksLikeUrl = /^(https?:\/\/)?[\w-]+(\.[\w-]+)+/i.test(linkQuery.trim()) // A page may move under any page except itself or one of its descendants // (the server rejects that cycle even if a stale client tries it). @@ -670,74 +636,6 @@ export function PagesClient({ initialId }: { initialId: string | null }) { return (
-
-
- - setFilter(e.target.value)} placeholder="Filter pages" className="h-8 pl-7 text-sm" /> -
-
- {visible.map((p) => ( -
{ - if (!draggedTabRef.current || draggedTabRef.current === p.id) return - e.preventDefault() - e.dataTransfer.dropEffect = 'move' - const rect = e.currentTarget.getBoundingClientRect() - setTabDrop({ id: p.id, after: e.clientX > rect.left + rect.width / 2 }) - }} - onDragLeave={(e) => { - if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setTabDrop(null) - }} - onDrop={(e) => { - e.preventDefault() - const rect = e.currentTarget.getBoundingClientRect() - dropTab(p, e.clientX > rect.left + rect.width / 2) - }} - title={filter.trim() ? 'Clear the filter to reorder pages' : 'Drag the grip to reorder page'} - className={cn( - 'group/tab flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-sm transition-colors', - p.id === activeId ? 'bg-primary/10 font-medium text-primary' : 'text-muted-foreground hover:bg-muted hover:text-foreground', - tabDrop?.id === p.id && 'ring-1 ring-primary/50', - )} - > - {!filter.trim() && ( - { - suppressTabClick.current = true - draggedTabRef.current = p.id - e.dataTransfer.effectAllowed = 'move' - e.dataTransfer.setData('text/plain', p.id) - }} - onDragEnd={() => { - draggedTabRef.current = null - setTabDrop(null) - setTimeout(() => { suppressTabClick.current = false }, 0) - }} - className="cursor-grab text-muted-foreground/40 opacity-0 transition-opacity hover:text-muted-foreground active:cursor-grabbing group-hover/tab:opacity-100" - aria-label={`Drag page ${p.title}`} - > - - - )} - -
- ))} -
- -
- {!page || page.id !== activeId ? (
@@ -753,8 +651,6 @@ export function PagesClient({ initialId }: { initialId: string | null }) { {saveState === 'dirty' && } - -