# Whiteboard Canvas

## Objective

Give a team an infinite canvas for notes, shapes and arrows they can move around together.

A pannable, zoomable canvas holding sticky notes, basic shapes, text and connectors, editable by several people at once.

## Before You Begin

This feature is being added to an application that already exists and already
works. Do not scaffold a new project, and do not assume a blank slate.

Inspect the codebase first and establish:

- The existing application structure and where code of this kind already lives.
- The framework and version in use.
- The existing design system — colours, spacing, typography, and component conventions.
- Existing UI components you can reuse instead of writing new ones.
- The existing database structure, if this feature needs to persist anything.
- The existing authentication and authorization system, if this feature is user-scoped.
- Dependencies already installed, so you don't add a library that duplicates one.
- The existing test setup and conventions.

Only start writing code once you understand the above. If the application
already implements part of this feature, extend it rather than replacing it.

## Implementation Instructions

1. Ship a small, coherent object set first: sticky note, rectangle, ellipse, free text, and a connector between two objects. A general-purpose diagramming engine is not the minimum version and should be deferred.
2. Reuse the app's existing realtime and presence layer. If Presence Indicators already exists, show collaborators on the canvas through it rather than opening a second live channel.
3. Make every object move, resize and delete with both pointer and keyboard, and give undo the same coverage. If the app has Undo Actions, canvas edits go into that history rather than a private stack of their own.
4. Persist continuously as people work. Reuse the app's Autosave behaviour if it exists, and make the saved state authoritative so a reload restores the board exactly.
5. Do not attempt pixel-perfect freehand drawing, image import and a template gallery in the first pass. Name them as deferred so the board that ships is finished rather than three things that are each nearly working.

## UI and UX Requirements

Match the application's existing design system exactly. Reuse its components,
spacing, and typography. This feature should look like it was always there.

## Responsive Requirements

Works on mobile, tablet, and desktop. Touch targets are large enough to hit on a
phone, and nothing overflows horizontally at 320px.

## Accessibility Requirements

- Fully keyboard navigable.
- Correct semantic elements and ARIA roles.
- Visible focus states.
- Meets WCAG AA contrast.
- Dynamic changes are announced to screen readers.
- Respects prefers-reduced-motion.

## Edge Cases

- Two people dragging at once must both keep their work. Merge concurrent edits per object and per property, so one person's move does not overwrite another's resize or wipe a note they were typing into.
- Pan and zoom must stay smooth as the board grows into the thousands of objects. Render only what is in view, and decide early what happens past that ceiling rather than letting the board grind to a halt.
- Connectors are attached to objects, not to coordinates. Moving a shape drags its connectors with it, and deleting a shape must resolve the connector deliberately rather than leaving an arrow pointing at nothing.
- Mouse, touch and trackpad all mean different things by the same gesture. Pinch, two-finger scroll and drag must behave consistently, and a trackpad scroll must not zoom when the user meant to pan.
- An exported snapshot must match what is on screen, including fonts. If a font is unavailable at export time the text reflows and the export no longer resembles the board.
- A dropped connection must not lose work. Queue edits locally, reconcile on reconnect, and tell the user plainly that they are offline rather than silently discarding changes.
- Boards are user-generated content. Decide who can view, who can edit, and what a shared link exposes before shipping sharing at all.
- Objects need readable names or labels for anyone not using a pointer, and an accessible list view of the board's contents is a better fallback than an empty canvas.

## Testing

Exercise the feature end to end in the running application. Cover every edge case
above, then run the existing test suite and confirm nothing regressed.

## Acceptance Criteria

- [ ] Notes, shapes, text and connectors can be created, moved, resized and deleted by pointer and by keyboard.
- [ ] Simultaneous edits by several people merge without one person's change erasing another's.
- [ ] Connectors stay attached when their shapes move and resolve deliberately when a shape is deleted.
- [ ] Pan and zoom stay responsive at the documented object ceiling.
- [ ] Board state persists continuously and a reload restores it exactly.
- [ ] An exported snapshot matches the on-screen layout and fonts.
- [ ] Presence and collaboration run through the app's existing realtime layer.
- [ ] The feature matches the existing design system.
- [ ] No existing functionality is broken.

## Adaptation Rules

- Match the existing design system. Do not introduce a new colour palette,
  spacing scale, or component library.
- Reuse existing components and utilities wherever they fit.
- Follow the naming, file layout, and code style already present.
- Do not upgrade, replace, or remove existing dependencies to make this
  feature fit. Adapt the feature to the app, not the app to the feature.
- Do not break existing functionality. If a change is genuinely required in
  existing code, make the smallest one that works and say so.
- If something in these instructions conflicts with how the application is
  built, follow the application and explain the deviation.

## Final Verification

Before you report the work as done:

1. Re-read the acceptance criteria above and check each one against what you
   actually built.
2. Run the application and exercise the feature end to end.
3. Run the existing test suite and confirm you have broken nothing.
4. Check the feature on mobile, tablet, and desktop widths.
5. Check keyboard navigation and focus handling.
6. Summarize what changed: files added, files modified, and anything you
   deliberately did differently because of how this application is built.

If any acceptance criterion is unmet, fix it before reporting completion.
