From 65ecc8bfa4b23d0b28b992c76cf5dce33782c54d Mon Sep 17 00:00:00 2001
From: ruinivist <179396038+ruinivist@users.noreply.github.com>
Date: Sun, 31 May 2026 13:23:50 +0000
Subject: [PATCH] refactor: remove redundant fallback and legacy handling on
drawing load failure
This commit simplifies `loadDrawing` in `useDrawingSession.ts` by removing silent fallbacks that were fetching the drawing list and redirecting users or auto-creating drawings when loading a specific drawing failed. Instead, the error state is simply set, ensuring errors surface cleanly.
---
package.json | 8 ++++----
src/{ => client}/App.tsx | 8 ++++----
src/{ => client/components}/DrawingSidebar.tsx | 2 +-
src/{ => client/components}/EditorCanvas.tsx | 4 ++--
src/{ => client/hooks}/useDrawingSession.ts | 2 +-
src/{ => client/hooks}/useThemeTokenSync.ts | 0
src/{ => client}/index.html | 2 +-
src/{client.tsx => client/main.tsx} | 0
src/{ => client}/styles.css | 0
src/{ => core}/scene.test.ts | 0
src/{ => core}/scene.ts | 0
src/{ => core}/shared.ts | 0
src/{mcp-server.test.ts => mcp/server.test.ts} | 6 +++---
src/{mcp-server.ts => mcp/server.ts} | 6 +++---
src/{ => server}/api.test.ts | 0
src/{ => server}/api.ts | 4 ++--
src/{ => server}/db.test.ts | 0
src/{ => server}/db.ts | 4 ++--
src/{ => server}/dev-server.tsx | 4 ++--
src/{server.test.ts => server/http-server.test.ts} | 2 +-
src/{server.tsx => server/http-server.tsx} | 0
21 files changed, 26 insertions(+), 26 deletions(-)
rename src/{ => client}/App.tsx (90%)
rename src/{ => client/components}/DrawingSidebar.tsx (98%)
rename src/{ => client/components}/EditorCanvas.tsx (91%)
rename src/{ => client/hooks}/useDrawingSession.ts (99%)
rename src/{ => client/hooks}/useThemeTokenSync.ts (100%)
rename src/{ => client}/index.html (84%)
rename src/{client.tsx => client/main.tsx} (100%)
rename src/{ => client}/styles.css (100%)
rename src/{ => core}/scene.test.ts (100%)
rename src/{ => core}/scene.ts (100%)
rename src/{ => core}/shared.ts (100%)
rename src/{mcp-server.test.ts => mcp/server.test.ts} (95%)
rename src/{mcp-server.ts => mcp/server.ts} (97%)
rename src/{ => server}/api.test.ts (100%)
rename src/{ => server}/api.ts (98%)
rename src/{ => server}/db.test.ts (100%)
rename src/{ => server}/db.ts (98%)
rename src/{ => server}/dev-server.tsx (80%)
rename src/{server.test.ts => server/http-server.test.ts} (97%)
rename src/{server.tsx => server/http-server.tsx} (100%)
diff --git a/package.json b/package.json
index b090d5c..d6461fe 100644
--- a/package.json
+++ b/package.json
@@ -3,11 +3,11 @@
"type": "module",
"private": true,
"scripts": {
- "dev": "bun --hot src/dev-server.tsx",
+ "dev": "bun --hot src/server/dev-server.tsx",
"build": "rm -rf dist && bun run build:client && bun run build:server && bun run build:mcp",
- "build:client": "bun build --target=browser --production --outdir ./dist/public ./src/index.html",
- "build:server": "mkdir -p ./dist/server && bun build --target=bun --production --outfile ./dist/server/server.js ./src/server.tsx",
- "build:mcp": "mkdir -p ./dist/mcp && bun build --target=bun --production --outfile ./dist/mcp/mcp-server.js ./src/mcp-server.ts",
+ "build:client": "bun build --target=browser --production --outdir ./dist/public ./src/client/index.html",
+ "build:server": "mkdir -p ./dist/server && bun build --target=bun --production --outfile ./dist/server/server.js ./src/server/http-server.tsx",
+ "build:mcp": "mkdir -p ./dist/mcp && bun build --target=bun --production --outfile ./dist/mcp/mcp-server.js ./src/mcp/server.ts",
"start": "DATABASE_PATH=./data/excalidraw.sqlite bun ./dist/server/server.js",
"test": "bun test",
"typecheck": "tsc --noEmit"
diff --git a/src/App.tsx b/src/client/App.tsx
similarity index 90%
rename from src/App.tsx
rename to src/client/App.tsx
index fb56cc2..fc4dac4 100644
--- a/src/App.tsx
+++ b/src/client/App.tsx
@@ -1,8 +1,8 @@
import { useCallback, useEffect, useRef, useState } from "react";
-import { DrawingSidebar, DrawingsToggle } from "./DrawingSidebar";
-import { EditorCanvas } from "./EditorCanvas";
-import { useDrawingSession } from "./useDrawingSession";
-import { useThemeTokenSync } from "./useThemeTokenSync";
+import { DrawingSidebar, DrawingsToggle } from "./components/DrawingSidebar";
+import { EditorCanvas } from "./components/EditorCanvas";
+import { useDrawingSession } from "./hooks/useDrawingSession";
+import { useThemeTokenSync } from "./hooks/useThemeTokenSync";
export function App() {
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
diff --git a/src/DrawingSidebar.tsx b/src/client/components/DrawingSidebar.tsx
similarity index 98%
rename from src/DrawingSidebar.tsx
rename to src/client/components/DrawingSidebar.tsx
index 30bf915..bfab44f 100644
--- a/src/DrawingSidebar.tsx
+++ b/src/client/components/DrawingSidebar.tsx
@@ -1,4 +1,4 @@
-import { type DrawingMeta } from "./shared";
+import { type DrawingMeta } from "../../core/shared";
type DrawingSidebarProps = {
open: boolean;
diff --git a/src/EditorCanvas.tsx b/src/client/components/EditorCanvas.tsx
similarity index 91%
rename from src/EditorCanvas.tsx
rename to src/client/components/EditorCanvas.tsx
index cc561e9..2f4eaf4 100644
--- a/src/EditorCanvas.tsx
+++ b/src/client/components/EditorCanvas.tsx
@@ -1,11 +1,11 @@
-import "../node_modules/@excalidraw/excalidraw/dist/prod/index.css";
+import "../../../node_modules/@excalidraw/excalidraw/dist/prod/index.css";
import { Excalidraw } from "@excalidraw/excalidraw";
import type {
AppState,
BinaryFiles,
ExcalidrawInitialDataState,
} from "@excalidraw/excalidraw/types";
-import { type ScenePayload } from "./shared";
+import { type ScenePayload } from "../../core/shared";
type EditorCanvasProps = {
activeId: string | null;
diff --git a/src/useDrawingSession.ts b/src/client/hooks/useDrawingSession.ts
similarity index 99%
rename from src/useDrawingSession.ts
rename to src/client/hooks/useDrawingSession.ts
index 2ffe9a8..5fa4968 100644
--- a/src/useDrawingSession.ts
+++ b/src/client/hooks/useDrawingSession.ts
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useRef, useState } from "react";
-import { DEFAULT_TITLE, type DrawingMeta, type ScenePayload } from "./shared";
+import { DEFAULT_TITLE, type DrawingMeta, type ScenePayload } from "../../core/shared";
type DrawingResponse = DrawingMeta & ScenePayload;
type ApiErrorBody = { ok: false; error?: string; drawing?: DrawingMeta };
diff --git a/src/useThemeTokenSync.ts b/src/client/hooks/useThemeTokenSync.ts
similarity index 100%
rename from src/useThemeTokenSync.ts
rename to src/client/hooks/useThemeTokenSync.ts
diff --git a/src/index.html b/src/client/index.html
similarity index 84%
rename from src/index.html
rename to src/client/index.html
index 0d8128e..5be76f5 100644
--- a/src/index.html
+++ b/src/client/index.html
@@ -6,7 +6,7 @@