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(onboarding): keep the tour ring inside the window for whole-page steps

rubenluetke10-beep744c633cff9d
diff --git a/jarvis/ui/web/frontend/src/components/onboarding/tour/Spotlight.tsx b/jarvis/ui/web/frontend/src/components/onboarding/tour/Spotlight.tsx
index 088a95a2ec..9018fa185f 100644
--- a/jarvis/ui/web/frontend/src/components/onboarding/tour/Spotlight.tsx
+++ b/jarvis/ui/web/frontend/src/components/onboarding/tour/Spotlight.tsx
@@ -3,7 +3,7 @@ import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from "re
import { createPortal } from "react-dom";
import { TOUR_LAYER_ATTR } from "../tourEvents";
import { EASE_OUT } from "../ui";
-import { cutout, padded, placeCard, type Rect, type TourPlacement } from "./tourSteps";
+import { cutout, fitToView, padded, placeCard, type Rect, type TourPlacement } from "./tourSteps";
const CARD_W = 320;
@@ -77,7 +77,7 @@ export function Spotlight({
return () => ro.disconnect();
}, []);
- const hole = rect ? padded(rect) : null;
+ const hole = rect ? fitToView(padded(rect), view) : null;
const whole: Rect = { x: 0, y: 0, w: view.w, h: view.h };
// No element (centred card): the hole collapses to a point in the middle,
// so the same clip-path shape still animates.
diff --git a/jarvis/ui/web/frontend/src/components/onboarding/tour/tourSteps.test.ts b/jarvis/ui/web/frontend/src/components/onboarding/tour/tourSteps.test.ts
index 8161ddc5be..11ec53a5ca 100644
--- a/jarvis/ui/web/frontend/src/components/onboarding/tour/tourSteps.test.ts
+++ b/jarvis/ui/web/frontend/src/components/onboarding/tour/tourSteps.test.ts
@@ -2,7 +2,7 @@ import { readdirSync, readFileSync, statSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import en from "@/i18n/locales/onboarding/en.json";
-import { cutout, placeCard, TOUR_STEPS } from "./tourSteps";
+import { cutout, fitToView, padded, placeCard, TOUR_STEPS } from "./tourSteps";
const SRC = join(__dirname, "..", "..", "..");
@@ -86,3 +86,17 @@ describe("placeCard", () => {
expect(placeCard(null, "below", card, view)).toEqual({ x: 480, y: 320 });
});
});
+
+describe("fitToView", () => {
+ const view = { w: 1280, h: 800 };
+
+ it("pulls a whole-page ring back inside the window", () => {
+ const ring = fitToView(padded({ x: 0, y: 32, w: 1280, h: 768 }), view);
+ expect(ring).toEqual({ x: 6, y: 24, w: 1268, h: 770 });
+ });
+
+ it("leaves a ring that already fits untouched", () => {
+ const ring = padded({ x: 100, y: 100, w: 200, h: 40 });
+ expect(fitToView(ring, view)).toEqual(ring);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/onboarding/tour/tourSteps.ts b/jarvis/ui/web/frontend/src/components/onboarding/tour/tourSteps.ts
index eb7bcf70e1..b4c28f42e7 100644
--- a/jarvis/ui/web/frontend/src/components/onboarding/tour/tourSteps.ts
+++ b/jarvis/ui/web/frontend/src/components/onboarding/tour/tourSteps.ts
@@ -82,6 +82,20 @@ export function padded(r: Rect, pad = PAD): Rect {
return { x: r.x - pad, y: r.y - pad, w: r.w + pad * 2, h: r.h + pad * 2 };
}
+/**
+ * Keep a highlight rect inside the window, `margin` from every edge. An
+ * element that fills the window (a whole page) would otherwise have its
+ * padded ring drawn off-screen, leaving no visible frame at all; clamped,
+ * the ring sits just inside the window edge instead.
+ */
+export function fitToView(r: Rect, view: { w: number; h: number }, margin = 6): Rect {
+ const x1 = Math.max(r.x, margin);
+ const y1 = Math.max(r.y, margin);
+ const x2 = Math.min(r.x + r.w, view.w - margin);
+ const y2 = Math.min(r.y + r.h, view.h - margin);
+ return { x: x1, y: y1, w: Math.max(0, x2 - x1), h: Math.max(0, y2 - y1) };
+}
+
/**
* Where the tour card goes for a highlighted rect, kept fully inside the
* window (`margin` from every edge). `inside` sits in the element's top-right