fix: auto-switch to page with most content when current page has trivial shapes

Previously the page-switch logic only triggered when the current page had 0 shapes.
The R2 data has 283 shapes on page:QZw03khAAJ7jNX7zQND64 but only 1 (MycelialIntelligence)
on page:page. Since page:page is the default, users saw only the MI shape, not their content.

Now also switches when current page has <=2 shapes but another page has >10.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-03-09 18:24:54 -07:00
parent 01fb250d29
commit ef4574d223
1 changed files with 10 additions and 2 deletions

View File

@ -859,8 +859,16 @@ export function Board() {
} }
}) })
// If current page has no shapes but another page does, switch to that page // If current page has very few shapes but another page has significantly more, switch to that page
if (editorShapes.length === 0 && pageWithMostShapes && pageWithMostShapes !== currentPageId) { // This handles the case where a default page:page exists with just 1-2 shapes
// but the real content is on a different page (e.g. page:QZw03khAAJ7jNX7zQND64)
const currentPageShapeCount = editorShapes.length
const shouldSwitchPage = pageWithMostShapes && pageWithMostShapes !== currentPageId && (
currentPageShapeCount === 0 || // No shapes on current page
(maxShapes > 10 && currentPageShapeCount <= 2) // Current page has trivial content, other page has real content
)
if (shouldSwitchPage) {
console.log(`📊 Board: Switching from ${currentPageId} (${currentPageShapeCount} shapes) to ${pageWithMostShapes} (${maxShapes} shapes)`)
try { try {
editor.setCurrentPage(pageWithMostShapes as any) editor.setCurrentPage(pageWithMostShapes as any)
// Focus camera on shapes after switching // Focus camera on shapes after switching