Skip to content

The agent that grows with you

fix(desktop): satisfy lint/title rules for lightbox zoom; map contributor evan

Brooklyn Nicholson37b16e98746f
diff --git a/apps/desktop/src/components/chat/zoomable-image.test.tsx b/apps/desktop/src/components/chat/zoomable-image.test.tsx
index 519f0766132..7d6f7f617c5 100644
--- a/apps/desktop/src/components/chat/zoomable-image.test.tsx
+++ b/apps/desktop/src/components/chat/zoomable-image.test.tsx
@@ -1,6 +1,5 @@
-import type { ReactNode } from 'react'
-
import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
+import type { ReactNode } from 'react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { I18nProvider } from '@/i18n/context'
diff --git a/apps/desktop/src/components/chat/zoomable-image.tsx b/apps/desktop/src/components/chat/zoomable-image.tsx
index cfdde7a8513..552f05ec417 100644
--- a/apps/desktop/src/components/chat/zoomable-image.tsx
+++ b/apps/desktop/src/components/chat/zoomable-image.tsx
@@ -3,8 +3,8 @@
import { useStore } from '@nanostores/react'
import { type ComponentProps, useEffect } from 'react'
-import { useZoomPan } from '@/components/ui/use-zoom-pan'
import { Dialog, DialogContent } from '@/components/ui/dialog'
+import { useZoomPan } from '@/components/ui/use-zoom-pan'
import { useImageDownload } from '@/hooks/use-image-download'
import { useI18n } from '@/i18n'
import { Download, ZoomIn, ZoomOut } from '@/lib/icons'
@@ -133,22 +133,18 @@ export function ImageLightbox({
<Dialog onOpenChange={onOpenChange} open={open}>
<DialogContent
bodyClassName="block overflow-visible p-0"
- className="w-auto max-h-[calc(100vh-12rem)] max-w-[calc(100vw-12rem)] border-0 bg-transparent shadow-none"
- overlayClassName="bg-black/60"
- showCloseButton={false}
chrome={
open && (
<div
className="fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 items-center gap-1 rounded-full border border-border/70 bg-background/85 p-1 shadow-lg backdrop-blur"
- onPointerDown={event => event.stopPropagation()}
onClick={event => event.stopPropagation()}
+ onPointerDown={event => event.stopPropagation()}
>
<button
aria-label={copy.zoomOut}
className="grid size-8 place-items-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50"
disabled={scale <= 0.25}
onClick={() => zoomOut()}
- title={copy.zoomOut}
type="button"
>
<ZoomOut className="size-4" />
@@ -157,7 +153,6 @@ export function ImageLightbox({
aria-label={copy.resetZoom}
className="min-w-14 rounded-full px-2 text-center text-xs font-medium tabular-nums text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
onClick={() => reset()}
- title={copy.resetZoom}
type="button"
>
{Math.round(scale * 100)}%
@@ -167,7 +162,6 @@ export function ImageLightbox({
className="grid size-8 place-items-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50"
disabled={scale >= 8}
onClick={() => zoomIn()}
- title={copy.zoomIn}
type="button"
>
<ZoomIn className="size-4" />
@@ -175,16 +169,19 @@ export function ImageLightbox({
</div>
)
}
+ className="w-auto max-h-[calc(100vh-12rem)] max-w-[calc(100vw-12rem)] border-0 bg-transparent shadow-none"
+ overlayClassName="bg-black/60"
+ showCloseButton={false}
>
<div className="group/lightbox relative inline-block">
<img
- ref={ref}
alt={alt ?? ''}
className={cn(
'block max-h-[calc(100vh-12rem)] max-w-[calc(100vw-12rem)] select-none rounded-lg object-contain shadow-2xl',
panning && 'cursor-grabbing'
)}
onClick={onImageClick}
+ ref={ref}
src={src}
style={{ ...style, cursor, touchAction: 'none' }}
{...stageProps}
diff --git a/apps/desktop/src/components/ui/use-zoom-pan.ts b/apps/desktop/src/components/ui/use-zoom-pan.ts
index 6d738f99633..a645902fd6a 100644
--- a/apps/desktop/src/components/ui/use-zoom-pan.ts
+++ b/apps/desktop/src/components/ui/use-zoom-pan.ts
@@ -1,7 +1,6 @@
import {
type CSSProperties,
type PointerEvent as ReactPointerEvent,
- type RefObject,
useCallback,
useEffect,
useRef,
@@ -54,10 +53,12 @@ export function useZoomPan<T extends HTMLElement = HTMLElement>(options: UseZoom
// a null ref and never attach the native wheel listener. Re-rendering on
// mount re-runs that effect with the node in hand.
const [node, setNode] = useState<T | null>(null)
+
const refCallback = useCallback((instance: T | null) => {
ref.current = instance
setNode(instance)
}, [])
+
const [transform, setTransform] = useState<Transform>({ scale: 1, x: 0, y: 0 })
const [panning, setPanning] = useState(false)
const [moved, setMoved] = useState(false)
@@ -163,6 +164,7 @@ export function useZoomPan<T extends HTMLElement = HTMLElement>(options: UseZoom
pointers.current.set(event.pointerId, { x: event.clientX, y: event.clientY })
const node = ref.current
+
if (!node) {
return
}
diff --git a/apps/desktop/src/components/ui/zoomable.tsx b/apps/desktop/src/components/ui/zoomable.tsx
index 6bed895f70d..5c1a5f35984 100644
--- a/apps/desktop/src/components/ui/zoomable.tsx
+++ b/apps/desktop/src/components/ui/zoomable.tsx
@@ -87,11 +87,11 @@ function ZoomPanViewer({
showCloseButton={false}
>
<div
- ref={ref}
className={cn(
'relative flex-1 touch-none select-none overflow-hidden',
panning ? 'cursor-grabbing' : 'cursor-grab'
)}
+ ref={ref}
{...stageProps}
>
<div className="absolute inset-0 grid place-items-center">
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]
new file mode 100644
index 00000000000..f377c55fd6e
--- /dev/null
+++ b/contributors/emails/[email protected]
@@ -0,0 +1,2 @@
+evan
+# PR #127247 lightbox zoom