|
| 1 | +## Task List |
| 2 | + |
| 3 | +T1: Add scratchpad editor primitives [L] — T2: Move feature state into an editor hook [M] — T3: Thin page/workspace UI around editor state [L] |
| 4 | + |
| 5 | +### T1: Add scratchpad editor primitives [L] |
| 6 | + |
| 7 | +**Objective**: Introduce a central scratchpad editor model for items, selection, and viewport. |
| 8 | +**Size**: L |
| 9 | +**Files**: |
| 10 | +- Create: `src/lib/scratch/editor.ts` |
| 11 | +- Create: `src/lib/scratch/viewport.ts` |
| 12 | +- Modify: `src/lib/scratch/types.ts` |
| 13 | +- Modify: `src/lib/scratch/storage.ts` |
| 14 | +**Implementation**: |
| 15 | +1. In `src/lib/scratch/types.ts`, add explicit viewport typing used by document/editor state. |
| 16 | +2. In `src/lib/scratch/editor.ts`, add editor state, reducer actions, selectors, item factory helpers, dirty-state helpers, and z-index/selection logic. |
| 17 | +3. In `src/lib/scratch/viewport.ts`, add pure pan/zoom and screen-to-canvas math helpers. |
| 18 | +4. In `src/lib/scratch/storage.ts`, add viewport storage and align item clearing with the versioned item envelope. |
| 19 | +**Boundaries**: Do not change Memos API behavior or card rendering markup here. |
| 20 | +**Dependencies**: None |
| 21 | +**Expected Outcome**: Scratchpad has reusable editor/document and viewport logic outside of React components. |
| 22 | +**Validation**: `pnpm exec tsc --noEmit` — exits 0 |
| 23 | + |
| 24 | +### T2: Move feature state into an editor hook [M] |
| 25 | + |
| 26 | +**Objective**: Isolate scratchpad document state, hydration, persistence, and local editing commands behind a dedicated hook. |
| 27 | +**Size**: M |
| 28 | +**Files**: |
| 29 | +- Create: `src/hooks/use-scratchpad-editor.ts` |
| 30 | +- Modify: `src/hooks/use-scratchpad.ts` |
| 31 | +**Implementation**: |
| 32 | +1. In `src/hooks/use-scratchpad-editor.ts`, use the new reducer/state helpers to hydrate items and viewport, persist them, and expose item/viewport commands plus local keyboard/delete behavior. |
| 33 | +2. In `src/hooks/use-scratchpad.ts`, compose the editor hook with instance storage and remote-save orchestration while shrinking direct document-mutation logic. |
| 34 | +**Boundaries**: Do not redesign connection testing or remote save semantics. |
| 35 | +**Dependencies**: T1 |
| 36 | +**Expected Outcome**: `useScratchpad` becomes a composition root over a narrower editor command surface. |
| 37 | +**Validation**: `pnpm exec tsc --noEmit` — exits 0 |
| 38 | + |
| 39 | +### T3: Thin page/workspace UI around editor state [L] |
| 40 | + |
| 41 | +**Objective**: Make scratchpad components consume explicit editor state instead of owning editor logic ad hoc. |
| 42 | +**Size**: L |
| 43 | +**Files**: |
| 44 | +- Create: `src/components/scratch/scratchpad-toolbar.tsx` |
| 45 | +- Modify: `src/components/scratch/workspace.tsx` |
| 46 | +- Modify: `src/app/scratchpad/page.tsx` |
| 47 | +- Modify: `src/components/scratch/card-item.tsx` |
| 48 | +**Implementation**: |
| 49 | +1. In `src/components/scratch/workspace.tsx`, consume external viewport state and pure viewport helpers while keeping only transient pointer-session state locally. |
| 50 | +2. In `src/components/scratch/scratchpad-toolbar.tsx`, extract top-bar UI and menu chrome from the page component. |
| 51 | +3. In `src/app/scratchpad/page.tsx`, reduce the page to feature composition. |
| 52 | +4. In `src/components/scratch/card-item.tsx`, keep drag/resize behavior compatible with externally managed viewport scale. |
| 53 | +**Boundaries**: Do not add new editor capabilities such as connectors, drawing tools, or collaboration. |
| 54 | +**Dependencies**: T1, T2 |
| 55 | +**Expected Outcome**: Page-level code is thinner and editor state flow is explicit at the component boundary. |
| 56 | +**Validation**: `pnpm exec biome check src/app/scratchpad/page.tsx src/components/scratch/workspace.tsx src/components/scratch/card-item.tsx src/components/scratch/scratchpad-toolbar.tsx src/hooks/use-scratchpad.ts src/hooks/use-scratchpad-editor.ts src/lib/scratch/editor.ts src/lib/scratch/viewport.ts src/lib/scratch/storage.ts src/lib/scratch/types.ts && pnpm exec tsc --noEmit` — exits 0 |
| 57 | + |
| 58 | +## Out-of-Scope Tasks |
| 59 | + |
| 60 | +- Add undo/redo history |
| 61 | +- Add lasso or marquee multi-select |
| 62 | +- Replace DOM card rendering with `<canvas>` or WebGL |
| 63 | +- Add multiplayer or collaborative syncing |
0 commit comments