Skip to content

feat: add canvas annotation system (rect, line, text draw tools)#122

Open
theblondealex wants to merge 2 commits into
collabs-inc:mainfrom
theblondealex:feat/canvas-annotations
Open

feat: add canvas annotation system (rect, line, text draw tools)#122
theblondealex wants to merge 2 commits into
collabs-inc:mainfrom
theblondealex:feat/canvas-annotations

Conversation

@theblondealex

Copy link
Copy Markdown
Contributor

Why

Working on a large project in Collab often means dozens of terminal and browser tiles scattered across a canvas with no way to communicate structure to yourself have order to the different projects you might run in parralell. There's no way to group related tiles, label what something does, or draw a connection between two terminals that are part of the same pipeline.

This comes up directly in #29 (canvas needs a way to visually group/organise tiles) and #25 (users want to annotate and label their workspace). Right now the only option is careful spatial arrangement, which breaks down fast as a canvas grows.

This PR adds a lightweight annotation layer — rects to group tiles, lines to connect them, and text labels — so you can impose structure on a canvas without changing how tiles themselves work.

Demo video

annotations.1.1.mov

note since recording the video the location of the draw has moved to near the + like below, and colour of the popovers to match DS

image image

Changes

File What changed
src/windows/shell/src/annotation-manager.ts New — pure state module: types, add/remove/update, selection, persist/restore
src/windows/shell/src/annotation-renderer.ts New — all SVG/DOM rendering, draw interactions, drag, popover, mode management
src/windows/shell/index.html Annotation layer DOM, draw toolbar button + tool popover
src/windows/shell/src/shell.css Annotation styles: layers, popovers, tile highlight glows, selection ring
src/windows/shell/src/renderer.js Wires annotation renderer into canvas; group drag + delete + restore
src/windows/shell/src/tile-interactions.js onGroupDragStart / onGroupDragMove / onGroupDragEnd callbacks for cross-system drag
src/windows/shell/src/tile-manager.js Threads group drag callbacks through to attachDrag
src/main/canvas-persistence.ts Adds AnnotationState union type to the persisted canvas schema

How it works

  • Annotations render behind the tile layer: SVG <g> elements for rects and lines (inside a masked group that hides annotations under tiles), DOM <div> elements for text
  • All three tools are single-click/drag to create, then revert to pointer mode automatically
  • Lines can be free (canvas coords) or connected (anchored to two tile centers — they track tile movement and only detach when dragged individually)
  • Multi-select marquee works across tiles and annotations together; dragging a mixed selection moves everything as a group
  • Annotations persist to canvas-state.json alongside tiles on every change; annotations is optional in the schema so existing state files load cleanly
  • Default colour is derived from --muted CSS variable so it adapts to light/dark mode

Closes #29, closes #25

Adds a draw toolbar button next to the settings cog that opens a popover
with three annotation tools:

- Rectangle: drag to place a rounded border box for grouping terminals
  visually; click/drag only activates on the stroke (interior is
  transparent to events)
- Line: free-draw or click two terminals to create an anchored connector;
  connected lines track terminal movement and only detach when the line
  itself is dragged individually
- Text: click to place a label; double-click to edit in-place

All annotations:
- Render behind the tile layer in a dedicated annotation layer (SVG for
  lines/rects, DOM for text)
- Are moveable by click+drag; multi-select via marquee (blue highlight)
  and drag moves the whole group including any selected tiles together
- Show a per-annotation popover on single click: trash (Delete/Backspace
  also works), hex colour input, ±font size for text
- Persist to canvas-state.json alongside tiles on every change
- Adapt default colour to light/dark mode via the --muted CSS variable

Draw-line mode highlights hovered terminals with a green glow (muted
pre-click, solid post-click) and shows a dashed preview line while
connecting; Escape cancels at any point.

Pencil button is positioned to the right of the update pill and left of
the settings cog, with dynamic positioning when the pill is visible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Putting text labels on the canvas Feature request: Tagging or region segmentation

1 participant