The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): give tours a themed spotlight and directional motion
Brooklyn Nicholsond433a452cc9c
diff --git a/apps/desktop/src/lib/tour/app-tour.css b/apps/desktop/src/lib/tour/app-tour.cssindex 84cd7dd35be..2c378712ead 100644--- a/apps/desktop/src/lib/tour/app-tour.css+++ b/apps/desktop/src/lib/tour/app-tour.css@@ -1,72 +1,212 @@-/* Theme bridge for the APP surface's tour popovers: driver.js ships a fixed- light palette, so repaint it with the app's own tokens and it follows every- theme (including custom skins) for free. Scoped to driver.js's classes.+/* Hermes surface treatment for the APP surface's tour popovers.- The preview surface keeps the stock look on purpose — it renders inside a- guest page where these variables don't exist. */+ driver.js ships a fixed light palette, a heavy drop shadow, and 19px/14px+ type — none of which is how this app draws a floating popover. Repaint it+ with the popover primitive's own recipe (components/ui/popover.tsx): a glass+ fill over --ui-bg-elevated, a single --ui-stroke-secondary hairline, and NO+ shadow. Radius and type follow the app scale, which is near-square+ (--radius-scalar: 0.2) and 12px-based.++ The scrim and the cutout geometry are config, not CSS — see TOUR_STYLE in+ run-tour.ts.++ The preview surface keeps the stock look on purpose: it renders inside a+ guest page where none of these variables exist. */.driver-popover {- background-color: var(--color-popover);- border: 1px solid var(--color-border);- border-radius: var(--radius-md);- box-shadow: var(--shadow-nous);- color: var(--color-popover-foreground);+ --tour-surface: color-mix(in srgb, var(--ui-bg-elevated) 92%, transparent);++ backdrop-filter: blur(12px);+ background-color: var(--tour-surface);+ border: 1px solid var(--ui-stroke-secondary);+ border-radius: var(--radius-lg);+ box-shadow: none;+ color: var(--foreground);font-family: var(--font-sans);+ max-width: 20rem;+ min-width: 15rem;+ padding: 0.75rem;}.driver-popover-title {- font-size: 0.875rem;+ font-size: 0.75rem;font-weight: 600;- line-height: 1.4;+ letter-spacing: -0.01em;+ line-height: 1rem;+}++.driver-popover-title[style*='block'] + .driver-popover-description {+ margin-top: 0.25rem;}.driver-popover-description {- color: var(--color-muted-foreground);- font-size: 0.8125rem;+ color: var(--ui-text-secondary);+ font-size: 0.75rem;+ line-height: 1.15rem;+}++.driver-popover-footer {+ gap: 0.75rem;+ margin-top: 0.75rem;}.driver-popover-progress-text {- color: var(--color-muted-foreground);- font-size: 0.75rem;+ color: var(--ui-text-tertiary);+ font-size: 0.6875rem;+ font-variant-numeric: tabular-nums;}.driver-popover-close-btn {- color: var(--color-muted-foreground);+ color: var(--ui-text-tertiary);+ transition: color 100ms;}.driver-popover-close-btn:hover,.driver-popover-close-btn:focus {- color: var(--color-foreground);+ color: var(--foreground);}+/* Matches the Button `secondary` + `xs` shape: 12px/1rem medium, 2.5px radius. */.driver-popover-footer-btn {- background-color: var(--color-secondary);- border-color: var(--color-border);- border-radius: var(--radius-sm);- color: var(--color-secondary-foreground);+ background-color: var(--ui-bg-quaternary);+ border: none;+ border-radius: 2.5px;+ color: var(--foreground);font-family: var(--font-sans);+ font-size: 0.75rem;+ font-weight: 500;+ line-height: 1rem;+ padding: 0.1875rem 0.5rem;text-shadow: none;+ transition: background-color 100ms;}.driver-popover-footer-btn:hover,.driver-popover-footer-btn:focus {- background-color: var(--color-accent);- color: var(--color-accent-foreground);+ background-color: var(--ui-control-hover-background);}-/* Each arrow variant paints exactly one border edge; the rest are transparent. */+.driver-popover-navigation-btns button + button {+ margin-left: 0.25rem;+}++/* The arrow is a CSS border triangle, so it can't share the body's+ backdrop-blur — paint it with the opaque token underneath the glass instead.+ Each variant colors exactly one edge; the rest stay transparent. */.driver-popover-arrow-side-left {- border-left-color: var(--color-popover);+ border-left-color: var(--ui-bg-elevated);}.driver-popover-arrow-side-right {- border-right-color: var(--color-popover);+ border-right-color: var(--ui-bg-elevated);}.driver-popover-arrow-side-top {- border-top-color: var(--color-popover);+ border-top-color: var(--ui-bg-elevated);}.driver-popover-arrow-side-bottom {- border-bottom-color: var(--color-popover);+ border-bottom-color: var(--ui-bg-elevated);+}++/* THE FADE — everything that isn't the spotlight recedes.++ Two layers, both themed, both live-editable here:+ 1. driver.js's own scrim path, repainted from the app background so light+ mode fades toward white and dark toward near-black (no mode branch —+ --background already resolves per theme).+ 2. The companion layer (spotlight-blur.ts), which carries the feathered+ edge and desaturates what's behind it. */+.driver-overlay path {+ fill: var(--background) !important;+ opacity: 0.8;+}++#__hermes-tour-spotlight-blur {+ backdrop-filter: grayscale(1) opacity(0.55);+ -webkit-backdrop-filter: grayscale(1) opacity(0.55);+}++/* Popover entrance, in two flavors — both slide AND fade.++ The tour ARRIVES by settling DOWN into place. Every step after slides in+ from the LEFT, so the sideways nudge reads as "next" (like turning a page)+ rather than repeating the arrival.++ Easing is the app's own enter curve (`thread-jump-in`, the transform+ transitions, the opacity fades) — NOT expo. Expo-out dumps ~70% of the+ travel in the first ~50ms and crawls through the rest, which is why a+ longer distance felt snappy-then-sludgy and the fade looked like it wasn't+ happening at all: opacity was ~0.95 before the eye caught it.++ driver.js builds a fresh popover node per step, so both re-trigger for free.++ `!important` because driver's own `.driver-fade .driver-popover` rule sets a+ plain fade on the same element and would otherwise win on order. */+.driver-popover {+ --tour-pop-travel: 10px;+ /* Centered steps have no neighbour to measure against — see the side rules. */+ --tour-pop-travel-centered: 5px;+ --tour-pop-duration: 340ms;+ --tour-pop-ease: cubic-bezier(0.22, 1, 0.36, 1);+}++@keyframes tour-pop-in {+ from {+ opacity: 0;+ transform: translateY(calc(var(--tour-pop-travel) * -1));+ }+}++/* One keyframe, direction supplied by the vars below. */+@keyframes tour-pop-next {+ from {+ opacity: 0;+ transform: translate(var(--tour-pop-x, 0), var(--tour-pop-y, 0));+ }+}++/* Enter from the side the popover LANDED on, so the motion agrees with the+ layout instead of fighting it: a popover to the left of its target drifts in+ from the left, one below its target rises up into it. driver.js sets these+ side classes as it positions each step, so the rule follows placement+ automatically — including when it flips a step to avoid a screen edge.++ The centered case (`side-over`, an element-less narration step) gets its own+ shorter travel. With no target beside it, nothing anchors the eye, so the+ same 10px that reads as a nudge next to an element reads as a real slide out+ in the open. */+.driver-popover.tour-pop-next.driver-popover-side-left {+ --tour-pop-x: calc(var(--tour-pop-travel) * -1);+}++.driver-popover.tour-pop-next.driver-popover-side-right {+ --tour-pop-x: var(--tour-pop-travel);+}++.driver-popover.tour-pop-next.driver-popover-side-top {+ --tour-pop-y: calc(var(--tour-pop-travel) * -1);+}++.driver-popover.tour-pop-next.driver-popover-side-bottom {+ --tour-pop-y: var(--tour-pop-travel);+}++.driver-popover.tour-pop-next.driver-popover-side-over {+ --tour-pop-y: var(--tour-pop-travel-centered);+}++.driver-popover.tour-pop-in {+ animation: tour-pop-in var(--tour-pop-duration) var(--tour-pop-ease) !important;+}++.driver-popover.tour-pop-next {+ animation: tour-pop-next var(--tour-pop-duration) var(--tour-pop-ease) !important;+}++@media (prefers-reduced-motion: reduce) {+ .driver-popover.tour-pop-in,+ .driver-popover.tour-pop-next {+ animation: none;+ }}diff --git a/apps/desktop/src/lib/tour/spotlight-blur.ts b/apps/desktop/src/lib/tour/spotlight-blur.tsnew file mode 100644index 00000000000..71a2fc76ce1--- /dev/null+++ b/apps/desktop/src/lib/tour/spotlight-blur.ts@@ -0,0 +1,191 @@+/**+ * SPOTLIGHT BLUR — a blurred scrim that keeps the highlighted element crisp.+ *+ * driver.js paints its scrim as ONE full-viewport <svg> whose fill path has the+ * spotlight punched out. A `backdrop-filter` on that element blurs the cutout+ * too, because backdrop-filter clips to the element's BOX, not its fill — which+ * is why the highlighted control came out fuzzy.+ *+ * So the blur goes on its own layer, masked to everything-except-the-spotlight.+ * Two details make it not look cheap:+ *+ * - The mask is an SVG <mask> whose hole is a ROUNDED rect run through a+ * feGaussianBlur, so the blur fades out across a soft band instead of+ * ending on a hard edge. (`clip-path` can't do this — it's binary. A+ * data-URI mask can, but rebuilding and reparsing that string every frame+ * is wasteful; an inline mask lets a frame be four attribute writes.)+ * - The hole follows driver.js's OWN animated rect (`__activeStagePosition`,+ * eased per frame by driver itself) rather than the target's static box,+ * so the blur travels with the cutout between steps instead of jumping to+ * the destination while the cutout is still gliding.+ *+ * App surface only — a preview guest page keeps driver.js's stock look.+ */++/** Matches DialogOverlay's scrim treatment. The actual effect (grayscale/fade)+ * lives in app-tour.css so it can be tuned in one place. */+const FEATHER_PX = 12++/** Matches TOUR_STYLE.stagePadding/stageRadius, so the soft hole sits over+ * driver's own cutout rather than beside it. */+const STAGE_PADDING = 6+const STAGE_RADIUS = 8++const LAYER_ID = '__hermes-tour-spotlight-blur'+const MASK_ID = '__hermes-tour-spotlight-mask'+const SVG_NS = 'http://www.w3.org/2000/svg'++/** One rect's worth of geometry — driver's stage, or an element's box. */+export interface Stage {+ height: number+ width: number+ x: number+ y: number+}++/** Reads driver.js's live (animated) stage rect. Supplied by run-tour. */+type StageSource = () => null | Stage++let frame = 0+let stageSource: StageSource | undefined+let hole: SVGRectElement | undefined+let outer: SVGRectElement | undefined++function teardownDom(): void {+ document.getElementById(LAYER_ID)?.remove()+ document.getElementById(`${LAYER_ID}-defs`)?.remove()+ hole = undefined+ outer = undefined+}++/** The blur layer plus the mask that shapes it. Built once per tour. */+function mount(): void {+ if (document.getElementById(LAYER_ID)) {+ return+ }++ const svg = document.createElementNS(SVG_NS, 'svg')++ svg.id = `${LAYER_ID}-defs`+ svg.setAttribute('aria-hidden', 'true')+ svg.style.cssText = 'position:fixed;width:0;height:0;pointer-events:none'++ const mask = document.createElementNS(SVG_NS, 'mask')++ mask.id = MASK_ID+ // Viewport coordinates, so the rects below take plain CSS pixels.+ mask.setAttribute('maskUnits', 'userSpaceOnUse')++ const filter = document.createElementNS(SVG_NS, 'filter')++ filter.id = `${MASK_ID}-feather`++ // Roomy region: a blur clipped to the shape's own box would square off the+ // very edge we're trying to soften.+ for (const [name, value] of [+ ['x', '-50%'],+ ['y', '-50%'],+ ['width', '200%'],+ ['height', '200%']+ ]) {+ filter.setAttribute(name, value)+ }++ const blur = document.createElementNS(SVG_NS, 'feGaussianBlur')++ blur.setAttribute('stdDeviation', String(FEATHER_PX / 2))+ filter.appendChild(blur)++ // White shows the blur, black hides it: paint everything, then punch a+ // feathered hole where the spotlight is.+ outer = document.createElementNS(SVG_NS, 'rect')+ outer.setAttribute('fill', 'white')++ hole = document.createElementNS(SVG_NS, 'rect')+ hole.setAttribute('fill', 'black')+ hole.setAttribute('rx', String(STAGE_RADIUS + STAGE_PADDING / 2))+ hole.setAttribute('filter', `url(#${filter.id})`)++ mask.append(outer, hole)+ svg.append(filter, mask)+ document.body.appendChild(svg)++ const layer = document.createElement('div')++ layer.id = LAYER_ID+ layer.setAttribute('aria-hidden', 'true')+ layer.style.cssText = [+ 'position:fixed',+ 'inset:0',+ 'pointer-events:none',+ // Under driver.js's own overlay (10000) so the scrim tint reads on top of+ // this, and far under the popover, which stays perfectly sharp.+ 'z-index:9998',+ `mask:url(#${MASK_ID})`,+ `-webkit-mask:url(#${MASK_ID})`+ ].join(';')++ document.body.appendChild(layer)+}++/** Move the feathered hole onto `stage`. Four attribute writes. */+function paint(stage: null | Stage): void {+ if (!hole || !outer) {+ return+ }++ outer.setAttribute('width', String(window.innerWidth))+ outer.setAttribute('height', String(window.innerHeight))++ if (!stage) {+ // A narration step highlights nothing: blur everything, no hole.+ hole.setAttribute('width', '0')+ hole.setAttribute('height', '0')++ return+ }++ hole.setAttribute('x', String(stage.x - STAGE_PADDING))+ hole.setAttribute('y', String(stage.y - STAGE_PADDING))+ hole.setAttribute('width', String(Math.max(0, stage.width + STAGE_PADDING * 2)))+ hole.setAttribute('height', String(Math.max(0, stage.height + STAGE_PADDING * 2)))+}++/** Follow the stage every frame — driver eases it, we just mirror it. */+function tick(): void {+ frame = requestAnimationFrame(tick)++ if (!document.querySelector('svg.driver-overlay')) {+ // The tour ended (last step, Esc, ✕, overlay click).+ stopSpotlightBlur()++ return+ }++ mount()+ paint(stageSource?.() ?? null)+}++/**+ * Track the live spotlight with a blurred, soft-edged layer. Idempotent: safe+ * to call on every tour action. Everything it creates dies with driver.js's+ * overlay, however the tour ended, so nothing lingers between tours.+ */+export function syncSpotlightBlur(stage: StageSource): void {+ stageSource = stage++ if (!frame) {+ frame = requestAnimationFrame(tick)+ }+}++/** Stop following and remove the layer. */+export function stopSpotlightBlur(): void {+ if (frame) {+ cancelAnimationFrame(frame)+ frame = 0+ }++ stageSource = undefined+ teardownDom()+}