From e0c0bd939ec5fdb21d93c36065c023f227dbb12b Mon Sep 17 00:00:00 2001 From: anhtahaylove Date: Fri, 3 Jul 2026 22:02:13 +0700 Subject: [PATCH] Route file reveal actions through the app command The frontend still called the opener plugin directly in several queue and processing surfaces even though the backend already exposes an open_file_location command with platform-specific reveal behavior. This keeps the UI on the app command boundary while avoiding the broader ProcessingContext rewrite from the larger upstream PR. Constraint: Upstream already registers open_file_location in Rust, so the frontend can reuse that command without adding backend surface area. Rejected: Port PR #94 wholesale | it pulls a larger ProcessingContext diff than needed for the Windows reveal fix. Confidence: high Scope-risk: narrow Directive: Keep file reveal UI actions routed through this helper unless the backend command is removed or renamed. Tested: biome targeted check for changed files; bun run tsc -b; cargo check in src-tauri after restoring the bundled yt-dlp binary; manual Show in folder on Windows custom build with a real downloaded sample-5s.mp4 file. Not-tested: macOS Finder reveal behavior; full Biome check in the clean Windows PR worktree because unrelated CRLF diagnostics affect untouched files. --- src/components/download/GalleryQueueItem.tsx | 4 ++-- src/components/download/QueueItem.tsx | 4 ++-- src/components/download/UniversalQueueItem.tsx | 4 ++-- src/components/processing/ChatPanel.tsx | 4 ++-- src/components/processing/HistoryDialog.tsx | 5 +++-- src/contexts/processing/processing-client.ts | 4 ++-- src/lib/open-file-location.ts | 5 +++++ 7 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 src/lib/open-file-location.ts diff --git a/src/components/download/GalleryQueueItem.tsx b/src/components/download/GalleryQueueItem.tsx index 26ea478a..0d852b7e 100644 --- a/src/components/download/GalleryQueueItem.tsx +++ b/src/components/download/GalleryQueueItem.tsx @@ -1,7 +1,7 @@ -import { revealItemInDir } from '@tauri-apps/plugin-opener'; import { CheckCircle2, Clock, FolderOpen, Globe, Loader2, X, XCircle } from 'lucide-react'; import { useCallback } from 'react'; import { useTranslation } from 'react-i18next'; +import { openFileLocation } from '@/lib/open-file-location'; import type { DownloadItem } from '@/lib/types'; import { cn } from '@/lib/utils'; @@ -27,7 +27,7 @@ export function GalleryQueueItem({ const handleOpenFolder = useCallback(async () => { if (!item.completedFilepath) return; try { - await revealItemInDir(item.completedFilepath); + await openFileLocation(item.completedFilepath); } catch (error) { console.error('Failed to open gallery output folder:', error); } diff --git a/src/components/download/QueueItem.tsx b/src/components/download/QueueItem.tsx index a04d2e3a..5604a263 100644 --- a/src/components/download/QueueItem.tsx +++ b/src/components/download/QueueItem.tsx @@ -1,4 +1,3 @@ -import { revealItemInDir } from '@tauri-apps/plugin-opener'; import { CheckCircle2, ChevronDown, @@ -24,6 +23,7 @@ import { SchedulePopover } from '@/components/download/SchedulePopover'; import { SimpleMarkdown } from '@/components/ui/simple-markdown'; import { useAI } from '@/contexts/AIContext'; import type { ScheduleConfig } from '@/hooks/useSchedule'; +import { openFileLocation } from '@/lib/open-file-location'; import type { DownloadItem, ItemDownloadSettings } from '@/lib/types'; import { cn } from '@/lib/utils'; import { extractYouTubeVideoId, youtubeThumbnailUrl } from '@/lib/youtube-url'; @@ -233,7 +233,7 @@ export function QueueItem({ if (!item.completedFilepath) return; try { - await revealItemInDir(item.completedFilepath); + await openFileLocation(item.completedFilepath); } catch (error) { console.error('Failed to open completed file location:', error); } diff --git a/src/components/download/UniversalQueueItem.tsx b/src/components/download/UniversalQueueItem.tsx index ea824f04..5bf8927a 100644 --- a/src/components/download/UniversalQueueItem.tsx +++ b/src/components/download/UniversalQueueItem.tsx @@ -1,4 +1,3 @@ -import { revealItemInDir } from '@tauri-apps/plugin-opener'; import { CheckCircle2, ChevronDown, @@ -24,6 +23,7 @@ import { SchedulePopover } from '@/components/download/SchedulePopover'; import { SimpleMarkdown } from '@/components/ui/simple-markdown'; import { useAI } from '@/contexts/AIContext'; import type { ScheduleConfig } from '@/hooks/useSchedule'; +import { openFileLocation } from '@/lib/open-file-location'; import type { DownloadItem, ItemUniversalSettings } from '@/lib/types'; import { cn } from '@/lib/utils'; import { SourceBadge } from './SourceBadge'; @@ -215,7 +215,7 @@ export function UniversalQueueItem({ if (!item.completedFilepath) return; try { - await revealItemInDir(item.completedFilepath); + await openFileLocation(item.completedFilepath); } catch (error) { console.error('Failed to open completed file location:', error); } diff --git a/src/components/processing/ChatPanel.tsx b/src/components/processing/ChatPanel.tsx index bdf1ec03..afeee9b8 100644 --- a/src/components/processing/ChatPanel.tsx +++ b/src/components/processing/ChatPanel.tsx @@ -1,5 +1,4 @@ import { open } from '@tauri-apps/plugin-dialog'; -import { revealItemInDir } from '@tauri-apps/plugin-opener'; import { Check, FileText, @@ -20,6 +19,7 @@ import { type DragEvent, useCallback, useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; +import { openFileLocation } from '@/lib/open-file-location'; import type { ChatAttachment, ChatMessage, ProcessingProgress } from '@/lib/types'; import { cn } from '@/lib/utils'; @@ -403,7 +403,7 @@ export function ChatPanel({