# Phase 1: Edit Mode State Infrastructure **Status:** ⬜ Not Started **Parent plan:** [PLAN.md](./PLAN.md) **Domain:** frontend ## Objective Create the foundational edit mode state management and toggle mechanism that all subsequent phases build upon. ## Tasks - [ ] Create `src/lib/stores/editMode.svelte.ts` with state: `{ active, boardId, dirty, changeCount }` - [ ] Export functions: `enterEditMode(boardId)`, `exitEditMode()`, `markDirty()`, `resetDirty()` - [ ] Add "Edit Mode" toggle button to `BoardHeader.svelte` (replaces the current "Edit" link to `/boards/[id]/edit`) - [ ] When toggled ON: set edit mode active, show visual indicator (subtle board border glow or tint) - [ ] When toggled OFF: if dirty, show confirmation dialog "Discard unsaved changes?" - [ ] Register keyboard shortcut `Ctrl+E` / `Cmd+E` to toggle edit mode - [ ] Pass edit mode state as Svelte context from board view page - [ ] Add `editMode` context consumer helpers for child components - [ ] Visual indicator: board gets a subtle colored top-bar or border when in edit mode ## Files to Modify/Create - `src/lib/stores/editMode.svelte.ts` — new store - `src/lib/components/board/BoardHeader.svelte` — replace Edit link with toggle button - `src/routes/boards/[boardId]/+page.svelte` — provide edit mode context, visual indicators ## Acceptance Criteria - Clicking the toggle enters/exits edit mode - Ctrl+E toggles edit mode - Board view page visually indicates edit mode is active - Child components can read edit mode state via context - Dirty state tracking works (increments on markDirty, resets on save/discard) ## Notes - Use Svelte 5 runes ($state, $derived) for the store - The keyboard shortcut must not conflict with existing shortcuts - Guest users / users without edit permission must NOT see the toggle ## Review Checklist - [ ] All tasks completed - [ ] Code follows project conventions - [ ] No unintended side effects - [ ] Build passes - [ ] Tests pass (new + existing) ## Handoff to Next Phase