Peach: Local-first video metadata scraper and media manager.
fix(web): 常驻任务卡只收自己画出来的那一张,冷启动不再被提前的收起带走
longmeidao86281fbe8019
diff --git a/frontend/src/react/library-processing/library-processing-dock.tsx b/frontend/src/react/library-processing/library-processing-dock.tsxindex 0319fb19a..40677b1a0 100644--- a/frontend/src/react/library-processing/library-processing-dock.tsx+++ b/frontend/src/react/library-processing/library-processing-dock.tsx@@ -8,10 +8,15 @@ import { useLibraryProcessingJob } from './use-library-processing';const TASK_TOAST = 'peach-library-processing';-/** 路由根持续观察,任务浮层不随换页卸载;普通回执使用有独立目标的栈。 */+/** 路由根持续观察,任务浮层不随换页卸载;普通回执使用有独立目标的栈。+ *+ * 只收自己画出来、还在栈里的那一张。Sonner 的收起分两步送达:先登记,下一帧再由栈把这个 id+ * 标成删除。页面刚打开、任务状态还没回来时若对一张不存在的卡发收起,栈那一帧在主线程忙时会+ * 落在随后画出任务卡的那次更新之后,把刚出现的任务卡一起收走,状态不变就再也不出来。 */export function LibraryProcessingDock({ toast: receipt }: Pick<LibraryProcessingProps, 'toast'>) {const { job, settled } = useLibraryProcessingJob({ toast: receipt, mode: 'notice' });const dismissed = useRef('');+ const shown = useRef(false);const state = job.data;const problem = job.isError ? state ? DISCONNECTED_TEXT : errorMessage(job.error) : '';useEffect(() => {@@ -20,15 +25,20 @@ export function LibraryProcessingDock({ toast: receipt }: Pick<LibraryProcessingconst currentFailure = state?.status === 'failed'&& (settled?.job_id === state.job_id || freshProcessingResult(state));if (!active && ((!problem && !currentFailure) || dismissed.current === key)) {- toast.dismiss(TASK_TOAST);+ if (shown.current) toast.dismiss(TASK_TOAST);+ shown.current = false;return;}toast.custom(() => <div className="peach-react"><ProcessingNoticePanel state={state} problem={problem} measure /></div>, {id: TASK_TOAST, toasterId: 'processing', duration: Infinity, dismissible: !active,closeButton: !active, className: 'processing-task-toast',- onDismiss: () => { dismissed.current = key },+ onDismiss: () => { dismissed.current = key; shown.current = false },});+ shown.current = true;}, [state, problem, settled]);- useEffect(() => () => { toast.dismiss(TASK_TOAST) }, []);+ useEffect(() => () => {+ if (shown.current) toast.dismiss(TASK_TOAST);+ shown.current = false;+ }, []);return null;}diff --git a/frontend/test/react/library-processing-dock.test.tsx b/frontend/test/react/library-processing-dock.test.tsxindex ac23a6cb6..f51cbd550 100644--- a/frontend/test/react/library-processing-dock.test.tsx+++ b/frontend/test/react/library-processing-dock.test.tsx@@ -22,7 +22,18 @@ it('页面打开时历史失败留在数据管理,不自动弹出任务卡', aawait open({ status: 'failed', job_id: 'old', issue_count: 7276,completed_at: Date.now() / 1000 - 4 * 86400, error: '7276 项需要处理' });expect(sonner.custom).not.toHaveBeenCalled();- expect(sonner.dismiss).toHaveBeenCalled();+ expect(sonner.dismiss).not.toHaveBeenCalled();+});++it('任务状态回来之前不发收起;画出过的任务卡在任务结束时才收', async () => {+ vi.stubGlobal('fetch', vi.fn(() => new Promise(() => {})));+ await mount(<QueryClientProvider client={queryClient}><LibraryProcessingDock toast={vi.fn()} /></QueryClientProvider>);+ expect(sonner.dismiss).not.toHaveBeenCalled();+ await act(async () => { queryClient.setQueryData(LIBRARY_PROCESSING_KEY, { status: 'paused', job_id: 'current' }) });+ expect(sonner.custom).toHaveBeenCalled();+ expect(sonner.dismiss).not.toHaveBeenCalled();+ await act(async () => { queryClient.setQueryData(LIBRARY_PROCESSING_KEY, { status: 'complete', job_id: 'current' }) });+ expect(sonner.dismiss).toHaveBeenCalledWith('peach-library-processing');});it('本次观察到的任务失败持续显示,关闭后保持收起', async () => {diff --git a/web/dist/peach-app.js b/web/dist/peach-app.jsindex 359748bb9..0f5ab4441 100644--- a/web/dist/peach-app.js+++ b/web/dist/peach-app.js@@ -2,7 +2,7 @@(function() {try {var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}, t = new e.Error().stack;- t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "003e0830-a951-4549-8fe0-edbab82a74ef", e._sentryDebugIdIdentifier = "sentry-dbid-003e0830-a951-4549-8fe0-edbab82a74ef");+ t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "99032ff4-87c0-4448-9107-37f6c03224b8", e._sentryDebugIdIdentifier = "sentry-dbid-99032ff4-87c0-4448-9107-37f6c03224b8");} catch {}})();var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, n) => {@@ -46243,14 +46243,14 @@ function Ehe({ toast: e }) {let { job: t, settled: n } = jH({toast: e,mode: "notice"- }), r = (0, D.useRef)(""), i = t.data, a = t.isError ? i ? hH : An(t.error) : "";+ }), r = (0, D.useRef)(""), i = (0, D.useRef)(!1), a = t.data, o = t.isError ? a ? hH : An(t.error) : "";return (0, D.useEffect)(() => {- let e = dH(i), t = i?.job_id || "unavailable", o = i?.status === "failed" && (n?.job_id === i.job_id || yH(i));- !e && (!a && !o || r.current === t) ? rH.dismiss(iU) : rH.custom(() => /* @__PURE__ */ (0, O.jsx)("div", {+ let e = dH(a), t = a?.job_id || "unavailable", s = a?.status === "failed" && (n?.job_id === a.job_id || yH(a));+ !e && (!o && !s || r.current === t) ? (i.current && rH.dismiss(iU), i.current = !1) : (rH.custom(() => /* @__PURE__ */ (0, O.jsx)("div", {className: "peach-react",children: /* @__PURE__ */ (0, O.jsx)(rU, {- state: i,- problem: a,+ state: a,+ problem: o,measure: !0})}), {@@ -46261,15 +46261,15 @@ function Ehe({ toast: e }) {closeButton: !e,className: "processing-task-toast",onDismiss: () => {- r.current = t;+ r.current = t, i.current = !1;}- });+ }), i.current = !0);}, [- i,a,+ o,n]), (0, D.useEffect)(() => () => {- rH.dismiss(iU);+ i.current && rH.dismiss(iU), i.current = !1;}, []), null;}//#endregion@@ -79996,4 +79996,4 @@ jNe($9);//#endregionexport { xI as $2ec61d1d4f780267$export$a8a3e93435678ff9, PI as $3a442827418ebe87$export$eb2fcfdbd7ba97d4, rR as $542a13ca2fa5b484$export$5b6b19405a83ff9d, CT as $72abaeab4d80592f$export$78efe591171d7d45, YR as $76d00c5a4edb230a$export$76ccd210b9029917, KR as $76d00c5a4edb230a$export$816b5d811295e6bc, QR as $76d00c5a4edb230a$export$b59bdbef9ce70de2, ez as $76d00c5a4edb230a$export$f6f0c3fe4ec306ea, GR as $76d00c5a4edb230a$export$f850895b287ef28e, Mde as $b4f18e3395fe64d7$export$3d96ec278d3efce4, jde as $b4f18e3395fe64d7$export$3e41faf802a29e71, Ode as $b4f18e3395fe64d7$export$b2539bed5023c21c, iz as $b4f18e3395fe64d7$export$e51a686c67fdaa2d, Fde as $bd263d78e9bf3c56$export$f5c9f3c2c4054eec, uw as $ea3928288112382f$export$439d29a4e110a164, gR as $f2ff30fde7b014be$export$3ddf2d174ce01153, CR as $fe21c36db05242bb$export$a98f0dcb43a68a25, wR as $fe21c36db05242bb$export$d7b12c4107be0d61, _fe as $l, BA as ACCENT_CHOICES, fwe as AMANE_BRIDGE_CHECK_URL, Z$ as AMANE_BRIDGE_KEY, pwe as AMANE_BRIDGE_REBUILD_URL, On as ApiError, dW as ArtSlot, J as Button, JF as ButtonLink, Efe as Bx, Bt as CLOUD_LOCATIONS, Z1 as CLOUD_PROXY_HELP, pr as COLUMN_SORT, l1 as CONFIGURATION_KEY, tX as CONFIGURATION_URL, mwe as COOKIE_TEXT_LIMIT, X$ as COVER_JOB_KEY, gi as CREDENTIAL_STATE, K$ as CUSTOM_SOURCES_KEY, G$ as CUSTOM_SOURCES_URL, rV as Checkbox, nV as CheckboxGlyph, qB as ChevronSortDown, hZ as Chip, q2 as CloudDownloadDialog, zH as CollapseChevron, RH as CollapseRegion, p$ as CollectionSummary, Gve as DEFAULT_CATEGORY, Mn as DEFAULT_SORT, LQ as DIAGNOSTICS_KEY, Hye as DIRECTORY_TEMPLATE_ERROR, M0 as DISCOVERY_SORTS, V2 as DOWNLOADS_KEY, B2 as DOWNLOADS_URL, TY as DUPLICATES_KEY, cY as DataTableFooter, iY as DataTableFrame, sY as DataTableSort, KH as Disclosure, SDe as DownloadsPanel, cfe as E3, Kve as ENTITY_REVIEW_KINDS, Y1 as ENTRY_LINKS_HELP, X1 as ENTRY_LINKS_HINT, bfe as Ea, Lfe as EmptyFocusButton, Iz as EmptyState, WH as ErrorText, ghe as ExternalLink, cr as FEEDS_KEY, lX as FEED_SCHEDULE_KEY, xke as FLOW_LABEL_X, L3 as FLOW_VIEWBOX, or as FOLLOW_CHECK_KEY, ar as FOLLOW_CREDENTIALS_KEY, M8 as FOLLOW_INITIAL_RANGE_OPTIONS, ir as FOLLOW_MANAGE_KEY, sr as FOLLOW_RESOLVE_KEY, cX as FOLLOW_SCHEDULE_KEY, vhe as Fact, _he as FactList, GH as FieldLabel, R$ as Fieldset, L$ as FieldsetTitle, RF as FilterGlass, zF as FilterGlassRows, LF as FilterIconButton, VF as FilterPill, hhe as Footer, bz as Gg, UF as GlassPill, UH as Help, Dz as HintText, pke as IDLE_POLL_MS, Pve as IDLE_REPAIR, MF as IconButton, Mz as Input, jz as InputBase, dA as JAV_LAYOUTS, P0 as JAV_RECOMMENDATION_GRID, MX as JUNK_KEY, X3 as JavHeader, Ove as KEEP_LABELS, ur as LAYOUTS, J1 as LIBRARY_FOLDER_HELP, uH as LIBRARY_PROCESSING_KEY, qY as LINKS_KEY, JY as LINK_CHECK_KEY, mye as LINK_KINDS, YY as LINK_PRUNE_KEY, Cn as LOC, Ez as Label, V$ as LibraryProcessingCard, $z as LibraryShortcuts, xH as LinkButton, NH as LoadingDots, ufe as M6, yye as MEDIA_PROCESSING_KEY, dX as MEDIA_PROCESSING_URL, AY as MEDIA_REPAIR_KEY, kY as MEDIA_REPAIR_URL, Bn as MEDIA_SOURCES_KEY, No as MEDIA_SOURCE_ICONS, Rt as MEDIA_SOURCE_OPTIONS, ZB as MENU_ITEM, QB as MENU_ITEM_INTERACTIVE, XB as MENU_POPOVER_SURFACE, CH as MenuDialog, sG as MixCard, Nz as ModalFrame, Ev as MotionConfigContext, Tz as NR, Fz as Note, Nfe as OA, mX as ORGANIZE_KEY, _X as ORPHAN_RECORDS_KEY, yz as OV, fz as P7, ACe as PHASES, nX as PICK_FOLDER_URL, U$ as PLAYLISTS_KEY, mTe as POLICY_COLUMNS, gTe as POLICY_COVER_NOTE, hTe as POLICY_MATRIX, q1 as POLICY_SUMMARY, oY as Pagination, B$ as PathLine, rF as PillTabList, FH as Progress, FY as QUALITY_GOALS_KEY, j$ as REPAIR_CARD_TEXT, jY as REPAIR_LIBRARIES_KEY, SX as RESOURCE_APPLY_KEY, xX as RESOURCE_SCAN_KEY, UCe as RESULT_PANEL, WCe as RESULT_SECTION, Wve as REVIEW_CATEGORIES, jX as REVIEW_COUNTS_KEY, RY as REVIEW_KEY, zY as REVIEW_LABELS, uW as RetryNote, Mfe as Rf, phe as Rows, uwe as SCRAPING_CHECK_URL, J$ as SCRAPING_COVER_URL, Y$ as SCRAPING_KEY, lwe as SCRAPING_SETTINGS_URL, bU as SEGMENT, yU as SEGMENTED_TRACK, sX as SETTINGS_KEY, rX as SETTINGS_URL, Nn as SORT_DEFAULT_DIR, jn as SORT_OPTIONS, Vt as SOURCE_LABELS, c3 as STATS_KEY, fhe as Section, mhe as SectionSkeleton, vU as SegmentedRadioGroup, nge as SegmentedTabList, KU as Segments, aY as Select, dU as Select$1, p1 as SelectField, fU as SelectItem, Ck as SelectionDock, BH as SettingsCard, dhe as SettingsRow, VH as SettingsSectionLabel, She as SiteLabel, TU as SortDirectionIcon, JU as SortKeys, bQ as SourceAvatar, XH as SourceLabel, qH as SourceMark, HH as Stack, z$ as StatusLabel, P2 as Switch, dF as TASKS_KEY, nke as TASTE_REFRESH_KEY, rke as TASTE_WINDOWS, uX as THUMBNAIL_JOBS_KEY, PX as TRASH_KEY, Ile as TRIGGER_LABELS, YJ as Table, hY as TableColumnControls, gY as TableColumnResizer, vY as TableSelectionHeader, IH as TaskProgress, kz as TextField, Oz as TextFieldContext, vz as Un, _$ as WANTS_KEY, r4 as WantMagnets, Jf as WithPromise, pz as Wt, _z as Xc, wz as Xf, ffe as Xt, lfe as _8, o as __commonJSMin, s as __exportAll, l as __toESM, jfe as aB, qr as addAlias, Kr as addSource, y$ as addWant, V as apiGet, H as apiSend, iA as appSettingsStore, sbe as applyConfirmText, AX as applyLeftovers, obe as applyPlanText, lbe as applyText, cA as applyTheme, Zg as asNumber, Yye as attachOrphan, kr as authorAvatar, jr as authorGroups, Or as authorInitial, Dr as authorName, wq as autoResetPageIndex, La as avatarInner, m3 as bandRows, Uye as baseName, Nve as batchOperate, Ok as boundedPreference, Ave as bulkCloudPreferences, Bz as busyProps, Afe as cB, MDe as cachedMagnetStates, Rf as calcGeneratorVelocity, Qve as canApprove, lf as cancelFrame, ebe as candidateText, MH as cardClass, wA as cardRatio, gz as cc, fi as checkEvidenceGap, di as checkFailures, ni as checkFeeds, vye as checkLine, li as checkReceipt, ui as checkSummary, gwe as checkText, pi as checkedText, NW as clickedBlank, Sve as cloudLocations, O0 as cloudProxySkeleton, Dx as clsx, Cfe as cn, Wm as collectMotionValues, rJ as columnVisibilityFeature, WJ as column_getCanSort, BJ as column_getSortFn, Xve as commonReviewSources, sV as configurationSection, ske as configureTasteBrowser, xc as confirmModal, qK as copyInstancePropertiesWithoutMemos, Aa as coverUrl, Jq as createColumnHelper, rwe as createPlaylist, _i as credentialDone, w0 as credentialsSkeleton, sye as currentReviewRow, eF as cx, Sz as dZ, iye as decisionPayload, aye as decisionReceipt, rye as defaultChoice, awe as deletePlaylist, K1 as diagnosticsSkeleton, RCe as discoveryArtwork, w$ as discoveryKey, BTe as discoveryScore, Eve as distinctName, uye as dropReviewRows, si as dropSources, kfe as du, jve as duplicateVictims, vF as elapsedText, Ia as entityFaceImg, en as entityPath, Sr as errorHeadline, An as errorMessage, B as esc, Sq as expandRowModel, lz as f1, xr as feedIntervalText, e1 as fetchAmaneBridge, zr as fetchCheckJob, u1 as fetchConfiguration, $$ as fetchCoverJob, Rr as fetchCredentials, q$ as fetchCustomSources, RQ as fetchDiagnostics, T$ as fetchDiscoveries, DY as fetchDuplicates, jle as fetchEarlier, Sye as fetchFeedSchedule, $r as fetchFeeds, Lr as fetchFollow, xye as fetchFollowSchedule, IX as fetchJunkSummary, QY as fetchLinkCheck, $Y as fetchLinkPrune, ZY as fetchLinkStats, bye as fetchMediaProcessing, MY as fetchMediaRepair, Vn as fetchMediaSources, hX as fetchOrganize, Fye as fetchOrganizeExample, vX as fetchOrphanRecords, Qr as fetchPending, W$ as fetchPlaylists, IY as fetchQualityGoals, NY as fetchRepairLibraries, Br as fetchResolveJob, wX as fetchResourceApply, CX as fetchResourceScan, WY as fetchReview, FX as fetchReviewCounts, fX as fetchSettings, Q$ as fetchSources, l3 as fetchStats, Vr as fetchSuggestions, pF as fetchTasks, P3 as fetchTaste, cke as fetchTasteJob, Cye as fetchThumbnailJobs, LX as fetchTrashSummary, v$ as fetchWants, Jve as filterReviewRows, xn as firstGrapheme, pK as flexRender, Cke as flowGraph, wke as flowLabel, SOe as fmtCount, hn as fmtDur, _n as fmtSize, Gle as foldRoutine, ii as followFeedByName, lr as followSuggestKey, qle as followupDetail, cf as frame, $de as g4, oJ as getDefaultPaginationState, CA as gridLayout, Ar as groupByAuthor, Wle as groupFollowups, VY as groupReviewRows, ibe as hasChanges, TX as hasResourceRoots, hF as hasResultProblems, mke as historySpan, uz as i2, fke as importTasteExport, T0 as indexersSkeleton, Af as interpolate, x$ as invalidateWants, _F as isActive, br as isBroken, mr as isLayout, hh as isMotionValue, BY as isReviewCategory, Kle as isRoutine, E0 as javBrowserSkeleton, I0 as javContentSkeleton, gA as javLayout, F0 as javTagSkeleton, mbe as junkBreakdown, owe as keepPlaylist, _e as keepPreviousData, Pr as keepSelected, u3 as known, rfe as l7, Ule as latestOfKind, POe as lengthRows, Wn as localTime, ri as lookupFeedActor, ofe as m7, xz as mM, qt as mapLimit, Zr as markItem, h3 as max, MOe as mediumRows, Mle as mergeFinished, g3 as min, fye as mirrorText, Lve as missingToolText, OY as mixedCloudPreferences, EF as momentText, Ry as motion, Km as motionValue, Gye as organizeOutcome, Q0 as overlayHost, hr as pageSizeOf, Nr as pageWindow, In as paginationRange, oi as patchSource, YV as peachHistory, YV as peachHistory$1, nye as pendingGenres, wOe as percentText, Rye as pickOrganizeFolder, Wye as planSummary, d3 as playedFor, EOe as playedItemUrl, fF as pollInterval, ds as popCount, nwe as posterUrl, kW as previewLibraryColor, Lye as previewOrganize, Bve as previewUrl, Hle as problemDestination, yF as progressText, YH as providerIcon, _ye as pruneText, DX as purgeCount, Xye as purgeOrphan, Cz as pv, Ofe as qE, U as queryClient, dz as r2, bke as radarRows, kOe as radialArc, AOe as radialBarSize, OOe as radialCeiling, DOe as radialSlices, Bj as randomId, vke as rankDetail, yke as rankShares, p3 as reachedShare, xF as readableErrorHeadline, VTe as recommendationScore, cye as recordGenre, Qye as recordsText, swe as recreatePlaylist, ewe as refreshPlaylists, tl as relayoutCovers, ci as reloadFollowManage, dye as reloadReview, yTe as rememberShape, Bye as rememberTemplates, Jr as removeAlias, ti as removeFeed, Gr as removeSource, dke as removeTasteSource, b$ as removeWants, Yr as renameAliasGroup, iwe as renamePlaylist, IOe as replayRows, E as require_jsx_runtime, v as require_react, S as require_react_dom, IK as require_with_selector, NCe as resetWants, Fn as resolveFollowSort, Wf as resolveStartTime, twe as resumeAssetId, qve as reviewGroupingOptions, pbe as reviewSummary, Yve as reviewWindow, eye as rowEvidence, UY as rowFieldName, pJ as rowPaginationFeature, PJ as rowSelectionFeature, qJ as rowSortingFeature, HY as rowSubject, tye as rowTags, $ve as rowTitle, efe as s5, Xr as saveCredential, abe as scanLine, Oye as schedulePollInterval, FCe as searchNote, Zve as selectReviewRange, Fr as selectionState, ei as setFeedEnabled, Wr as setSourceEnabled, dV as settingsPath, Tve as sharedNamePrefix, XV as shellNavigate, y8 as showToast, sn as siteMarkUrl, oq as skipFirstRun, tF as sortCx, _r as sortLabel, Ht as sourceDefaultCost, hi as sourceIconUrl, cbe as sourceMeta, ns as spinnerHtml, Df as spring, Rz as spriteGlyph, Hr as startCheck, hye as startLinkCheck, gye as startLinkPrune, zye as startOrganize, Ur as startResolve, nbe as startResourceApply, tbe as startResourceScan, uke as startTasteRefresh, Rle as statusLabel, Ive as statusLine, yr as statusText, TA as storeJavLayout, oye as submitDecision, OF as summaryItems, Yq as tableFeatures, sq as tableMemo, Mr as tableRows, Vle as taskIssues, F3 as tasteDate, gke as tasteDimensions, hke as tasteHours, N3 as tasteKey, ake as tasteRefetchInterval, oke as tasteTime, Uu as time, gfe as tl, Ir as toggleGroup, I3 as topScores, yfe as uo, AH as useAction, RZ as useBackgroundJob, tu as useConstant, FF as useHorizontalScroller, nu as useIsomorphicLayoutEffect, jW as useLibraryTints, Ct as useMutation, iV as useOverlayScrollbar, St as useQuery, A as useQueryClient, Ay as useReducedMotion, Dye as useRunSchedule, Tye as useSaveFollowSchedule, pX as useSaveSettings, kye as useSaveThumbnailMode, JJ as useTable, dY as useTablePreferences, Mve as victimBytes, PCe as wantName, TOe as watchNote, f3 as watchedShare, Hs as wireHorizontalScroller, Vye as withOrganizeJob };-//# debugId=003e0830-a951-4549-8fe0-edbab82a74ef\ No newline at end of file+//# debugId=99032ff4-87c0-4448-9107-37f6c03224b8\ No newline at end of file