From b8d009c9730c7864148a1fde1ab6de66a87266a6 Mon Sep 17 00:00:00 2001 From: LyAhn Date: Mon, 6 Jul 2026 00:47:13 +0100 Subject: [PATCH] fix(frontend): sync sidebar pause menu with per-worker background task state Only require a worker to be paused if it currently has pending work for that folder, instead of demanding all four worker flags be true. The background tasks panel only lets you toggle stages it shows, so the old check stayed out of sync after pausing everything visible. Also grants start-dragging and start-resize-dragging window permissions. --- src-tauri/capabilities/default.json | 10 +++++++--- src/components/sidebar/FolderItem.tsx | 28 ++++++++++++++++++++------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 93b55f7..da77b5a 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -2,7 +2,9 @@ "$schema": "../gen/schemas/desktop-schema.json", "identifier": "default", "description": "Capability for the main window", - "windows": ["main"], + "windows": [ + "main" + ], "permissions": [ "core:default", "opener:default", @@ -19,6 +21,8 @@ "core:window:allow-minimize", "core:window:allow-close", "core:window:allow-toggle-maximize", - "core:window:allow-is-maximized" + "core:window:allow-is-maximized", + "core:window:allow-start-dragging", + "core:window:allow-start-resize-dragging" ] -} +} \ No newline at end of file diff --git a/src/components/sidebar/FolderItem.tsx b/src/components/sidebar/FolderItem.tsx index c19631f..7695c60 100644 --- a/src/components/sidebar/FolderItem.tsx +++ b/src/components/sidebar/FolderItem.tsx @@ -39,14 +39,28 @@ export function FolderItem({ const mutedFolderIds = useGalleryStore((state) => state.mutedFolderIds) const setAllWorkersPaused = useGalleryStore((state) => state.setAllWorkersPaused) const folderWorkers = useGalleryStore((state) => state.workerPaused[folder.id]) + const folderJobs = useGalleryStore((state) => state.mediaJobProgress[folder.id]) const isMuted = mutedFolderIds.includes(folder.id) - // "Fully paused" only when every worker for this folder is paused. - const isPausedAll = - !!folderWorkers && - folderWorkers.thumbnail && - folderWorkers.metadata && - folderWorkers.embedding && - folderWorkers.tagging + // "Fully paused" means every worker that currently has pending work is + // paused. Workers with nothing pending are ignored — the background tasks + // panel only lets you toggle the stages it actually shows, so requiring + // every worker key to be literally true left this permanently out of sync + // (menu kept offering "Pause" after the visible work was already paused). + const hasPendingWork = + (folderJobs?.thumbnail_pending ?? 0) > 0 || + (folderJobs?.metadata_pending ?? 0) > 0 || + (folderJobs?.embedding_pending ?? 0) > 0 || + (folderJobs?.tagging_pending ?? 0) > 0 + const isPausedAll = hasPendingWork + ? ((folderJobs?.thumbnail_pending ?? 0) === 0 || !!folderWorkers?.thumbnail) && + ((folderJobs?.metadata_pending ?? 0) === 0 || !!folderWorkers?.metadata) && + ((folderJobs?.embedding_pending ?? 0) === 0 || !!folderWorkers?.embedding) && + ((folderJobs?.tagging_pending ?? 0) === 0 || !!folderWorkers?.tagging) + : !!folderWorkers && + folderWorkers.thumbnail && + folderWorkers.metadata && + folderWorkers.embedding && + folderWorkers.tagging const isIndexing = progress && !progress.done const isMissing = !!folder.scan_error && !isIndexing