From 1eb824f04bb5a79607fb44201e015e65f5ccbe9f Mon Sep 17 00:00:00 2001 From: Michael Burr Date: Thu, 12 Nov 2026 17:59:02 +0000 Subject: [PATCH 01/59] feat(files): let the file manager table fill the content pane The listing sat in WIDE_CONTAINER (59rem), the doc-column width shared with the dashboard, leaving wide empty margins on large screens. Add TABLE_CONTAINER (fills the padded pane, capped and centred at 120rem) and use it for the file manager so the flexible Name column takes the extra width. --- packages/frontend/src/components/FileManager.tsx | 8 ++++---- packages/frontend/src/lib/pageContainer.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/components/FileManager.tsx b/packages/frontend/src/components/FileManager.tsx index 05467a8..01ef66b 100644 --- a/packages/frontend/src/components/FileManager.tsx +++ b/packages/frontend/src/components/FileManager.tsx @@ -3,7 +3,7 @@ import { createPortal } from "react-dom"; import { useNavigate, useOutletContext } from "react-router-dom"; import type { DocsLayoutContext } from "@/layouts/DocsLayout"; import { notifySiteTreeChanged } from "@/components/SidebarPageTree"; -import { PAGE_PADDING, WIDE_CONTAINER } from "@/lib/pageContainer"; +import { PAGE_PADDING, TABLE_CONTAINER } from "@/lib/pageContainer"; import { Folder, FileText, FilePlus, House, FolderPlus, Search, X, Download, Upload, Trash2, Pencil, Link, Sparkles, PenTool, MoreHorizontal, FolderInput, Code, RefreshCw, SquareCheck, ChevronDown, Check, Minus } from "lucide-react"; import { Checkbox as CheckboxPrimitive } from "radix-ui"; import { Button } from "@/components/ui/button"; @@ -1686,9 +1686,9 @@ export function FileManager({ projectId, projectName, folderId, myRole, aiEnable isDesktop - so role/name lookups stay unique. */} {createInHeader && createPortal(createSplitButton, headerActionSlot!)} - {/* Shared page container: same left edge and width as the dashboard - and other wide pages (see lib/pageContainer.ts). */} -
+ {/* Shared page padding; the listing fills the pane (TABLE_CONTAINER) + rather than the doc-column width (see lib/pageContainer.ts). */} +
{/* Toolbar - search fills the row (bulk Delete joins it on the right while a selection is active). Below md the actions drop to their own full-width row under the search, with the create split button diff --git a/packages/frontend/src/lib/pageContainer.ts b/packages/frontend/src/lib/pageContainer.ts index 187da1d..b1ebab5 100644 --- a/packages/frontend/src/lib/pageContainer.ts +++ b/packages/frontend/src/lib/pageContainer.ts @@ -31,3 +31,11 @@ export const READING_CONTAINER = `mx-auto max-w-[44rem] ${DOC_COLUMN_LEFT}`; /** Wide index pages (59rem / 944px - equal 120px margins at 1440): dashboard, wide file previews. */ export const WIDE_CONTAINER = `mx-auto max-w-[59rem] ${DOC_COLUMN_LEFT}`; + +/** + * Data tables (the file manager): fill the padded pane instead of aligning to + * the doc column, since a listing's flexible Name column benefits from every + * pixel. Capped at 120rem (1920px) and centred so an ultrawide monitor doesn't + * stretch rows until the trailing columns sit a screen away from the names. + */ +export const TABLE_CONTAINER = "mx-auto max-w-[120rem]"; From cc57d88d8979772fc91d5c9e8629217d03860b5d Mon Sep 17 00:00:00 2001 From: Michael Burr Date: Mon, 16 Nov 2026 18:54:35 +0000 Subject: [PATCH 02/59] fix(docs): ask before the doc editor throws away unsaved work (CRT1) --- packages/frontend/src/pages/DocPage.tsx | 48 ++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/pages/DocPage.tsx b/packages/frontend/src/pages/DocPage.tsx index e417c59..494416e 100644 --- a/packages/frontend/src/pages/DocPage.tsx +++ b/packages/frontend/src/pages/DocPage.tsx @@ -483,6 +483,7 @@ export function DocPage() { const [collabFatalReason, setCollabFatalReason] = useState(null); const [resetConfirmOpen, setResetConfirmOpen] = useState(false); const [resettingCollab, setResettingCollab] = useState(false); + const [discardConfirmOpen, setDiscardConfirmOpen] = useState(false); const assetsFolderPromiseRef = useRef>>(new Map()); const coverInputRef = useRef(null); @@ -1043,6 +1044,30 @@ export function DocPage() { return () => { cancelled = true; }; }, [revisionView, diffBase, prevRevisionMeta, prevRevisionContent, docId]); + // Local edits that leaving edit mode (or the tab) would throw away. In a + // live collab session the room already mirrors the body to the server, so + // only the title draft counts there. + const collabLive = realtimeEnabled && !collabFatal && !isNewDoc && !!currentUser; + const hasUnsavedEdits = editing && (isNewDoc + ? titleDraft.trim() !== "" || draft.trim() !== "" + : !!doc && ((!collabLive && draft !== doc.content) || titleDraft.trim() !== doc.title)); + + // Warn before the tab/window closes with unsaved edits (mirrors FilePage's + // drawing guard). In-app route changes can't be blocked this way: useBlocker + // needs a data router and the app mounts a plain . + useEffect(() => { + if (!hasUnsavedEdits) return; + const warn = (e: BeforeUnloadEvent) => { e.preventDefault(); e.returnValue = ""; }; + window.addEventListener("beforeunload", warn); + return () => window.removeEventListener("beforeunload", warn); + }, [hasUnsavedEdits]); + + // The editor's Cancel: confirm first when it would discard work. + function requestExitEditing() { + if (hasUnsavedEdits) setDiscardConfirmOpen(true); + else cancelEditing(); + } + async function handleRevert() { if (!docId || !viewingRevision) return; setReverting(true); @@ -1252,7 +1277,7 @@ export function DocPage() { + +
+ {error.message && ( +
+ Error details +
+              {error.message}
+            
+
+ )} +
+
+ ); +} diff --git a/packages/frontend/src/components/Turnstile.tsx b/packages/frontend/src/components/Turnstile.tsx index 151fb36..fb16e80 100644 --- a/packages/frontend/src/components/Turnstile.tsx +++ b/packages/frontend/src/components/Turnstile.tsx @@ -1,4 +1,11 @@ -import { forwardRef, useEffect, useImperativeHandle, useRef } from "react"; +import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react"; +import { AlertTriangle } from "lucide-react"; +import { Button } from "@/components/ui/button"; + +const TURNSTILE_SRC = "https://challenges.cloudflare.com/turnstile/v0/api.js"; +// How long to wait for the challenge script before telling the user it failed +// (it never arrives when a content blocker eats it). +const LOAD_TIMEOUT_MS = 8000; declare global { interface Window { @@ -39,6 +46,8 @@ export const Turnstile = forwardRef(function Tu const onExpireRef = useRef(onExpire); onVerifyRef.current = onVerify; onExpireRef.current = onExpire; + const [failed, setFailed] = useState(false); + const [attempt, setAttempt] = useState(0); // Turnstile tokens are single-use at siteverify, so a failed submit must // re-run the challenge. reset() replays it and fires the callback with a @@ -54,17 +63,32 @@ export const Turnstile = forwardRef(function Tu useEffect(() => { const sitekey = import.meta.env.VITE_TURNSTILE_SITE_KEY as string; let intervalId: ReturnType | null = null; + const startedAt = Date.now(); + // render() throws on a bad/missing sitekey; never let that blank the page. function render() { if (!containerRef.current) return; - widgetIdRef.current = window.turnstile.render(containerRef.current, { - sitekey, - callback: (token) => onVerifyRef.current(token), - "expired-callback": () => onExpireRef.current?.(), - "error-callback": () => onExpireRef.current?.(), - theme: "dark", - size: "flexible", - }); + try { + widgetIdRef.current = window.turnstile.render(containerRef.current, { + sitekey, + callback: (token) => onVerifyRef.current(token), + "expired-callback": () => onExpireRef.current?.(), + "error-callback": () => onExpireRef.current?.(), + theme: "dark", + size: "flexible", + }); + } catch (err) { + console.error("Turnstile failed to render", err); + setFailed(true); + } + } + + // A retry after the script was blocked asks for it again. + if (attempt > 0 && !window.turnstile) { + const script = document.createElement("script"); + script.src = TURNSTILE_SRC; + script.async = true; + document.head.appendChild(script); } if (window.turnstile) { @@ -75,6 +99,10 @@ export const Turnstile = forwardRef(function Tu clearInterval(intervalId!); intervalId = null; render(); + } else if (Date.now() - startedAt > LOAD_TIMEOUT_MS) { + clearInterval(intervalId!); + intervalId = null; + setFailed(true); } }, 100); } @@ -86,7 +114,27 @@ export const Turnstile = forwardRef(function Tu widgetIdRef.current = null; } }; - }, []); + }, [attempt]); + + if (failed) { + return ( +
+
+ ); + } return
; }); diff --git a/packages/frontend/src/layouts/DocsLayout.tsx b/packages/frontend/src/layouts/DocsLayout.tsx index b9dfd8a..0c98403 100644 --- a/packages/frontend/src/layouts/DocsLayout.tsx +++ b/packages/frontend/src/layouts/DocsLayout.tsx @@ -49,6 +49,7 @@ import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, Command import { UserAvatar } from "@/components/UserAvatar"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; import { ProjectSquareLogo } from "@/components/ProjectSquareLogo"; +import { ErrorBoundary } from "@/components/ErrorBoundary"; // A row of GET /api/projects. doc_count / member_count are only present when // the list was fetched with `?counts=1` (the dashboard cards). @@ -1152,7 +1153,10 @@ export function DocsLayout() {
)}
- + {/* A broken page keeps the sidebar and top bar around it. */} + + +
From 76d230b3ea11507a6872af30853405e2ef61e419 Mon Sep 17 00:00:00 2001 From: Michael Burr Date: Mon, 16 Nov 2026 18:54:36 +0000 Subject: [PATCH 04/59] fix(frontend): fix AlertDialog buttons at the root so destructive confirms render red (CRT3) --- packages/frontend/src/components/ui/alert-dialog.tsx | 12 ++++++++---- packages/frontend/src/pages/DocPage.tsx | 2 +- packages/frontend/src/pages/OrgSettingsPage.tsx | 6 +++--- packages/frontend/src/pages/SiteSettingsPage.tsx | 8 ++++---- packages/frontend/src/pages/UserSettingsPage.tsx | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/frontend/src/components/ui/alert-dialog.tsx b/packages/frontend/src/components/ui/alert-dialog.tsx index 7a9add1..35cfb20 100644 --- a/packages/frontend/src/components/ui/alert-dialog.tsx +++ b/packages/frontend/src/components/ui/alert-dialog.tsx @@ -150,10 +150,12 @@ function AlertDialogAction({ }: React.ComponentProps & Pick, "variant" | "size">) { return ( - @@ -168,10 +170,12 @@ function AlertDialogCancel({ }: React.ComponentProps & Pick, "variant" | "size">) { return ( - diff --git a/packages/frontend/src/pages/DocPage.tsx b/packages/frontend/src/pages/DocPage.tsx index 494416e..60e6532 100644 --- a/packages/frontend/src/pages/DocPage.tsx +++ b/packages/frontend/src/pages/DocPage.tsx @@ -1992,7 +1992,7 @@ export function DocPage() { Cancel { e.preventDefault(); void handleMoveToTrash(); }} disabled={trashing} > diff --git a/packages/frontend/src/pages/OrgSettingsPage.tsx b/packages/frontend/src/pages/OrgSettingsPage.tsx index 81f37af..e2d43a6 100644 --- a/packages/frontend/src/pages/OrgSettingsPage.tsx +++ b/packages/frontend/src/pages/OrgSettingsPage.tsx @@ -535,7 +535,7 @@ export function OrgSettingsPage() { Cancel handleDetach(site)} > Detach @@ -577,7 +577,7 @@ export function OrgSettingsPage() { Cancel Yes, delete @@ -606,7 +606,7 @@ export function OrgSettingsPage() { Cancel Yes, leave diff --git a/packages/frontend/src/pages/SiteSettingsPage.tsx b/packages/frontend/src/pages/SiteSettingsPage.tsx index 8b02cc7..022a16d 100644 --- a/packages/frontend/src/pages/SiteSettingsPage.tsx +++ b/packages/frontend/src/pages/SiteSettingsPage.tsx @@ -1821,7 +1821,7 @@ export function SiteSettingsPage() { Cancel @@ -2534,7 +2534,7 @@ export function SiteSettingsPage() { Cancel handleRevokeKey(key)} > Revoke key @@ -2685,7 +2685,7 @@ export function SiteSettingsPage() { Cancel @@ -2720,7 +2720,7 @@ export function SiteSettingsPage() { Cancel diff --git a/packages/frontend/src/pages/UserSettingsPage.tsx b/packages/frontend/src/pages/UserSettingsPage.tsx index f1594c4..afe84f6 100644 --- a/packages/frontend/src/pages/UserSettingsPage.tsx +++ b/packages/frontend/src/pages/UserSettingsPage.tsx @@ -2847,7 +2847,7 @@ export function UserSettingsPage() { Cancel From 73c75b6095142086e1c2923ce9134670db5416b8 Mon Sep 17 00:00:00 2001 From: Michael Burr Date: Mon, 16 Nov 2026 18:54:36 +0000 Subject: [PATCH 05/59] fix(frontend): one name for recents, no 'workspace' on the 404, demo copy names the Edit button (CRT4) --- packages/frontend/src/layouts/DocsLayout.tsx | 2 +- packages/frontend/src/lib/demoServer.ts | 8 ++++---- packages/frontend/src/pages/DashboardPage.tsx | 2 +- packages/frontend/src/pages/NotFoundPage.test.tsx | 4 ++-- packages/frontend/src/pages/NotFoundPage.tsx | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/frontend/src/layouts/DocsLayout.tsx b/packages/frontend/src/layouts/DocsLayout.tsx index 0c98403..4ef26b5 100644 --- a/packages/frontend/src/layouts/DocsLayout.tsx +++ b/packages/frontend/src/layouts/DocsLayout.tsx @@ -943,7 +943,7 @@ export function DocsLayout() { {visibleRecentItems.length > 0 && (

- Recently accessed + Recent

@@ -298,7 +298,7 @@ export function SidebarPageTree({ return (
-

+

Contents

From 1d53835ae74eb37042edc47c8853bc1d99e03564 Mon Sep 17 00:00:00 2001 From: Michael Burr Date: Mon, 16 Nov 2026 18:54:48 +0000 Subject: [PATCH 11/59] fix(frontend): export as PDF only offers toggles for what the page shows (DOC3) --- .../src/components/ExportPdfDialog.tsx | 57 +++++++++---------- packages/frontend/src/pages/DocPage.tsx | 2 + 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/packages/frontend/src/components/ExportPdfDialog.tsx b/packages/frontend/src/components/ExportPdfDialog.tsx index 01cf372..a85367a 100644 --- a/packages/frontend/src/components/ExportPdfDialog.tsx +++ b/packages/frontend/src/components/ExportPdfDialog.tsx @@ -21,9 +21,13 @@ interface Props { documentName?: string; open?: boolean; onOpenChange?: (open: boolean) => void; + /** The page shows an AI summary block - otherwise its toggle is a dead control and is hidden. */ + hasAiSummary?: boolean; + /** The page shows the "Last updated" line - otherwise its toggle is hidden. */ + hasLastUpdated?: boolean; } -export function ExportPdfDialog({ trigger, documentName, open: controlledOpen, onOpenChange }: Props) { +export function ExportPdfDialog({ trigger, documentName, open: controlledOpen, onOpenChange, hasAiSummary = true, hasLastUpdated = true }: Props) { const [uncontrolledOpen, setUncontrolledOpen] = useState(false); const open = controlledOpen ?? uncontrolledOpen; const setOpen = (next: boolean) => { @@ -51,20 +55,14 @@ export function ExportPdfDialog({ trigger, documentName, open: controlledOpen, o Export as PDF - Opens your browser's print dialog. Choose Save as PDF as the destination to download a file with selectable text and working links. + Opens your browser's print dialog. Choose Save as PDF as the destination for a file with selectable text and working links. Margins and scale are set there too.
-
-

Layout

-

Paper size and colour theme for the PDF.

-
+

Layout

-
- -

A4 is the default.

-
+ setNewKeyScope(val as ApiKeyScope)} disabled={!canMintWriteKey}> - + @@ -2468,7 +2468,10 @@ export function SiteSettingsPage() { )}
+ {/* Same footer as "Create invite link": an explicit + Cancel beside the primary action. */} + From 52ddcc226639a29440c95756b6e2c2875db9d8bf Mon Sep 17 00:00:00 2001 From: Michael Burr Date: Mon, 16 Nov 2026 18:54:56 +0000 Subject: [PATCH 18/59] feat(frontend): add a real 'Show sidebar' button when the desktop sidebar is collapsed (SHL3) --- packages/frontend/src/layouts/DocsLayout.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/layouts/DocsLayout.tsx b/packages/frontend/src/layouts/DocsLayout.tsx index af5f71b..3c1a37d 100644 --- a/packages/frontend/src/layouts/DocsLayout.tsx +++ b/packages/frontend/src/layouts/DocsLayout.tsx @@ -38,6 +38,7 @@ import { Upload, Building2, Menu, + PanelLeftOpen, LayoutGrid, X, } from "lucide-react"; @@ -1085,16 +1086,20 @@ export function DocsLayout() { {(displayCrumbs.length > 0 || !sidebarOpen) && (
{!sidebarOpen && ( )} {/* Phones show only the final crumb (the current page/doc title, From 54e32d56b82105dd2faf181a022cd2869a469e34 Mon Sep 17 00:00:00 2001 From: Michael Burr Date: Mon, 16 Nov 2026 18:54:57 +0000 Subject: [PATCH 19/59] feat(public): make the site name the public site's home link (PUB1) --- packages/frontend/src/pages/PublicDocPage.tsx | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/pages/PublicDocPage.tsx b/packages/frontend/src/pages/PublicDocPage.tsx index 35995a7..761a870 100644 --- a/packages/frontend/src/pages/PublicDocPage.tsx +++ b/packages/frontend/src/pages/PublicDocPage.tsx @@ -743,6 +743,7 @@ export function PublicDocPage() { // Desktop top bar breadcrumb: site name (links to the home doc, or the // generated site index when there is none) › current page. const homeDocId = data.docs?.find(d => d.is_home === 1)?.id ?? null; + const siteHomeHref = homeDocId ? href(homeDocId) : hostMode ? "/" : `/s/${linkSlug}`; const currentNavDoc = data.docs?.find(d => d.id === data.doc.id); const pageTitle = isGraph ? "Graph" @@ -806,6 +807,14 @@ export function PublicDocPage() { )}>