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.

feat(appshot): CleanShot X's tapered arrow and an editor window in its proportions

rubenluetke10-beep3e8622850797
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.py
index 5f14ba3464..7af89fb300 100644
--- a/jarvis/ui/desktop_app.py
+++ b/jarvis/ui/desktop_app.py
@@ -856,6 +856,36 @@ def window_restores_maximized(title: str) -> bool:
return False
+def detached_window_size(view: str, screen: tuple[int, int] | None) -> tuple[int, int]:
+ """Opening size of a detached window.
+
+ The appshot editor opens in CleanShot X's proportions: about two fifths of
+ the screen's width and a little under half its height, centred — a tool
+ window in front of the app, never one that looks like the app shrunk. It
+ never goes below the size its whole toolbar needs. Every other view keeps
+ the compact default.
+ """
+ if view != "appshot-editor" or not screen:
+ return 1100, 750
+ screen_w, screen_h = screen
+ width = min(screen_w, max(_EDITOR_MIN_SIZE[0], int(screen_w * 0.4)))
+ height = min(screen_h, max(_EDITOR_MIN_SIZE[1], int(screen_h * 0.46)))
+ return width, height
+
+
+#: The smallest appshot editor window that still shows every toolbar button.
+_EDITOR_MIN_SIZE = (900, 600)
+
+
+def _primary_screen_size(webview_module: Any) -> tuple[int, int] | None:
+ """The first screen's size in pywebview's units, or None when unknown."""
+ try:
+ screen = webview_module.screens[0]
+ return int(screen.width), int(screen.height)
+ except Exception: # noqa: BLE001 - unknown screen: the default size
+ return None
+
+
def _bring_window_to_front_by_title(title: str) -> bool:
"""Win32 fallback for hidden/minimized pywebview windows.
@@ -5204,11 +5234,12 @@ class DesktopApp:
import webview # noqa: PLC0415 — [desktop] extra, never module-level
title = self._detached_title(view)
+ width, height = detached_window_size(view, _primary_screen_size(webview))
window = webview.create_window(
title,
- f"{self._url()}/?view={view}&solo=1",
- width=1100,
- height=750,
+ f"{self._url()}{fallback}",
+ width=width,
+ height=height,
min_size=(800, 520),
resizable=True,
frameless=True,
@@ -5278,12 +5309,13 @@ class DesktopApp:
try:
import webview # noqa: PLC0415 — [desktop] extra, never module-level
+ width, height = detached_window_size(view, _primary_screen_size(webview))
window = webview.create_window(
self._detached_title(view),
f"{self._url()}/?view={view}&solo=1",
- width=1100,
- height=750,
- min_size=(800, 520),
+ width=width,
+ height=height,
+ min_size=_EDITOR_MIN_SIZE,
resizable=True,
frameless=True,
easy_drag=False,
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/de.json b/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/de.json
index 218b8cec3c..97c0e61b79 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/de.json
@@ -71,6 +71,10 @@
"card_seconds": "Karte in der Ecke",
"card_seconds_hint": "Wie lange das Bild nach einem Appshot in der Bildschirmecke bleibt.",
"card_seconds_option": "{0} Sekunden",
- "card_until_closed": "Bis ich sie schließe"
+ "card_until_closed": "Bis ich sie schließe",
+ "arrow_style": "Pfeilstil",
+ "arrow_tapered": "Spitz zulaufend",
+ "arrow_classic": "Klassisch",
+ "arrow_double": "Zwei Spitzen"
}
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/en.json b/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/en.json
index c630ac089f..4b347e9801 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/en.json
@@ -71,6 +71,10 @@
"card_seconds": "Corner card",
"card_seconds_hint": "How long the picture rests in the screen corner after an appshot.",
"card_seconds_option": "{0} seconds",
- "card_until_closed": "Until I close it"
+ "card_until_closed": "Until I close it",
+ "arrow_style": "Arrow style",
+ "arrow_tapered": "Tapered",
+ "arrow_classic": "Classic",
+ "arrow_double": "Two heads"
}
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/es.json b/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/es.json
index 1633be58e8..913e2efd0a 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/appshot_editor/es.json
@@ -71,6 +71,10 @@
"card_seconds": "Tarjeta en la esquina",
"card_seconds_hint": "Cuánto tiempo queda la imagen en la esquina de la pantalla tras un appshot.",
"card_seconds_option": "{0} segundos",
- "card_until_closed": "Hasta que la cierre"
+ "card_until_closed": "Hasta que la cierre",
+ "arrow_style": "Estilo de flecha",
+ "arrow_tapered": "Afilada",
+ "arrow_classic": "Clásica",
+ "arrow_double": "Dos puntas"
}
}
diff --git a/jarvis/ui/web/frontend/src/lib/appshotEditorModel.test.ts b/jarvis/ui/web/frontend/src/lib/appshotEditorModel.test.ts
index c688dbc307..7a79d2e028 100644
--- a/jarvis/ui/web/frontend/src/lib/appshotEditorModel.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/appshotEditorModel.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import {
+ ARROW_STYLES,
BACKGROUND_PRESETS,
DEFAULT_BACKGROUND,
TOOL_KEYS,
@@ -18,6 +19,7 @@ import {
rectFrom,
redo,
strokeWidths,
+ taperedArrowOutline,
textSize,
toolForKey,
translate,
@@ -210,3 +212,37 @@ describe("contrast", () => {
expect(contrastOn("#1c1c1e")).toBe("#ffffff");
});
});
+
+describe("tapered arrow", () => {
+ const width = (a: { x: number; y: number }, b: { x: number; y: number }) => Math.hypot(a.x - b.x, a.y - b.y);
+
+ it("starts as a fine point, swells to the neck and ends in a wider swept-back head", () => {
+ const outline = taperedArrowOutline({ x: 0, y: 0 }, { x: 200, y: 0 }, 6);
+ const [tailTop, neckTop, barbTop, tip, barbBottom, neckBottom, tailBottom] = outline;
+ expect(outline).toHaveLength(7);
+ expect(tip).toEqual({ x: 200, y: 0 });
+ const tail = width(tailTop, tailBottom);
+ const neck = width(neckTop, neckBottom);
+ const head = width(barbTop, barbBottom);
+ expect(tail).toBeLessThan(neck);
+ expect(neck).toBeLessThan(head);
+ // The barbs sit behind the neck: the head's base is concave.
+ expect(barbTop.x).toBeLessThan(neckTop.x);
+ });
+
+ it("keeps a short arrow's head in proportion and draws nothing for a dot", () => {
+ const short = taperedArrowOutline({ x: 0, y: 0 }, { x: 20, y: 0 }, 13);
+ expect(short[2].x).toBeGreaterThanOrEqual(0);
+ expect(taperedArrowOutline({ x: 5, y: 5 }, { x: 5.5, y: 5 }, 6)).toEqual([]);
+ });
+
+ it("grows with the stroke size", () => {
+ const thin = taperedArrowOutline({ x: 0, y: 0 }, { x: 300, y: 0 }, 2);
+ const thick = taperedArrowOutline({ x: 0, y: 0 }, { x: 300, y: 0 }, 13);
+ expect(width(thick[2], thick[4])).toBeGreaterThan(width(thin[2], thin[4]));
+ });
+
+ it("offers three arrow looks", () => {
+ expect(ARROW_STYLES).toEqual(["tapered", "classic", "double"]);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/appshotEditorModel.ts b/jarvis/ui/web/frontend/src/lib/appshotEditorModel.ts
index 00c4c80eb9..6d881426b0 100644
--- a/jarvis/ui/web/frontend/src/lib/appshotEditorModel.ts
+++ b/jarvis/ui/web/frontend/src/lib/appshotEditorModel.ts
@@ -43,9 +43,18 @@ export interface Rect {
export type TextStyle = "plain" | "label" | "outline";
export type RedactMode = "pixelate" | "blur";
+/**
+ * ``tapered``: CleanShot X's arrow — a filled shape that starts as a fine
+ * point and swells towards a swept-back head. ``classic``: line plus head.
+ * ``double``: a head at both ends.
+ */
+export type ArrowStyle = "tapered" | "classic" | "double";
+
+export const ARROW_STYLES: readonly ArrowStyle[] = ["tapered", "classic", "double"];
type Shape =
- | { kind: "arrow" | "line"; from: Point; to: Point; color: string; width: number }
+ | { kind: "arrow"; from: Point; to: Point; color: string; width: number; style?: ArrowStyle }
+ | { kind: "line"; from: Point; to: Point; color: string; width: number }
| { kind: "rect" | "filled" | "ellipse"; rect: Rect; color: string; width: number }
| { kind: "pen" | "highlight"; points: Point[]; color: string; width: number }
| { kind: "text"; at: Point; text: string; color: string; size: number; style: TextStyle }
@@ -439,6 +448,63 @@ export function contrastOn(hex: string): string {
return luminance > 0.6 ? "#111111" : "#ffffff";
}
+/**
+ * The outline of a tapered arrow, tail to tip and back, in picture space.
+ *
+ * Measured along the arrow: a fine tail point, a shaft that widens to the
+ * neck, and a head whose barbs sweep back past the neck — the concave base
+ * that makes CleanShot X's arrow read as one confident stroke. Everything
+ * scales with the stroke width; a short arrow keeps its head in proportion.
+ * Empty for an arrow too short to draw.
+ */
+export function taperedArrowOutline(from: Point, to: Point, width: number): Point[] {
+ const dx = to.x - from.x;
+ const dy = to.y - from.y;
+ const length = Math.hypot(dx, dy);
+ if (length < 2) return [];
+ const ux = dx / length;
+ const uy = dy / length;
+ const nx = -uy;
+ const ny = ux;
+ const head = Math.min(Math.max(12, width * 4.6 + 6), length * 0.62);
+ const barb = head * 0.56;
+ const neckAt = length - head * 0.7;
+ const tail = Math.max(0.6, width * 0.14);
+ const neck = Math.max(1.4, width * 0.78);
+ const at = (along: number, across: number): Point => ({
+ x: from.x + ux * along + nx * across,
+ y: from.y + uy * along + ny * across,
+ });
+ return [
+ at(0, tail),
+ at(neckAt, neck),
+ at(length - head, barb),
+ at(length, 0),
+ at(length - head, -barb),
+ at(neckAt, -neck),
+ at(0, -tail),
+ ];
+}
+
+function taperedArrow(ctx: CanvasRenderingContext2D, from: Point, to: Point, width: number) {
+ const outline = taperedArrowOutline(from, to, width);
+ if (outline.length === 0) return;
+ ctx.beginPath();
+ ctx.moveTo(outline[0].x, outline[0].y);
+ for (const point of outline.slice(1)) ctx.lineTo(point.x, point.y);
+ ctx.closePath();
+ // A soft lift off the picture, and a hairline of the same colour to round
+ // the corners — the arrow should look drawn, not cut out.
+ ctx.shadowColor = "rgba(0,0,0,0.32)";
+ ctx.shadowBlur = Math.max(3, width * 1.1);
+ ctx.shadowOffsetY = Math.max(1, width * 0.3);
+ ctx.fill();
+ ctx.shadowColor = "transparent";
+ ctx.lineWidth = Math.max(1, width * 0.22);
+ ctx.lineJoin = "round";
+ ctx.stroke();
+}
+
function arrow(ctx: CanvasRenderingContext2D, from: Point, to: Point, width: number) {
const angle = Math.atan2(to.y - from.y, to.x - from.x);
const head = Math.max(10, width * 4);
@@ -586,7 +652,15 @@ export function paintShape(ctx: CanvasRenderingContext2D, base: CanvasImageSourc
ctx.strokeStyle = op.color;
ctx.fillStyle = op.color;
ctx.lineWidth = op.width;
- arrow(ctx, op.from, op.to, op.width);
+ if (op.style === "classic") {
+ arrow(ctx, op.from, op.to, op.width);
+ } else if (op.style === "double") {
+ arrow(ctx, op.from, op.to, op.width);
+ arrow(ctx, op.to, op.from, op.width);
+ } else {
+ // Tapered is the default, also for arrows drawn before styles existed.
+ taperedArrow(ctx, op.from, op.to, op.width);
+ }
break;
case "line":
ctx.strokeStyle = op.color;
diff --git a/jarvis/ui/web/frontend/src/views/AppshotEditor.tsx b/jarvis/ui/web/frontend/src/views/AppshotEditor.tsx
index 734d0e3fcd..79cecee35a 100644
--- a/jarvis/ui/web/frontend/src/views/AppshotEditor.tsx
+++ b/jarvis/ui/web/frontend/src/views/AppshotEditor.tsx
@@ -31,6 +31,7 @@ import { fill, useLocaleChunk, useT } from "@/i18n";
import { copyAppshotPng } from "@/lib/appshotClipboard";
import { latestAppshotImageUrl } from "@/lib/appshotApi";
import {
+ ARROW_STYLES,
BACKGROUND_PRESETS,
COLORS,
CROP_RATIOS,
@@ -61,6 +62,7 @@ import {
undo as undoHistory,
viewport,
withId,
+ type ArrowStyle,
type Background,
type Draft,
type History,
@@ -135,6 +137,7 @@ const TOOL_ICONS: Record<Tool, typeof Square | null> = {
const COLOR_KEY = "jarvis.appshotEditor.color";
+const ARROW_KEY = "jarvis.appshotEditor.arrowStyle";
const BACKGROUND_KEY = "jarvis.appshotEditor.background";
function readStored<T>(key: string, fallback: T, valid: (value: unknown) => value is T): T {
@@ -157,6 +160,8 @@ function writeStored(key: string, value: unknown) {
}
}
+const isArrowStyle = (value: unknown): value is ArrowStyle =>
+ typeof value === "string" && (ARROW_STYLES as readonly string[]).includes(value);
const isColor = (value: unknown): value is string => typeof value === "string" && /^#[0-9a-f]{6}$/i.test(value);
const isBackground = (value: unknown): value is Background =>
typeof value === "object" && value !== null && "preset" in value && "padding" in value;
@@ -216,6 +221,13 @@ export function AppshotEditor({ appshotId, onClose, onApplied, variant = "overla
const [tool, setTool] = useState<Tool>("arrow");
const [color, setColorState] = useState(() => readStored(COLOR_KEY, COLORS[0], isColor));
const [widthIndex, setWidthIndex] = useState(2);
+ const [arrowStyle, setArrowStyleState] = useState<ArrowStyle>(() =>
+ readStored(ARROW_KEY, "tapered" as ArrowStyle, isArrowStyle),
+ );
+ const setArrowStyle = (next: ArrowStyle) => {
+ setArrowStyleState(next);
+ writeStored(ARROW_KEY, next);
+ };
const [zoom, setZoom] = useState<"fit" | number>("fit");
const [menu, setMenu] = useState<"" | "style" | "zoom">("");
const [dragging, setDragging] = useState(false);
@@ -474,8 +486,10 @@ export function AppshotEditor({ appshotId, onClose, onApplied, variant = "overla
let shape: Draft;
switch (tool) {
case "arrow":
+ shape = { kind: "arrow", from: p, to: p, color, width, style: arrowStyle };
+ break;
case "line":
- shape = { kind: tool, from: p, to: p, color, width };
+ shape = { kind: "line", from: p, to: p, color, width };
break;
case "rect":
case "filled":
@@ -905,6 +919,26 @@ export function AppshotEditor({ appshotId, onClose, onApplied, variant = "overla
/>
</label>
</QuickTooltip>
+ {tool === "arrow" && (
+ <div className="flex shrink-0 items-center gap-0.5" role="group" aria-label={label("arrow_style")} data-testid="appshot-editor-arrow-style">
+ {ARROW_STYLES.map((style) => (
+ <QuickTooltip key={style} content={label(`arrow_${style}`)} side="bottom">
+ <button
+ type="button"
+ aria-label={label(`arrow_${style}`)}
+ aria-pressed={arrowStyle === style}
+ onClick={() => setArrowStyle(style)}
+ className={cn(
+ "flex h-7 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground",
+ arrowStyle === style && "bg-foreground/20 text-foreground",
+ )}
+ >
+ <ArrowStyleIcon style={style} />
+ </button>
+ </QuickTooltip>
+ ))}
+ </div>
+ )}
{/* Free space: in its own window this is where the window is moved from. */}
<div className={cn("h-full min-w-4 flex-1", variant === "window" && "pywebview-drag-region")} aria-hidden />
@@ -1205,6 +1239,23 @@ export function AppshotEditor({ appshotId, onClose, onApplied, variant = "overla
);
}
+/** The three arrow looks, drawn small. */
+function ArrowStyleIcon({ style }: { style: ArrowStyle }) {
+ return (
+ <svg viewBox="0 0 20 20" className="h-[15px] w-[15px]" aria-hidden>
+ {style === "tapered" ? (
+ <path d="M3 17 L13.6 8.6 L11.6 6.4 L17 3 L14.4 9.3 L12.6 7.6 L3.6 17.6 Z" fill="currentColor" />
+ ) : (
+ <>
+ <path d="M4 16 L15 5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" />
+ <path d="M16.5 3.5 L10.8 5.2 L14.8 9.2 Z" fill="currentColor" />
+ {style === "double" && <path d="M2.5 17.5 L4.2 11.8 L8.2 15.8 Z" fill="currentColor" />}
+ </>
+ )}
+ </svg>
+ );
+}
+
const ROUND_ICON =
"flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground disabled:pointer-events-none disabled:opacity-40";
diff --git a/tests/unit/ui/test_desktop_show_window.py b/tests/unit/ui/test_desktop_show_window.py
index da2f24f8d5..1b5cd815f4 100644
--- a/tests/unit/ui/test_desktop_show_window.py
+++ b/tests/unit/ui/test_desktop_show_window.py
@@ -21,6 +21,7 @@ from __future__ import annotations
import inspect
import threading
+from types import SimpleNamespace
import pytest
@@ -324,3 +325,48 @@ def test_the_shipped_index_satisfies_the_probe() -> None:
index = Path(desktop_app.__file__).parent / "web" / "frontend" / "index.html"
assert "root" in desktop_app._SPA_DOCUMENT_PROBE # noqa: SLF001
assert 'id="root"' in index.read_text(encoding="utf-8")
+
+
+def test_the_appshot_editor_window_opens_in_cleanshot_proportions() -> None:
+ """Live 2026-10-03: the editor should sit in front of the app like
+ CleanShot X's — about 2/5 of the screen wide, a bit under half its height
+ — never so small that toolbar buttons drop off, never as big as the app."""
+ from jarvis.ui.desktop_app import detached_window_size
+
+ assert detached_window_size("visualization", (2560, 1440)) == (1100, 750)
+ assert detached_window_size("appshot-editor", (2560, 1440)) == (1024, 662)
+ assert detached_window_size("appshot-editor", None) == (1100, 750)
+ # A small screen: the toolbar's minimum, but never past the screen.
+ assert detached_window_size("appshot-editor", (1280, 720)) == (900, 600)
+ assert detached_window_size("appshot-editor", (800, 500)) == (800, 500)
+
+
+def test_an_open_editor_window_is_pointed_at_the_new_appshot(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """The appshot card opens the editor through ``open_detached_window`` with
+ a query; an editor already open is re-pointed, never duplicated."""
+ app = DesktopApp.__new__(DesktopApp)
+ loaded: list[str] = []
+ scripts: list[str] = []
+ shown: list[bool] = []
+ existing = SimpleNamespace(
+ load_url=loaded.append,
+ # The warm page answers: it switched to the new appshot in place.
+ evaluate_js=lambda js: scripts.append(js) or True,
+ show=lambda: shown.append(True),
+ )
+ app._detached_windows = {"appshot-editor": existing} # noqa: SLF001
+ app._url = lambda: "http://127.0.0.1:47821" # type: ignore[method-assign] # noqa: SLF001
+ raised: list[str] = []
+ monkeypatch.setattr(
+ "jarvis.ui.desktop_app._bring_window_to_front_by_title", lambda title: raised.append(title)
+ )
+
+ result = app.open_detached_window("appshot-editor", query="appshot=a1b2c3d4")
+
+ assert result == {"ok": True, "already_open": True, "view": "appshot-editor"}
+ assert loaded == [], "a warm editor is re-pointed, not reloaded"
+ assert scripts and '"a1b2c3d4"' in scripts[0]
+ assert shown == [True]
+ assert len(raised) == 1