Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(appshot): pen, highlighter and counter always draw instead of grabbing marks

rubenluetke10-beep9630d6bafef4
diff --git a/docs/appshots.md b/docs/appshots.md
index 714598d525..b5e6c03c0c 100644
--- a/docs/appshots.md
+++ b/docs/appshots.md
@@ -121,14 +121,6 @@ app. Nothing navigates away.
| Key | Tool | What it does |
|---|---|---|
| V | Select and move | Click an annotation to select it; drag moves it, arrow keys nudge it (Shift = 10 px), Delete removes it. Double-click a text to change it. The only tool that also picks spotlights and redactions. |
-
-With **any** tool, an annotation can be taken by the hand: the pointer turns
-into a move cursor over it, a drag moves it, and a click selects it. A fresh
-annotation is selected right away. A selected one shows round grips — at both
-ends of an arrow or line (drag the tip somewhere else), at the corners of a
-box, a stroke or a redaction (resize from the opposite corner), at a text's
-corner (its size) and on a counter's rim (the badge's size). Every move and
-reshape is one undo step.
| A / L | Arrow / Line | Shift snaps to 45°. |
| R / F / E | Rectangle / Filled rectangle / Ellipse | Shift makes a square or circle. |
| D | Draw | Freehand, smoothed. |
@@ -140,6 +132,19 @@ reshape is one undo step.
| K | Crop | Free, 1:1, 4:3 or 16:9; undo brings the rest back. |
| B | Background | Frames the picture on a backdrop (eight presets, padding, corner radius, shadow); applied on copy, save and use. |
+Taking hold of annotations: the **select tool** picks up any annotation —
+the pointer turns into a move cursor over it, a drag moves it, a click
+selects it. A **shape tool** (arrow, line, boxes, text, spotlight, redact)
+selects the shape it just drew and can reshape or move only that one; a
+press anywhere else, also on an older annotation, draws a new shape.
+**Draw, Highlighter and Counter never take hold of anything**: their strokes
+and badges are not selected, so writing over earlier ink or placing the next
+number right beside the last one always draws. A selected annotation shows
+round grips — at both ends of an arrow or line (drag the tip somewhere
+else), at the corners of a box, a stroke or a redaction (resize from the
+opposite corner), at a text's corner (its size) and on a counter's rim (the
+badge's size). Every move and reshape is one undo step.
+
Colours: eight presets plus any colour from the system picker; the last one
is remembered. Sizes: the slider or keys 1–5. History: Ctrl+Z, Ctrl+Shift+Z
or Ctrl+Y (⌘ on macOS).
diff --git a/jarvis/ui/web/frontend/src/lib/appshotEditorModel.test.ts b/jarvis/ui/web/frontend/src/lib/appshotEditorModel.test.ts
index 764256f2f2..74c11ba013 100644
--- a/jarvis/ui/web/frontend/src/lib/appshotEditorModel.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/appshotEditorModel.test.ts
@@ -16,6 +16,7 @@ import {
contrastOn,
emptyHistory,
frameLayout,
+ grabScope,
hitTest,
isMeaningful,
nextCounter,
@@ -295,3 +296,21 @@ describe("grips", () => {
expect(handleCursor("to")).toBe("grab");
});
});
+
+describe("grabScope", () => {
+ it("lets only the select tool pick up any annotation", () => {
+ expect(grabScope("move")).toBe("any");
+ });
+
+ it("keeps pen, highlighter and counter drawing over what is already there", () => {
+ expect(grabScope("pen")).toBe("none");
+ expect(grabScope("highlight")).toBe("none");
+ expect(grabScope("counter")).toBe("none");
+ });
+
+ it("lets a shape tool reshape only the shape it just drew", () => {
+ for (const tool of ["arrow", "line", "rect", "filled", "ellipse", "text", "redact", "spotlight"] as const) {
+ expect(grabScope(tool)).toBe("selected");
+ }
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/appshotEditorModel.ts b/jarvis/ui/web/frontend/src/lib/appshotEditorModel.ts
index 70921dc75b..3b9d093d8c 100644
--- a/jarvis/ui/web/frontend/src/lib/appshotEditorModel.ts
+++ b/jarvis/ui/web/frontend/src/lib/appshotEditorModel.ts
@@ -87,6 +87,21 @@ export const TOOL_KEYS: readonly { tool: Tool; key: string }[] = [
{ tool: "background", key: "b" },
];
+/**
+ * What a press with ``tool`` may take hold of instead of drawing:
+ *
+ * - ``any``: the select tool picks up every annotation;
+ * - ``selected``: a shape tool reshapes or moves only the annotation it has
+ * selected (the one it just drew); a press anywhere else draws a new one;
+ * - ``none``: pen, highlighter and counter always draw, so writing over
+ * earlier ink or placing badges side by side never drags anything along.
+ */
+export function grabScope(tool: Tool): "any" | "selected" | "none" {
+ if (tool === "move") return "any";
+ if (tool === "pen" || tool === "highlight" || tool === "counter") return "none";
+ return "selected";
+}
+
export function toolForKey(key: string): Tool | null {
const lower = key.toLowerCase();
return TOOL_KEYS.find((entry) => entry.key === lower)?.tool ?? null;
diff --git a/jarvis/ui/web/frontend/src/views/AppshotEditor.tsx b/jarvis/ui/web/frontend/src/views/AppshotEditor.tsx
index f8f9ac5c38..ea0a825181 100644
--- a/jarvis/ui/web/frontend/src/views/AppshotEditor.tsx
+++ b/jarvis/ui/web/frontend/src/views/AppshotEditor.tsx
@@ -47,6 +47,7 @@ import {
emptyHistory,
exportPng,
frameLayout,
+ grabScope,
hitTest,
isMeaningful,
nextCounter,
@@ -500,14 +501,25 @@ export function AppshotEditor({ appshotId, onClose, onApplied, variant = "overla
return true;
};
+ /** The annotation a press at ``p`` would move with the current tool, if any. */
+ const grabbable = (p: Point) => {
+ const scope = grabScope(tool);
+ if (scope === "none") return null;
+ const hit = hitTest(ops, p, 6 / scale, measure, { areas: tool === "move" });
+ if (!hit || (tool === "text" && hit.kind === "text")) return null;
+ return scope === "any" || hit.id === selectedId ? hit : null;
+ };
+
const onPointerDown = (event: React.PointerEvent<HTMLCanvasElement>) => {
if (!image || event.button !== 0) return;
const p = toImage(event);
if (tool === "background") return;
if (tool !== "crop") {
- // Every annotation can be taken by the hand, whatever tool is active:
- // a grip of the selected one reshapes it, the annotation itself moves.
- if (selected && selectedLive) {
+ // The select tool takes hold of any annotation; a shape tool only of
+ // the one it has selected (a grip reshapes it, the body moves it); pen,
+ // highlighter and counter never do — a press with them always draws.
+ const scope = grabScope(tool);
+ if (scope !== "none" && selected && selectedLive) {
const grip = handleAt(selectedLive, p, (GRIP_RADIUS + 4) / scale, measure);
if (grip) {
event.preventDefault();
@@ -518,8 +530,8 @@ export function AppshotEditor({ appshotId, onClose, onApplied, variant = "overla
}
// Spotlights and redactions cover what lies in them, so only the
// select tool picks them; with a drawing tool they stay drawable on.
- const hit = hitTest(ops, p, 6 / scale, measure, { areas: tool === "move" });
- if (hit && !(tool === "text" && hit.kind === "text")) {
+ const hit = grabbable(p);
+ if (hit) {
event.preventDefault();
if (typing) commitText();
event.currentTarget.setPointerCapture?.(event.pointerId);
@@ -538,7 +550,9 @@ export function AppshotEditor({ appshotId, onClose, onApplied, variant = "overla
return;
}
if (tool === "counter") {
- setSelectedId(push({ kind: "counter", at: p, n: nextCounter(ops), color, size: counterSize(width) }));
+ // Not selected afterwards: the next click right beside it places the
+ // next number instead of dragging this one.
+ push({ kind: "counter", at: p, n: nextCounter(ops), color, size: counterSize(width) });
return;
}
event.currentTarget.setPointerCapture?.(event.pointerId);
@@ -579,10 +593,12 @@ export function AppshotEditor({ appshotId, onClose, onApplied, variant = "overla
if (!current) {
// Say with the pointer what a press here would do: reshape, move, or draw.
if (!image || tool === "crop" || tool === "background") return setHoverCursor(null);
- const grip = selectedLive ? handleAt(selectedLive, p, (GRIP_RADIUS + 4) / scale, measure) : null;
+ const grip =
+ selectedLive && grabScope(tool) !== "none"
+ ? handleAt(selectedLive, p, (GRIP_RADIUS + 4) / scale, measure)
+ : null;
if (grip) return setHoverCursor(handleCursor(grip));
- const hit = hitTest(ops, p, 6 / scale, measure, { areas: tool === "move" });
- setHoverCursor(hit && !(tool === "text" && hit.kind === "text") ? "move" : null);
+ setHoverCursor(grabbable(p) ? "move" : null);
return;
}
if (current.kind === "resize") {
@@ -627,12 +643,15 @@ export function AppshotEditor({ appshotId, onClose, onApplied, variant = "overla
if (!isMeaningful(shape)) return;
const id = push(shape);
if (shape.kind === "crop") setTool("move");
- // A fresh annotation is selected at once, so its grips are right there.
- else setSelectedId(id);
+ // A fresh shape is selected at once, so its grips are right there; ink
+ // is not, or its box would catch the next stroke written beside it.
+ else if (grabScope(tool) !== "none") setSelectedId(id);
};
const onDoubleClick = (event: React.MouseEvent<HTMLCanvasElement>) => {
- if (!image || typing) return;
+ // Only the select and text tools open a text for editing; a quick
+ // double stroke with the pen stays ink.
+ if (!image || typing || (tool !== "move" && tool !== "text")) return;
editTextAt(toImage(event));
};