Skip to content

WSI annotations: measurements, points, freehand/brush, notes, review, sharing, list, GeoJSON, undo - #38

Draft
raylim wants to merge 78 commits into
codex/wsi-rd-annotationsfrom
codex/wsi-annotation-tools
Draft

raylim wants to merge 78 commits into
codex/wsi-rd-annotationsfrom
codex/wsi-annotation-tools

Conversation

@raylim

@raylim raylim commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Annotation authoring tools for the WSI viewer package, on top of #19. Frontend only. Everything runs against the annotation service on cBioPortal/cbioportal-tile-server main, except what needs cBioPortal/cbioportal-tile-server#51:

  • Review by users other than the creator needs its POST /annotations/{id}/review route. Without it, the viewer falls back to creator-only review.
  • All-or-nothing batch saves need its transactional POST /annotations/batch. The route itself is already on main.
  • That PR also lets only trusted writers create machine-made annotations; the viewer never sends a machine provenance.source of its own.

Bulk actions in single requests, comment threads, slide notes, review undo and restoring deleted annotations need cBioPortal/cbioportal-tile-server#52 (stacked on cBioPortal#51): POST /annotations/batch-update, /batch-delete and /batch-review, /annotations/{id}/comments, /slide-notes (plus a /wsi/slide-notes route in the proxy), review decision: "reset", and soft deletes with POST /annotations/{id}/restore and /batch-restore. Without them, bulk actions send one request per annotation, the thread and slide-notes UI stays hidden, reviews can't be undone, and Undo of a delete creates the annotation again with a new id. The viewer reads both the paged thread and notes lists of that PR ({…, total, offset, limit, has_more, next_offset}, "Show more") and the whole lists of an older service, shows its 422 caps (1,000 comments per annotation, 1,000 notes per slide), and says "This shape can't be saved" for a 422 on target (its selector rules).

Toolbar

  • Viewing shows only Annotate, Display (an eye) and a ⋯ menu over the slide. Annotate opens one compact row with the tools grouped by task, each a labelled role="group" between dividers: Select (V); Draw: Shape ▾ (rectangle R, ellipse, circle) and Outline ▾ (polygon P, freehand F, brush B, smart brush Shift+B, magic wand W); Count: Point (C) and HPF field (Shift+C); Measure (L or M); then Drawing as, then Undo and Redo. A save status sits before the Display eye.
  • The row stays one row with both sidebars open at a 1600-pixel window (a viewer of 904 pixels on the patient Pathology Slides tab, 944 on the permalink page), also with a long layer name in Drawing as (as AI pattern maps have; the layer choice is capped at 112 pixels and the label field is 88). Below a 960-pixel viewer the toolbar is compact (a ResizeObserver on the viewer pane; data-compact on the toolbar): the "Drawing as:" text becomes the group's tooltip (the group keeps its aria-label) and the save status shows its icon alone, its text in the tooltip and the live region. Compact, the row fits down to about a 780-pixel viewer and wraps between groups only below that. The e2e layout check runs at 1920- and 1600-pixel windows and at 904- and 880-pixel viewers.
  • Measure is one tool for lengths and angles, with Keep as annotation in its options: on, the line is saved as an annotation with its length (L); off, a quick ruler that is never saved (M). The choice is remembered, the button picks the last one, toggling it while Measure is on switches at once, and a split by a line turns it on.
  • A drawing tool stays on after each shape, so shapes are drawn one after another without picking the tool again, and its button stays highlighted. It stays on until Esc, Select (V), a click on the active tool or another tool. Esc first drops a shape being drawn (a drag, a stroke or a polygon's vertices so far) and keeps the tool; with nothing being drawn it goes back to Select; with Select it clears the selection. A finished polygon (double-click or a click on its first vertex) leaves the tool ready for the next one, and each shape takes the next auto-label. Picking a tool or starting a shape closes a click tooltip left from Select.
  • Shape and Outline are split buttons: the button draws with the group's last tool, the arrow opens its menu.
  • The toolbar has one Tab stop (a roving tabindex: the control last focused, else the first); the arrow keys, Home and End move within it.
  • The toolbar's menus and popovers (⋯, Shape and Outline menus, Display, the color palette, the shortcut list) open over the slide's zoom buttons.
  • Tools are icons with tooltips that name the shortcut, and the active one is filled blue. The active tool's options (brush width, tolerance, HPF field area, point count, Measure's Keep as annotation) show in a strip anchored under the toolbar's left end, out of its layout, so the tool buttons, Drawing as, Undo/Redo, Display and ⋯ never move as tools change; the strip is a labelled group ("Brush options") that follows the tools in the arrow-key order. The save status keeps a minimum width while Annotate is on (the width of the icon when compact), with tabular figures. The live measurement shows next to the pointer while drawing.
  • Save status: "Saving… N" while N annotations, comments or notes are being sent or wait to be sent (dropped points not yet sent, and the items of each write request not yet answered: a batch counts its items), "N not saved" with Retry for dropped points the service refused, and "Saved" once a change on the slide was saved (shown while Annotate is on; saving and not saved show either way). A hidden role="status" region kept on the page announces it: a change of state at once, a changing count at most every 1.5 s, so counting points does not read out every click (the Point tool's count is announced the same way). Failed edits, deletes and reviews reload the slide and say so in the Annotations section.
  • Drawing as holds the layer, the label field (vocabulary and strict mode honoured, free text otherwise, auto-labels kept) and a color swatch. The color belongs to the layer: picking a layer switches to its color, and the swatch's palette (named colors and custom colors) sets that layer's color for new annotations. A layer's color is the user's choice, else its annotations' most common color, else blue for Default and a color of its own for a new layer. Another layer's color picked for this layer is named after this layer, and the list shows no color chip whose name is a layer's.
  • ⋯ holds Review AI annotations (N)…, the sharing of new annotations (Shared or Private), Export (all, or those shown), Import… and the keyboard shortcuts. An import's preview and progress show under the bar.
  • Tool shortcuts work only while Annotate is on and the focus is not in a text field (a slider, checkbox or radio button is not one); H, ] and [ work Annotate on or off; the review keys work while the review card is open and come first. Each key has one meaning: R is always the rectangle and never a review key, C is the Point tool, and "." always shows or hides the details sidebar (Annotate on or off, and while reviewing). OpenSeadragon's R (rotate), F (flip) and W (pan up) keys are off, Annotate on or off (the arrows still pan).
  • While annotations load, after a failed load, signed out or read-only, Annotate is disabled and a status says why. Annotate off also turns shape editing off, so a click on a shape only shows its tooltip.
  • Annotate on or off, the Shape and Outline menus' last tools, Measure's Keep as annotation and layer colors are remembered in localStorage (a stored Shape tool no longer in the menu, such as the HPF field, falls back to the rectangle).

Magic wand and smart brush (tissue-aware selection)

Classical image processing, no model. Both save ordinary regions (a polygon, or a region with holes or parts), drawn as the toolbar's layer, label and color, and load with their Web Worker as their own async chunk (wsi-tissue, about 70 KB) when either is first picked.

  • Magic wand (W, Outline menu): a click on tissue shows at once a dashed outline of the connected region of similar color (flood fill from the click). While it waits, dragging the press up raises the tolerance and down lowers it, and the wheel does the same (Shift by 5); the tolerance (1–80, 15 by default) shows next to the click and in the toolbar. The wheel does not zoom while an outline waits (it would also change which pixels are read); the zoom buttons and keys still zoom, and Enter or Esc gives the wheel back. Shift+click adds a region (union), Alt+click cuts one out (hole or notch, with the shape-editing operations); each click keeps its own tolerance and a drag or scroll changes the last one's. Clicks are computed one at a time in order, so Shift+clicks made while one computes all count. A press inside the outline only adjusts the tolerance. Enter or a double-click saves, Esc discards, Ctrl+Z takes back the last click; the saved region undoes like any shape. Alt as the first click with regions selected makes a red outline that Enter cuts out of them; in "Cut a hole…" the outline is the shape cut out.
  • Smart brush (Shift+B, Outline menu next to Brush): the brush's width in µm, but it paints only pixels within the tolerance of the color under the start of the stroke and connected to the stroke within the band, so it stops at a tissue edge and does not jump a gap. It shows a live outline of what it painted and saves that (Alt as it ends cuts it out of the selected regions); a stroke that painted nothing says so. Each stroke finishes on its own, so one started while the previous is still being saved is kept.
  • Color distance: CIELAB with lightness at half weight, √((0.5·ΔL*)² + Δa*² + Δb*²), from the mean color within 2.5 µm of the click, after a box blur about 1 µm each way (3×3 at 1 µm per pixel, 9×9 at 0.25; running sums). Both are in µm, so a click on screen at 40× and one on 10× tiles average the same tissue. Lab is near perceptually uniform, so one tolerance means about the same visible difference for H&E and IHC: eosin pink, hematoxylin purple, DAB brown and background differ in hue and chroma, which count fully, while staining intensity within a tissue varies with thickness and focus, so lightness counts half. Color deconvolution was not used: it needs stain vectors per stain and scanner. Colors are quantized to a 32,768-entry Lab table.
  • Outline: holes under 500 µm² (about 25 µm across: nuclei, specks) are filled, larger ones (lumens, vessels) kept; smart-brush parts under 50 µm² dropped. The mask boundary is followed pixel edge by pixel edge (4-connected regions) through the edge midpoints (the marching-squares contour), then simplified with Douglas–Peucker at 1 µm of tissue (at least 0.75 analysis pixels), independent of the zoom.
  • Pixel source (hybrid): at an effective 10× or more (as the status bar computes it), the OpenSeadragon canvas's own pixels (CSS × devicePixelRatio; a canvas over 4096 px a side is read in a 4096 px window around the click or stroke start), mapped through the viewport to level-0 image pixels, once the view's tiles are drawn (waiting up to 5 s; still loading, it uses tiles, so an outline never comes from a half-drawn view); an outline reaching the edge of the view stops there and says so. Zoomed out, rotated or flipped, or with an unreadable canvas: the tile server's tiles of the level nearest 10× (about 1 µm per pixel) around the click, fetched as blobs with the viewer's own tile URLs (/wsi/tiles/zxy/…?studyId&key&enc, session cookie) and stitched offscreen; it starts at about 512 px square (2 or 3 tiles each way), grows on each side the fill reaches by half its span (at least 2 tiles) up to 4096 px a side (about 4 mm at 10×), shows the outline at each step, stops growing when a newer tolerance or click arrives, says when it is cut at the limit, and shows a spinner while loading. A new outline or Esc cancels the tile requests still waiting (AbortSignal), and nothing an earlier click finishes shows afterwards. Outlines are in image pixels either way; on a synthetic slide the two sources agree within 3% of the area. The status under the slide names the source and the time from the click to the first outline; the outline element carries data-source, data-ms and data-seed (the click in image pixels).
  • Worker: fill, hole filling and contour run in a Web Worker (inlined by rollup-plugin-web-worker-loader, started from a Blob URL, no extra file to serve); the raster is transferred once per click and kept for tolerance changes, and each click is computed at its latest tolerance. A raster stays while a click of the outline, a stroke or the next click can use it (one grown for a later click replaces it for all) and is dropped once nothing refers to it. A slider is not a text field, so Enter, Esc and the shortcuts still work with the tolerance slider focused. Without a worker (no Worker, or a CSP without blob: workers) the same code runs on the main thread. checkWsiBundle also checks the tissue code is not in an initial bundle.

Quick ruler

  • Measure with Keep as annotation off (M) drags a ruler that reads the length (µm, or mm from 1 mm, per-axis mpp; pixels without one) and the angle from the horizontal (0–179°). The ruler stays on the slide, a yellow line on a dark halo with end ticks, following it as it pans and zooms, until the next measurement or Esc; a click without a drag keeps it. Esc drops a measurement being dragged, then clears the ruler, then goes to Select.
  • It is not an annotation: nothing is sent, it is off the undo history and out of GeoJSON exports, and it goes with the slide. The downloaded view includes it while it shows, also with H.

High-power fields and points inside regions

  • HPF field (Shift+C), in the toolbar's Count group next to Point, places a high-power field with a click (a drag still pans): a circle of a set area of tissue centred on the click, saved as a circle annotation (an ellipse in pixels when the x and y scales differ), labelled "HPF n" with the next number after the highest on the slide or being saved, on the active layer. A dashed circle under the pointer previews it. The toolbar offers 0.159, 0.196, 0.237 (default), 0.283, 0.332 or 0.374 mm², each with its field diameter ("0.237 mm² (0.55 mm), default"), or a custom 0.01–5 mm², remembered locally. It needs the slide's mpp; without one its button is disabled and says why.
  • Every region (rectangle, ellipse, circle, polygon, freehand, brush, and regions with holes or parts) shows Points inside: N (label n, …) · d per mm² in its list row and tooltip when it holds points: all points on the slide, whatever layer or filter hides them, by label term, with the density from the region's area on a slide with a scale. Points in a hole are not inside. A region without points shows no count, except while the Point or HPF field tool is on and on a field itself. Points are indexed by x, so a region tests only the points within its bounds, and counts are cached until the annotations change.
  • With fields on the slide, the Annotations section's Counts adds a table of the points in them per label, per 10 HPF (count over fields, times 10) and per mm² (count over the fields' area), and the fields' area. It counts the user's own fields and points by default (Count fields and points of: You, the drawing layer, or All users). A point in overlapping fields counts once and the overlap's area once (pairwise circle lenses), and overlapping fields are named under the table. Under 10 fields the per-10-HPF rate is provisional: italic, not bold, "Provisional: based on N fields". Each rate column has an info icon with its explanation (also its header's aria-describedby).
  • What an HPF is is explained in plain language wherever HPFs appear: the HPF field button's description, an info icon by the area picker and one by the field table (tooltips on hover and focus, and the same text as each control's aria-describedby): "HPF (high-power field): the area of tissue seen through the microscope at high magnification (40× objective). Mitoses and other counts are often reported per 10 HPF. The field's area depends on the microscope's eyepiece (its field number): pick your microscope's area, or enter it in mm². Default 0.237 mm² (0.55 mm diameter)." The table's icon also explains its two rate columns.
  • GeoJSON exports add Num points, Num points: <label> and Points per mm^2 to a region's measurements.

