Skip to content

Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.

fix(stacks): photo tiles for every stack, correct sub-image drags, reliable collapse UX, no stuck hover bars

Deepender259c8fb4fd47c5
diff --git a/electron/main/drag.ts b/electron/main/drag.ts
index 3ba131c..5022859 100644
--- a/electron/main/drag.ts
+++ b/electron/main/drag.ts
@@ -15,7 +15,7 @@
*/
import { app, nativeImage, type WebContents } from 'electron'
import { Resvg } from '@resvg/resvg-js'
-import { copyFileSync, mkdirSync, writeFileSync, existsSync } from 'node:fs'
+import { copyFileSync, mkdirSync, writeFileSync, existsSync, statSync } from 'node:fs'
import { join, extname } from 'node:path'
import { getUnpackagedTempDir, toUnpackagedFilePaths } from '../store/paths'
import type { DragRequest, ItemData } from '../../shared/types'
@@ -69,9 +69,13 @@ export function formatScreenshotFilename(capturedAt?: number, ext = 'png', index
* Resolve a DragRequest into concrete ItemData along with capture timestamp.
*
* If `paths` is provided (dragging one file out of an expanded bundle), synthesize
- * a singleton `files` item. Otherwise look up the full item by id.
+ * a singleton `files` item. If `imageId` is provided, resolve that ONE image of
+ * an image-collection and report its sibling index (1-based) via `subIndex` so
+ * staging can give it a collision-free filename — every image in a collection
+ * shares the parent's capturedAt stamp, and identical stamps otherwise collapse
+ * every sub-drag onto the first-staged file.
*/
-export function resolveDragData(req: DragRequest): { data: ItemData; capturedAt?: number } | null {
+export function resolveDragData(req: DragRequest): { data: ItemData; capturedAt?: number; subIndex?: number } | null {
if (req.paths && req.paths.length > 0) {
prefetchFileIcons(req.paths)
return { data: { kind: 'files', paths: req.paths } }
@@ -83,15 +87,26 @@ export function resolveDragData(req: DragRequest): { data: ItemData; capturedAt?
prefetchFileIcons(item.data.paths)
}
- if (req.imageId && item.data.kind === 'image-collection') {
- const img = item.data.images.find((i) => i.imageId === req.imageId)
- if (img) return { data: { kind: 'image', ...img }, capturedAt: item.capturedAt }
+ if (req.imageId) {
+ if (item.data.kind === 'image-collection') {
+ const idx = item.data.images.findIndex((i) => i.imageId === req.imageId)
+ if (idx >= 0) {
+ return { data: { kind: 'image', ...item.data.images[idx] }, capturedAt: item.capturedAt, subIndex: idx + 1 }
+ }
+ // Requested image no longer exists in this collection. Refuse the drag
+ // rather than silently dragging the whole collection (which surfaced as
+ // "dragging any row always delivered the top image").
+ console.warn('[Drag] sub-image not found in collection; aborting drag. id=', req.id, 'imageId=', req.imageId)
+ return null
+ }
+ console.warn('[Drag] imageId requested for non-collection item; aborting drag. id=', req.id)
+ return null
}
return { data: item.data, capturedAt: item.capturedAt }
}
-export function startDragOut(sender: WebContents, data: ItemData, capturedAt?: number): boolean {
- const staged = stageDragFile(data, capturedAt)
+export function startDragOut(sender: WebContents, data: ItemData, capturedAt?: number, subIndex?: number): boolean {
+ const staged = stageDragFile(data, capturedAt, typeof subIndex === 'number' ? { indexSuffix: subIndex } : undefined)
if (!staged) return false
const icon = dragIcon(data)
@@ -133,14 +148,47 @@ export function prestageDrag(req: DragRequest): void {
try {
const resolved = resolveDragData(req)
if (!resolved) return
- const { data, capturedAt } = resolved
- stageDragFile(data, capturedAt)
+ const { data, capturedAt, subIndex } = resolved
+ stageDragFile(data, capturedAt, typeof subIndex === 'number' ? { indexSuffix: subIndex } : undefined)
dragIcon(data)
} catch {}
}
+/**
+ * Resolve a unique destination path inside `temp` for a staged image.
+ *
+ * WHY NOT A BLIND existsSync SKIP: images inside one collection share the
+ * parent's capturedAt stamp, so distinct photos computed identical names —
+ * the first staged file won and every sibling silently reused it. We now
+ * treat an existing candidate as reusable ONLY when its size matches the
+ * expected payload; otherwise we append Windows-style " (2)", " (3)"…
+ * until the name is genuinely free.
+ */
+function resolveUniqueImageDest(temp: string, fileName: string, ext: string, expectedBytes: number): string {
+ const cleanExt = ext.replace(/^\./, '') || 'png'
+ const base = fileName.replace(/\.[^.]+$/, '')
+ let candidate = join(temp, `${base}.${cleanExt}`)
+ if (!existsSync(candidate)) return candidate
+
+ // Existing file: reusable only if it plausibly holds this exact payload.
+ try {
+ if (expectedBytes > 0 && statSync(candidate).size === expectedBytes) return candidate
+ } catch { /* fall through to suffixing */ }
+
+ let n = 2
+ do {
+ candidate = join(temp, `${base} (${n}).${cleanExt}`)
+ n++
+ } while (existsSync(candidate) && n < 1000)
+ return candidate
+}
+
/** Resolve the item to a concrete file path to hand to the OS. */
-export function stageDragFile(data: ItemData, capturedAt?: number): Staged | null {
+export function stageDragFile(
+ data: ItemData,
+ capturedAt?: number,
+ opts?: { indexSuffix?: number }
+): Staged | null {
const cacheKey = getStagedCacheKey(data, capturedAt)
const cached = stagedCache.get(cacheKey)
if (cached && existsSync(cached.file)) {
@@ -165,13 +213,14 @@ export function stageDragFile(data: ItemData, capturedAt?: number): Staged | nul
const ext = extname(src) || '.png'
const fileName = formatClipboardImageFilename(capturedAt, ext, {
source: data.source,
- fileName: data.fileName
+ fileName: data.fileName,
+ indexSuffix: opts?.indexSuffix
})
- const dest = join(temp, fileName)
+ // Sub-images of one collection share the parent's stamp; guarantee a
+ // distinct file per photo instead of blind-reusing an existing name.
+ const dest = resolveUniqueImageDest(temp, fileName, ext, data.bytes || 0)
try {
- if (!existsSync(dest)) {
- copyFileSync(src, dest)
- }
+ copyFileSync(src, dest)
} catch {
return null
}
@@ -190,11 +239,9 @@ export function stageDragFile(data: ItemData, capturedAt?: number): Staged | nul
fileName: img.fileName,
indexSuffix: idx
})
- const dest = join(temp, fileName)
+ const dest = resolveUniqueImageDest(temp, fileName, ext, img.bytes || 0)
try {
- if (!existsSync(dest)) {
- copyFileSync(src, dest)
- }
+ copyFileSync(src, dest)
paths.push(dest)
idx++
} catch {
diff --git a/electron/main/ipc.ts b/electron/main/ipc.ts
index 1989481..1f0dfdc 100644
--- a/electron/main/ipc.ts
+++ b/electron/main/ipc.ts
@@ -699,7 +699,7 @@ export function registerSendListeners(): void {
console.log('[IPC] start-drag: no data resolved')
return
}
- const { data, capturedAt } = resolved
+ const { data, capturedAt, subIndex } = resolved
console.log('[IPC] start-drag: kind=', data.kind)
// Usage accounting parity with click-to-paste: a whole-item drag counts
@@ -715,7 +715,7 @@ export function registerSendListeners(): void {
// dragged item appear to vanish ~0.5 s into any drag gesture.
setHeartbeatPaused(true)
- const dragStarted = startDragOut(sender, data, capturedAt)
+ const dragStarted = startDragOut(sender, data, capturedAt, subIndex)
console.log('[IPC] start-drag returned, sending drag-end')
sender.send('item:drag-end')
diff --git a/src/components/ClipboardItem.tsx b/src/components/ClipboardItem.tsx
index aa15266..affcad3 100644
--- a/src/components/ClipboardItem.tsx
+++ b/src/components/ClipboardItem.tsx
@@ -50,27 +50,52 @@ const ClipboardItemBase = forwardRef<HTMLDivElement, Props>(({ item }, ref) => {
const setInternalDragReq = useStore.getState().setInternalDragReq
const startDrag = useDragOut()
const [copied, setCopied] = useState(false)
- const [expanded, setExpanded] = useState(false)
- const open = useStore((s) => s.open)
+ // Accordion expansion: ONE stack open at a time, coordinated store-wide
+ // (expanding another stack collapses this one; Escape / outside click /
+ // filter or settings switches collapse via the same store field).
+ const expandedStackId = useStore((s) => s.expandedStackId)
+ const expanded = expandedStackId === item.id
+ const setExpandedFlag = useCallback((v: boolean) => {
+ useStore.getState().setExpandedStackId(v ? item.id : null)
+ }, [item.id])
// Shared clock: one refcounted interval refreshes every mounted card's
// relative-time label in a single batched pass (replaces the per-card
// setInterval, which scaled terribly across hundreds of cards).
useRelativeTimeTick()
- useEffect(() => {
- if (!open) {
- setExpanded(false)
- }
- }, [open])
-
const isPreviewing = useStore((s) => s.previewItemId) === item.id
const isBundle = (item.data.kind === 'files' && item.data.paths.length > 1) || item.data.kind === 'image-collection'
useEffect(() => {
- if (!isBundle) setExpanded(false)
- }, [isBundle])
+ if (!isBundle && expanded) setExpandedFlag(false)
+ }, [isBundle, expanded, setExpandedFlag])
+
+ // ── Intuitive collapse affordances ──────────────────────────────────────
+ // While THIS stack is the open one, a pointerdown anywhere OUTSIDE this
+ // card (other cards, empty shelf space) collapses it — standard disclosure
+ // behavior. Everything INSIDE this card is exempt, including its empty
+ // padding/margins: a partial-boundary exemption caused the infamous
+ // collapse→re-expand bounce, because the follow-up click event dispatched
+ // against freshly-collapsed state and the body contract re-opened it.
+ // The preview flyout is exempt too, so interacting there never surprises.
+ useEffect(() => {
+ if (!expanded) return
+
+ const onPointerDown = (e: PointerEvent): void => {
+ const target = e.target as Element | null
+ if (!target || typeof target.closest !== 'function') return
+ if (target.closest('[data-expanded-stack]')) return
+ if (target.closest('[data-preview-flyout], .preview-flyout')) return
+ setExpandedFlag(false)
+ }
+
+ document.addEventListener('pointerdown', onPointerDown, true)
+ return () => {
+ document.removeEventListener('pointerdown', onPointerDown, true)
+ }
+ }, [expanded, setExpandedFlag])
const onCopy = useCallback((e: React.MouseEvent) => {
e.stopPropagation()
@@ -89,18 +114,18 @@ const ClipboardItemBase = forwardRef<HTMLDivElement, Props>(({ item }, ref) => {
e?.stopPropagation()
if (isBundle) {
playCardExpandSound(true)
- setExpanded(true)
+ setExpandedFlag(true)
if (useStore.getState().tutorialStep === 4 && item.id === 'onboarding-files') {
useStore.getState().setTutorialStep(5)
}
}
- }, [isBundle, item.id])
+ }, [isBundle, item.id, setExpandedFlag])
const onCollapse = useCallback((e?: React.MouseEvent) => {
e?.stopPropagation()
playCardExpandSound(false)
- setExpanded(false)
- }, [])
+ setExpandedFlag(false)
+ }, [setExpandedFlag])
const handleDragStart = useCallback((e: React.DragEvent, req: DragRequest) => {
if (item.data.kind === 'text') {
@@ -135,6 +160,7 @@ const ClipboardItemBase = forwardRef<HTMLDivElement, Props>(({ item }, ref) => {
animate={{ opacity: 1 }}
transition={{ layout: { duration: 0.18, ease: [0.22, 1, 0.36, 1] } }}
className={`item${item.pinned ? ' pinned' : ''}${isBundle ? ' bundle' : ''}`}
+ data-expanded-stack={expanded ? 'true' : undefined}
>
{copied && (
<motion.div
@@ -399,13 +425,24 @@ function BundleToolbar({
onTogglePin?: () => void
}) {
return (
- <div className="bundle-actions">
+ // The ENTIRE toolbar bar is a collapse target — a huge, always-visible
+ // hit area where the user's eyes already are. The pills stopPropagation,
+ // so Copy/Pin/Delete still do their own jobs without collapsing.
+ <div
+ className="bundle-actions"
+ title={t('item.collapsePinned')}
+ onClick={(e) => {
+ e.stopPropagation()
+ onCollapse(e)
+ }}
+ >
<button
type="button"
className="bundle-collapse-hit"
title={t('item.collapsePinned')}
onClick={(e) => {
e.stopPropagation()
+ e.currentTarget.blur()
onCollapse(e)
}}
>
@@ -423,16 +460,28 @@ function BundleToolbar({
title={pinned ? t('item.unpin') : t('item.pin')}
onClick={(e) => {
e.stopPropagation()
+ e.currentTarget.blur()
onTogglePin()
}}
>
{pinned ? <PinFillIcon /> : <PinIcon />}
</button>
)}
- <button className="act" title={t('item.copy')} onClick={(e) => { e.stopPropagation(); onCopy(e) }}>
+ {/* blur() on every pill: without it the button keeps focus and the
+ card's :focus-within rule latches the action bar open after the
+ cursor leaves. */}
+ <button
+ className="act"
+ title={t('item.copy')}
+ onClick={(e) => { e.stopPropagation(); e.currentTarget.blur(); onCopy(e) }}
+ >
<CopyIcon />
</button>
- <button className="act danger" title={t('item.delete')} onClick={(e) => { e.stopPropagation(); onRemove() }}>
+ <button
+ className="act danger"
+ title={t('item.delete')}
+ onClick={(e) => { e.stopPropagation(); e.currentTarget.blur(); onRemove() }}
+ >
<TrashIcon />
</button>
</div>
@@ -455,19 +504,6 @@ function BundleFluidPreview({
onRemove: () => void
onCollapse: (e?: React.MouseEvent) => void
}) {
- const mixedStack = item.data.kind === 'files' && (() => {
- const entries = item.data.entries
- const paths = item.data.paths
- let hasImage = false
- let hasNonImage = false
- for (let i = 0; i < paths.length; i++) {
- const e = entries?.[i]
- if (e?.isImage && e.preview) hasImage = true
- else hasNonImage = true
- }
- return hasImage && hasNonImage
- })()
-
if (item.data.kind === 'image-collection') {
const more = item.data.images.length - 1
return (
@@ -476,25 +512,32 @@ function BundleFluidPreview({
stack={
<>
<div className="bundle-stack-large">
- {item.data.images.slice(0, 4).reverse().map((img, idx, arr) => {
+ {/* Photo stacks wear the same fixed-shape folder tile as file
+ stacks (FileStackPhoto masks each preview into the SVG
+ silhouette), fanned with the same CENTER-symmetric spread
+ math as the files branch so larger stacks stay inside the
+ container instead of clipping at the card edge. */}
+ {item.data.images.slice(0, 4).map((img, pathIndex) => ({ img, pathIndex })).reverse().map(({ img }, idx, arr) => {
const realIndex = arr.length - 1 - idx
+ const spread = arr.length > 1 ? 22 : 0
+ const rotSpread = arr.length > 1 ? 9 : 0
+ const centerOffset = ((arr.length - 1) * spread) / 2
+ const centerRot = ((arr.length - 1) * rotSpread) / 2
+ const stackMotion = {
+ x: realIndex * spread - centerOffset,
+ y: realIndex * 5,
+ rotate: realIndex * rotSpread - centerRot,
+ scale: 1 - realIndex * 0.05
+ }
return (
- <motion.img
+ <motion.div
key={img.imageId}
- src={img.preview}
- loading="lazy"
- decoding="async"
- className="bundle-stack-card"
- animate={{
- x: realIndex * 20 - 20,
- y: realIndex * 6,
- rotate: realIndex * 6 - 6,
- scale: 1 - realIndex * 0.05
- }}
+ className="bundle-stack-icon-item"
+ animate={stackMotion}
style={{ zIndex: 10 - realIndex }}
- draggable={false}
- initial={{ borderRadius: 8 }}
- />
+ >
+ <FileStackPhoto src={img.preview} width={112} height={112} />
+ </motion.div>
)
})}
</div>
@@ -511,15 +554,17 @@ function BundleFluidPreview({
onRemove={onRemove}
onTogglePin={() => useStore.getState().togglePin(item.id, !item.pinned)}
/>
- {item.data.images.map((img) => (
- <motion.div
- key={img.imageId}
- className="fluid-card-row"
- variants={rowVariants}
- draggable
- onDragStartCapture={(e: any) => { e.stopPropagation(); onDragStart(e, { id: item.id, imageId: img.imageId }) }}
- onClick={(e) => { e.stopPropagation(); tryPaste(() => window.edge.pasteSubitem({ id: item.id, imageId: img.imageId })) }}
- >
+ {item.data.images.map((img) => (
+ <motion.div
+ key={img.imageId}
+ className="fluid-card-row"
+ variants={rowVariants}
+ draggable
+ onMouseEnter={() => window.edge.prestageDrag({ id: item.id, imageId: img.imageId })}
+ onPointerDown={() => window.edge.prestageDrag({ id: item.id, imageId: img.imageId })}
+ onDragStartCapture={(e: any) => { e.stopPropagation(); onDragStart(e, { id: item.id, imageId: img.imageId }) }}
+ onClick={(e) => { e.stopPropagation(); tryPaste(() => window.edge.pasteSubitem({ id: item.id, imageId: img.imageId })) }}
+ >
<div className="fluid-row-icon">
<img
src={img.preview}
@@ -538,7 +583,7 @@ function BundleFluidPreview({
<button
className="act subitem-delete-btn"
title={t('item.ungroup')}
- onClick={(e) => { e.stopPropagation(); window.edge.splitItem({ id: item.id, imageId: img.imageId, splitPlacement: 'after' }); }}
+ onClick={(e) => { e.stopPropagation(); e.currentTarget.blur(); window.edge.splitItem({ id: item.id, imageId: img.imageId, splitPlacement: 'after' }); }}
>
<MinusIcon width={12} height={12} />
</button>
@@ -565,7 +610,6 @@ function BundleFluidPreview({
const realIndex = arr.length - 1 - idx
const entry = entries?.[pathIndex]
const isImg = !!(entry?.isImage && entry.preview)
- const largePhoto = isImg && !mixedStack
const spread = arr.length > 1 ? 22 : 0
const rotSpread = arr.length > 1 ? 9 : 0
const centerOffset = ((arr.length - 1) * spread) / 2
@@ -577,23 +621,9 @@ function BundleFluidPreview({
scale: 1 - realIndex * 0.05
}
- if (largePhoto) {
- return (
- <motion.img
- key={`${item.id}-${pathIndex}`}
- src={entry.preview}
- alt=""
- loading="lazy"
- decoding="async"
- draggable={false}
- className="bundle-stack-card"
- animate={stackMotion}
- style={{ zIndex: 10 - realIndex }}
- initial={{ borderRadius: 8 }}
- />
- )
- }
-
+ // Single unified tile path: photos wear the folder-silhouette
+ // mask (FileStackPhoto), everything else wears its category's
+ // pastel SVG icon — identical geometry for every stack size.
return (
<motion.div
key={`${item.id}-${pathIndex}`}
@@ -658,14 +688,14 @@ function BundleFluidPreview({
<button
className="act subitem-copy-btn"
title={t('item.copyFilePath')}
- onClick={(e) => { e.stopPropagation(); window.edge.copySubitem({ id: item.id, paths: [filePath] }); }}
+ onClick={(e) => { e.stopPropagation(); e.currentTarget.blur(); window.edge.copySubitem({ id: item.id, paths: [filePath] }); }}
>
<CopyIcon width={12} height={12} />
</button>
<button
className="act subitem-delete-btn"
title={t('item.ungroup')}
- onClick={(e) => { e.stopPropagation(); window.edge.splitItem({ id: item.id, paths: [filePath], splitPlacement: 'after' }); }}
+ onClick={(e) => { e.stopPropagation(); e.currentTarget.blur(); window.edge.splitItem({ id: item.id, paths: [filePath], splitPlacement: 'after' }); }}
>
<MinusIcon width={12} height={12} />
</button>
diff --git a/src/store/appStore.ts b/src/store/appStore.ts
index cdb3f25..da525be 100644
--- a/src/store/appStore.ts
+++ b/src/store/appStore.ts
@@ -38,6 +38,13 @@ interface AppState {
setSettingsSubView: (subView: 'main' | 'changelog') => void
/** True while an OS file drag is hovering the panel (prevents premature close). */
dragActive: boolean
+ /**
+ * The one stack/bundle whose expanded sub-item list is open (accordion).
+ * Single source of truth so expanding one stack collapses the previous,
+ * and so Escape / outside-click / view switches can coordinate closure.
+ */
+ expandedStackId: string | null
+ setExpandedStackId: (id: string | null) => void
/** True if the active drag originated from within the app itself. Stores the drag request (which item/sub-item). */
internalDragReq: import('../../shared/types').DragRequest | null
/** Active toasts (auto-dismissed after a short delay). */
@@ -119,12 +126,16 @@ export const useStore = create<AppState>((set, get) => ({
// The list remounts on filter change; leave the flyout open and it
// would float over a tab that no longer contains the source card.
if (get().previewItemId) get().setPreviewItemId(null)
+ // Same for an expanded stack: its card may not exist in the new tab.
+ set({ expandedStackId: null })
},
open: false,
settingsOpen: false,
settingsSubView: 'main',
setSettingsSubView: (subView) => set({ settingsSubView: subView }),
dragActive: false,
+ expandedStackId: null,
+ setExpandedStackId: (expandedStackId) => set({ expandedStackId }),
internalDragReq: null,
toasts: [],
tutorialStep: 0,
@@ -277,10 +288,17 @@ export const useStore = create<AppState>((set, get) => ({
setOpen: (open) => {
set({ open })
if (!open) {
+ // Release any focused control inside the blade. Without this, a button
+ // left focused from a click keeps matching the card's :focus-within
+ // rule and its action bar stays lit after the next open.
+ // (Accessed via globalThis with structural typing so this module keeps
+ // compiling under the DOM-less node tsconfig.)
+ const active = (globalThis as { document?: { activeElement?: { blur?: () => void } } }).document?.activeElement
+ try { active?.blur?.() } catch { /* ignore */ }
// NOTE: Do NOT reset styleFlyoutOpen here — closePanel() handles the
// sequencing so the flyout exit animation completes before the panel closes.
// Only reset previewItemId so the normal preview flyout clears correctly.
- set({ previewItemId: null, previewItemRect: null })
+ set({ previewItemId: null, previewItemRect: null, expandedStackId: null })
edge.setPreviewMode(false)
}
},
@@ -291,7 +309,8 @@ export const useStore = create<AppState>((set, get) => ({
previewItemId: null,
previewItemRect: null,
previewFlyoutRect: null,
- styleFlyoutOpen: false
+ styleFlyoutOpen: false,
+ expandedStackId: null
})
},
setDragActive: (dragActive) => set({ dragActive }),
diff --git a/src/styles/global.css b/src/styles/global.css
index 3cab6b7..582b330 100644
--- a/src/styles/global.css
+++ b/src/styles/global.css
@@ -82,7 +82,6 @@ svg {
.kind-badge,
.changelog-pill,
.copy-curve-container,
-.bundle-stack-card,
.style-card {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
diff --git a/src/styles/item.css b/src/styles/item.css
index 9b55455..c547066 100644
--- a/src/styles/item.css
+++ b/src/styles/item.css
@@ -179,20 +179,6 @@
justify-content: center;
}
-.bundle-stack-card {
- position: absolute;
- top: 10px;
- left: 50%;
- margin-left: calc(-50% + 20px);
- width: calc(100% - 40px);
- height: 94px;
- object-fit: cover;
- border-radius: 8px;
- border: 1px solid rgba(255, 255, 255, 0.15);
- box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
- transform-origin: bottom center;
-}
-
.bundle-stack-icon-item {
position: absolute;
top: 50%;
@@ -714,7 +700,10 @@
margin-top: 8px;
}
-/* Bundle actions (Copy all / Delete) placed at the top when expanded */
+/* Bundle actions (Collapse / Copy all / Delete) placed at the top when
+ expanded. The WHOLE bar collapses the stack on click — pills inside call
+ stopPropagation, so they keep their own actions. No hover fill: the cursor
+ + tooltip already communicate the target. */
.bundle-actions {
display: flex;
align-items: center;
@@ -723,6 +712,7 @@
width: 100%;
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
margin-bottom: 6px;
+ cursor: pointer;
}
.bundle-collapse-hit {
diff --git a/tests/storeDragStaging.test.ts b/tests/storeDragStaging.test.ts
index 4f58c41..db11e1d 100644
--- a/tests/storeDragStaging.test.ts
+++ b/tests/storeDragStaging.test.ts
@@ -142,4 +142,69 @@ describe('stageDragFile uses the correct staging root per build', () => {
}, stamp)
expect(staged).toBeNull()
})
+
+ // ---------------------------------------------------------------------
+ // REGRESSION: sub-images of one collection share the parent's capturedAt
+ // stamp. The old blind existsSync-skip collapsed every sibling onto the
+ // first-staged file, so dragging ANY expanded row delivered the top image.
+ // ---------------------------------------------------------------------
+ it('stages two DIFFERENT sub-images sharing one timestamp as two distinct files', () => {
+ writeImage('sub_a')
+ writeImage('sub_b')
+ const base = { width: 10, height: 10 } as const
+
+ const a = stageDragFile({ kind: 'image', imageId: 'sub_a', ...base, bytes: 'png-sub_a'.length, ext: 'png' },
+ stamp, { indexSuffix: 1 })
+ const b = stageDragFile({ kind: 'image', imageId: 'sub_b', ...base, bytes: 'png-sub_b'.length, ext: 'png' },
+ stamp, { indexSuffix: 2 })
+
+ expect(a).not.toBeNull()
+ expect(b).not.toBeNull()
+ expect(a!.file).not.toBe(b!.file)
+ expect(readFileSync(a!.file, 'utf8')).toBe('png-sub_a')
+ expect(readFileSync(b!.file, 'utf8')).toBe('png-sub_b')
+ })
+
+ it('never reuses an existing staged name that holds different content (auto "(2)" rename)', () => {
+ writeImage('victim') // source whose payload differs from the impostor below
+ const tempDir = join(fsRoots.userData, 'temp')
+ mkdirSync(tempDir, { recursive: true })
+ // Impostor: occupies the exact candidate name with WRONG content/size.
+ writeFileSync(join(tempDir, 'Screenshot 2026-08-15 22.30.45.png'), 'impostor-bytes')
+
+ const staged = stageDragFile({
+ kind: 'image',
+ imageId: 'victim',
+ width: 10,
+ height: 10,
+ bytes: 'png-victim'.length,
+ ext: 'png'
+ }, stamp)
+
+ expect(staged).not.toBeNull()
+ expect(readFileSync(staged!.file, 'utf8')).toBe('png-victim')
+ expect(staged!.file).toMatch(/Screenshot 2026-08-15 22\.30\.45 \(2\)\.png$/)
+ // The impostor file must remain untouched.
+ expect(readFileSync(join(tempDir, 'Screenshot 2026-08-15 22.30.45.png'), 'utf8')).toBe('impostor-bytes')
+ })
+
+ it('reuses an existing staged name only when the payload size matches exactly', () => {
+ writeImage('same')
+ const tempDir = join(fsRoots.userData, 'temp')
+ mkdirSync(tempDir, { recursive: true })
+ writeFileSync(join(tempDir, 'Image 2026-08-15 22.30.45.png'), 'png-same')
+
+ const first = stageDragFile({
+ kind: 'image',
+ imageId: 'same',
+ width: 10,
+ height: 10,
+ bytes: 'png-same'.length,
+ ext: 'png',
+ source: 'image'
+ }, stamp)
+ expect(first).not.toBeNull()
+ expect(first!.file).toBe(join(tempDir, 'Image 2026-08-15 22.30.45.png'))
+ expect(readFileSync(first!.file, 'utf8')).toBe('png-same')
+ })
})