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.

feat(multi-display): synchronize tray menu, fix fallback & add confirmation pop-up

Deepender25bf19cea415ba
diff --git a/electron/clipboard/ClipboardWatcher.ts b/electron/clipboard/ClipboardWatcher.ts
index 3a9a60a..091469d 100644
--- a/electron/clipboard/ClipboardWatcher.ts
+++ b/electron/clipboard/ClipboardWatcher.ts
@@ -42,7 +42,7 @@ export class ClipboardWatcher {
// We detected a change. Wait a short moment to ensure it's not a transient
// injection by a dictation app or macro that quickly restores the clipboard.
- setTimeout(() => {
+ setTimeout(async () => {
if (this.paused) return
const stableSig = clipboardSignature()
@@ -54,7 +54,9 @@ export class ClipboardWatcher {
this.lastSig = sig
- const data = readClipboard()
+ // readClipboard is async: on Windows it awaits a PowerShell
+ // GetFileDropList() call to retrieve ALL selected files.
+ const data = await readClipboard()
if (!data) {
return
}
diff --git a/electron/clipboard/formats.ts b/electron/clipboard/formats.ts
index 06cfa1a..9590f9a 100644
--- a/electron/clipboard/formats.ts
+++ b/electron/clipboard/formats.ts
@@ -8,24 +8,39 @@
*/
import { clipboard } from 'electron'
import { execFile } from 'node:child_process'
+import { promisify } from 'node:util'
import type { ItemData } from '../../shared/types'
import { getSystemPowerShellPath } from '../main/powershell'
import { filterValidPaths } from '../main/pathValidation'
+const execFileAsync = promisify(execFile)
+
/** Windows clipboard format name for a copied-file list. */
export const CF_FILE_LIST = 'FileNameW'
-/** Read the list of copied file paths (Windows), or null if none. */
-function readFileList(): string[] | null {
+/**
+ * Async version: reads the full list of copied file paths via PowerShell
+ * GetFileDropList(), which is the only reliable way to retrieve ALL selected
+ * files from a multi-file Explorer copy (CF_HDROP / FileNameW only carries
+ * the first file as a legacy single-path fallback).
+ *
+ * Falls back to parsing the FileNameW UTF-16LE buffer directly if PowerShell
+ * is unavailable or times out.
+ */
+async function readFileListAsync(): Promise<string[] | null> {
try {
+ // First, confirm there is actually a file list on the clipboard before
+ // spawning a process. FileNameW being present is sufficient signal.
const buf = clipboard.readBuffer(CF_FILE_LIST)
if (!buf || buf.length < 4) return null
if (process.platform === 'win32') {
try {
const psPath = getSystemPowerShellPath()
- // Non-blocking execFile fallback via powershell with strict absolute path & timeout
- execFile(
+ // Await the result so we actually get all paths — the previous
+ // implementation fired execFile with a callback that returned from
+ // the closure, not from readFileList(), so the result was dropped.
+ const { stdout } = await execFileAsync(
psPath,
[
'-NoProfile',
@@ -33,20 +48,20 @@ function readFileList(): string[] | null {
'-Command',
'Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::GetFileDropList()'
],
- { encoding: 'utf8', timeout: 1500 },
- (err, stdout) => {
- if (!err && stdout) {
- const paths = filterValidPaths(stdout.split(/\r?\n/).map((l) => l.trim()))
- if (paths.length > 0) return paths
- }
- }
+ { encoding: 'utf8', timeout: 2000 }
)
+ if (stdout) {
+ const paths = filterValidPaths(stdout.split(/\r?\n/).map((l) => l.trim()))
+ if (paths.length > 0) return paths
+ }
} catch (err) {
console.error('[formats] Failed to read file drop list via PowerShell:', err)
}
}
- // Fast, non-blocking fallback: parse the FileNameW buffer directly
+ // Non-Windows or PowerShell fallback: parse the FileNameW buffer directly.
+ // On Windows this will typically only return the first file, but it is
+ // better than nothing when PowerShell is unavailable.
const wide = buf.toString('utf16le')
const parts = filterValidPaths(wide.split('\u0000').map((s) => s.trim()))
return parts.length ? parts : null
@@ -176,11 +191,15 @@ export function isClipboardExcluded(): boolean {
}
/**
- * Snapshot the current clipboard into a single ItemData, or null if it's empty.
+ * Async snapshot of the current clipboard into a single ItemData, or null.
+ *
* Order matters: a file copy should win over its text fallback, an image wins
* over nothing, otherwise we keep text (preferring HTML if it carries rich text).
+ *
+ * This is async because reading the full multi-file list from a Windows
+ * Explorer copy requires a PowerShell round-trip (GetFileDropList).
*/
-export function readClipboard(): ItemData | null {
+export async function readClipboard(): Promise<ItemData | null> {
if (isClipboardExcluded()) {
return null
}
@@ -188,7 +207,7 @@ export function readClipboard(): ItemData | null {
const formats = clipboard.availableFormats()
// Files first — a file copy also places text on the clipboard, which we ignore.
- const files = readFileList()
+ const files = await readFileListAsync()
if (files && files.length) return { kind: 'files', paths: files }
// Text vs Image priority heuristic based on available formats.
diff --git a/electron/main/geometry.ts b/electron/main/geometry.ts
index 0f934cb..141b04a 100644
--- a/electron/main/geometry.ts
+++ b/electron/main/geometry.ts
@@ -31,13 +31,13 @@ export function computeStickBounds(params: StickBoundsParams): StickBoundsResult
display = displays.find(d => d.id === displayId)
}
- if (!display && currentBounds) {
+ if (!display && displayId === undefined && currentBounds) {
const nearest = findNearestDisplay(displays, currentBounds)
if (nearest) display = nearest
}
if (!display) {
- display = displays[0]
+ display = displays.find(d => (d as any).isPrimary) || displays[0]
}
const wa = display.workArea
diff --git a/electron/main/ipc.ts b/electron/main/ipc.ts
index 723f725..79857f8 100644
--- a/electron/main/ipc.ts
+++ b/electron/main/ipc.ts
@@ -14,8 +14,9 @@ import { filterValidPaths, isValidFilePath, isExistingFilePath } from './pathVal
import { type InvokeMap, type InvokeChannel, type SendMap, type SendChannel } from '../../shared/ipc'
import { getStore, loadSettings, saveSettings, pushState, addFiles, getWatcher } from './state'
import { getMainWindow } from './window'
-import { setInteractive, setHeartbeatPaused, setHotZoneWidth, repositionWindow } from './window'
+import { setInteractive, setHeartbeatPaused, setHotZoneWidth, repositionWindow, currentStickDisplayId, getDisplayListOptions, popUpAndRetract } from './window'
import { getOnboardingWindow } from './onboardingWindow'
+import { rebuildTrayMenu } from './tray'
import { startDragOut, resolveDragData } from './drag'
import { clipboardSignature } from '../clipboard/formats'
import type { ItemData, MergeResult } from '../../shared/types'
@@ -190,10 +191,11 @@ export function registerIpc(): void {
const response = await fetch('https://api.github.com/repos/Deepender25/Edge-Drop/releases/latest', {
headers: {
'User-Agent': 'Edge-Drop-App'
- }
+ },
+ signal: AbortSignal.timeout(5000)
})
if (!response.ok) {
- console.error('[IPC] app:check-update fetch failed with status:', response.status)
+ console.warn('[IPC] app:check-update GitHub API status:', response.status)
return null
}
const data = await response.json() as any
@@ -207,7 +209,8 @@ export function registerIpc(): void {
downloadUrl
}
} catch (err) {
- console.error('[IPC] app:check-update error:', err)
+ const msg = err instanceof Error ? err.message : String(err)
+ console.log(`[IPC] app:check-update skipped (${msg})`)
return null
}
})
@@ -480,8 +483,10 @@ export function registerIpc(): void {
}
if (patch.stickPosition !== undefined || patch.stickDisplayId !== undefined) {
repositionWindow()
+ popUpAndRetract(1500)
}
pushState.settings(next)
+ rebuildTrayMenu()
return next
})
@@ -501,22 +506,7 @@ export function registerIpc(): void {
})
handle('displays:list', () => {
- const all = screen.getAllDisplays()
- const primary = screen.getPrimaryDisplay()
- return all.map((d) => {
- const rawName = (d as any).label || ''
- const name = rawName || (d.id === primary.id ? 'Primary' : `Display #${d.id}`)
- return {
- id: d.id,
- bounds: { x: d.bounds.x, y: d.bounds.y, width: d.bounds.width, height: d.bounds.height },
- isPrimary: d.id === primary.id,
- label: d.id === primary.id
- ? `${name} (Primary) ${d.bounds.width}×${d.bounds.height}`
- : `${name} ${d.bounds.width}×${d.bounds.height}`,
- name: d.id === primary.id ? `${name} (Primary)` : name,
- resolution: `${d.bounds.width}×${d.bounds.height}`
- }
- })
+ return getDisplayListOptions()
})
}
diff --git a/electron/main/tray.ts b/electron/main/tray.ts
index a862931..314bc59 100644
--- a/electron/main/tray.ts
+++ b/electron/main/tray.ts
@@ -10,7 +10,7 @@ import { Menu, Tray, app, nativeImage, Notification, screen } from 'electron'
import { existsSync } from 'node:fs'
import { PATHS } from '../store/paths'
import { loadSettings, saveSettings } from '../store/settings'
-import { getMainWindow, setVisible, repositionWindow } from './window'
+import { getMainWindow, setVisible, repositionWindow, getDisplayListOptions, registerWindowRepositionListener, popUpAndRetract } from './window'
import type { StickPosition } from '../../shared/types'
import { pushState } from './state'
@@ -57,24 +57,20 @@ export function createTray(): Tray {
} catch { /* ignore */ }
}
- function buildDisplaySubmenu(currentId: number | undefined): Electron.MenuItemConstructorOptions[] {
- const all = screen.getAllDisplays()
- const primary = screen.getPrimaryDisplay()
- return all.map((d) => {
- const name = (d as any).label || (d.id === primary.id ? 'Primary' : `Display #${d.id}`)
- return {
- label: d.id === primary.id
- ? `${name} (Primary) ${d.bounds.width}×${d.bounds.height}`
- : `${name} ${d.bounds.width}×${d.bounds.height}`,
- type: 'radio' as const,
- checked: currentId === d.id,
- click: () => {
- const next = saveSettings({ stickDisplayId: d.id })
- pushState.settings(next)
- repositionWindow()
- }
+ function buildDisplaySubmenu(): Electron.MenuItemConstructorOptions[] {
+ const options = getDisplayListOptions()
+ return options.map((d) => ({
+ label: d.label,
+ type: 'radio' as const,
+ checked: d.isCurrent,
+ click: () => {
+ const next = saveSettings({ stickDisplayId: d.id })
+ pushState.settings(next)
+ repositionWindow()
+ popUpAndRetract(1500)
+ rebuild()
}
- })
+ }))
}
function buildStickSubmenu(current: StickPosition): Electron.MenuItemConstructorOptions[] {
@@ -86,6 +82,8 @@ export function createTray(): Tray {
const next = saveSettings({ stickPosition: pos })
pushState.settings(next)
repositionWindow()
+ popUpAndRetract(1500)
+ rebuild()
}
}))
}
@@ -120,6 +118,7 @@ export function createTray(): Tray {
const next = saveSettings({ incognito: item.checked })
pushState.settings(next)
applyIncognito(next.incognito)
+ rebuild()
}
},
{ type: 'separator' },
@@ -129,7 +128,7 @@ export function createTray(): Tray {
},
{
label: 'Display',
- submenu: buildDisplaySubmenu(settings.stickDisplayId)
+ submenu: buildDisplaySubmenu()
},
{ type: 'separator' },
{
@@ -150,12 +149,28 @@ export function createTray(): Tray {
pushState.togglePanel()
})
- // Refresh checkmarks each time the menu is shown.
- tray.on('right-click', () => tray?.popUpContextMenu())
+ // Rebuild menu dynamically right before showing to ensure displays & checkmarks are 100% current.
+ tray.on('right-click', () => {
+ rebuild()
+ tray?.popUpContextMenu()
+ })
+
+ // Listen for display changes to keep tray context menu updated in real-time.
+ screen.on('display-added', rebuild)
+ screen.on('display-removed', rebuild)
+ screen.on('display-metrics-changed', rebuild)
+
+ registerWindowRepositionListener(rebuild)
+ trayMenuRebuilder = rebuild
rebuild()
return tray
}
+let trayMenuRebuilder: (() => void) | null = null
+export function rebuildTrayMenu(): void {
+ trayMenuRebuilder?.()
+}
+
/** Reflect incognito toggle into the watcher without the renderer round-trip. */
let incognitoApply: ((v: boolean) => void) | null = null
export function registerIncognitoApplier(fn: (v: boolean) => void): void {
diff --git a/electron/main/window.ts b/electron/main/window.ts
index 7609822..dd43d30 100644
--- a/electron/main/window.ts
+++ b/electron/main/window.ts
@@ -29,7 +29,7 @@ import { APP_CONFIG } from './config'
import { runtime } from './config'
import { PATHS } from '../store/paths'
import { computeStickBounds } from './geometry'
-import { loadSettings } from '../store/settings'
+import { loadSettings, saveSettings } from '../store/settings'
export const PANEL_WIDTH = 384
/** Visual width of the blade when collapsed (only used by the renderer). */
@@ -197,13 +197,26 @@ export function stopCursorPoll(): void {
}
function getStickGeometry(): { x: number; y: number; width: number; height: number } {
- const settings = loadSettings()
+ let settings = loadSettings()
+ const primaryDisplay = screen.getPrimaryDisplay()
const allDisplays = screen.getAllDisplays().map(d => ({
id: d.id,
- workArea: { ...d.workArea }
+ workArea: { ...d.workArea },
+ isPrimary: d.id === primaryDisplay.id
}))
- const primaryHeight = screen.getPrimaryDisplay().workArea.height
+ // Auto-heal: If configured stickDisplayId is disconnected, immediately reset to undefined
+ // so the panel instantly falls back to the Primary Display and stays fully usable.
+ if (settings.stickDisplayId !== undefined && !allDisplays.some(d => d.id === settings.stickDisplayId)) {
+ console.log(`[Main] Configured stickDisplayId (${settings.stickDisplayId}) disconnected. Falling back immediately to Primary Display (${primaryDisplay.id}).`)
+ settings = saveSettings({ stickDisplayId: undefined })
+ if (mainWindow && !mainWindow.isDestroyed() && !mainWindow.webContents.isDestroyed()) {
+ mainWindow.webContents.send('state:settings', settings)
+ }
+ popUpAndRetract(1500)
+ }
+
+ const primaryHeight = primaryDisplay.workArea.height
const windowHeight = primaryHeight
const currentWindowWidth = previewActive ? 820 : PANEL_WIDTH
@@ -256,10 +269,24 @@ export function createWindow(): BrowserWindow {
// Start click-through with no forwarding — edge detection is done via cursor poll.
mainWindow.setIgnoreMouseEvents(true, { forward: false })
+ const handleDisplayChange = (triggerPopUp = false) => {
+ console.log('[Main] Display metrics/topology changed — validating bounds and repositioning window')
+ repositionWindow()
+ if (triggerPopUp) {
+ popUpAndRetract(1500)
+ }
+ }
+
// Keep the panel glued to the primary display if the work area changes.
- screen.on('display-metrics-changed', repositionWindow)
- screen.on('display-added', () => setTimeout(repositionWindow, 500))
- screen.on('display-removed', () => setTimeout(repositionWindow, 500))
+ screen.on('display-metrics-changed', () => handleDisplayChange(false))
+ screen.on('display-added', () => {
+ handleDisplayChange(true)
+ setTimeout(() => handleDisplayChange(false), 300)
+ })
+ screen.on('display-removed', () => {
+ handleDisplayChange(true)
+ setTimeout(() => handleDisplayChange(false), 300)
+ })
// Respect OS-level always-on-top reordering.
mainWindow.on('focus', () => {
@@ -317,10 +344,87 @@ export function stopHeartbeat(): void {
}
}
+let onWindowRepositioned: (() => void) | null = null
+export function registerWindowRepositionListener(fn: () => void): void {
+ onWindowRepositioned = fn
+}
+
+export function getActiveDisplayId(allDisplays?: Electron.Display[]): number {
+ const displays = allDisplays ?? screen.getAllDisplays()
+ const settings = loadSettings()
+ if (settings.stickDisplayId !== undefined && displays.some(d => d.id === settings.stickDisplayId)) {
+ return settings.stickDisplayId
+ }
+ if (currentStickDisplayId !== undefined && displays.some(d => d.id === currentStickDisplayId)) {
+ return currentStickDisplayId
+ }
+ return screen.getPrimaryDisplay().id
+}
+
+export function getDisplayListOptions(): Array<{
+ id: number
+ bounds: { x: number; y: number; width: number; height: number }
+ isPrimary: boolean
+ isCurrent: boolean
+ label: string
+ name: string
+ resolution: string
+}> {
+ const all = screen.getAllDisplays()
+ const primary = screen.getPrimaryDisplay()
+ const activeId = getActiveDisplayId(all)
+
+ return all.map((d, index) => {
+ const isPrimary = d.id === primary.id
+ const rawName = (d as any).label || (d as any).name || ''
+ const fallbackName = isPrimary ? 'Primary Monitor' : `Display ${index + 1}`
+ const baseName = rawName.trim() ? rawName.trim() : fallbackName
+ const name = isPrimary
+ ? (baseName.toLowerCase().includes('primary') ? baseName : `${baseName} (Primary)`)
+ : baseName
+ return {
+ id: d.id,
+ bounds: { x: d.bounds.x, y: d.bounds.y, width: d.bounds.width, height: d.bounds.height },
+ isPrimary,
+ isCurrent: d.id === activeId,
+ label: `${name} ${d.bounds.width}×${d.bounds.height}`,
+ name,
+ resolution: `${d.bounds.width}×${d.bounds.height}`
+ }
+ })
+}
+
+let popUpTimer: ReturnType<typeof setTimeout> | null = null
+export function popUpAndRetract(durationMs = 1500): void {
+ if (!mainWindow || mainWindow.isDestroyed() || !mainWindow.webContents || mainWindow.webContents.isDestroyed()) return
+ if (mainWindow.isMinimized()) mainWindow.restore()
+ mainWindow.showInactive()
+ mainWindow.setAlwaysOnTop(true, 'screen-saver')
+
+ const wasAlreadyOpen = interactive
+ console.log(`[Main] Popping up panel briefly to confirm new screen/edge location (wasAlreadyOpen=${wasAlreadyOpen})`)
+ mainWindow.webContents.send('window:toggle', true)
+
+ if (popUpTimer !== null) clearTimeout(popUpTimer)
+ if (!wasAlreadyOpen) {
+ popUpTimer = setTimeout(() => {
+ popUpTimer = null
+ if (mainWindow && !mainWindow.isDestroyed() && !mainWindow.webContents.isDestroyed()) {
+ console.log('[Main] Retracting panel after brief confirmation pop-up')
+ mainWindow.webContents.send('window:toggle', false)
+ }
+ }, durationMs)
+ }
+}
+
export function repositionWindow(): void {
if (!mainWindow || mainWindow.isDestroyed()) return
+ if (mainWindow.isMinimized()) mainWindow.restore()
+ mainWindow.showInactive()
+ mainWindow.setAlwaysOnTop(true, 'screen-saver')
const g = getStickGeometry()
mainWindow.setBounds({ ...g })
+ onWindowRepositioned?.()
}
/** Toggle the panel between shown (always on top) and fully hidden. */
diff --git a/public/logo-black.png b/public/logo-black.png
deleted file mode 100644
index d20897f..0000000
Binary files a/public/logo-black.png and /dev/null differ
diff --git a/public/logo-white.png b/public/logo-white.png
deleted file mode 100644
index 8ea700c..0000000
Binary files a/public/logo-white.png and /dev/null differ
diff --git a/shared/types.ts b/shared/types.ts
index b4ef805..3bb5fd4 100644
--- a/shared/types.ts
+++ b/shared/types.ts
@@ -67,6 +67,7 @@ export interface DisplayInfo {
id: number
bounds: { x: number; y: number; width: number; height: number }
isPrimary: boolean
+ isCurrent?: boolean
label: string
name: string
resolution: string
@@ -112,6 +113,7 @@ export interface Settings {
/** Reduce motion for the panel animations. */
reduceMotion: boolean
/** When true, automatically clears unpinned items on device/app restart. */
+ /** When true, automatically clears unpinned items on device/app restart. */
clearUnpinnedOnRestart: boolean
/** Hours after which unpinned items are automatically purged (0 = Never). */
autoDeleteHours: number
@@ -121,6 +123,16 @@ export interface Settings {
tutorialCompleted: boolean
stickPosition: StickPosition
stickDisplayId?: number
+ /**
+ * When true, restores the bouncy overshoot panel-open animation.
+ * Off by default because it requires extra GPU compositing work.
+ */
+ bounceAnimation: boolean
+ /**
+ * When true, blurs the panel during open/close.
+ * Off by default because filter: blur is resource-heavy.
+ */
+ blurAnimation: boolean
}
export const DEFAULT_SETTINGS: Settings = {
@@ -136,7 +148,9 @@ export const DEFAULT_SETTINGS: Settings = {
uiStyle: 'modern',
tutorialCompleted: false,
stickPosition: 'left',
- stickDisplayId: undefined
+ stickDisplayId: undefined,
+ bounceAnimation: false,
+ blurAnimation: false
}
diff --git a/src/App.tsx b/src/App.tsx
index 59c3e6c..d81b0d3 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -33,8 +33,16 @@ export default function App() {
const offToast = edge.onToast((t) => pushToast(t))
const offToggle = edge.onToggle((forceOpen) => {
const next = forceOpen !== undefined ? forceOpen : !useStore.getState().open
- useStore.getState().setOpen(next)
- edge.setInteractive(next)
+ if (!next && useStore.getState().previewItemId) {
+ useStore.getState().setPreviewItemId(null)
+ edge.setInteractive(false)
+ window.setTimeout(() => {
+ useStore.getState().setOpen(false)
+ }, 240)
+ } else {
+ useStore.getState().setOpen(next)
+ edge.setInteractive(next)
+ }
})
const offOpenSettings = edge.onOpenSettings(() => {
useStore.getState().setOpen(true)
diff --git a/src/components/ClipboardItem.tsx b/src/components/ClipboardItem.tsx
index 40ee306..6378e12 100644
--- a/src/components/ClipboardItem.tsx
+++ b/src/components/ClipboardItem.tsx
@@ -26,22 +26,7 @@ import { getFileKind } from '../lib/fileType'
import { CopyIcon, FileKindIcon, ImageIcon, LinkIcon, PinIcon, PinFillIcon, TrashIcon, MinusIcon, ChevronUpIcon, ExpandIcon, ContractIcon } from './icons'
import '../styles/item.css'
-/**
- * Module-level paste guard — shared across ALL item instances.
- * Tracks the timestamp of the last paste so that any subsequent click
- * (including the second click of a double-click) within PASTE_COOLDOWN ms
- * is silently dropped. This is the only reliable way to prevent double-paste:
- * it is synchronous, stateless across renders, and immune to async IPC races.
- */
-let _lastPasteAt = 0
-const PASTE_COOLDOWN = 600 // ms
-
-function tryPaste(fn: () => void): void {
- const now = Date.now()
- if (now - _lastPasteAt < PASTE_COOLDOWN) return
- _lastPasteAt = now
- fn()
-}
+import { tryPaste } from '../lib/tryPaste'
interface Props {
item: ClipboardItemDto
@@ -122,16 +107,23 @@ function ClipboardItemBase({ item }: Props) {
return (
<motion.div
layout
- initial={open ? { opacity: 0, y: 8, scale: 0.98 } : false}
+ initial={open ? { opacity: 0, y: 6, scale: 0.97 } : false}
animate={{ opacity: 1, y: 0, scale: 1 }}
- exit={{ opacity: 0, scale: 0.95, transition: { duration: 0.14 } }}
- transition={{ type: 'spring', stiffness: 420, damping: 34 }}
+ exit={{ opacity: 0, scale: 0.96, transition: { duration: 0.1, ease: 'easeIn' } }}
+ transition={{
+ type: 'spring',
+ stiffness: 500,
+ damping: 38,
+ mass: 0.6,
+ restDelta: 0.001,
+ restSpeed: 0.001
+ }}
className={`item${item.pinned ? ' pinned' : ''}${isBundle ? ' bundle' : ''}`}
>
<div
className={`item-main${isPreviewing ? ' force-actions previewing' : ''}`}
data-id={item.id}
- draggable={item.data.kind !== 'text' && (!isBundle || !expanded)}
+ draggable={!isPreviewing && item.data.kind !== 'text' && (!isBundle || !expanded)}
onDragStart={(e) => handleDragStart(e, { id: item.id })}
onDragEnd={() => setInternalDragReq(null)}
onDragOver={(e) => {
@@ -159,7 +151,7 @@ function ClipboardItemBase({ item }: Props) {
setInternalDragReq(null)
}
}}
- onClick={isBundle && !expanded ? onExpand : (!isBundle ? onPaste : undefined)}
+ onClick={isPreviewing ? undefined : (isBundle && !expanded ? onExpand : (!isBundle ? onPaste : undefined))}
>
<div className="body">
{isBundle ? (
@@ -238,78 +230,67 @@ function ClipboardItemBase({ item }: Props) {
)
}
+// Bundle expand/collapse — all blur removed; opacity+y+scale composite trivially.
const containerVariants = {
- hidden: { opacity: 0, filter: 'blur(6px)' },
- visible: {
- opacity: 1,
- filter: 'blur(0px)',
- transition: {
- opacity: { duration: 0.22, ease: 'easeOut' },
- filter: { duration: 0.22, ease: 'easeOut' },
- staggerChildren: 0.05,
- delayChildren: 0.02
+ hidden: { opacity: 0 },
+ visible: {
+ opacity: 1,
+ transition: {
+ opacity: { duration: 0.18, ease: 'easeOut' },
+ staggerChildren: 0.04,
+ delayChildren: 0.01
}
},
- exit: {
- opacity: 0,
- filter: 'blur(6px)',
- transition: {
- opacity: { duration: 0.16, ease: 'easeIn' },
- filter: { duration: 0.16, ease: 'easeIn' },
- staggerChildren: 0.03,
+ exit: {
+ opacity: 0,
+ transition: {
+ opacity: { duration: 0.12, ease: 'easeIn' },
+ staggerChildren: 0.025,
staggerDirection: -1
}
}
};
const rowVariants = {
- hidden: { opacity: 0, y: 12, scale: 0.97, filter: 'blur(4px)' },
- visible: {
- opacity: 1,
- y: 0,
+ hidden: { opacity: 0, y: 8, scale: 0.98 },
+ visible: {
+ opacity: 1,
+ y: 0,
scale: 1,
- filter: 'blur(0px)',
- transition: {
- y: { type: 'spring', stiffness: 420, damping: 28 },
- scale: { type: 'spring', stiffness: 420, damping: 28 },
- opacity: { duration: 0.2, ease: 'easeOut' },
- filter: { duration: 0.2, ease: 'easeOut' }
+ transition: {
+ y: { type: 'spring', stiffness: 500, damping: 38, mass: 0.6, restDelta: 0.001 },
+ scale: { type: 'spring', stiffness: 500, damping: 38, mass: 0.6, restDelta: 0.001 },
+ opacity: { duration: 0.16, ease: 'easeOut' }
}
},
- exit: {
- opacity: 0,
- y: -8,
+ exit: {
+ opacity: 0,
+ y: -6,
scale: 0.97,
- filter: 'blur(4px)',
- transition: {
- y: { duration: 0.14, ease: 'easeIn' },
- scale: { duration: 0.14, ease: 'easeIn' },
- opacity: { duration: 0.14, ease: 'easeIn' },
- filter: { duration: 0.14, ease: 'easeIn' }
+ transition: {
+ y: { duration: 0.1, ease: 'easeIn' },
+ scale: { duration: 0.1, ease: 'easeIn' },
+ opacity: { duration: 0.1, ease: 'easeIn' }
}
}
};
const stackVariants = {
- hidden: { opacity: 0, filter: 'blur(5px)', scale: 0.96 },
- visible: {
- opacity: 1,
- filter: 'blur(0px)',
+ hidden: { opacity: 0, scale: 0.96 },
+ visible: {
+ opacity: 1,
scale: 1,
- transition: {
- scale: { type: 'spring', stiffness: 420, damping: 28 },
- opacity: { duration: 0.2, ease: 'easeOut' },
- filter: { duration: 0.2, ease: 'easeOut' }
+ transition: {
+ scale: { type: 'spring', stiffness: 480, damping: 38, mass: 0.6, restDelta: 0.001 },
+ opacity: { duration: 0.18, ease: 'easeOut' }
}
},
- exit: {
- opacity: 0,
- filter: 'blur(5px)',
+ exit: {
+ opacity: 0,
scale: 0.96,
- transition: {
- scale: { duration: 0.16, ease: 'easeIn' },
- opacity: { duration: 0.16, ease: 'easeIn' },
- filter: { duration: 0.16, ease: 'easeIn' }
+ transition: {
+ scale: { duration: 0.12, ease: 'easeIn' },
+ opacity: { duration: 0.12, ease: 'easeIn' }
}
}
};
diff --git a/src/components/Panel.tsx b/src/components/Panel.tsx
index 7e3aae7..cfc64d2 100644
--- a/src/components/Panel.tsx
+++ b/src/components/Panel.tsx
@@ -26,6 +26,8 @@ export function Panel() {
const settingsOpen = useStore((s) => s.settingsOpen)
const setSettingsOpen = useStore((s) => s.setSettingsOpen)
const setQuery = useStore((s) => s.setQuery)
+ const bounceAnimation = settings.bounceAnimation
+ const blurAnimation = settings.blurAnimation
useEffect(() => {
if (!open) {
@@ -226,18 +228,14 @@ export function Panel() {
onDrop={onDrop}
style={containerStyle}
animate={{
- scale: open ? [0.92, 1.05, 0.98, 1] : 1,
- filter: open ? 'blur(0px)' : 'blur(16px)'
+ scale: bounceAnimation && open ? [0.92, 1.05, 0.98, 1] : 1,
+ filter: blurAnimation ? (open ? 'blur(0px)' : 'blur(16px)') : 'blur(0px)',
+ opacity: open ? 1 : 0.98
}}
transition={{
- scale: {
- duration: 0.55,
- ease: [0.22, 1, 0.36, 1]
- },
- filter: {
- duration: open ? 0.8 : 0.45,
- ease: open ? [0.16, 1, 0.3, 1] : [0.4, 0, 0.2, 1]
- }
+ scale: bounceAnimation && open ? { duration: 0.55, ease: [0.22, 1, 0.36, 1] } : { duration: 0.15 },
+ filter: blurAnimation ? { duration: open ? 0.8 : 0.45, ease: open ? [0.16, 1, 0.3, 1] : [0.4, 0, 0.2, 1] } : { duration: 0.1 },
+ opacity: { duration: open ? 0.12 : 0.08, ease: 'easeOut' }
}}
>
{isRight ? (
@@ -279,10 +277,10 @@ export function Panel() {
{settingsOpen ? (
<motion.div
key="settings"
- initial={{ opacity: 0, x: isRight ? -10 : 10 }}
- animate={{ opacity: 1, x: 0, y: 0 }}
- exit={{ opacity: 0, x: isRight ? 10 : -10 }}
- transition={{ duration: 0.15 }}
+ initial={{ opacity: 0, x: isRight ? -8 : 8 }}
+ animate={{ opacity: 1, x: 0 }}
+ exit={{ opacity: 0, x: isRight ? 8 : -8 }}
+ transition={{ type: 'spring', stiffness: 400, damping: 36, mass: 0.6 }}
style={{ flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden', position: 'relative' }}
>
<div style={{ position: 'absolute', top: 0, left: 0, right: 0, height: 18, background: 'linear-gradient(to bottom, #000000, transparent)', pointerEvents: 'none', zIndex: 10 }} />
@@ -292,10 +290,10 @@ export function Panel() {
) : (
<motion.div
key="list"
- initial={{ opacity: 0, x: isRight ? 10 : -10 }}
- animate={{ opacity: 1, x: 0, y: 0 }}
- exit={{ opacity: 0, x: isRight ? -10 : 10 }}
- transition={{ duration: 0.15 }}
+ initial={{ opacity: 0, x: isRight ? 8 : -8 }}
+ animate={{ opacity: 1, x: 0 }}
+ exit={{ opacity: 0, x: isRight ? -8 : 8 }}
+ transition={{ type: 'spring', stiffness: 400, damping: 36, mass: 0.6 }}
style={{ flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden', position: 'relative' }}
>
<div style={{ position: 'absolute', top: 0, left: 0, right: 0, height: 18, background: 'linear-gradient(to bottom, #000000, transparent)', pointerEvents: 'none', zIndex: 10 }} />
diff --git a/src/components/PreviewFlyout.tsx b/src/components/PreviewFlyout.tsx
index 0150804..2e1a5af 100644
--- a/src/components/PreviewFlyout.tsx
+++ b/src/components/PreviewFlyout.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react'
+import { useState, useRef, useEffect } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { useStore } from '../store/appStore'
import { formatBytes } from '../lib/format'
@@ -7,6 +7,7 @@ import { FileKindIcon, FolderOpenIcon, CopyIcon, CheckIcon } from './icons'
import { createPortal } from 'react-dom'
import { useAdaptiveSpring } from '../hooks/useAdaptiveSpring'
import { useDragOut } from '../hooks/useDragOut'
+import { tryPaste } from '../lib/tryPaste'
export function PreviewFlyout({ isRight }: { isRight: boolean }) {
const previewItemId = useStore((s) => s.previewItemId)
@@ -33,6 +34,32 @@ export function PreviewFlyout({ isRight }: { isRight: boolean }) {
const maxFlyoutHeight = `calc(${(settings.panelHeight || 0.6) * 100}vh - 24px)`
const [dragOver, setDragOver] = useState(false)
+ const flyoutRef = useRef<HTMLDivElement | null>(null)
+
+ useEffect(() => {
+ if (!item || !flyoutRef.current) {
+ useStore.getState().setPreviewFlyoutRect(null)
+ return
+ }
+
+ const updateRect = () => {
+ if (flyoutRef.current) {
+ const r = flyoutRef.current.getBoundingClientRect()
+ useStore.getState().setPreviewFlyoutRect({ top: r.top, bottom: r.bottom })
+ }
+ }
+
+ updateRect()
+ const ro = new ResizeObserver(updateRect)
+ ro.observe(flyoutRef.current)
+ window.addEventListener('resize', updateRect)
+
+ return () => {
+ ro.disconnect()
+ window.removeEventListener('resize', updateRect)
+ useStore.getState().setPreviewFlyoutRect(null)
+ }
+ }, [item?.id])
const handleDragOver = (e: React.DragEvent) => {
const activeDrag = useStore.getState().internalDragReq
@@ -81,15 +108,17 @@ export function PreviewFlyout({ isRight }: { isRight: boolean }) {
zIndex: 5,
}}>
<motion.div
+ ref={flyoutRef}
key={item.id}
className="preview-flyout"
data-preview-flyout="true"
- initial={{ opacity: 0, scaleX: 0.3, scaleY: 0.15 }}
- animate={{ opacity: 1, scaleX: 1, scaleY: 1 }}
- exit={{ opacity: 0, scaleX: 0.3, scaleY: 0.15 }}
- transition={{
+ initial={{ opacity: 0, scale: 0.88, y: 8 }}
+ animate={{ opacity: 1, scale: 1, y: 0 }}
+ exit={{ opacity: 0, scale: 0.88, y: 8 }}
+ transition={{
...adaptiveSpring,
- opacity: { type: 'tween', duration: 0.18, ease: 'easeOut' }
+ opacity: { type: 'tween', duration: 0.16, ease: 'easeOut' },
+ y: { type: 'spring', stiffness: 420, damping: 36, mass: 0.65, restDelta: 0.001 }
}}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
@@ -237,7 +266,16 @@ function PreviewContent({ item }: { item: any }) {
: item.data.text
const isCode = looksLikeCode(text)
return (
- <div style={{ position: 'relative', display: 'flex', flexDirection: 'column', gap: 10 }}>
+ <div
+ onClick={(e) => {
+ const sel = window.getSelection()?.toString()
+ if (sel && sel.trim().length > 0) return
+ e.stopPropagation()
+ tryPaste(() => useStore.getState().paste(item.id))
+ }}
+ title="Click to paste"
+ style={{ position: 'relative', display: 'flex', flexDirection: 'column', gap: 10, cursor: 'pointer' }}
+ >
<div style={{ display: 'flex', justifyContent: 'flex-end', position: 'sticky', top: 0, zIndex: 2 }}>
<QuickActionButton
title="Copy Text"
@@ -272,6 +310,11 @@ function PreviewContent({ item }: { item: any }) {
startDrag(req)
}}
onDragEnd={() => useStore.getState().setInternalDragReq(null)}
+ onClick={(e) => {
+ e.stopPropagation()
+ tryPaste(() => useStore.getState().paste(item.id))
+ }}
+ title="Click to paste · Drag to move"
style={{ display: 'flex', flexDirection: 'column', gap: 12, position: 'relative', cursor: 'grab' }}
>
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 6, position: 'absolute', top: 8, right: 8, zIndex: 2 }}>
@@ -306,6 +349,11 @@ function PreviewContent({ item }: { item: any }) {
startDrag(req)
}}
onDragEnd={() => useStore.getState().setInternalDragReq(null)}
+ onClick={(e) => {
+ e.stopPropagation()
+ tryPaste(() => window.edge.pasteSubitem({ id: item.id, imageId: img.imageId }))
+ }}
+ title="Click to paste image · Drag to move"
style={{ display: 'flex', flexDirection: 'column', gap: 8, position: 'relative', cursor: 'grab' }}
>
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 6, position: 'absolute', top: 8, right: 8, zIndex: 2 }}>
@@ -343,6 +391,11 @@ function PreviewContent({ item }: { item: any }) {
startDrag(req)
}}
onDragEnd={() => useStore.getState().setInternalDragReq(null)}
+ onClick={(e) => {
+ e.stopPropagation()
+ tryPaste(() => useStore.getState().paste(item.id))
+ }}
+ title={`Click to paste "${fileName}" · Drag to move`}
style={{ display: 'flex', flexDirection: 'column', gap: 12, position: 'relative', cursor: 'grab' }}
>
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 6, position: 'absolute', top: 8, right: 8, zIndex: 2 }}>
@@ -412,6 +465,11 @@ function PreviewContent({ item }: { item: any }) {
startDrag(req)
}}
onDragEnd={() => useStore.getState().setInternalDragReq(null)}
+ onClick={(e) => {
+ e.stopPropagation()
+ tryPaste(() => window.edge.pasteSubitem({ id: item.id, paths: [p] }))
+ }}
+ title={`Click to paste "${fileName}" · Drag to move`}
style={{
display: 'flex',
flexDirection: 'column',
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx
index 22176dd..59b34c3 100644
--- a/src/components/Settings.tsx
+++ b/src/components/Settings.tsx
@@ -16,6 +16,8 @@ export function Settings() {
return (
<div className="settings-list">
+
+ {/* ── Update banner ───────────────────────────────────────────── */}
{updateInfo?.hasUpdate && (
<>
<div className="update-prompt">
@@ -33,11 +35,39 @@ export function Settings() {
</>
)}
- {/* Clear unpinned on restart */}
+ {/* ══ GROUP: Behaviour ════════════════════════════════════════════ */}
+ <div className="setting-group-label">Behaviour</div>
+
+ <div className="setting-row">
+ <div className="setting-info">
+ <div className="setting-title">Launch at login</div>
+ <div className="setting-desc">Start silently in background when computer boots</div>
+ </div>
+ <Toggle
+ checked={settings.launchAtLogin}
+ onChange={(v) => patch({ launchAtLogin: v })}
+ />
+ </div>
+
+ <div className="setting-divider" />
+
+ <div className="setting-row">
+ <div className="setting-info">
+ <div className="setting-title">Incognito mode</div>
+ <div className="setting-desc">Temporarily pause recording new clipboard items</div>
+ </div>
+ <Toggle
+ checked={settings.incognito}
+ onChange={(v) => patch({ incognito: v })}
+ />
+ </div>
+
+ <div className="setting-divider" />
+
<div className="setting-row">
<div className="setting-info">
<div className="setting-title">Clear unpinned on restart</div>
- <div className="setting-desc">Wipe unpinned items whenever device restarts</div>
+ <div className="setting-desc">Wipe unpinned items whenever the app restarts</div>
</div>
<Toggle
checked={settings.clearUnpinnedOnRestart}
@@ -47,7 +77,6 @@ export function Settings() {
<div className="setting-divider" />
- {/* Auto-delete timer */}
<div className="setting-row vertical">
<div className="setting-info">
<div className="setting-title">Auto-delete timer</div>
@@ -74,7 +103,6 @@ export function Settings() {
<div className="setting-divider" />
- {/* History capacity */}
<div className="setting-row vertical">
<div className="setting-info">
<div className="setting-title">History capacity</div>
@@ -98,13 +126,66 @@ export function Settings() {
</div>
</div>
+ {/* ══ GROUP: Position ═════════════════════════════════════════════ */}
+ <div className="setting-group-label" style={{ marginTop: 20 }}>Position</div>
+
+ <div className="setting-row vertical">
+ <div className="setting-info">
+ <div className="setting-title">Stick position</div>
+ <div className="setting-desc">Screen edge to attach the panel to</div>
+ </div>
+ <div className="setting-pills">
+ {[
+ { label: 'Left', val: 'left' as const },
+ { label: 'Right', val: 'right' as const }
+ ].map((opt) => (
+ <button
+ key={opt.label}
+ className={`pill ${settings.stickPosition === opt.val ? 'active' : ''}`}
+ onClick={() => patch({ stickPosition: opt.val })}
+ >
+ {opt.label}
+ </button>
+ ))}
+ </div>
+ </div>
+
<div className="setting-divider" />
- {/* Edge trigger height */}
+ <div className="setting-row vertical">
+ <div className="setting-info">
+ <div className="setting-title">Display</div>
+ <div className="setting-desc">Monitor to stick the panel to</div>
+ </div>
+ <div className="setting-pills">
+ {displays.length === 0 && <div className="pill disabled">Loading...</div>}
+ {displays.map((d) => {
+ const currentDisplay = displays.find((disp) => disp.isCurrent)
+ const activeDisplayId = currentDisplay
+ ? currentDisplay.id
+ : (settings.stickDisplayId ?? displays.find((disp) => disp.isPrimary)?.id ?? displays[0]?.id)
+ const isActive = activeDisplayId === d.id
+ return (
+ <button
+ key={d.id}
+ className={`pill display-pill ${isActive ? 'active' : ''}`}
+ onClick={() => patch({ stickDisplayId: d.id })}
+ >
+ <div className="pill-name">{d.name}</div>
+ <div className="pill-res">{d.resolution}</div>
+ </button>
+ )
+ })}
+ </div>
+ </div>
+
+ {/* ══ GROUP: Trigger zone ═════════════════════════════════════════ */}
+ <div className="setting-group-label" style={{ marginTop: 20 }}>Trigger Zone</div>
+
<div className="setting-row vertical">
<div className="setting-info">
<div className="setting-title">Edge trigger height</div>
- <div className="setting-desc">Hover area size on screen edge</div>
+ <div className="setting-desc">Hover area size on the screen edge</div>
</div>
<div className="setting-pills">
{[
@@ -125,11 +206,10 @@ export function Settings() {
<div className="setting-divider" />
- {/* Edge trigger width */}
<div className="setting-row vertical">
<div className="setting-info">
<div className="setting-title">Edge trigger thickness</div>
- <div className="setting-desc">Physical thickness of the trigger area</div>
+ <div className="setting-desc">Physical thickness of the invisible trigger strip</div>
</div>
<div className="setting-pills">
{[
@@ -150,11 +230,10 @@ export function Settings() {
<div className="setting-divider" />
- {/* Panel height */}
<div className="setting-row vertical">
<div className="setting-info">
<div className="setting-title">Panel height</div>
- <div className="setting-desc">Vertical size of the clipboard panel</div>
+ <div className="setting-desc">Vertical size of the clipboard shelf</div>
</div>
<div className="setting-pills">
{[
@@ -173,90 +252,45 @@ export function Settings() {
</div>
</div>
- <div className="setting-divider" />
-
- {/* Stick position */}
- <div className="setting-row vertical">
- <div className="setting-info">
- <div className="setting-title">Stick position</div>
- <div className="setting-desc">Screen edge to attach the panel</div>
- </div>
- <div className="setting-pills">
- {[
- { label: 'Left', val: 'left' as const },
- { label: 'Right', val: 'right' as const }
- ].map((opt) => (
- <button
- key={opt.label}
- className={`pill ${settings.stickPosition === opt.val ? 'active' : ''}`}
- onClick={() => patch({ stickPosition: opt.val })}
- >
- {opt.label}
- </button>
- ))}
- </div>
- </div>
-
- <div className="setting-divider" />
-
- {/* Display picker */}
- <div className="setting-row vertical">
- <div className="setting-info">
- <div className="setting-title">Display</div>
- <div className="setting-desc">Monitor to stick the panel to</div>
- </div>
- <div className="setting-pills">
- {displays.length === 0 && <div className="pill disabled">Loading...</div>}
- {displays.map((d) => {
- const activeDisplayId = settings.stickDisplayId ?? displays.find(d => d.isPrimary)?.id;
- return (
- <button
- key={d.id}
- className={`pill display-pill ${activeDisplayId === d.id ? 'active' : ''}`}
- onClick={() => patch({ stickDisplayId: d.id })}
- >
- <div className="pill-name">{d.name}</div>
- <div className="pill-res">{d.resolution}</div>
- </button>
- )
- })}
- </div>
- </div>
-
- <div className="setting-divider" />
+ {/* ══ GROUP: Animations ═══════════════════════════════════════════ */}
+ <div className="setting-group-label" style={{ marginTop: 20 }}>Animations</div>
- {/* Incognito mode */}
<div className="setting-row">
<div className="setting-info">
- <div className="setting-title">Incognito mode</div>
- <div className="setting-desc">Temporarily pause recording new clipboard items</div>
+ <div className="setting-title">Bounce animation</div>
+ <div className="setting-desc">
+ Adds a springy overshoot pop when the panel opens.
+ <span className="setting-badge-subtle">May slightly affect performance</span>
+ </div>
</div>
<Toggle
- checked={settings.incognito}
- onChange={(v) => patch({ incognito: v })}
+ checked={settings.bounceAnimation ?? false}
+ onChange={(v) => patch({ bounceAnimation: v })}
/>
</div>
<div className="setting-divider" />
- {/* Launch at login */}
<div className="setting-row">
<div className="setting-info">
- <div className="setting-title">Launch at login</div>
- <div className="setting-desc">Start silently in background when computer boots</div>
+ <div className="setting-title">Blur animation</div>
+ <div className="setting-desc">
+ Blurs the panel as it opens and closes.
+ <span className="setting-badge-subtle">May slightly affect performance</span>
+ </div>
</div>
<Toggle
- checked={settings.launchAtLogin}
- onChange={(v) => patch({ launchAtLogin: v })}
+ checked={settings.blurAnimation ?? false}
+ onChange={(v) => patch({ blurAnimation: v })}
/>
</div>
- <div className="setting-divider" />
+ {/* ══ Footer ══════════════════════════════════════════════════════ */}
+ <div className="setting-divider" style={{ marginTop: 16 }} />
- {/* GitHub Star Promo */}
<div className="github-promo">
<div className="github-promo-text">
- If you like the application, please give a star to the GitHub repository - it means a lot!
+ If you like the application, please give a star to the GitHub repository — it means a lot!
</div>
<button
className="github-promo-btn"
diff --git a/src/components/Toast.tsx b/src/components/Toast.tsx
index db2ea86..a3497b7 100644
--- a/src/components/Toast.tsx
+++ b/src/components/Toast.tsx
@@ -23,7 +23,7 @@ export function ToastStack() {
initial={{ opacity: 0, y: 16, scale: 0.96 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: 10, scale: 0.96 }}
- transition={{ type: 'spring', stiffness: 420, damping: 32 }}
+ transition={{ type: 'spring', stiffness: 500, damping: 40, mass: 0.5, restDelta: 0.001, restSpeed: 0.001 }}
onClick={() => dismiss(t.id)}
title="Dismiss"
>
diff --git a/src/hooks/useAdaptiveSpring.ts b/src/hooks/useAdaptiveSpring.ts
index af93396..9c54eac 100644
--- a/src/hooks/useAdaptiveSpring.ts
+++ b/src/hooks/useAdaptiveSpring.ts
@@ -1,22 +1,64 @@
import { useMemo } from 'react'
+/**
+ * Returns Framer Motion spring presets calibrated to the current display.
+ *
+ * Goals:
+ * - Critically damped (ratio ≥ 1.0) — settles without overshoot or ring.
+ * - restDelta / restSpeed as tight as possible — Framer exits the animation
+ * loop the moment motion is sub-pixel, freeing the compositor immediately.
+ * - Hi-DPI: stiffer + heavier damping because sub-pixel overshoot is
+ * more visible at 2× and the GPU fill-rate budget is tighter on 4K.
+ */
export function useAdaptiveSpring() {
return useMemo(() => {
const dpr = window.devicePixelRatio || 1
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches
if (prefersReducedMotion) {
- // Instant transition
- return { type: 'tween', duration: 0.01 }
+ return { type: 'tween', duration: 0.01 } as const
}
if (dpr >= 1.75) {
- // Hi-DPI (2x+): Stiffer, higher damping to settle in fewer frames.
- // Reduces GPU compositor work on 4K displays where fill-rate is a bottleneck.
- return { type: 'spring', stiffness: 420, damping: 34, mass: 0.8 }
+ // Hi-DPI (2×+): critically damped, settles in ≈8 frames at 120Hz.
+ return {
+ type: 'spring',
+ stiffness: 480,
+ damping: 42,
+ mass: 0.7,
+ restDelta: 0.001,
+ restSpeed: 0.001
+ } as const
}
- // Standard DPI: Default smooth spring
- return { type: 'spring', stiffness: 380, damping: 30, mass: 0.8 }
+ // Standard DPI: slightly springy but no overshoot.
+ return {
+ type: 'spring',
+ stiffness: 420,
+ damping: 38,
+ mass: 0.7,
+ restDelta: 0.001,
+ restSpeed: 0.001
+ } as const
+ }, [])
+}
+
+/**
+ * A gentler spring for secondary surfaces (flyout content, settings panes).
+ * Slightly slower stiffness so it doesn't feel abrupt against the blade motion.
+ */
+export function useSubtleSpring() {
+ return useMemo(() => {
+ const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches
+ if (prefersReducedMotion) return { type: 'tween', duration: 0.01 } as const
+
+ return {
+ type: 'spring',
+ stiffness: 340,
+ damping: 34,
+ mass: 0.65,
+ restDelta: 0.001,
+ restSpeed: 0.001
+ } as const
}, [])
}
diff --git a/src/hooks/useEdgeHover.ts b/src/hooks/useEdgeHover.ts
index b27ce41..e193c4b 100644
--- a/src/hooks/useEdgeHover.ts
+++ b/src/hooks/useEdgeHover.ts
@@ -67,34 +67,6 @@ export function notifyPreviewClosedByUser(): void {
}
export function useEdgeHover(): void {
- const open = useStore((s) => s.open)
- const setOpen = useStore((s) => s.setOpen)
- const settings = useStore((s) => s.settings)
- const dragActive = useStore((s) => s.dragActive)
- const setDragActive = useStore((s) => s.setDragActive)
- const internalDragReq = useStore((s) => s.internalDragReq)
- const previewItemId = useStore((s) => s.previewItemId)
-
- // All reactive values accessed inside events kept in refs so the
- // event-listener effect never needs to restart (restarting cancels timers).
- const openRef = useRef(open)
- openRef.current = open
-
- const dragActiveRef = useRef(dragActive)
- dragActiveRef.current = dragActive
-
- const internalDragRef = useRef(!!internalDragReq)
- internalDragRef.current = !!internalDragReq
-
- const settingsRef = useRef(settings)
- settingsRef.current = settings
-
- const previewRef = useRef(previewItemId)
- previewRef.current = previewItemId
-
- // Access setPreviewItemId without subscribing (avoids restarting the stable effect).
- const setPreviewItemId = useStore.getState().setPreviewItemId
-
// Throttle the self-healing setInteractive(true) call.
// Without this, it fires at 60Hz (every 16ms) via the cursor-edge poll,
// flooding the IPC queue and starving the messages that open the panel.
@@ -111,7 +83,7 @@ export function useEdgeHover(): void {
useEffect(() => {
const recompute = () => {
const h = window.innerHeight
- const s = settingsRef.current
+ const s = useStore.getState().settings
const half = h * s.hotZoneHeight / 2
const panelHalfH = h * (s.panelHeight || 0.5) / 2
zone.current = {
@@ -124,7 +96,7 @@ export function useEdgeHover(): void {
recompute()
window.addEventListener('resize', recompute)
return () => window.removeEventListener('resize', recompute)
- }, [settings.hotZoneHeight, settings.panelHeight])
+ }, [])
// Single stable effect — deps never change after mount.
useEffect(() => {
@@ -133,37 +105,39 @@ export function useEdgeHover(): void {
let interactiveTimer: number | undefined
const closePanel = () => {
- if (!openRef.current) return
- if (dragActiveRef.current && !internalDragRef.current) return
+ const state = useStore.getState()
+ if (!state.open) return
+ if (state.dragActive && !state.internalDragReq) return
// If preview is open, dismiss it first and wait for its exit
// animation to finish (~350ms) before collapsing the panel.
// This prevents both animations from fighting each other.
- if (previewRef.current) {
- setPreviewItemId(null)
+ if (state.previewItemId) {
+ state.setPreviewItemId(null)
window.setTimeout(() => {
- setOpen(false)
+ useStore.getState().setOpen(false)
if (interactiveTimer !== undefined) window.clearTimeout(interactiveTimer)
interactiveTimer = window.setTimeout(() => {
interactiveTimer = undefined
- if (!openRef.current) edge.setInteractive(false)
+ if (!useStore.getState().open) edge.setInteractive(false)
}, 180)
- }, 350)
+ }, 240)
return
}
- setOpen(false)
+ state.setOpen(false)
if (interactiveTimer !== undefined) window.clearTimeout(interactiveTimer)
interactiveTimer = window.setTimeout(() => {
interactiveTimer = undefined
- if (!openRef.current) {
+ if (!useStore.getState().open) {
edge.setInteractive(false)
}
}, 180)
}
const scheduleClose = (delay = GRACE_MS) => {
- if (dragActiveRef.current && !internalDragRef.current) return
+ const state = useStore.getState()
+ if (state.dragActive && !state.internalDragReq) return
if (graceTimer !== undefined) return // already closing
// If the user just closed the preview via X, give them extra time before
// the clipboard collapses so they can keep using it.
@@ -203,8 +177,8 @@ export function useEdgeHover(): void {
interactiveTimer = undefined
}
edge.setInteractive(true)
- if (openRef.current) return
- setOpen(true)
+ if (useStore.getState().open) return
+ useStore.getState().setOpen(true)
}
// ── panel:leave / panel:enter (from Panel.tsx blade div) ──────────────
@@ -215,14 +189,29 @@ export function useEdgeHover(): void {
const isInsideBlade = () => {
const { x, y } = lastClient.current
if (x < -BUFFER_PX || y < 0) return true // unknown — be conservative, don't close
- const s = settingsRef.current
- const currentPanelWide = previewRef.current ? PREVIEW_WIDE : PANEL_WIDE
+ const state = useStore.getState()
+ const s = state.settings
+ const currentPanelWide = state.previewItemId ? PREVIEW_WIDE : PANEL_WIDE
+ let insideX = false
if (s.stickPosition === 'right') {
- return x >= window.innerWidth - currentPanelWide - BUFFER_PX && x <= window.innerWidth + BUFFER_PX
+ insideX = x >= window.innerWidth - currentPanelWide - BUFFER_PX && x <= window.innerWidth + BUFFER_PX
+ } else {
+ insideX = x >= -BUFFER_PX && x <= currentPanelWide + BUFFER_PX
+ }
+ if (!insideX) return false
+
+ const inPreviewCol = s.stickPosition === 'right'
+ ? x < window.innerWidth - KEEP_OPEN_PX
+ : x > KEEP_OPEN_PX
+
+ if (inPreviewCol && state.previewItemId && state.previewFlyoutRect) {
+ const FLYOUT_BUFFER = 24
+ return y >= state.previewFlyoutRect.top - FLYOUT_BUFFER && y <= state.previewFlyoutRect.bottom + FLYOUT_BUFFER
}
- // left
- return x >= -BUFFER_PX && x <= currentPanelWide + BUFFER_PX
+
+ const { midY, panelHalfH } = zone.current
+ return y >= midY - panelHalfH && y <= midY + panelHalfH
}
const onPanelLeave = () => {
@@ -245,9 +234,10 @@ export function useEdgeHover(): void {
lastClient.current = { x: data.x, y: data.y }
const { stickPosition, displayWidth } = data
const { top, bottom, midY, panelHalfH } = zone.current
+ const state = useStore.getState()
- const currentKeepOpenPx = previewRef.current ? PREVIEW_WIDE - 15 : KEEP_OPEN_PX
- const currentStartClosePx = previewRef.current ? PREVIEW_WIDE + 20 : START_CLOSE_PX
+ const currentKeepOpenPx = state.previewItemId ? PREVIEW_WIDE - 15 : KEEP_OPEN_PX
+ const currentStartClosePx = state.previewItemId ? PREVIEW_WIDE + 20 : START_CLOSE_PX
switch (stickPosition) {
case 'right': {
@@ -255,7 +245,7 @@ export function useEdgeHover(): void {
const inEdge = distFromRight >= -BUFFER_PX && distFromRight <= TRIGGER_PX
const inZone = data.y >= top && data.y <= bottom
- if (inEdge && inZone && !openRef.current) {
+ if (inEdge && inZone && !state.open) {
cancelClose()
if (dwellTimer === undefined) {
dwellTimer = window.setTimeout(() => {
@@ -271,7 +261,7 @@ export function useEdgeHover(): void {
dwellTimer = undefined
}
- if (!openRef.current) return
+ if (!state.open) return
const now = Date.now()
if (now - lastSetInteractiveRef.current > 2000) {
@@ -279,7 +269,14 @@ export function useEdgeHover(): void {
edge.setInteractive(true)
}
- const insideY = data.y >= midY - panelHalfH && data.y <= midY + panelHalfH
+ const inPreviewColumn = distFromRight > KEEP_OPEN_PX
+ let insideY = false
+ if (inPreviewColumn && state.previewItemId && state.previewFlyoutRect) {
+ const FLYOUT_BUFFER = 24
+ insideY = data.y >= state.previewFlyoutRect.top - FLYOUT_BUFFER && data.y <= state.previewFlyoutRect.bottom + FLYOUT_BUFFER
+ } else {
+ insideY = data.y >= midY - panelHalfH && data.y <= midY + panelHalfH
+ }
if (distFromRight >= -BUFFER_PX && distFromRight <= currentKeepOpenPx && insideY) {
cancelClose()
@@ -292,14 +289,12 @@ export function useEdgeHover(): void {
break
}
-
-
// left
default: {
const inEdge = data.x >= -BUFFER_PX && data.x <= TRIGGER_PX
const inZone = data.y >= top && data.y <= bottom
- if (inEdge && inZone && !openRef.current) {
+ if (inEdge && inZone && !state.open) {
cancelClose()
if (dwellTimer === undefined) {
dwellTimer = window.setTimeout(() => {
@@ -315,7 +310,7 @@ export function useEdgeHover(): void {
dwellTimer = undefined
}
- if (!openRef.current) return
+ if (!state.open) return
const now = Date.now()
if (now - lastSetInteractiveRef.current > 2000) {
@@ -323,7 +318,14 @@ export function useEdgeHover(): void {
edge.setInteractive(true)
}
- const insideY = data.y >= midY - panelHalfH && data.y <= midY + panelHalfH
+ const inPreviewColumn = data.x > KEEP_OPEN_PX
+ let insideY = false
+ if (inPreviewColumn && state.previewItemId && state.previewFlyoutRect) {
+ const FLYOUT_BUFFER = 24
+ insideY = data.y >= state.previewFlyoutRect.top - FLYOUT_BUFFER && data.y <= state.previewFlyoutRect.bottom + FLYOUT_BUFFER
+ } else {
+ insideY = data.y >= midY - panelHalfH && data.y <= midY + panelHalfH
+ }
if (data.x >= -BUFFER_PX && data.x <= currentKeepOpenPx && insideY) {
cancelClose()
@@ -333,21 +335,20 @@ export function useEdgeHover(): void {
if (data.x > currentStartClosePx || data.x < -BUFFER_PX || !insideY) {
scheduleClose()
}
- break
}
}
})
// ── keyboard ───────────────────────────────────────────────────────────
const onKeyDown = (e: KeyboardEvent) => {
- if (e.key === 'Escape' && openRef.current) scheduleClose(0)
+ if (e.key === 'Escape' && useStore.getState().open) scheduleClose(0)
}
// ── OS file drag awareness ─────────────────────────────────────────────
const onDocDragEnter = (e: DragEvent) => {
if (e.dataTransfer?.types.includes('Files')) {
e.preventDefault()
- setDragActive(true)
+ useStore.getState().setDragActive(true)
openPanel()
}
}
@@ -359,17 +360,17 @@ export function useEdgeHover(): void {
}
const onDocDragLeave = (e: DragEvent) => {
if (!e.relatedTarget) {
- setDragActive(false)
- if (internalDragRef.current) scheduleClose(0)
+ useStore.getState().setDragActive(false)
+ if (useStore.getState().internalDragReq) scheduleClose(0)
}
}
const onDocDrop = (e: DragEvent) => {
e.preventDefault()
- setDragActive(false)
+ useStore.getState().setDragActive(false)
}
const onDocDragEnd = (e: DragEvent) => {
e.preventDefault()
- setDragActive(false)
+ useStore.getState().setDragActive(false)
}
// ── register ───────────────────────────────────────────────────────────
@@ -396,6 +397,5 @@ export function useEdgeHover(): void {
window.clearTimeout(graceTimer)
window.clearTimeout(interactiveTimer)
}
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [setOpen, setDragActive])
+ }, [])
}
diff --git a/src/lib/tryPaste.ts b/src/lib/tryPaste.ts
new file mode 100644
index 0000000..224e0e9
--- /dev/null
+++ b/src/lib/tryPaste.ts
@@ -0,0 +1,16 @@
+/**
+ * Shared module-level paste guard across ALL item instances and preview flyouts.
+ * Tracks the timestamp of the last paste so that any subsequent click
+ * (including the second click of a double-click) within PASTE_COOLDOWN ms
+ * is silently dropped. This synchronous, stateless guard prevents double-paste
+ * across renderers and avoids async IPC races.
+ */
+let _lastPasteAt = 0
+const PASTE_COOLDOWN = 600 // ms
+
+export function tryPaste(fn: () => void): void {
+ const now = Date.now()
+ if (now - _lastPasteAt < PASTE_COOLDOWN) return
+ _lastPasteAt = now
+ fn()
+}
diff --git a/src/store/appStore.ts b/src/store/appStore.ts
index 5e5a99f..548a12b 100644
--- a/src/store/appStore.ts
+++ b/src/store/appStore.ts
@@ -73,6 +73,8 @@ interface AppState {
setDragActive: (active: boolean) => void
setInternalDragReq: (req: import('../../shared/types').DragRequest | null) => void
setPreviewItemId: (id: string | null, rect?: { y: number; height: number }) => void
+ previewFlyoutRect: { top: number; bottom: number } | null
+ setPreviewFlyoutRect: (rect: { top: number; bottom: number } | null) => void
/* toasts */
pushToast: (toast: ToastMsg) => void
@@ -157,8 +159,10 @@ export const useStore = create<AppState>((set, get) => ({
}
edge.setInternalDrag(!!internalDragReq)
},
+ previewFlyoutRect: null,
+ setPreviewFlyoutRect: (rect) => set({ previewFlyoutRect: rect }),
setPreviewItemId: (id, rect) => {
- set({ previewItemId: id, previewItemRect: rect || null })
+ set({ previewItemId: id, previewItemRect: rect || null, ...(id ? {} : { previewFlyoutRect: null }) })
if (id) {
edge.setPreviewMode(true)
}
diff --git a/src/styles/item.css b/src/styles/item.css
index 4ab657d..eef9ee3 100644
--- a/src/styles/item.css
+++ b/src/styles/item.css
@@ -13,7 +13,8 @@
border-radius: 16px;
user-select: none;
-webkit-user-select: none;
- transition: background 0.3s ease, border-color 0.3s ease;
+ /* Specific properties only — avoids interpolating every inherited prop. */
+ transition: background 0.18s ease, border-color 0.18s ease;
overflow: hidden;
}
@@ -59,6 +60,7 @@
.item-main:active {
transform: scale(0.98);
+ transition: transform 0.08s ease;
}
.body {
@@ -208,7 +210,11 @@
backdrop-filter: blur(12px);
opacity: 0;
pointer-events: none;
- transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
+ /* Specific properties — prevents `all` from catching unrelated inherited changes.
+ will-change promotes the layer ahead of hover so the slide-in is smooth. */
+ transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
+ transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
+ will-change: transform, opacity;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.8);
z-index: 20;
}
@@ -229,7 +235,7 @@
border-radius: 50%;
color: rgba(255, 255, 255, 0.6);
background: transparent;
- transition: all 0.2s ease;
+ transition: background 0.14s ease, color 0.14s ease;
}
.act:hover {
background: rgba(255, 255, 255, 0.15);
@@ -249,8 +255,14 @@
/* ------------------------------------------------------------------ */
/* Card is actively being previewed — dim body so flyout takes focus */
+.item-main.previewing {
+ cursor: default;
+}
+
.item-main.previewing .body {
opacity: 0.45;
+ pointer-events: none;
+ user-select: none;
/* Use calc with --dpr to ensure consistent *visual* blur while saving GPU on 4K */
filter: blur(calc(3px / var(--dpr, 1)));
transition: opacity 0.3s ease, filter 0.3s ease;
diff --git a/src/styles/panel.css b/src/styles/panel.css
index 8f3d3f4..8489676 100644
--- a/src/styles/panel.css
+++ b/src/styles/panel.css
@@ -83,9 +83,13 @@
display: block;
}
-/* CSS transition for clip-path (Framer Motion can't interpolate calc() properly) */
+/* CSS transition for clip-path (Framer Motion can't interpolate calc() properly).
+ cubic-bezier(0.22, 1, 0.36, 1) is an exponential ease-out — fast initial
+ velocity that decelerates to zero, giving the panel a crisp "snapping open"
+ feel without overshoot or bounce. 0.46s is just long enough to be readable
+ at 60Hz without feeling sluggish on fast hardware. */
.blade-container {
- transition: clip-path 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
+ transition: clip-path 0.46s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Parent container solid block extension to prevent screen edge blur transparency */
diff --git a/src/styles/settings.css b/src/styles/settings.css
index 6f83658..b8e8283 100644
--- a/src/styles/settings.css
+++ b/src/styles/settings.css
@@ -56,6 +56,33 @@
flex-shrink: 0;
}
+.setting-group-label {
+ font-size: 11px;
+ font-weight: 700;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ color: #a1a1aa;
+ margin: 12px 4px 4px;
+ user-select: none;
+}
+
+.setting-group-label:first-of-type {
+ margin-top: 4px;
+}
+
+.setting-badge-subtle {
+ display: inline-block;
+ margin-left: 6px;
+ padding: 1px 6px;
+ font-size: 10.5px;
+ font-weight: 500;
+ color: #a1a1aa;
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ border-radius: 999px;
+ vertical-align: middle;
+}
+
/* Minimalist Pill Selector (Replaces Sliders!) */
.setting-pills {
display: flex;