Reviewing AI annotations one by one

  • Review AI (N) (next to the Show chips at the top of the Annotations section) or the ⋯ item opens a card at the bottom left of the slide. It steps through the unreviewed AI annotations (assistant and model) that the user may review among those shown (shown layers, with AI unreviewed on under Show); when Show or the layers hide them all, the entry is disabled and says so: each is fitted in the view and highlighted with a dashed yellow frame, and the card shows its label, origin (with provenance.model), layer, area/perimeter or length, and note.
  • A or Enter accepts (Enter on a focused button stays that button's own) and X rejects (the review route as below), then the next one shows; a reject asks first (X or Reject once; X, Enter or Confirm reject confirms, Esc cancels; the card says what a reject does, as the button's aria-describedby); S or → skips; ← goes to the previous one still unreviewed; Esc or × closes. The order wraps, so skipped ones come back. "N of M reviewed" counts those reviewed by anyone (or gone) of the ones the queue started with; the end says "All M AI annotations reviewed." or why some are left.
  • Order: nearest next. It starts at the annotation nearest the slide's top-left corner and always goes to the nearest one not yet visited, so the view usually moves by about one annotation; only the last steps can jump further. Above 3,000 annotations it uses horizontal bands, alternately left to right and right to left. A plain reading order was not used because it jumps back across the slide at every row.
  • Keys: while the card is open, A, Enter, X, S, → and ← belong to the review and come before the tool shortcuts (tool keys wait until the card closes), OpenSeadragon does not pan or rotate with them, and they do nothing while typing or when a toolbar control already took the arrow. The card says so, and the shortcut help lists them in their own section.
  • A 409 reloads the slide and keeps the card on the same annotation while it still needs review (press A or X again); if someone else reviewed it meanwhile the card moves on. Without the review route only the user's own AI annotations are queued, and with none the entry is disabled with the fallback message. Signed out, read-only or loading, the entry is disabled with the reason; a refusal mid-review ends the queue with the sign-in or read-only message. The annotation under review shows even when its layer or its kind is hidden.

Display

  • Display (the eye next to ⋯) opens a popover, Annotate on or off: Fill opacity 0–100% (20% by default), Outlines only, Labels on the slide, Hide all annotations (H) and Show (below). A dot on the eye marks a non-default setting; it is crossed out while all are hidden.
  • One visibility model: what shows is decided by the layers' eyes and solo plus Show, with four kinds: Mine (the user's own, including "AI, edited" ones the user made), Others (other users' shared ones), AI unreviewed and AI accepted (machine-made, by review). With the user unknown there is no Others and Mine reads Manual. Show is in the Display popover (checkboxes) and at the top of the Annotations section (toggle chips, aria-pressed), each kind with its count on the shown layers, so the shown kinds add up to what the slide shows; both set the same state. The slide, the list and its counts, the section's title, ]/[, Ctrl+A, the review queue (Review AI (N)) and "shown" exports all read the same set; the list's own filters (text, layer, author, label) only narrow the list. There is no separate "Hide unreviewed AI annotations" checkbox or "AI and manual" list filter; neither was ever stored, so no preference needed migrating.
  • Whenever anything is left out of the list (a layer, a kind, a list filter) or H hides all, a hint above the list says N hidden by filters · Show all; Show all shows every layer and kind, clears the list's filters and turns H off. The annotation under review still shows, and a link to a hidden annotation shows its layer and kind again. Show is for this visit only, like hide all, so a slide never opens looking empty.
  • Slide labels sit at each shape's top-left corner, white on a dark band (7:1 or more on any tissue). Larger shapes are labelled first, a label that would overlap one already shown is left out, shapes under 24 screen pixels on both sides and points get none, and at most 150 show; they follow the slide as it moves.
  • Labels, highlights and selection frames are drawn in an SVG overlay over the slide that ignores the pointer. GeoJSON exports hold annotation data only.
  • Downloaded view: the status bar's download draws the annotations over the slide's canvas as they show (wsiAnnotationSnapshot.ts; holes filled even-odd, so they stay empty): what shows (layers, solo and Show), the Display fill or outlines only, points as their markers, and the labels on the slide when on; nothing while all are hidden (H). Shapes are traced in level-0 pixels through the overlay's image-to-screen mapping and drawn at the snapshot's measured pixel ratio, so they line up at any device pixel ratio. The quick ruler is drawn too while it shows. The copy is first filled with the color behind the slide (the stage's gray, read from the page), so the area around a zoomed-out slide is gray rather than black, with annotations off too. The shape being drawn, the selection, the selection box and the review highlight are left out. The file name is unchanged.
  • H hides every annotation on the slide while the list, counts and tools stay.
  • Each layer row has a solo button (a ring, with a dot when on) that shows only that layer; pressing it again, or Show all layers in the popover, shows the layers hidden before. A layer's eye ends the solo.
  • Fill, outlines only and labels are remembered in localStorage (with try/catch); hide all and solo are not.

Stepping through annotations, and links to one

  • ] and [ step through the annotations the list shows (what shows, and its filters), Annotate on or off, in the same nearest-next order, wrapping around. Each is fitted and highlighted, and a bar at the bottom says "3 of 17: label" (role="status") with ‹ ›, Copy link and ×. A list row's label highlights its annotation too. Esc clears the selection first, else the highlight. ]/[ were picked because N/P would clash with P (Polygon) and the arrows belong to the review card and to OpenSeadragon's panning.
  • Copy link (the bar, and a link icon on each saved list row) copies a URL that opens the slide at the annotation, by the opaque slide key and the annotation id only:
    • Pathology Slides tab: /patient/wsiHESlides?studyId=…&caseId=…&pathologySlideSettings={"annotationId":"…"}#wsi:slide=<slide key>: the existing deep-link hash selects the slide, and annotationId is a new key of the pathologySlideSettings node (PatientViewUrlWrapper), read by PatientWsiSlidesTab;
    • /wsi/patient/{patient}?studyId=…&slideKey=…&annotationId=…, read by WsiPatientViewRoute.
  • The viewer gets requestedAnnotationId, requestedAnnotationSlideKey, onRequestedAnnotationUsed and annotationLink props. The linked annotation opens only on the link's slide (the hash's slide on the tab, slideKey on the permalink), once, when its annotations load; both hosts then drop annotationId from the address (history.replaceState, keeping the #wsi: hash), so a reload or another slide does not open it again. Opening it: its hidden layer is shown (ending a solo), its kind is turned on under Show, hide all is turned off, and it is fitted and highlighted. A missing, rejected or another user's private annotation (none of which the service lists) gives "The linked annotation is not on this slide…" in the bar. Without the Clipboard API the bar shows the link to copy by hand.

Selecting several annotations

  • With Select (no drawing tool), Annotate on or off: Shift+click adds or removes the shape or point under the pointer (the smallest where shapes overlap), Shift+drag adds the annotations wholly inside the box, each list row has a checkbox, Ctrl/Cmd+A selects everything the list shows when the focus is in the viewer (or nowhere while Annotate is on; elsewhere the page's select-all is left alone), and Esc clears. Selected shapes get a thicker outline and a dashed blue frame.
  • A bar under the toolbar says N selected and has one Actions ▾ menu button (wsiMenu.tsx): Relabel N… (a label field in the bar; Enter applies, Esc cancels), Move N to layer ▸, Sharing of N ▸ and Edit shapes ▸ (submenus), Accept N, Reject N…, Delete N… and Clear selection. Relabel, move, sharing and delete apply to the user's own annotations; Accept and Reject to unreviewed AI annotations the user may review (anyone's, through the review route). Items act on a pick, never while arrowing through, and each names its count and, at its end, whether Ctrl+Z undoes it ("Ctrl+Z undoes" or "Can't be undone"). A role="status" says what was done, skipped ("skipped 1 that is not yours") and not saved.
  • Confirm and undo rules, the same everywhere: Delete and Reject ask first (Reject naming what it does and that Undo (Ctrl+Z) can take it back; Delete naming any comments, and that Undo brings them back with the annotation); whatever Ctrl+Z can undo says so in the menu and, once done, under the status ("Undo reject of 2 AI annotations with Ctrl+Z or the toolbar's Undo."). Accept does not ask. On a service that cannot reset reviews, the menu, the reject confirmation and the status say "Can't be undone" / "Reviews can't be undone." instead.
  • Relabel, move and sharing go through POST /annotations/batch-update, delete through batch-delete, accept and reject through batch-review, and their undo through batch-review (reset) and batch-restore, in requests of up to 100 annotations, each with its current version, saved all or none. A 409 lists the stale ones: they are reported as changed elsewhere, the slide reloads so they show as stored, and the rest are sent again from the reloaded versions. A 403 or 404 naming an item reports it by label with the service's reason and sends the rest again (a missing one also reloads the slide). A 404 "Not Found" or 405 means the route is missing: that action and later ones of its kind send one request per annotation, four at a time, as before. The status names up to three that were not saved, and why.
  • Relabel, move and sharing undo and redo as one step (a group history entry), as do a bulk delete (one batch-restore per 100) and a bulk accept or reject (one batch-review reset per 100).
  • Edit shapes ▸ is enabled while regions are selected (below).

Editing shapes: holes, merge, split

  • Storage: a region of one ring stays an SvgSelector <polygon>, so existing annotations read, render and edit unchanged. Holes and parts are stored as Annotorious writes a multi-polygon, which the service stores as given: one <path fill-rule="evenodd"> per part in a <g>, the outer ring then the holes as closed subpaths (<svg><g><path fill-rule="evenodd" d="M 0,0 L 100,0 L 100,100 L 0,100 Z M 40,40 L 40,60 L 60,60 L 60,40 Z" /></g></svg>), level-0 pixels rounded to 0.01. Annotorious draws it with the holes empty and edits its vertices; the viewer parses it (parseAnnotationShape → multipolygon), measures, counts points and hit-tests with holes left out. An older viewer draws it but lists it without a size.
  • Actions ▾ › Edit shapes ▸ in the selection bar (the order of selection counts), each item with its count, disabled with the reason otherwise:
    • Merge N regions: one new annotation of their union (parts that do not touch stay parts), with the first selected's label, layer and color;
    • Subtract: the others cut out of the first selected;
    • Intersect N regions: one new annotation where all overlap; the originals stay;
    • Cut a hole…: the next closed shape drawn (any shape or outline tool; the brush works as an eraser) is cut out of each selected region it overlaps (hole, notch or pieces); it picks the Outline menu's last tool unless a closed-shape tool is on and stays on for more holes until Esc, Done or Select. Holding Alt as a shape ends cuts it out once, without the menu (in the shortcut help);
    • Split … by a line… (one region): the next line drawn across it (Measure, which the split turns on with Keep as annotation, or a freehand or polygon path) splits it; each piece is its own annotation with the region's label, layer and color, and the pieces are selected. A line that does not cross it says so and saves nothing;
    • Separate parts: each part of a multi-part region becomes its own annotation.
      A bar under the menu says what to draw while a cut or split waits; the bar's status says what was done, kept and not saved.
  • Ownership: results are always the user's. Merge may combine any regions the user can see, own or shared by others; the result is a new annotation (sharing as the first selected when it is the user's, else the default). The user's own originals are deleted, except AI ones; other users' stay, and the status names them ("Kept "Theirs": it is not yours, so it stays as it is."). The user's own AI originals stay because only the service's trusted writers may create a machine-made annotation, so undo could not bring a deleted one back; the status says so. Subtract, cut, split and separate change the user's own region in place (a split keeps the largest piece under its id); on another user's region they make new annotations of the user's and leave it. A cut or split rectangle or ellipse becomes a polygon (an ellipse with 96 vertices).
  • AI, edited, within the service's trusted-writer rule (no service change): the user's own machine-made region changed in place keeps its provenance.source (an update by the creator may keep it; review fields stay as stored) and gets edited: true, also when its vertices are dragged; a new annotation made from AI annotations is written as {source: "manual", operation, derived_from: [ids], derived_from_ai: true} (from other annotations, the same without derived_from_ai). Both show AI, edited; History says "Created (merge of 2 annotations, from AI)" or "Shape edited by a person"; a derived one is the user's, so it counts as Mine and is not in the review queue.
  • Undo: each operation is one step ("Undo merge", "Undo cut", "Undo split", …, a labelled group entry): undo deletes what it created, puts the previous shape back on what it changed (versioned PUT) and restores the deleted originals under their ids, with their comments; redo applies it again.
  • All or nothing: new annotations are saved first (batch saves), then changed shapes (versioned PUTs), then the originals' deletes (one all-or-none batch-delete). If any part fails (a merge whose originals cannot be deleted, a split whose region changed meanwhile), what was saved is taken back (created ones deleted, changed ones put back, deleted ones restored under their ids), the status says what failed and that nothing changed, and nothing is left to undo. Operations run one after another, so a second cut drawn while the first saves applies to the saved shape and version.
  • Library: polygon-clipping 0.15.7 (MIT; deps splaytree, MIT, and robust-predicates, Unlicense), about 29 KB minified / 9 KB gzipped, in the package's dependencies and pnpm-lock.yaml. It and wsiAnnotationShapeOps.ts load as their own async chunk, wsi-shapeops, when a shape operation (or a wand Shift/Alt+click) first runs; area, bounds and parts (wsiRegionUtils.ts) stay in the viewer. checkWsiBundle fails a build with polygon-clipping outside that chunk. A split cuts a 0.2-pixel band along the line (about 0.05 µm at 0.25 µm/px), so pieces do not touch; slivers under 1 px² are dropped.

Side by side: H&E and IHC, manual alignment, annotation transfer

  • Compare in the main slide's status bar opens a second viewer next to the slide, split by a draggable divider (role="separator", arrow keys by 5%, Home/End; each slide keeps at least 20%). It is disabled with the reason when the patient has no other slide. A bar above the slides holds Lock views, how the views follow each other, Set anchor/Clear anchor, Align and copy and close.
  • Panes: each is a labelled region ("Left slide: IHC TTF-1 · WSI-7716-db01-44f7") with a header of the stain, a slide picker and the Slide ID, and shows its own slide's annotations, status bar and zoom buttons. The left pane is the main slide (slide list and #wsi: link); the right pane keeps no URL state (ownsUrlState: false on its controller host). The main stage keeps its place in the React tree, so its OpenSeadragon viewer is not rebuilt when Compare opens or closes.
  • Active pane: a press or the focus in a pane makes it active (blue header line). Only it shows the annotation toolbar and takes the annotation keys (tools, undo/redo, H, ]/[, review keys, Ctrl+A); the other pane's drawing stops (setPaneActive). The details sidebar follows the active pane. F6 moves the focus to the other slide. A viewer the host hides (hidden, e.g. an inactive tab left mounted) takes no annotation keys at all (setViewerHidden), so a key on another tab never reviews the AI annotation under review. The review card's focus fallback looks for the annotation list in its own viewer only.
  • Pairing (wsiComparePairing.ts): the picker lists the patient's servable slides relative to the other pane's slide in option groups: Same block, then Same part, then the rest by sample and part (that slide's sample first, unmatched last); within a group the counterpart stain first (IHC next to H&E, H&E next to IHC or other). Compare opens the first, so an H&E opens with the same block's IHC and an IHC with the same block's H&E. Groups come from the hierarchy (sample → part → block), stains from stain_kind.
  • Sync (wsiCompareSync.ts; Lock views, on by default): the pane last pressed, scrolled or typed in leads; its pan/zoom/rotate/flip requests move the other to the mapped target, so both animate together; a pane opening another slide follows and does not lead until it is open. The map:
    • aligned (3+ pairs): centre through the fit, zoom divided by its scale (square root of the area ratio), rotation turned by its angle; a mirrored fit keeps the leader's orientation mirrored left to right, without flipping the view (OpenSeadragon maps screen points without its flip, so overlays would be misplaced);
    • anchor: after Set anchor with both centred on the same tissue, by distance in µm from the two centres (per-axis mpp), at equal µm per screen pixel;
    • relative otherwise: the same place relative to each image, the same share of the width.
  • Alignment (wsiCompareTransform.ts, wsiCompareStore.ts): Align and copy opens a fixed-height panel (the slides do not move as it changes). With Place points on (on at first without an alignment), a click (a drag still pans) on a feature of either slide, then on the same feature of the other, makes a numbered pair; shapes ignore clicks meanwhile. Markers are buttons: drag to move, arrow keys to nudge (1 or 10 screen pixels), Delete to remove the pair (or × on its chip). A complete pair shows a dashed ring where the fit puts the other point.
    • Similarity (closed-form least squares; a mirrored fit only when it has under half the squared error) or Affine (least squares; collinear points refused); both need 3 complete pairs.
    • Residuals: each pair's distance from its fitted place in µm of the right slide (pixels without a scale), with RMS and largest; 3 pairs with affine is flagged as an exact fit.
    • Reset restores the points, model and anchor from when the panel opened; Clear points removes them (Reset brings them back).
    • Kept per slide pair in localStorage (wsi-compare-alignment:v1:<key>:<key>, keys sorted so either side order finds it), with try/catch.
  • Transfer: Selected (N) or Layer … (N) copies the active pane's annotations to the other slide through the fit (its inverse right to left) as new annotations of the user's with the source's label, layer, color and note: rectangles and ellipses become polygons, regions keep holes and parts, points/lines/polylines their kind. Saved in batch creates as one undo step on the target ("Undo transfer of 3 annotations"), whose pane becomes active. provenance: {source: "manual", operation: "transfer", transferred_from: {slide_key, annotation_id}, transform_model, transform_residual_um (or _px), verified: false}, plus derived_from_ai: true from an AI source (shown "AI, edited"); source: "manual" passes the trusted-writer rule. List row and tooltip show Transferred · unverified/· verified; Mark verified (creator only, versioned PUT, off the undo history) adds verified: true, verified_by, verified_at. History reads "Created (copied from slide WSI-… through an alignment)" and "Place verified".
  • Shortcut help has a Side by side section (F6, Place points click, marker arrows/Delete, divider arrows).

Stored body

  • The layer is written to body.layer_name, the color to body.color (letter case kept), and body.comment holds the user's note. body.provenance is carried through every update; shape editing adds edited: true to an AI annotation a person reshaped, and writes source: "manual", operation, derived_from (and derived_from_ai: true from AI annotations) on the annotations it makes; a side-by-side copy writes the transfer provenance above.
  • Rows from before layer_name was used kept the layer in comment and sent no layer_name, color or provenance, so the service stored its defaults (Default, #2f80ed). A row is read as legacy, with comment as its layer, only when it has no provenance, those defaults, and a one-line comment of at most 100 characters. A row with provenance (the assistant, scripts, loaders) keeps its one-line comment as a note. The viewer writes #2f80ed as #2F80ED, so its own rows never match.
  • A legacy row's stored comment is written back unchanged until the user edits the note, so a note can never be erased by being misread as a layer. A comment that only repeats layer_name (as the assistant writes) is not shown as a note. The rules are in wsiAnnotationBody.ts and the README.

Review, sharing and notes

  • AI annotations show an AI · unreviewed / AI · accepted badge, and AI, edited (AI, edited · unreviewed while still to review) once a person changed one (see Editing shapes). These are annotations whose provenance.source is agent or assistant (the research assistant) or model, ai or precomputed (a model). The tooltip says which, and names provenance.model when set. Show hides them by their review (AI unreviewed, AI accepted), on the slide and in the list alike.
  • Review: any user who can edit in the study may Accept or Reject an unreviewed AI annotation, whoever created it.
    • Both send POST /annotations/{id}/review with {decision, version}. The service records review_status, reviewed_by and reviewed_at.
    • A rejected annotation is kept by the service as a review record and is no longer listed, so the viewer drops it.
    • A 409, or a 404 saying the annotation is gone, reloads the slide.
    • Undo of a review: each accept or reject (one, or in bulk) is one undo step ("Undo reject", "Undo accept of 3 AI annotations"). Undo sends {decision: "reset", version} (batch-review for several): the annotation is unreviewed again, a rejected one is listed again, and the review card goes back to it. Redo reviews it again. Only the latest reviewer may reset: when another user reviewed it since, the service's 403 is shown as "Could not undo the accept of "Tumor": bob reviewed it since, and only the latest reviewer can undo a review." (not as lost access). A 409 or 404 reloads the slide and names it.
    • A service whose review route refuses reset as an unknown decision (a 422 on decision) is remembered for the session: the first Undo says "This annotation service cannot undo reviews…" and drops reviews from the history, later reviews stay off it, and Undo right after one says "Reviews can't be undone." before undoing the earlier edit.
    • The route counts as missing on a 405, or a 404 whose JSON detail is "Not Found". The viewer then falls back for the session: the creator accepts with a versioned PUT and rejects by deleting, neither on the undo history, and a note (not an error) says how it was recorded. Other users see no review buttons. Any other 404, such as a proxy's HTML page, reports that the review was not saved and decides nothing.
  • Ownership: the viewer gets the signed-in user as annotationUser: the page's AppStore.userName (the backend's Authentication.getName(), which the study access check forwards as X-Auth-Request-User and the service records as created_by). Both the Pathology Slides tab and the /wsi/patient/... permalink route pass it; user_display_name is only the last fallback.
    • Label edit, delete, note and sharing controls show only on the user's own annotations, and only those shapes can be dragged.
    • A layer delete removes only the user's annotations. Its confirmation gives the user's own count and says the layer stays while other users have annotations in it.
    • With the user unknown, the controls show on every annotation and the service refuses other users' changes.
  • Private / shared: a default for new annotations in the toolbar's ⋯ menu (shared unless changed, remembered locally) and a per-annotation badge that switches visible_to between null (private) and [] (shared with the study). The README notes for services and loaders that an annotation created with visible_to null (or without it) is creator-only, so machine-made annotations meant for review must be created with []; the viewer creates shared annotations by default.
  • A service 403 for editing another user's annotation is shown as a per-annotation error; it does not make the study read-only.
  • Notes: each list row shows and edits body.comment, separate from the label, saved with a versioned PUT. The tooltip shows it too.
  • History: under each row, the creator and date, and a History ▸ disclosure with what the service stores: created (by whom, when, by which assistant or model), the review (review_status, reviewed_by, reviewed_at) and the last change with its version (version, updated_at). The service records no editor for an update, so the last change is credited to the reviewer when it is the review (saved within 5 s of reviewed_at), else to the creator, the only user who may edit. The tooltip says "By alice · version 3". A full audit log would need a change table in the service; the History block says so.

Comment threads

  • Each saved annotation's list row has a Comments disclosure with the thread's count (comment_count) as a badge. A paged thread loads 100 at a time: Show more comments (N more) at its end; a cap's 422 message is shown.
  • Deleting (row, bulk, layer) or merging away an annotation with comments asks first, naming the count and whether other users wrote some (loading those threads, up to 20), and saying that Undo brings it back with its comments and that otherwise the service removes deleted annotations and their comments for good after 30 days (its default).
  • Deleting and restoring: the service's deletes keep the annotation and its thread. Undo of a delete (row, bulk, layer, or the originals of a merge) sends POST /annotations/{id}/restore with the version it was deleted at (one batch-restore per 100 for several): the same id comes back at the next version with its comment_count, so comments and links to it survive; redo deletes it again. Merge, split and shape-edit rollbacks restore the originals they deleted the same way. One already purged (404) is created again with a new id. On a service without the route (405 or 404 "Not Found", remembered for the session) Undo creates the annotation again with a new id, the history follows it, the delete warning says the comments go, and Undo says "… was created again as a new annotation; its 2 comments could not be restored." It loads the thread under the row, oldest first, each comment with author, time and "(edited)". Users who can edit add a comment (Ctrl/Cmd+Enter or Comment; 1–4,000 characters, a count near the limit) and edit or delete their own (Delete after a confirmation); others' comments have no controls. The annotation's note stays separate. The tooltip says "2 comments".
  • Focus: opening focuses the comment field, a post keeps it there (emptied), a delete returns it there; editing focuses the editor, and Save or Escape returns to Edit.
  • Threads show only on a service whose list carries comment_count; a 404 "Not Found" or 405 from the thread route turns them off for the session. Another user's comment ("Only its author can change this comment.") and a comment deleted meanwhile (the thread reloads) show on the thread as role="alert"; an annotation gone or no longer shared reloads the slide.

Slide notes and tags

  • The sidebar's Slide notes section (above Layers; below them while Annotate is on) holds notes on the open slide itself (/slide-notes), each with text, tags, author, time, "(edited)" and Private or Shared. Above them, the slide's tags with how many notes carry each, most used first; a tag filters the notes (aria-pressed).
  • Users who can edit add a note: text (up to 4,000 characters; Ctrl/Cmd+Enter adds), tags (Enter or a comma adds one, Backspace in the empty field removes the last, × removes one; suggested from the slide's tags; up to 20 of 1–40 letters, digits, spaces or _-.:/+# starting with a letter or digit, checked before sending; a repeat in another case dropped) and Shared with the study or Private, starting from the ⋯ menu's default. They edit and delete only their own, with the note's version; a 409 or a note gone meanwhile reloads the notes and says so.
  • Notes load when the section first shows (a collapsed section loads nothing) and again on another slide or study; the title gives the count (the service's total). Paged, Show more notes (N more) loads the next 100, the tag summary counts all notes, and a cap's 422 message is shown. An answer read after another slide opened is dropped, so a note never lands on the wrong slide. Without the route (404 "Not Found" or 405) the section goes away for the session.

Measuring and drawing

  • Editing waits for the load: drawing and editing are off until the slide's annotations have loaded. A failed load shows an alert with Retry.
  • Measurements: line length, and area and perimeter of rectangles, ellipses, circles and polygons, in µm/mm and µm²/mm² from the slide's tile_metadata.mpp, scaled per axis. A region with holes or parts measures its outer rings less its holes, and a perimeter along every ring. Shown in the list, the tooltip and, while drawing a line or box, next to the cursor. Without an mpp, sizes are in pixels, and the panel says so even before any annotation exists.
  • Points: the Point tool (C) drops a point per click (a drag still pans) and, like the other tools, stays on until Esc. New points are labelled with the active label, else the layer color's name, else "Point". A point is an SvgSelector circle of radius 0, drawn as a fixed-size marker on a canvas kept out of Annotorious, so hundreds stay fast. A toolbar count and a per-label/per-layer tally (under Counts) update at once.
    • Points are saved together in batch requests: half a second after the last click, on a tool change, and when the page is hidden. Undo waits for unsent points.
    • Points dropped one after another undo as one step ("Undo create of 12 points"): the drops of one Point tool session with no other change in between and at most 3 s between two drops (POINT_UNDO_GROUP_MS). Another tool or the Point tool picked again, Esc, any other change, undo or redo, or a longer pause starts a new step; the pause bounds what one undo can take back while counting at a steady pace. Each point stays its own annotation, edited or deleted on its own. A run undoes with batch-delete (one by one without it) and redoes with batch saves.
    • An edit or delete of a point whose save is in flight waits for that save and applies to the saved id; an edit shows at once.
    • Points still unsent when another slide or study opens, or the page unloads, are sent with keepalive and without waiting for an answer: in batches when the batch route is known to exist, else as one POST per point, all at once.
    • Points the service refuses for access (401/403) stay on the slide marked Not saved, with "N points were not saved." and Retry (e.g. after signing in again). Points that could not be sent before another slide opened are reported there.
  • Freehand traces an outline. Brush paints a band 10–500 µm wide (50 µm by default), converted with the slide's mpp so a stroke covers the same tissue at every zoom; a circle under the pointer shows its size. Without an mpp the width is 8–64 screen pixels at the zoom the stroke starts at, and the toolbar says so. Points are appended to the stroke in place, and the preview adds each new point to its polyline (SVGPointList.appendItem), placing the whole stroke again only when the slide moves, so a 5,000-point stroke costs the same per move as a short one. Both are simplified with Douglas–Peucker (1.5 screen pixels at the finest zoom the stroke was drawn at) and saved as polygons (the brush as its outline), so they have an area and export to QuPath as regions.
  • Zooming while drawing: the wheel and zoom buttons pan and zoom the slide mid-gesture. Each pointer position becomes level-0 image pixels when it happens, with the slide as shown at that moment (also mid-animation); the shape being drawn is kept in image pixels, and its outline, the live measurement and the brush circle are redrawn on OpenSeadragon animation/update-viewport, so they stay on their tissue. A polygon closes on its first vertex where it is now. The status bar's cursor position follows the pointer during a drag, stroke or polygon too. Only the pointer that started a press draws (with pointer capture); pointercancel or lost capture drops the drag shape or stroke, and a polygon keeps its vertices.
  • Editing, undo and redo: while Annotate is on, Annotorious's shape and vertex editing saves only the new geometry over the stored annotation. Undo (toolbar, Ctrl/Cmd+Z outside text fields) reverses the session's last create (delete), edit (PUT of the previous version with the current version), delete (restore under the same id) or review (reset). Redo (toolbar, Ctrl/Cmd+Shift+Z or Ctrl+Y) applies an undone change again the same way. Layer deletes, bulk actions and imports undo and redo as one step; annotations created again on a service without restores get new ids and both histories follow them. A new change clears the redo history.

Labels, list, export and import

  • Label vocabulary: annotations.labelVocabulary / labelVocabularyStrict in the runtime, from the portal properties wsi_annotation_label_vocabulary (comma-separated) and wsi_annotation_label_vocabulary_strict. The label fields suggest the terms and the slide's used labels and accept free text, or with strict offer only the terms. There is no default vocabulary.
  • Label terms: the point tally and the GeoJSON class group a viewer auto-label (a palette color's name or hex and a number, e.g. "Tumor 1", "Tumor 2") under its base ("Tumor"). Vocabulary terms and other labels are their own term, so "Grade 1/2/3" and "Gleason pattern 3/4/5" stay apart.
  • Sidebar while Annotate is on: the Annotations section comes first and takes the height the other sections leave (at least 360 pixels, or 55% of the window when more; taller content scrolls inside it), and its list fills that height instead of a 260-pixel box, still virtualized. Then Layers and Slide notes, then the slide's details, with Clinical collapsed until opened (its open state while annotating remembered on its own key). Annotate off keeps the earlier order. The sections are keyed, so they move rather than remount and keep drafts, open threads and scroll positions.
  • Annotation list: from the top, the Show chips with Review AI (N), the hidden hint, Counts, the filters (label/note text, layer, author), then the rows. Counts is a disclosure, collapsed by default and remembered, whose button summarizes it ("Counts · 6 points · 1 HPF"); collapsed it renders nothing. Open, it holds the point table, the HPF table and Group by… (remembered), which shows the listed annotations per layer or per label group, one cloud at a time. A label groups under its base term: a trailing count such as " (13 tiles)" is dropped, and an auto-label's number too; vocabulary terms and graded labels such as "Grade 2" or "Gleason pattern 4" are never merged. The eight largest groups show, the rest behind +N more. A label chip filters the list to that group (pressed again, it clears). Each row's label pans and zooms the slide to its annotation.
  • Long lists: more than 100 rows are virtualized: only the rows in and near the view render (about 15 of 5,000), at offsets from measured heights (a ResizeObserver catches a note or thread opening; a render measures only new rows, the view's height is measured on resize, and the scroll position is applied once per frame), with aria-posinset/aria-setsize; the focused row stays rendered when scrolled away. In any list ↑/↓ move between rows' labels and Home/End to the ends, rendering the row first, and the list scrolls to the annotation the slide is pointed at (]/[, review, a link).
  • GeoJSON export (⋯ menu): all annotations, or those shown (layers and Show), as a QuPath-compatible FeatureCollection in level-0 pixels, with name, classification {name, color}, layer, note and QuPath-named measurements (and ai_edited). A region with holes is a Polygon with its inner rings, one of several parts a MultiPolygon. The slide is named by its opaque slide key only.
  • GeoJSON import (⋯ menu): refuses a file over 25 MB before reading it. It validates geometry, coordinates inside the slide, vertex/feature limits (all rings together) and a strict vocabulary (skips name the feature, and the part of a MultiPolygon), then previews the counts and skipped features. A Polygon keeps its holes and a MultiPolygon is one annotation of all its parts; MultiPoint and MultiLineString still split into one annotation per part. On confirmation it creates the annotations with batch saves, which undo as one step. Refused items are named with the service's reason; the rest are still created.
  • Batch saves use POST /annotations/batch, with at most 100 annotations and about 3 MiB per request (60 KiB with keepalive). A 422 naming items marks those as refused and sends the rest once more; a 413 halves the request; a 404/405 switches the session to single POSTs (four at a time, or all at once with keepalive).

Accessibility

  • All controls are native buttons, inputs and selects. Icon buttons (edit label, delete annotation, delete layer, remove color, cancel) have labels naming their target; decorative icons and the color dot are aria-hidden.
  • After accept, reject, delete or a label save, focus moves to the row, else the next (or previous) row, else the list.
  • Help that lived only in a title has an info icon (tooltip on hover and focus) whose text is the control's aria-describedby (WsiInfo): the tolerance, each HPF rate column, and the reject consequence. The AI and Transferred badges are role="img" named by their text and description. Sidebar text is at least 11 px, and the click tooltip's lines are not dimmed.
  • Text keeps at least 4.5:1 contrast: text on a color (color-name badges, the active palette color) is black or white by luminance, and the blue and gray text colors are darkened.
  • The toolbar is a role="toolbar" with a label; the arrow keys, Home and End move between its controls, and fields keep their own arrow keys. Shape, Outline, ⋯ and the selection bar's Actions are menu buttons (aria-haspopup, aria-expanded) whose menus open with Enter, Space or the down arrow, move with the arrow keys, Home and End, close with Escape, Tab, a press outside or a pick, and return focus to the button. Actions' submenus (Move to layer, Sharing, Edit shapes) are menu items with aria-haspopup/aria-expanded that open beside them with Enter, Space, a click or →, keep their own arrow keys, and close with ← or Escape back to their item; the parent menu moves only between its own items. Tools and the sharing default are menuitemradio / aria-pressed; the color palette and the shortcut list are dialogs that close with Escape. Every icon button has an aria-label naming its shortcut.
  • The review card is a non-modal role="dialog" named "Review AI annotations": it takes the focus on Accept, keeps it inside as it moves on, ignores clicks while a decision saves (aria-disabled, so focus is not lost), and gives the focus back to the button that opened it (else the list). Its buttons carry aria-keyshortcuts. Progress, decisions, the focused-annotation bar, link messages and bulk results are role="status".
  • The Display popover is a dialog that focuses the fill slider (aria-valuetext in %) and closes with Escape back to the eye; the bulk bar is a labelled group whose Actions items say how many they apply to and whether Ctrl+Z undoes them. Slide labels are white on at least 70% black, and the new buttons keep 4.5:1 or more.
  • The disabled Annotate button stays readable, and the status next to it is role="status". Errors and the unsaved-points notice are role="alert"; the review note is role="status".
  • New controls: Measure and the HPF area select and field are labelled and keyboard operable; the save status is a role="status" region; Show is a fieldset of labelled checkboxes in Display and a labelled group of aria-pressed chips in the sidebar; Counts is a disclosure (aria-expanded/aria-controls); the Draw, Count and Measure groups are labelled; History, Comments and the thread are disclosures (aria-expanded/aria-controls) with a labelled region; comment and note fields, tag chips' remove buttons ("Remove tag QC") and tag filters (aria-pressed) are labelled; invalid tags are announced (role="alert", aria-invalid). New text keeps 4.5:1 or more on its background.

Known follow-ups

  • History shows only what the service stores; a full audit log needs a change table in the annotation service.
  • Model-based tissue segmentation is deferred.
  • Alignments are kept in the browser only; a server-side store per slide pair needs an annotation-service change. Automatic registration is not built.

Tests

  • Package Jest (packages/cbioportal-wsi-viewer, --env=jsdom): 742 tests in 57 suites. Besides geometry, GeoJSON round trips, the point layer and the panel and toolbar, they cover:
    • tissue sessions (wsiTissueSession.spec.ts): three Shift+clicks, two arriving while the first computes, all combined; an earlier step still computing after a later step grew the shared tile window (no "raster is gone"); a click at the left of a 5200×2400 hi-DPI canvas selected; nothing shown after Esc while tiles load, and those fetches aborted; a new click aborting the previous click's fetches;
    • the smart brush keeping a stroke started while the previous one is saved (wsiTissueTools.spec.tsx); two quick cuts both applied on the saved version, a merge whose original-delete is refused and a split whose PUT conflicts both taken back with no undo entry, a merge whose first original was deleted before the second was refused taken back by restoring it under its id (with its comment), and the same on a service without restores by creating it again, undo of a merge restoring the originals in one batch-restore, a 422 on target saying the shape can't be saved, and the merge warning for originals with comments (wsiAnnotationShapeEdit.spec.tsx);
    • a slide-note answer read after another slide opened dropped; paged notes with Show more, the tag summary over all and the cap's message (wsiSlideNotes.spec.tsx); a paged thread with Show more and the cap's message, the delete warning naming other users' comments and saying Undo brings them back, Undo restoring the annotation under its id with its thread intact and redo deleting it again, and on a service without restores the annotation created again with a new id and Undo's "could not be restored" (wsiAnnotationThread.spec.tsx);
    • reject asking first in the card (X, Enter, Esc, Cancel; its aria-describedby), in the row and in bulk, R never rejecting, a key on another tab doing nothing; Undo of the queue's reject and accept resetting them and the card going back to the rejected one (wsiAnnotationReview, wsiAnnotationControls); the Edit shapes… menu acting only on a pick;
    • a short list scrolling to the pointed-at row (wsiAnnotationListPerf.spec.tsx); a link opening only on its slide, once, telling the host (wsiAnnotationNavigation.spec.tsx);
    • HPF: own fields and points by default, a point in two fields counted once, the overlap's area once, the overlap named, All users, the provisional rate, each rate column's described info icon (wsiAnnotationHpf.spec.tsx);
    • keys: R always the rectangle and never a review key, C the Point tool, "." never a tool and always the details sidebar (Annotate on, and while reviewing), A or Enter accepting while Enter on a focused button stays the button's, a checkbox or radio not a typing target, OpenSeadragon's R/F/W off Annotate on or off (wsiAnnotationController.spec.ts, wsiAnnotationReview.spec.tsx, WSIViewer.panels.spec.tsx);
    • the one visibility model (wsiAnnotationOrigins.spec.tsx, wsiAnnotationController.spec.ts, wsiAnnotationControls.spec.tsx): Show's checkboxes and the sidebar's chips setting one state; the slide, the list, "visible" exports and the review entry agreeing (Review AI disabled, saying why, with AI unreviewed hidden); "N hidden by filters" counting layers, Show and list filters, and Show all clearing them; a link showing a hidden kind again;
    • the sidebar (wsiMetaSidebar.spec.tsx, wsiAnnotationControls.spec.tsx): the order with Annotate off and on, Annotations filling (flex: 1 1 0), Clinical collapsed by default while annotating and remembered on its own key, the usual state back with Annotate off; the list filling its section instead of the 260-pixel box; Counts collapsed by default, remembered, summarizing its points, with the chip clouds behind Group by;
    • tools (wsiAnnotationToolbar.spec.tsx, wsiAnnotationMeasure.spec.tsx, wsiAnnotationHpf.spec.tsx): the Draw, Count and Measure groups in order, the Shape menu without HPF, the HPF button disabled with the reason without a scale; Measure's Keep as annotation (L keeps, M rulers, toggling while on switches, remembered, the button picking the last); the compact toolbar below a 960-pixel viewer ("Drawing as:" and the save status text in tooltips, back to full when wider, a 0 width from a hidden tab ignored, the arrow keys and accessible names kept);
    • the Actions menu (wsiAnnotationBulk.spec.tsx, wsiAnnotationBatch.spec.tsx, wsiAnnotationShapeEdit.spec.tsx): its items in order with counts and undo notes, a submenu opened with → and closed with ← back to its item, Relabel… opening the field, Delete and Reject asking with "Ctrl+Z undoes" on Accept and Reject, Edit shapes acting only on a pick; one Tab stop in the toolbar, the tolerance's described info icon, the badge's role="img", the throttled live regions (wsiAnnotationToolbar, wsiAnnotationControls, wsiAnnotationSaveStatus);
    • side by side, pure (wsiCompare.spec.ts): similarity fits exactly with rotation and scale, a mirrored section fitted as a reflection but never from noise alone, affine with shear and collinear points refused, inverse and composition, per-pair residuals in µm with RMS and largest (px without a scale), 3 pairs needed and affine-with-3 flagged exact; a rectangle mapped to a turned polygon, a multipolygon's holes and parts kept with area ×s², points/lines/polylines kept, ellipses as polygons, selectors written and read back; pairing order (same block with the counterpart stain first, same part, other parts and samples, unmatched last), the IHC defaulting to its block's H&E, option groups and labels; localStorage either way round, empty removed, unreadable or throwing storage survived; sync by relative position, by µm from an anchor, through an alignment both ways (centre, zoom, rotation), a mirrored alignment, the short way round;
    • side by side, controllers (wsiCompareController.spec.tsx, stand-in OpenSeadragon viewers): one active pane; locked panning in both directions without echo, unlocked independence, relocking from the active pane; an opening pane following, not leading; the anchor; 3 pairs fitted then mapping centre, zoom and rotation, kept in localStorage; move, delete, clear and reset; a quick click placing a point while a drag does not; copying a holed AI region through the alignment as one batch create with the transfer provenance (derived_from_ai), the badge, Mark verified (PUT), undo and redo; no copy without an alignment; the panel's residuals and copy choices; two controllers listening: Ctrl+Z and H act on the active pane only, tool keys off in the inactive one;
    • hidden viewer (wsiAnnotationReview.spec.tsx, WSIViewer.behavior.spec.tsx): with the review queue open and the viewer hidden, R, A, S, Ctrl+Z and H do nothing; hidden reaches the annotation controller;
    • tissue selection core (wsiTissueCore.spec.ts): Lab distance with half-weight lightness and H&E/DAB/background separations; flood fill of the clicked region only, transparent pixels never filled; tolerance growth; contour of a square through edge midpoints (99.5 px² for 10×10); the box blur at radius 0, 1 and 2 with transparent pixels left out; small holes filled and large kept; regions touching at a corner traced as two parts; Douglas–Peucker on closed rings; the smart brush stopping at an edge, not jumping a gap, and painting two parts across a stripe;
    • the OpenSeadragon pixel host (wsiTissueOsdHost.spec.ts): the canvas read at devicePixelRatio 2 and placed in image pixels; no screen pixels when rotated, tainted or still loading after the wait (and read once the view's tiles are drawn); the levels from the tile source and tiles fetched as blobs with the viewer's URLs and the session cookie;
    • tissue sources and sessions (wsiTissueSelect.spec.ts, on a synthetic slide served as tiles and as a canvas): the source switching at 10× (objective power, mpp, neither); the 10× level picked; tile stitching with edge and failed tiles and growth without refetching; the cap and its edges; the same click outlined from the canvas (devicePixelRatio 2) and from tiles within 3% of each other and of the true area; fallback to tiles when the canvas cannot be read; the tile window growing across tiles and keeping the lumen and disks as holes; the notes at the size limit and at the view edge; the latest tolerance winning; Shift adds, Alt cuts, a click taken back; hole, simplification, seed-window and blur settings in µm; the smart brush at both sources stopping at the tissue edge;
    • the wand and smart brush in the controller (wsiTissueTools.spec.tsx): W, click, Enter saving a <polygon> with the drawing-as layer and color, undo deleting it; Shift+click saved as a two-part region, Ctrl+Z taking back a click; Alt+click with a drag down to a lower tolerance cutting a hole; drag and wheel changing the tolerance (the wheel left alone when nothing waits), a range input not counted as typing, Esc discarding; Alt as the first click cutting the outline out of a selected region (one PUT, "Undo cut"); Shift+B and a stroke along an edge saved within the tissue; a stroke that painted nothing; the Outline menu entries, the tolerance slider and options group, the tolerance chip, the source and time, and the shortcut help;
    • shape editing (wsiAnnotationShapeOps.spec.ts, wsiAnnotationShapeEdit.spec.tsx, wsiAnnotationBody.spec.ts): the <polygon>/evenodd-path storage and parsing (relative, H/V, open paths as polylines, curves refused); area outer minus holes and perimeter over all rings (per-axis mpp); points inside and hit-testing with holes; Polygon-with-holes and MultiPolygon GeoJSON round trips and a bad part skipped by name; union, difference (hole, notch, nothing left), intersection, split by straight and bent lines keeping holes, separate parts; in the controller: cut by the menu and by Alt, as one undo/redo step, Esc stopping it; an AI region cut keeping its source with edited: true ("AI, edited · unreviewed") and undo putting the stored provenance back; another user's region cut into a new annotation; a cut that misses or covers everything; merge deleting the user's originals with undo/redo re-creating them; another user's shared region kept with the message; the user's own AI region kept, the result derived_from_ai ("AI, edited", not in the review queue); split (largest piece in place, undo), a line that does not cross; subtract, intersect, separate; the selection bar's menu and hint; points inside hidden at 0 unless counting; the even-odd fill of the downloaded view. The in-memory test service refuses machine-made creates and source changes, as the service does;
    • the toolbar: only Annotate, Display and ⋯ until Annotate is on, and remembered; disabled with its reason while loading, signed out or read-only; Shape and Outline menus from the keyboard, each reusing its last tool; arrow-key navigation along the toolbar; brush width and point count only with their tools; layer choice and swatch setting the layer color; the ⋯ menu's review entry, sharing, export, import and sectioned shortcut help; undo and redo buttons;
    • the quick ruler (wsiAnnotationMeasure.spec.tsx): length and angle per axis; M, drag, the reading while dragging and after; nothing sent, off the history and out of exports; a click keeps it, the next replaces it, Esc clears it then goes to Select; it follows a zoom and goes with the slide; drawn in the downloaded view with H;
    • HPF and counts (wsiAnnotationHpf.spec.tsx): a field placed by click with the chosen area (0.237 mm² by default, unequal scales), "HPF n" numbering also for fields placed before the previous save returns, the area control (presets with their diameters, custom, out of range refused, remembered), the tool off without an mpp; the HPF explanation on the menu item (tooltip and description), the area picker (description and focusable info icon) and the table (both rate columns explained); points inside rectangles and polygons by label with the density, in the row, tooltip and GeoJSON; per-10-HPF and per-mm² rates;
    • the save status (wsiAnnotationSaveStatus.spec.tsx): "Saving… 3" for queued then sent points, "Saved", an edit counting one, "2 not saved" with Retry sending them again, the live region always present;
    • long lists and strokes (wsiAnnotationListPerf.spec.tsx): 5,000 annotations render as a window of under 30 rows within a 3 s budget, follow scrolling, keep checkboxes, move with ↑/↓/Home/End keeping the focused row, and scroll to the focused annotation; a 5,000-point freehand stroke is captured in place with each point placed on screen once (under 6 conversions per move) and placed again once when the slide moves;
    • Show and history (wsiAnnotationOrigins.spec.tsx): the history rules (review credited by time); Show toggles filtering what Annotorious draws and the list, counts, Manual when the user is unknown, a link lifting the filter; the History disclosure and tooltip line;
    • threads (wsiAnnotationThread.spec.tsx): read, add (Ctrl+Enter), edit, delete own with the count and focus, others' without controls, the note untouched, refusals, a deleted annotation, a service without threads and a route that turns out missing;
    • slide notes (wsiSlideNotes.spec.tsx): tag rules; loading only when shown; the tag summary and filter; add with tags and sharing, edit, delete with version and focus; a 409 reloading; a service without the route;
    • review undo and restore (wsiAnnotationBatch.spec.tsx): a single reject undone with one reset and a bulk accept with one batch-review reset, redo reviewing both again; the bulk reject confirmation and undo note; a reset refused with 403 because another user reviewed since, explained and editing kept on; the older service refusing reset (422 on decision): the notice, reviews dropped from the history, "Can't be undone" and "Reviews can't be undone." from then on, and Undo going on to the earlier edit; a bulk delete undone with one batch-restore (same ids, comment count kept) and redone with one batch-delete; a layer delete undone in one batch-restore, comments kept, and redone;
    • bulk batches (wsiAnnotationBatch.spec.tsx): relabel in batches of 100 as one undo step, delete and review in one batch, a 409 reported and the rest saved after a reload, 403/404 items named and the rest saved, the per-annotation fallback; the older-service path stays in wsiAnnotationBulk.spec.tsx;
    • point undo runs (wsiAnnotationPointUndo.spec.tsx): three drops over two saves undone in one batch-delete and redone in one batch-restore under their ids, created again with new ids on a service without restores, new steps after a pause, a tool change or another change, the fallback without batch-delete;
    • the downloaded view (wsiAnnotationSnapshot.spec.ts): shapes, points and labels drawn at the screen place times the pixel ratio, outlines only, hidden layers, solo and H left out, the background filled before the slide, taken from the nearest opaque ancestor, and used by the download with annotations off;
    • review queue, display, stepping and links, selection, drawing tools that stay on, redo, label groups, the stored body, points, imports, accessibility and zooming mid-gesture as before.
  • App Jest (after rebuilding the package dist): the WSI suites (wsiAppConfig, wsiClinicalRows, wsiPatientClinicalData, WsiPatientViewRoute, PatientWsiSlidesTab, PatientViewUrlWrapper, FilesAndLinks, ResourcePolicy, assertWsiOsdBundle): 71 tests in 9 suites pass. They check that both hosts pass the link's slide key and drop annotationId from the address (keeping the hash), and that checkWsiBundle fails a build with the tissue tools in an initial bundle or polygon-clipping outside the wsi-shapeops chunk.
  • Bundle (production build): the viewer chunk is 428 KB (114 KB gzipped; 436 KB / 117 KB before polygon-clipping moved out), wsi-shapeops 29 KB (9 KB), wsi-tissue 74 KB (24 KB); the initial bundles do not change.
  • Playwright side by side (wsi-compare-mocked.spec.ts, 3 new tests, PW_SUITE=wsi only): five mocked slides (H&E, the same block's IHC TTF-1 rendered as the H&E's tissue turned 90°, an H&E recut, another block's Ki-67, another part's H&E) with PNG tiles. (1) Compare opens the IHC next to the H&E; the right picker's groups are Same block [IHC, recut] / Same part [Ki-67] / sample · Part 2; the left picker leads with the H&E; labelled regions; one toolbar, following the focus; H hides the active pane's annotations only, F6 switches and the other pane's H is its own; another slide from the picker; close (7.4 s). (2) Locked views: a drag on the right pane moves the left (its #wsi: x grows by over 500 px) (9.7 s). (3) Three point pairs on the disks of both slides give an RMS under 8 µm and "Aligned: 3 points"; the user's rectangle copied by layer is one batch create on the IHC with the transfer provenance, its corners turned with the tissue within 25 px; the right pane becomes active and lists it as "Transferred · unverified"; Mark verified (PUT with verified_by), "Undo transfer of 1 annotation" deletes it, the source is untouched (10.1 s). Passed --repeat-each=4 with 2 workers (12/12, 7.4–10.5 s each); about 30 s with 2 workers, only in the WSI suite. The annotation service mock and PNG encoder moved to wsi-annotation-mocks.ts (the mock now lists rows by slide_id).
  • Playwright (WSI suite, mocked, against a local production build): wsi-annotation-tools-mocked.spec.ts has 28 tests. On a synthetic 4096-pixel slide whose mocked tiles are rendered PNGs (5 levels): the magic wand zoomed out (10× tiles fetched), a tolerance drag (15 → 25) and a scroll (→ 24) without zooming, Shift+click adding a second disk, Enter saving one two-part region, undo; then the tissue outlined, an Alt+click dragged down to 4 cutting a lighter disk out as a hole, a double-click saving it, undo (5.2 s); the same click outlined from 10× tiles and from on-screen pixels at 18×, the saved areas within 3% of each other (9.4 s); the smart brush along a disk's edge saving a region that stops at the edge (5.6 s); and a layout check at 1920 px wide that records the boxes of the tool buttons, Drawing as, Undo, Display and ⋯, switches through every tool (rectangle, ellipse, circle, HPF, line, measure, polygon, freehand, brush, smart brush, wand, point), drops two points until "Saved" shows, and finds no box moved (7.1 s). These four passed --repeat-each=4 with 2 workers. The HPF test also checks the per-mm² column. Among the earlier tests, shape editing: a hole cut with "Cut a hole…" and a rectangle (one versioned PUT, the list's area equals the outer ring less the hole, Shift+click in the hole selects nothing, undo; 4.3 s); two of the user's regions merged (one batch create + one batch-delete, a 200×120 union) and undone (4.2 s); a merge with another user's shared region keeping it with the message (3.7 s); a split along a line (PUT + batch create, both pieces labelled and selected, undo; 3.9 s); a holed and a two-part region exported as Polygon with an inner ring and MultiPolygon (3.5 s). Also: a ruler that sends nothing (3.7 s); an HPF field with a custom area and the points inside it with the per-10-HPF rate (3.7 s); "Saving… 1" while a write is held, then "Saved" (3.4 s); a comment added with Ctrl+Enter and edited (3.5 s); a slide note with two tags, private (3.2 s); a bulk accept in one batch-review (3.5 s); three point drops undone in one batch-delete and redone (4.3 s); a bulk relabel in one batch-update. The mocked service answers the batch, comment and slide-note routes, can hold writes, and refuses machine-made creates as the service does. With 2 workers the three WSI files (28 + 9 + 3 tests) pass in about 2.4 min; the shape-editing tests passed --repeat-each=3 with 2 workers. No fixed waits. They run only with PW_SUITE=wsi, so they add no time to the default CI shards.
  • Playwright, the simplifications (wsi-annotation-tools-mocked.spec.ts): the toolbar layout test runs at 1920- and 1600-pixel windows with both sidebars open (the 1600 one a 944-pixel viewer) and with the window narrowed until the viewer itself is 904 and 880 pixels, with a long layer name, checking full or compact mode, one row inside the viewer and no shift through every tool and Measure's Keep toggle (about 8.5 s each); Show's AI unreviewed chip hiding rows, the hint and Show all, Review AI disabled meanwhile (3.6 s); Enter accepting in the review card (7.6 s); Measure with Keep as annotation saving a line (4.2 s); Actions › Relabel… with the undo note (4.1 s); Actions › Accept 2 (3.4 s); the HPF field from the Count group and its table under Counts (3.6 s); C for points and the point table under Counts (4.2 s); a split turning Measure on with Keep (3.8 s). The new test adds about 8 s to the WSI suite. No fixed waits.
  • Playwright, review undo and restore (wsi-annotation-tools-mocked.spec.ts, now 31 tests: 2 added, 2 changed; the mocked service keeps deleted rows and comments, restores them and resets reviews): rejecting an AI annotation (the confirmation saying Undo can take it back), then Undo returning it to AI · unreviewed with Accept offered, through one reset (3.3 s); deleting an annotation with another user's comment (the softened warning), then Undo restoring it under the same id with POST …/restore and its comment still in the thread (3.5 s). The two changed tests now expect the new reject confirmation and "Accept 2Ctrl+Z undoes". They add about 7 s to the WSI suite. No fixed waits.
  • Running the WSI e2e suite: these specs run only with PW_SUITE=wsi, and CircleCI does not run them (enabling them upstream is a separate PR). They mock every backend route, so a production build is enough: pnpm run buildAll, serve dist/ with an index.html fallback for SPA routes such as /wsi/patient/…, then in end-to-end-test-playwright/: PW_SUITE=wsi LOCALDEV=0 CBIOPORTAL_URL=http://127.0.0.1:<port> npx playwright test tests/wsi-annotation-tools-mocked.spec.ts tests/wsi-compare-mocked.spec.ts tests/wsi-foundation-mocked.spec.ts --workers=3. All 45 pass (about 2.8 min with 3 workers), compare and the four toolbar widths included; wsi-annotation-tools-mocked.spec.ts passed --repeat-each=5 with 3 workers (165/165, 5.7 min). The zoomed-mid-gesture test waits for the viewer's data-wsi-animating="false" (OpenSeadragon's animation-finish) rather than for two equal samples.
  • Root tsc --noEmit -p ., buildMain + checkWsiBundle and Prettier 1.19 on the changed files are clean.

🤖 Generated with Claude Code

raylim and others added 30 commits November 16, 2026 19:04
The viewer wrote the layer name into body.comment. It now writes
layer_name and color, keeps comment for the user's note, and carries the
stored provenance through every update so an edit never drops it.

Rows written the old way sent neither layer_name nor color, so the
service stored its defaults. Such a row (layer_name Default, color
exactly #2f80ed, one-line comment of at most 100 characters) is read
with comment as its layer. The viewer writes the service default color
as #2F80ED, so its own rows never match. The rule is in
wsiAnnotationBody.ts and the README.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
An annotation whose provenance.source is agent, as the service writes
for a saved research-assistant proposal, shows an AI badge in the list
and tooltip. Until a user reviews it, the list offers Accept, which saves
provenance.review_status accepted and reviewed_at with a versioned PUT,
and Reject, which deletes it. A checkbox hides unreviewed AI annotations
on the slide and in the list.

The service refuses an edit of another user's annotation with a 403
naming the creator rule; that is now shown as a per-annotation error
instead of turning the study read-only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
New annotations were always sent with visible_to []. The toolbar now
has a Shared/Private default for new annotations (shared unless changed,
remembered in localStorage), and each list row shows a Private or
Shared badge that switches the annotation with a versioned PUT (null is
private to the creator, [] is shared with the study). A PUT sends
visible_to only when the viewer knows the stored value. There is no group
choice: the proxy sends no groups.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Lines show their length; rectangles, ellipses, circles and polygons show
area and perimeter, in µm/mm and µm²/mm² from the slide's
microns-per-pixel (the tile metadata mpp the status bar uses), scaled per
axis. The list rows and the click tooltip show them, and drawing a line
or box shows its length or area next to the cursor. Without a valid mpp
sizes are in pixels and the list says the slide has no scale.

Selector parsing (FragmentSelector rectangles and the SVG shapes the
viewer writes) and the shoelace, Ramanujan and path-length math are in
wsiAnnotationGeometryUtils.ts with unit tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Each list row shows the annotation's note (body.comment) below its
label, with + Note / Edit note for users who can edit. The note is
edited in a textarea (Ctrl/Cmd+Enter saves, Esc cancels) and saved with a
versioned PUT that leaves the label, layer and provenance as they are.
The click tooltip shows the note too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The Annotations section gets a filter bar (label or note text, layer,
author when there are several, AI origin when there is any) and counts
of the listed annotations per layer and per label term (the label
without a trailing number, so auto-labels count together; a label chip
filters to it). Each label is a button that pans and zooms the slide to
the annotation's bounds with a margin. Rows are a labelled list, and
every control is a native button, input or select.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A Point tool drops a point per click (a drag still pans) and stays on
until Esc. Points are SvgSelectors holding a radius-0 circle in level-0
image pixels, labelled with the active color's name. Annotorious has no
point shape, so points are drawn as fixed-size markers on a canvas over
the viewer, redrawn once per frame from an affine image-to-screen
mapping, and kept out of Annotorious; adding a point no longer re-sets
the unchanged shapes there. A point shows and counts before its save
returns. The toolbar shows the active label's count while the tool is
on, the Annotations section a Point counts table per label and layer,
and clicking a marker shows its tooltip.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Free draws while the mouse button is held and saves the traced outline
as a polygon; Brush paints a band of a fixed on-screen width (8-64 px,
chosen in the toolbar) and saves the band's outline as a polygon, offset
to both sides with mitred corners and round caps. Strokes are sampled
every 2 screen pixels and simplified with Douglas-Peucker at 1.5 screen
pixels (iterative, so long strokes are safe). A brush stroke is a
polygon rather than a line with a width so it has an area, edits like a
polygon and exports to QuPath as a region. The preview shows the stroke
as it is drawn.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The toolbar gets a label field for new annotations (empty keeps the
color-name auto-label). The runtime's annotations config can name label
terms (labelVocabulary) and require them (labelVocabularyStrict); the
portal passes the frontend properties wsi_annotation_label_vocabulary
(comma-separated) and wsi_annotation_label_vocabulary_strict. The label
field and the list's label editor suggest the terms and the slide's
used labels while accepting free text, or with strict become a choice
of the terms, and a label outside them cannot be saved. No default
vocabulary ships: terms are site-specific, and without them the field
suggests the slide's own labels.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The Annotations section exports the slide's annotations (all, or those
on visible layers) as a QuPath-compatible GeoJSON FeatureCollection: one
Feature per annotation in level-0 image pixels, with name,
classification {name, color}, layer, note and QuPath-named measurements.
The collection names the slide by its opaque slide key only; no image
ids, sealed sources, object keys, creators or provenance details.

Import reads a GeoJSON file, validates it (point, line and polygon
geometries and their multi forms, finite coordinates inside the slide,
vertex and feature limits, strict vocabulary), shows a preview of what
it will create and what it skips, and on confirmation saves the
annotations four at a time with the file's label, class color, layer and
note. createAnnotation now resolves to the saved annotation.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Undo (toolbar button, or Ctrl/Cmd+Z outside text fields) reverses this
session's last change on the slide: a create is deleted, an edit is
reversed by a PUT of the previous version with the current version
number, and a delete is re-created with its body, geometry and sharing,
after which later undos follow the new id. A layer delete and an import
undo as one step; the history holds 50 changes and resets with the
slide or study.

Annotorious already edits a selected shape's position and vertices.
Its update now carries only the new geometry over the stored annotation,
so a drag keeps the label, note, layer, sharing and provenance instead
of falling back to the active layer and color.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A WSI-suite Playwright test against mocked backend routes and an
in-memory annotation service (versions checked on PUT) draws a line and
checks its live and saved length in µm, saves a note and checks the
versioned PUT, drops three points and checks the toolbar count, tally
and radius-0 circle selectors, and exports GeoJSON, checking the
FeatureCollection, its slide key, measurements and note and that no
sealed source or image id is in it. wsi-foundation-mocks exports
makeSlideRow so the test can give the slide an mpp.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The annotation sections were added newest first. They now run from the
stored body and sharing, through labels, notes and measurements, to the
drawing tools, editing, the list and export/import.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
An annotation whose provenance.source is a model source (model, ai,
precomputed) now gets the AI badge, the Accept/Reject buttons and the
hide-unreviewed filter, like the research assistant's (agent, assistant).
The badge's tooltip says which made it, naming provenance.model when set.
A rejected AI annotation is not shown.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Accept and Reject now use the annotation service's review route
(POST /annotations/{id}/review with the decision and version), which any
user of the study may call on an AI annotation. An accepted annotation
shows as accepted; a rejected one is kept by the service as a review
record and dropped from the list.

With the signed-in user known (annotationUser, passed from the portal
user name), edit, delete, note and sharing controls show only on the
user's own annotations, only those shapes can be dragged, and deleting a
layer deletes only the user's annotations in it.

A service without the review route (404/405 not about the annotation)
falls back to the creator-only PUT/DELETE, hides the review buttons on
other users' annotations and says that reviews cannot be recorded.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The brush width is now chosen in µm (10–500, 50 by default) and converted
to image pixels with the slide's mpp, so a stroke covers the same tissue
at every zoom. A circle under the pointer shows the brush's size at the
current zoom, and the stroke previews at that width. Without a slide
scale the width stays in screen pixels and the toolbar says so.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
GeoJSON imports and dropped points are created with the annotation
service's batch route (POST /annotations/batch), up to 100 annotations
and about 3 MiB per request. Points are saved half a second after the
last click, when the tool changes and when the page is hidden; points
still unsent when another slide opens or the page unloads are sent with
keepalive. Undo waits for unsent points; each saved point still undoes on
its own, and an import undoes as one step.

A 422 naming items marks those refused, with the service's reason, and
sends the rest once more; an import names the refused features in its
message. A 413 halves the request. A service without the batch route
(404/405) gets single POSTs for the rest of the session.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A row with no layer_name or color gets the service's defaults, so a
one-line note written by the assistant or a script was read as a legacy
layer, and the next edit sent an empty comment. The legacy rule now needs
a row without provenance, and a legacy row's stored comment is sent back
unchanged until the user edits the note.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…d ids

A point being saved was out of the queue but still had its draft id, so a
delete sent then got a 404 (taken as done) and the save brought the point
back, and an edit failed and reloaded the slide. Points in flight are now
tracked by draft id; an edit shows at once and is saved on the saved id,
and a delete waits for the save and deletes the saved point.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… batch route

Points flushed on a slide or study change, or when the page hides, were
posted to /annotations/batch while the route was unknown; with no batch
route the 404 was dropped and the points never resent, and the page-hide
fallback sent only four single POSTs. These flushes now use the batch
route only when it is known to exist, and otherwise send one keepalive
POST per point, all at once.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
When a point save was refused (401 or 403), the queued points were removed
from the slide and the failure was not reported, and points still queued
were dropped on a slide change. Refused points now stay on the slide marked
"Not saved", with "N points were not saved." and a Retry that sends them
again (e.g. after signing in again); points that could not be sent before
another slide or study opened are reported there.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
labelTerm dropped any trailing number, so "Grade 1/2/3" and "Gleason
pattern 3/4/5" were counted, tallied and exported (GeoJSON
classification.name) as one class. Only the viewer's own auto-labels (a
palette color's name or hex and a number) now count under their base; a
vocabulary term and any other label are their own term.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Without the review route, a creator's accept or reject now shows a note
on how it was recorded instead of an error, and is not undoable, like a
review. The route counts as missing only on a 405 or a 404 whose JSON
detail is "Not Found"; another 404 (a proxy's page) reports that the
review was not saved and decides nothing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… user

The slide permalink route passed no user name, so annotation ownership
fell back to the configured display name. It now passes AppStore.userName
(the backend's Authentication.getName(), the user the study access check
forwards as X-Auth-Request-User), and the Pathology Slides tab requires it;
user_display_name stays only as the last fallback.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… right

An import now refuses a file over 25 MB before reading or parsing it,
with the file's size in the message. A label outside a strict vocabulary
named the draft's position instead of the feature's, which differ once a
multi-part feature splits; drafts now carry their feature's index. Tests
cover the remaining validation refusals: too many vertices, an
unsupported geometry, a MultiPolygon with a bad part, a short open ring,
and no slide size.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Edit, delete, layer-delete, remove-color and cancel icon buttons get
  aria-labels naming their target; the layer eye icon and the color dot
  are aria-hidden.
- After accept, reject, delete or a label save, focus goes to the row,
  else the next (or previous) row, else the list.
- Text on a color (color-name badges, the active palette color) is black
  or white by luminance; the blue of the active layer, links and buttons
  is darkened to 5.1:1, and the cBioPortal#999/#bbb text to the 4.7:1 muted gray.
- The default-sharing toggle keeps a fixed label and reports its state
  with aria-pressed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…er deletes

- The point tool labels points "Point" with the default color, not
  "Default".
- A label chip filters the list by that exact label term (and toggles),
  instead of a text search that also matched notes.
- Editing stays off until the slide's annotations have loaded; a failed
  load shows an alert with Retry.
- The layer delete confirmation counts only the user's own annotations,
  and says the layer stays while other users have annotations in it.
- The "no microns-per-pixel scale" note shows before any annotation exists.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…-gesture

Drawing previews were kept in screen pixels captured at each event, so a
wheel or button zoom mid-gesture left the outline, the brush circle and the
live measurement where they were on screen while the tissue moved under
them. The polygon close check compared clicks to those stale positions,
freehand/brush simplification and the no-scale brush width used the zoom
at pointerup, and pointer positions were read against the end of a zoom
animation rather than what was shown.

The shape being drawn is now kept in image pixels and projected on each
OpenSeadragon animation/update-viewport event; pointer positions are read
with the current viewport; strokes simplify at the finest zoom used and the
brush width is fixed at stroke start; only the pressing pointer draws, with
pointer capture, and pointercancel/lostpointercapture end the press.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nd label groups

- Redo mirrors undo: each undo leaves the entry that applies the change
  again; imports and layer deletes redo as one step, re-created ids are
  followed in both histories, a new change clears redo, reviews stay out.
- Annotate on/off and the Shape and Outline menus' last tools, remembered
  in localStorage; shape editing only while Annotate is on.
- A color per layer: the user's choice, else its annotations' most common
  color, else the default or a color of its own.
- V/R/L/P/F/B/. pick tools while Annotate is on and not typing;
  Ctrl/Cmd+Shift+Z and Ctrl+Y redo; OpenSeadragon's R and F are kept off.
- labelGroup: list counts group labels without a trailing count such as
  " (13 tiles)", never merging vocabulary or graded labels.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim and others added 30 commits November 18, 2026 14:13
…slide

The slide's canvas is transparent outside the slide, so the JPEG was black
there. The copy is now filled with the color shown behind the canvas (the
stage's gray) before the slide and annotations are drawn, with annotations
off too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…s, notes, batches and point undo

The mocked annotation service now answers batch-update, batch-delete and
batch-review (all or none), comment threads and slide notes, and can hold
writes. Seven new tests: a ruler that sends nothing; an HPF field with the
points inside it and the per-10-HPF rate; "Saving… 1" then "Saved"; a
comment added and edited; a slide note with tags; a bulk accept in one
batch-review; three point drops undone and redone in one step. The bulk
relabel test now expects one batch-update.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Fields placed quickly one after another read the slide's highest "HPF n"
before the previous save had returned, so two could get the same number.
The numbers being saved now count as taken. A batch refusal whose item is
not in the request no longer blames the request's first annotation; the
request counts as not saved.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Regions can have holes and several parts. One ring stays a <polygon>
selector; holes and parts are stored as Annotorious writes a
multi-polygon (an evenodd <path> per part in a <g>). Measurements take
the outer rings less the holes, perimeters every ring; points inside,
hit-testing and the downloaded view leave holes out; GeoJSON exports a
Polygon with inner rings or a MultiPolygon and imports both whole.

The selection bar's "Edit shapes…" menu merges, subtracts, intersects,
cuts a hole (or Alt as a shape ends), splits by a line and separates
parts, with polygon-clipping 0.15.7 (MIT). Results are the user's: the
user's own regions change in place, others' stay and give new
annotations; a merge deletes the user's own non-AI originals. An AI
region changed in place keeps its source with edited: true; a new
annotation from AI ones is source "manual" with derived_from_ai; both
show "AI, edited". Each operation is one undo step.

A region without points no longer reads "Points inside: 0", except
while counting (Point or HPF tool) and on a field.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…plit, export holes

The mocked service also refuses machine-made creates, as the service's
trusted-writer rule does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Magic wand (W, Outline menu): a click outlines the connected region of
similar color (flood fill); drag up/down or scroll changes the tolerance
live, Shift+click adds, Alt+click cuts out, Enter or double-click saves a
polygon/multipolygon drawn as the toolbar's layer, label and color, Esc
discards, Ctrl+Z takes back a click. Alt as the first click cuts the
saved outline out of the selected regions.

Smart brush (Shift+B): paints only pixels like the color under the start
of the stroke, connected to the stroke, with the brush width in µm.

Color distance in CIELAB with lightness at half weight, after a 3×3 blur;
holes under 500 µm² filled; crack-following contour through edge
midpoints (marching squares) and Douglas-Peucker at 1 µm. Pixels from the
OSD canvas at 10× or more, else 10× tiles fetched as blobs and stitched,
growing to 4096 px with a note when cut. Work runs in an inline Web
Worker (rollup-plugin-web-worker-loader) in its own wsi-tissue chunk;
checkWsiBundle checks it stays out of the initial bundles.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
An info icon (tooltip on hover and focus, the same text as each control's
aria-describedby) says what an HPF is: the Shape menu's "HPF field" item,
the field area picker and the field table. Area presets show their field
diameter ("0.237 mm² (0.55 mm), default"). The field table adds a per mm²
column and explains both rate columns.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The active tool's options (brush width, tolerance, HPF field area, point
count) move to a strip anchored under the toolbar, out of its layout: the
tool buttons, Drawing as, Undo/Redo, Display and the menu stay put as
tools change. The strip is a labelled group ("Brush options") that
follows the tools in the arrow-key order. The save status keeps a minimum
width while annotating, with tabular figures. A mocked Playwright test
records the controls' boxes and switches through every tool, then drops
points until "Saved" shows, at a width where the toolbar is one row.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…der; smaller first tile window

On 27720 the focus stayed on the tolerance slider after dragging it (a
press on the slide does not move it), and Enter was ignored as typing. A
range input takes no text, so Enter, Esc and the shortcuts now apply.

The tile window around a zoomed-out wand click starts at 512 analysis
pixels (2 or 3 tiles each way) instead of 1024: most clicks need few
tiles, and larger selections still grow it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…to the first outline

On 27720 a zoomed-out click on tissue at a high tolerance grew the tile
window 2 tiles per step up to the cap, re-stitching each time. It now
grows by half its span (at least 2 tiles), shows the outline at every
step, stops growing when a newer tolerance or click arrives, and the time
shown is from the click to the first outline. A step's tolerance is no
longer reset by an older run finishing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`data-seed` on the outline (beside `data-source` and `data-ms`) gives the
last click in level-0 image pixels, so checks can confirm that two
clicks at different zooms hit the same tissue.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The box blur before selection is about 1 µm each way (3×3 at 1 µm per
pixel, 9×9 at 0.25) and the seed color the mean within 2.5 µm of the
click, both from the raster's scale, so a click on screen at 40× and one
on 10× tiles average the same tissue. The blur uses running sums, so its
cost does not grow with the radius.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
On 27720 a click soon after zooming read a half-loaded canvas (the
1.5 s wait for the view's tiles ran out) and outlined less than the same
click on tiles. It now waits up to 5 s and, with tiles still loading,
uses the tile source instead. Tests of the OpenSeadragon host: the canvas
read at devicePixelRatio 2 and placed in image pixels; rotated, tainted
and still-loading views; levels and blob tile fetches with the viewer's
URLs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ansfer

Compare (status bar) opens a second viewer next to the slide with a
draggable divider. Each pane has its own slide picker (same block, then
same part, then the rest of the patient's slides, the other stain first),
stain and Slide ID, and shows its own annotations. Only the active pane
shows the annotation toolbar and takes the annotation keys; F6 moves the
focus between panes, and a hidden viewer (inactive tab) takes no keys.

Views are locked by default: the pane last used leads, through 3+ point
pairs fitted as a similarity or affine map (least squares, residuals in
µm), else an anchor in µm, else the same relative position. Points are
placed, dragged, nudged and deleted on the slides; the alignment is kept
per slide pair in localStorage.

Selected annotations or a layer copy through the alignment as new manual
annotations (holes and parts kept), saved in batches as one undo step,
marked transferred and unverified with the source, model and residual;
Mark verified saves verified: true. The review card's focus fallback is
scoped to its own viewer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
wsi-compare-mocked.spec.ts (3 tests, PW_SUITE=wsi): Compare opens the
same block's IHC with the picker grouped by match level, keys and H go
to the active pane only and F6 switches; panning the right pane moves the
left; three point pairs on synthetic H&E and turned IHC tiles give a
small residual, a copied rectangle lands on the same tissue with its
provenance, Mark verified and undo. The annotation service mock and PNG
encoder move to wsi-annotation-mocks.ts, and the mock lists rows by
slide.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e "Block" in option labels

On 27720 picking a slide in the right pane moved the left one: the new
slide's home view raised pan and zoom events while the right pane led.
A pane now follows while its slide opens and leads again once open. The
picker's option labels for other parts read "Part 5 · Block 1", not
"Block Block 1", when the source already names the block so.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…notes and links

- Magic wand: every Shift/Alt+click is computed (a queue of steps, each at
  its latest tolerance), a raster still used by an earlier step is never
  dropped when the tile window grows (steps move to the grown raster;
  rasters are released only when nothing refers to them), a hi-DPI canvas
  larger than the cap is read around the click or stroke start rather than
  its centre, and after Esc nothing a late tile or step finishes shows.
  A new click or Esc cancels the earlier tile fetches (AbortSignal).
- Smart brush: a stroke finishes on its own (stroke handles), so a stroke
  started while the previous one is still being saved is kept, and the
  save of one no longer resets the gesture of the next.
- Shape edits run one after another, so two quick cuts both apply on the
  saved geometry and version. An operation saved only in part (a merge
  whose original-delete fails, a split whose PUT conflicts) is taken back:
  what it created is deleted, what it changed put back and what it
  deleted created again, with a clear message and no undo entry. The
  originals of a merge go in one all-or-none batch-delete.
- Slide notes: an answer read after another slide opened is dropped, so a
  note can no longer land on the wrong slide.
- Annotation list: a short list scrolls to the annotation the slide is
  pointed at (the row's offset in the list).
- Links: a requested annotation opens only on the link's slide, once; the
  hosts pass that slide key and drop annotationId from the address once
  it was used.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Reject asks first and moves off R: X (or Reject) in the review card asks
  in the card and X or Enter confirms (Esc cancels); the list row's and the
  selection bar's Reject confirm with the count and what a reject does.
  Undo right after a review says "Reviews can't be undone." instead of
  undoing an earlier edit; pressed again it undoes that edit.
- The selection bar's Move to layer…, Sharing… and Edit shapes… are menu
  buttons (the toolbar's role="menu", moved to wsiMenu.tsx), so arrowing
  through them never acts.
- Deleting or merging away annotations with comments asks first, naming
  the comment count and whether other users wrote some; Undo that creates
  one again says its comments could not be restored.
- HPF table: counts the user's own fields and points by default (or the
  drawing layer, or all users), counts a point in overlapping fields once
  and their overlap once, names overlapping fields, and marks the rate per
  10 HPF provisional (not bold, "based on N fields") under 10 fields. Each
  rate column has an info icon (WsiInfo) instead of a title only.
- README: the review, bulk-menu, thread and HPF rules, and the service
  changes that would allow undoing a review and keeping a thread.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- R is always the rectangle; ellipse, circle and the HPF field are picked
  from the Shape menu, so R can no longer start an HPF field.
- "." picks Point while Annotate is on, does nothing while the review card
  is open, and otherwise shows or hides the details sidebar (the
  sidebar's button always does), so it never folds the sidebar mid-review.
- OpenSeadragon's R (rotate), F (flip) and W (pan up) keys are off with
  Annotate off too; the arrow keys still pan.
- A checkbox or radio button (a list row's selection box) is not a typing
  target, so the shortcuts keep working after one is ticked.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…d live regions

- Help that lived only in a title has an info icon whose tooltip shows on
  hover and focus and whose text is the control's aria-describedby
  (WsiInfo): the wand and smart brush tolerance, each HPF rate column; the
  review card says what a reject does (aria-describedby), and the list
  row's Reject is described too.
- The AI and Transferred badges are role="img" with their description as
  their name, not an aria-label on a plain span.
- Sidebar text of 9-10 px is 11 px, and the click tooltip's lines are no
  longer dimmed with opacity.
- The toolbar has one Tab stop (a roving tabindex: the control last
  focused, else the first); the arrow keys, Home and End move within it.
- Counting points no longer announces every click: the Point tool's count
  and the save status show at once and announce through hidden live
  regions that pass a changing count at most every 1.5 s (a change of
  state at once).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…shape ops)

- annotations is an observable.ref (the array is always replaced, items
  are plain objects); comment threads, comment counts and the selection
  are observable maps read per key, so a thread or a checkbox changing
  re-renders only its row.
- Slide labels: bounds are computed once per change of the shown
  annotations, and on each frame shapes outside the view or too small for
  a label are culled in image pixels before mapping, sorting and placing.
- Annotation list: the scroll position is applied once per animation
  frame, the view's height is measured on resize rather than read in
  render, and a render measures only rows not measured yet.
- Shape operations and polygon-clipping load as their own async chunk
  (wsi-shapeops) when one first runs; region measuring moved to
  wsiRegionUtils.ts. The magic wand loads the same chunk for Shift/Alt
  clicks instead of bundling a second copy. checkWsiBundle fails a build
  with polygon-clipping outside that chunk.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…wait

- Comment threads and slide notes read the service's paged lists
  ({…, total, offset, limit, has_more, next_offset}) as well as an older
  service's whole list: "Show more comments" / "Show more notes" load the
  next page without repeating what shows, counts and the tag summary use
  the service's totals, and a deleted item shifts the next offset back.
  A cap's 422 (1,000 comments per annotation, 1,000 notes per slide)
  shows the service's message.
- A 422 on an annotation's target (the service's selector rules) says
  "This shape can't be saved" for a create, a batch item or an edit (the
  edit reloads the slide as stored); a PUT on an annotation deleted
  meanwhile (404) reloads and says so.
- The viewer element carries data-wsi-animating while OpenSeadragon
  animates; the zoomed-mid-gesture e2e test waits for it instead of
  sampling the outline until two reads agree.
- E2E: the review test confirms its reject (X twice, the row's dialog),
  shape operations are picked from the Edit shapes… menu, a merge deletes
  its originals in one batch-delete, and the save status's live region is
  its own element.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
What shows is decided by the layers' eyes and solo plus one Show
control with four kinds: Mine, Others, AI unreviewed and AI accepted.
Show sits in the Display popover (checkboxes) and at the top of the
Annotations section (toggle chips), each kind with its count on the
shown layers. The sidebar's "Hide unreviewed AI annotations" checkbox
and the list's "AI and manual" select are gone; neither was stored, so
no preference needs migrating.

The slide, the list and its counts, ]/[, Ctrl+A, the review queue
(Review AI (N)) and "visible" exports all read the same shown set. A
hint above the list says "N hidden by filters" with Show all whenever
layers, Show or the list's filters leave annotations out, or H hides
them on the slide.

README: the Show model, and the service note that visible_to null is
creator-only while the viewer creates shared annotations by default.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
While the review card is open, A or Enter accepts (Enter on a focused
button stays that button's own), X asks before a reject (X or Enter
confirms, Esc cancels), S or → skips, ← goes back and Esc exits. R is
never a review key: it is always the rectangle once the card closes.

"." now always shows or hides the details sidebar, Annotate on or off
and while reviewing; the Point tool moves to C. The shortcut help lists
every key, including "." and "|" for the panels and Enter for accept.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
While Annotate is on, the details sidebar puts Annotations first and
lets it take the height the other sections leave (at least 360 px, or
55% of the window when that is more; taller content scrolls inside
it); the list fills that height instead of a 260 px box and stays
virtualized. Layers and Slide notes follow, then the slide's details,
with Clinical collapsed until opened (its own remembered state while
annotating). With Annotate off the order is as before. Sections are
keyed, so turning Annotate on or off moves them without remounting.

The point table, the HPF table and the per-layer and per-label counts
move under one Counts disclosure, collapsed by default and remembered;
its button summarizes what it holds ("Counts · 6 points · 2 HPF"). The
chip clouds sit behind a remembered "Group by…" select, one at a time.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The toolbar groups the tools by task, each a labelled group between
dividers: Draw (Shape ▾: rectangle, ellipse, circle; Outline ▾:
polygon, freehand, brush, smart brush, magic wand), Count (Point, now
C, and HPF field, out of the Shape menu, Shift+C, its area preset in
the options strip) and Measure.

Line and Measure are one Measure tool with a "Keep as annotation"
option in the options strip: on, the line is saved (L); off, a quick
ruler that is never saved (M). The choice is remembered; toggling it
while Measure is on switches at once, and a split by a line turns it
on. A stored Shape tool no longer in the menu falls back to the
rectangle.

The toolbar stays one row at a 1600 px window with both sidebars open;
the layout e2e check now runs at 1920 and 1600 px and checks one row
as well as no shift. The shortcut help and README follow.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The selection bar shows "N selected" and one Actions ▾ menu button:
Relabel N… (a label field in the bar), Move N to layer ▸, Sharing of
N ▸ and Edit shapes ▸ (submenus beside their item: → or a click opens,
← or Escape closes, focus returns), Accept N, Reject N…, Delete N… and
Clear selection. Each item names its count and, at its end, whether
Ctrl+Z undoes it.

The confirm and undo rules are the same everywhere: Delete and Reject
ask first; whatever Ctrl+Z can undo says so in the menu and, once done,
under the status; reviews say they can't be undone. The shared menu
moves only between its own items, so a submenu keeps its own keys.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Undo of a delete (one, bulk, layer, or the originals of a merge) restores
the annotation under its id with POST /annotations/{id}/restore or
batch-restore, sending the version it was deleted at, so its comments and
links survive; redo deletes it again. Shape-edit rollbacks restore the
originals the same way. The delete warning for annotations with comments
says Undo brings them back and that the service purges deleted
annotations after 30 days by default.

Accept and reject, one or in bulk, are one undo step each: undo sends
decision "reset" (batch-review for several), redo reviews again. The
reject confirmation stays, saying Undo can take it back. A reset refused
because another user reviewed it since says so.

On an older service (restore route missing; reset refused as an unknown
decision) the viewer remembers it for the session and falls back to
creating annotations again with new ids, and to reviews that can't be
undone. The in-memory test service models soft deletes, restores and
resets.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The mocked annotation service models soft deletes, restores and review
resets. Two Playwright tests: a reject undone returns to unreviewed, and
the delete of an annotation with a comment undone keeps the annotation
and its comment. The README documents the undo rules and deleting and
restoring.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Below 960 px of viewer width the toolbar turns compact: the "Drawing as:"
text becomes a tooltip on its group and the save status shows its icon
alone at a fixed width, with the text in its tooltip and live region. A
ResizeObserver on the viewer pane switches the mode, so the tools stay on
one row down to about 780 px of viewer (the patient tab with both
sidebars open at a 1600 px window gives 904 px). Switching tools still
moves nothing, and the roving tab stop and accessible names are kept.

The layout e2e now also sets the viewer itself to 904 and 880 px, and
checks which mode the toolbar is in.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

1 participant