@tangle-network/agent-app 0.46.13 → 0.46.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assistant/index.js +1 -1
- package/dist/chat-react/index.js +1 -1
- package/dist/{chunk-5SSUCLBW.js → chunk-3PFKLSIZ.js} +3 -2
- package/dist/chunk-3PFKLSIZ.js.map +1 -0
- package/dist/{chunk-OOE2TPY2.js → chunk-TY2DALJG.js} +10 -1
- package/dist/chunk-TY2DALJG.js.map +1 -0
- package/dist/studio/generation.d.ts +6 -0
- package/dist/studio/index.js +3 -1
- package/dist/studio/ports.d.ts +3 -0
- package/dist/studio-react/index.js +108 -65
- package/dist/studio-react/index.js.map +1 -1
- package/dist/studio-react/studio-composer.d.ts +4 -1
- package/dist/studio-react/studio-generation-screen.d.ts +3 -1
- package/dist/studio-react/studio-home-screen.d.ts +3 -1
- package/dist/studio-react/use-vault-save-state.d.ts +9 -0
- package/dist/web-react/chat-composer.d.ts +5 -1
- package/dist/web-react/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5SSUCLBW.js.map +0 -1
- package/dist/chunk-OOE2TPY2.js.map +0 -1
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
generationAspectRatio,
|
|
10
10
|
generationBatchKey,
|
|
11
11
|
generationError,
|
|
12
|
+
generationSavedToVault,
|
|
12
13
|
generationSpecSegments,
|
|
13
14
|
generationStatus,
|
|
14
15
|
generationVaultPath,
|
|
@@ -34,7 +35,7 @@ import {
|
|
|
34
35
|
textToVideoSibling,
|
|
35
36
|
userSafeGenerationMessage,
|
|
36
37
|
validateCustomImageSize
|
|
37
|
-
} from "../chunk-
|
|
38
|
+
} from "../chunk-TY2DALJG.js";
|
|
38
39
|
import {
|
|
39
40
|
useInfiniteScroll
|
|
40
41
|
} from "../chunk-KKBTPZIE.js";
|
|
@@ -796,6 +797,7 @@ function StudioComposer({
|
|
|
796
797
|
onGenerated,
|
|
797
798
|
variant = "home",
|
|
798
799
|
pickReferenceImage,
|
|
800
|
+
sendTone = "contrast",
|
|
799
801
|
className
|
|
800
802
|
}) {
|
|
801
803
|
const [type, setType] = useState3("image");
|
|
@@ -1118,7 +1120,7 @@ function StudioComposer({
|
|
|
1118
1120
|
title: "Generate",
|
|
1119
1121
|
disabled: !canSubmit,
|
|
1120
1122
|
onClick: () => void generate(),
|
|
1121
|
-
className:
|
|
1123
|
+
className: `ml-auto inline-flex h-8 w-8 flex-none items-center justify-center rounded-full ${sendTone === "primary" ? "bg-primary text-primary-foreground" : "bg-foreground text-background"} transition ${sendTone === "primary" ? "hover:bg-primary/90" : "hover:opacity-90"} disabled:cursor-not-allowed disabled:opacity-40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-card`,
|
|
1122
1124
|
children: /* @__PURE__ */ jsx2(ArrowUp, { className: "h-4 w-4", strokeWidth: 2 })
|
|
1123
1125
|
}
|
|
1124
1126
|
)
|
|
@@ -1578,7 +1580,9 @@ function MediaTile({
|
|
|
1578
1580
|
const [saving, setSaving] = useState6(false);
|
|
1579
1581
|
const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(saveOpen, setSaveOpen);
|
|
1580
1582
|
const vaultPath = generationVaultPath(generation);
|
|
1583
|
+
const savedToVault = generationSavedToVault(generation);
|
|
1581
1584
|
const status = generationStatus(generation);
|
|
1585
|
+
const canSaveToVault = status === "succeeded" && !isLocalGeneration(generation);
|
|
1582
1586
|
const isSpeech = generation.type === "speech";
|
|
1583
1587
|
const isPlaying = isSpeech && playback.activeId === generation.id && playback.playing;
|
|
1584
1588
|
useEffect6(() => playback.registerPositionNode(generation.id, waveNode), [
|
|
@@ -1685,7 +1689,7 @@ function MediaTile({
|
|
|
1685
1689
|
children: /* @__PURE__ */ jsx6(Download, { size: 15, strokeWidth: 1.5 })
|
|
1686
1690
|
}
|
|
1687
1691
|
),
|
|
1688
|
-
!
|
|
1692
|
+
canSaveToVault && !savedToVault && actions?.save && /* @__PURE__ */ jsxs5("div", { ref: containerRef, children: [
|
|
1689
1693
|
/* @__PURE__ */ jsx6(
|
|
1690
1694
|
"button",
|
|
1691
1695
|
{
|
|
@@ -1714,7 +1718,7 @@ function MediaTile({
|
|
|
1714
1718
|
}
|
|
1715
1719
|
)
|
|
1716
1720
|
] }),
|
|
1717
|
-
vaultPath && actions?.vaultHref && /* @__PURE__ */ jsx6(
|
|
1721
|
+
savedToVault && vaultPath && actions?.vaultHref && /* @__PURE__ */ jsx6(
|
|
1718
1722
|
"a",
|
|
1719
1723
|
{
|
|
1720
1724
|
href: actions.vaultHref(vaultPath),
|
|
@@ -1731,7 +1735,7 @@ function MediaTile({
|
|
|
1731
1735
|
children: /* @__PURE__ */ jsx6(FolderOpen, { size: 15, strokeWidth: 1.5 })
|
|
1732
1736
|
}
|
|
1733
1737
|
),
|
|
1734
|
-
vaultPath && !actions?.vaultHref && actions?.onOpenVault && /* @__PURE__ */ jsx6(
|
|
1738
|
+
savedToVault && vaultPath && !actions?.vaultHref && actions?.onOpenVault && /* @__PURE__ */ jsx6(
|
|
1735
1739
|
"button",
|
|
1736
1740
|
{
|
|
1737
1741
|
type: "button",
|
|
@@ -1775,7 +1779,7 @@ function MediaTile({
|
|
|
1775
1779
|
children: isPlaying ? /* @__PURE__ */ jsx6(Pause, { size: 11, strokeWidth: 1.5, fill: "currentColor" }) : /* @__PURE__ */ jsx6(Play, { size: 11, strokeWidth: 1.5, fill: "currentColor" })
|
|
1776
1780
|
}
|
|
1777
1781
|
),
|
|
1778
|
-
vaultPath && /* @__PURE__ */ jsxs5("span", { className: "studio-chip-dark inline-flex h-5 items-center gap-1 rounded-full pl-1.5 pr-2 text-[11px]", children: [
|
|
1782
|
+
savedToVault && vaultPath && /* @__PURE__ */ jsxs5("span", { className: "studio-chip-dark inline-flex h-5 items-center gap-1 rounded-full pl-1.5 pr-2 text-[11px]", children: [
|
|
1779
1783
|
/* @__PURE__ */ jsx6(FolderOpen, { size: 12, strokeWidth: 1.5 }),
|
|
1780
1784
|
"In vault"
|
|
1781
1785
|
] })
|
|
@@ -2005,12 +2009,14 @@ function MediaViewerModal({
|
|
|
2005
2009
|
const ratio = generationAspectRatio(generation);
|
|
2006
2010
|
const status = generationStatus(generation);
|
|
2007
2011
|
const vaultPath = generationVaultPath(generation);
|
|
2012
|
+
const savedToVault = generationSavedToVault(generation);
|
|
2013
|
+
const canSaveToVault = status === "succeeded" && !isLocalGeneration(generation);
|
|
2008
2014
|
const metaSegments = [
|
|
2009
2015
|
TYPE_LABELS[generation.type] ?? generation.type,
|
|
2010
2016
|
generation.model,
|
|
2011
2017
|
...generationSpecSegments(generation),
|
|
2012
2018
|
generation.createdAt ? relativeTime(generation.createdAt) : null,
|
|
2013
|
-
vaultPath
|
|
2019
|
+
savedToVault ? vaultPath : null
|
|
2014
2020
|
].filter((segment) => typeof segment === "string" && segment.length > 0);
|
|
2015
2021
|
function onPanelKeyDown(event) {
|
|
2016
2022
|
if (event.key !== "Tab" || hasOpenPopover()) return;
|
|
@@ -2047,8 +2053,8 @@ function MediaViewerModal({
|
|
|
2047
2053
|
width: `min(100%, calc(70vh * ${ratio}))`,
|
|
2048
2054
|
aspectRatio: ratio
|
|
2049
2055
|
};
|
|
2050
|
-
const vaultHref = vaultPath && actions?.vaultHref ? actions.vaultHref(vaultPath) : null;
|
|
2051
|
-
const viewControl = vaultPath && (vaultHref || actions?.onOpenVault);
|
|
2056
|
+
const vaultHref = savedToVault && vaultPath && actions?.vaultHref ? actions.vaultHref(vaultPath) : null;
|
|
2057
|
+
const viewControl = savedToVault && vaultPath && (vaultHref || actions?.onOpenVault);
|
|
2052
2058
|
const modal = /* @__PURE__ */ jsx7(
|
|
2053
2059
|
"div",
|
|
2054
2060
|
{
|
|
@@ -2096,7 +2102,7 @@ function MediaViewerModal({
|
|
|
2096
2102
|
]
|
|
2097
2103
|
}
|
|
2098
2104
|
),
|
|
2099
|
-
!
|
|
2105
|
+
canSaveToVault && !savedToVault && actions?.save && /* @__PURE__ */ jsxs6("div", { ref: popover.containerRef, children: [
|
|
2100
2106
|
/* @__PURE__ */ jsxs6(
|
|
2101
2107
|
"button",
|
|
2102
2108
|
{
|
|
@@ -2153,10 +2159,10 @@ function MediaViewerModal({
|
|
|
2153
2159
|
|
|
2154
2160
|
// src/studio-react/studio-home-screen.tsx
|
|
2155
2161
|
import {
|
|
2156
|
-
useCallback as
|
|
2162
|
+
useCallback as useCallback9,
|
|
2157
2163
|
useEffect as useEffect11,
|
|
2158
|
-
useMemo as
|
|
2159
|
-
useState as
|
|
2164
|
+
useMemo as useMemo7,
|
|
2165
|
+
useState as useState11
|
|
2160
2166
|
} from "react";
|
|
2161
2167
|
|
|
2162
2168
|
// src/studio-react/studio-confirm.tsx
|
|
@@ -2476,6 +2482,33 @@ function useDeferredDelete(options) {
|
|
|
2476
2482
|
return { pendingIds, request, flush };
|
|
2477
2483
|
}
|
|
2478
2484
|
|
|
2485
|
+
// src/studio-react/use-vault-save-state.ts
|
|
2486
|
+
import { useCallback as useCallback8, useMemo as useMemo6, useState as useState10 } from "react";
|
|
2487
|
+
function useVaultSaveState(generations) {
|
|
2488
|
+
const [results, setResults] = useState10(() => /* @__PURE__ */ new Map());
|
|
2489
|
+
const savedGenerations = useMemo6(() => generations.map((generation) => {
|
|
2490
|
+
const result = results.get(generation.id);
|
|
2491
|
+
if (!result) return generation;
|
|
2492
|
+
return {
|
|
2493
|
+
...generation,
|
|
2494
|
+
metadata: {
|
|
2495
|
+
...generation.metadata,
|
|
2496
|
+
vaultPath: result.vaultPath,
|
|
2497
|
+
savedToVaultAt: result.savedToVaultAt ?? true
|
|
2498
|
+
}
|
|
2499
|
+
};
|
|
2500
|
+
}), [generations, results]);
|
|
2501
|
+
const applySaveResults = useCallback8((saved) => {
|
|
2502
|
+
if (saved.length === 0) return;
|
|
2503
|
+
setResults((current) => {
|
|
2504
|
+
const next = new Map(current);
|
|
2505
|
+
for (const result of saved) next.set(result.generationId, result);
|
|
2506
|
+
return next;
|
|
2507
|
+
});
|
|
2508
|
+
}, []);
|
|
2509
|
+
return { generations: savedGenerations, applySaveResults };
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2479
2512
|
// src/studio-react/studio-home-screen.tsx
|
|
2480
2513
|
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2481
2514
|
function StudioHomeScreen({
|
|
@@ -2485,33 +2518,36 @@ function StudioHomeScreen({
|
|
|
2485
2518
|
onOpenHistory,
|
|
2486
2519
|
workspaceId,
|
|
2487
2520
|
pickReferenceImage,
|
|
2521
|
+
sendTone,
|
|
2488
2522
|
actions,
|
|
2489
2523
|
recentLimit = 20,
|
|
2490
2524
|
className
|
|
2491
2525
|
}) {
|
|
2492
|
-
const [viewer, setViewer] =
|
|
2493
|
-
const [confirmTargets, setConfirmTargets] =
|
|
2526
|
+
const [viewer, setViewer] = useState11(null);
|
|
2527
|
+
const [confirmTargets, setConfirmTargets] = useState11(null);
|
|
2494
2528
|
const playback = useStudioPlayback();
|
|
2495
2529
|
const { toast } = useStudioToast();
|
|
2530
|
+
const { generations: savedGenerations, applySaveResults } = useVaultSaveState(generations);
|
|
2496
2531
|
const deferredDelete = useDeferredDelete({
|
|
2497
2532
|
remove: actions?.remove ?? (async () => {
|
|
2498
2533
|
})
|
|
2499
2534
|
});
|
|
2500
|
-
const navigateNewBatch = useBatchNavigation({ seed:
|
|
2501
|
-
const wrappedOnGenerated =
|
|
2535
|
+
const navigateNewBatch = useBatchNavigation({ seed: savedGenerations, onOpenGeneration });
|
|
2536
|
+
const wrappedOnGenerated = useCallback9((generation) => {
|
|
2502
2537
|
onGenerated(generation);
|
|
2503
2538
|
navigateNewBatch(generation);
|
|
2504
2539
|
}, [navigateNewBatch, onGenerated]);
|
|
2505
|
-
const visible =
|
|
2506
|
-
() =>
|
|
2507
|
-
[deferredDelete.pendingIds,
|
|
2540
|
+
const visible = useMemo7(
|
|
2541
|
+
() => savedGenerations.filter((generation) => !deferredDelete.pendingIds.has(generation.id)),
|
|
2542
|
+
[deferredDelete.pendingIds, savedGenerations]
|
|
2508
2543
|
);
|
|
2509
|
-
const renderedViewer = viewer ?
|
|
2544
|
+
const renderedViewer = viewer ? savedGenerations.find((generation) => generation.id === viewer.id) ?? viewer : null;
|
|
2510
2545
|
const requestDelete = actions?.remove ? (generation) => setConfirmTargets([generation]) : void 0;
|
|
2511
|
-
const onSaved =
|
|
2546
|
+
const onSaved = useCallback9((results) => {
|
|
2547
|
+
applySaveResults(results);
|
|
2512
2548
|
const first = results[0];
|
|
2513
2549
|
if (first) toast({ message: `Saved to vault \xB7 ${first.vaultPath}` });
|
|
2514
|
-
}, [toast]);
|
|
2550
|
+
}, [applySaveResults, toast]);
|
|
2515
2551
|
useEffect11(() => playback.stop, [playback.stop]);
|
|
2516
2552
|
function confirmDelete() {
|
|
2517
2553
|
const targets = confirmTargets;
|
|
@@ -2529,6 +2565,7 @@ function StudioHomeScreen({
|
|
|
2529
2565
|
variant: "home",
|
|
2530
2566
|
workspaceId,
|
|
2531
2567
|
pickReferenceImage,
|
|
2568
|
+
sendTone,
|
|
2532
2569
|
onGenerated: wrappedOnGenerated
|
|
2533
2570
|
}
|
|
2534
2571
|
)
|
|
@@ -2587,11 +2624,11 @@ function StudioHomeScreen({
|
|
|
2587
2624
|
// src/studio-react/studio-generation-screen.tsx
|
|
2588
2625
|
import { CircleAlert } from "lucide-react";
|
|
2589
2626
|
import {
|
|
2590
|
-
useCallback as
|
|
2627
|
+
useCallback as useCallback10,
|
|
2591
2628
|
useEffect as useEffect12,
|
|
2592
|
-
useMemo as
|
|
2629
|
+
useMemo as useMemo8,
|
|
2593
2630
|
useRef as useRef10,
|
|
2594
|
-
useState as
|
|
2631
|
+
useState as useState12
|
|
2595
2632
|
} from "react";
|
|
2596
2633
|
import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2597
2634
|
var FALLBACK_DOCK_HEIGHT = 190;
|
|
@@ -2608,6 +2645,7 @@ function StudioGenerationScreen({
|
|
|
2608
2645
|
onOpenGeneration,
|
|
2609
2646
|
workspaceId,
|
|
2610
2647
|
pickReferenceImage,
|
|
2648
|
+
sendTone,
|
|
2611
2649
|
actions,
|
|
2612
2650
|
className
|
|
2613
2651
|
}) {
|
|
@@ -2617,14 +2655,15 @@ function StudioGenerationScreen({
|
|
|
2617
2655
|
const { stop: stop2 } = useStudioPlayback();
|
|
2618
2656
|
const stopRef = useRef10(stop2);
|
|
2619
2657
|
stopRef.current = stop2;
|
|
2620
|
-
const [dockHeight, setDockHeight] =
|
|
2621
|
-
const [viewerId, setViewerId] =
|
|
2622
|
-
const [deleteTarget, setDeleteTarget] =
|
|
2658
|
+
const [dockHeight, setDockHeight] = useState12(FALLBACK_DOCK_HEIGHT);
|
|
2659
|
+
const [viewerId, setViewerId] = useState12(null);
|
|
2660
|
+
const [deleteTarget, setDeleteTarget] = useState12(null);
|
|
2661
|
+
const { generations: savedGenerations, applySaveResults } = useVaultSaveState(generations);
|
|
2623
2662
|
const remove = actions?.remove;
|
|
2624
2663
|
const { pendingIds, request } = useDeferredDelete({ remove: remove ?? noRemove });
|
|
2625
|
-
const rows =
|
|
2626
|
-
() => generationsInBatch(
|
|
2627
|
-
[batchKey,
|
|
2664
|
+
const rows = useMemo8(
|
|
2665
|
+
() => generationsInBatch(savedGenerations, batchKey).filter((row) => !pendingIds.has(row.id)),
|
|
2666
|
+
[batchKey, pendingIds, savedGenerations]
|
|
2628
2667
|
);
|
|
2629
2668
|
const first = rows[0];
|
|
2630
2669
|
const prompt = first?.prompt ?? "";
|
|
@@ -2635,12 +2674,13 @@ function StudioGenerationScreen({
|
|
|
2635
2674
|
const columns = rows.length === 4 ? 2 : Math.min(rows.length, 4) || 1;
|
|
2636
2675
|
const maxWidth = rows.length > 1 || first?.type === "speech" ? 820 : first?.type !== "image" ? 640 : ratio < 1 ? 380 : 408;
|
|
2637
2676
|
const viewerGeneration = viewerId ? rows.find((row) => row.id === viewerId) ?? null : null;
|
|
2638
|
-
const onSaved =
|
|
2677
|
+
const onSaved = useCallback10((results) => {
|
|
2678
|
+
applySaveResults(results);
|
|
2639
2679
|
const saved = results[0];
|
|
2640
2680
|
if (saved) toast({ message: `Saved to vault \xB7 ${saved.vaultPath}` });
|
|
2641
|
-
}, [toast]);
|
|
2681
|
+
}, [applySaveResults, toast]);
|
|
2642
2682
|
const navigateNewBatch = useBatchNavigation({ seed: [], currentBatchKey: batchKey, onOpenGeneration });
|
|
2643
|
-
const handleGenerated =
|
|
2683
|
+
const handleGenerated = useCallback10((generation) => {
|
|
2644
2684
|
onGenerated(generation);
|
|
2645
2685
|
navigateNewBatch(generation);
|
|
2646
2686
|
}, [navigateNewBatch, onGenerated]);
|
|
@@ -2762,6 +2802,7 @@ function StudioGenerationScreen({
|
|
|
2762
2802
|
variant: "docked",
|
|
2763
2803
|
workspaceId,
|
|
2764
2804
|
pickReferenceImage,
|
|
2805
|
+
sendTone,
|
|
2765
2806
|
onGenerated: handleGenerated
|
|
2766
2807
|
}
|
|
2767
2808
|
)
|
|
@@ -2792,10 +2833,10 @@ function StudioGenerationScreen({
|
|
|
2792
2833
|
|
|
2793
2834
|
// src/studio-react/studio-history-screen.tsx
|
|
2794
2835
|
import {
|
|
2795
|
-
useCallback as
|
|
2836
|
+
useCallback as useCallback12,
|
|
2796
2837
|
useEffect as useEffect14,
|
|
2797
|
-
useMemo as
|
|
2798
|
-
useState as
|
|
2838
|
+
useMemo as useMemo10,
|
|
2839
|
+
useState as useState14
|
|
2799
2840
|
} from "react";
|
|
2800
2841
|
import {
|
|
2801
2842
|
ArrowLeft,
|
|
@@ -2811,7 +2852,7 @@ import {
|
|
|
2811
2852
|
} from "lucide-react";
|
|
2812
2853
|
|
|
2813
2854
|
// src/studio-react/use-generation-history.ts
|
|
2814
|
-
import { useCallback as
|
|
2855
|
+
import { useCallback as useCallback11, useEffect as useEffect13, useMemo as useMemo9, useRef as useRef11, useState as useState13 } from "react";
|
|
2815
2856
|
function seedSignature(page) {
|
|
2816
2857
|
if (!page) return "";
|
|
2817
2858
|
return `${page.nextCursor ?? ""}|${page.items.map((item) => item.id).join(",")}`;
|
|
@@ -2823,14 +2864,14 @@ function useGenerationHistory({
|
|
|
2823
2864
|
initialPage
|
|
2824
2865
|
}) {
|
|
2825
2866
|
const startsFromSeed = q === "" && type === "all" && initialPage !== void 0;
|
|
2826
|
-
const [items, setItems] =
|
|
2827
|
-
const [nextCursor, setNextCursor] =
|
|
2867
|
+
const [items, setItems] = useState13(startsFromSeed ? initialPage.items : []);
|
|
2868
|
+
const [nextCursor, setNextCursor] = useState13(
|
|
2828
2869
|
startsFromSeed ? initialPage.nextCursor ?? null : null
|
|
2829
2870
|
);
|
|
2830
|
-
const [phase, setPhase] =
|
|
2871
|
+
const [phase, setPhase] = useState13(
|
|
2831
2872
|
startsFromSeed ? "idle" : "loadingFirst"
|
|
2832
2873
|
);
|
|
2833
|
-
const [reloadKey, setReloadKey] =
|
|
2874
|
+
const [reloadKey, setReloadKey] = useState13(0);
|
|
2834
2875
|
const seqRef = useRef11(0);
|
|
2835
2876
|
const resetAbortRef = useRef11(null);
|
|
2836
2877
|
const loadMoreAbortRef = useRef11(null);
|
|
@@ -2845,7 +2886,7 @@ function useGenerationHistory({
|
|
|
2845
2886
|
const seedRef = useRef11(initialPage);
|
|
2846
2887
|
seedRef.current = initialPage;
|
|
2847
2888
|
const isDefaultView = q === "" && type === "all";
|
|
2848
|
-
const seedKey =
|
|
2889
|
+
const seedKey = useMemo9(() => seedSignature(initialPage), [initialPage]);
|
|
2849
2890
|
useEffect13(() => {
|
|
2850
2891
|
resetAbortRef.current?.abort();
|
|
2851
2892
|
loadMoreAbortRef.current?.abort();
|
|
@@ -2889,7 +2930,7 @@ function useGenerationHistory({
|
|
|
2889
2930
|
})();
|
|
2890
2931
|
return () => controller.abort();
|
|
2891
2932
|
}, [q, type, seedKey, isDefaultView, reloadKey]);
|
|
2892
|
-
const loadMore =
|
|
2933
|
+
const loadMore = useCallback11(() => {
|
|
2893
2934
|
const cursor = nextCursorRef.current;
|
|
2894
2935
|
if (!cursor || loadingFirstRef.current || loadingMoreRef.current) return;
|
|
2895
2936
|
const current = viewRef.current;
|
|
@@ -2920,11 +2961,11 @@ function useGenerationHistory({
|
|
|
2920
2961
|
}
|
|
2921
2962
|
})();
|
|
2922
2963
|
}, []);
|
|
2923
|
-
const retry =
|
|
2964
|
+
const retry = useCallback11(() => {
|
|
2924
2965
|
if (lastOpRef.current === "more") loadMore();
|
|
2925
2966
|
else setReloadKey((key) => key + 1);
|
|
2926
2967
|
}, [loadMore]);
|
|
2927
|
-
const reload =
|
|
2968
|
+
const reload = useCallback11(() => {
|
|
2928
2969
|
setReloadKey((key) => key + 1);
|
|
2929
2970
|
}, []);
|
|
2930
2971
|
useEffect13(
|
|
@@ -2986,15 +3027,15 @@ function StudioHistoryScreen({
|
|
|
2986
3027
|
const playback = useStudioPlayback();
|
|
2987
3028
|
const { stop: stop2 } = playback;
|
|
2988
3029
|
const { toast } = useStudioToast();
|
|
2989
|
-
const [query, setQuery] =
|
|
2990
|
-
const [debouncedQuery, setDebouncedQuery] =
|
|
2991
|
-
const [type, setType] =
|
|
2992
|
-
const [selectMode, setSelectMode] =
|
|
2993
|
-
const [selected, setSelected] =
|
|
2994
|
-
const [viewer, setViewer] =
|
|
2995
|
-
const [confirmTargets, setConfirmTargets] =
|
|
2996
|
-
const [saveOpen, setSaveOpen] =
|
|
2997
|
-
const [savePending, setSavePending] =
|
|
3030
|
+
const [query, setQuery] = useState14("");
|
|
3031
|
+
const [debouncedQuery, setDebouncedQuery] = useState14("");
|
|
3032
|
+
const [type, setType] = useState14("all");
|
|
3033
|
+
const [selectMode, setSelectMode] = useState14(false);
|
|
3034
|
+
const [selected, setSelected] = useState14(() => /* @__PURE__ */ new Set());
|
|
3035
|
+
const [viewer, setViewer] = useState14(null);
|
|
3036
|
+
const [confirmTargets, setConfirmTargets] = useState14(null);
|
|
3037
|
+
const [saveOpen, setSaveOpen] = useState14(false);
|
|
3038
|
+
const [savePending, setSavePending] = useState14(false);
|
|
2998
3039
|
const savePopover = usePopover(saveOpen, setSaveOpen);
|
|
2999
3040
|
useEffect14(() => {
|
|
3000
3041
|
if (query === debouncedQuery) return;
|
|
@@ -3002,6 +3043,7 @@ function StudioHistoryScreen({
|
|
|
3002
3043
|
return () => window.clearTimeout(timer);
|
|
3003
3044
|
}, [debouncedQuery, query, searchDebounceMs]);
|
|
3004
3045
|
const history = useGenerationHistory({ fetchPage, q: debouncedQuery, type, initialPage });
|
|
3046
|
+
const { generations: savedGenerations, applySaveResults } = useVaultSaveState(history.items);
|
|
3005
3047
|
const deferredDelete = useDeferredDelete({
|
|
3006
3048
|
remove: actions?.remove ?? (async () => {
|
|
3007
3049
|
})
|
|
@@ -3009,11 +3051,11 @@ function StudioHistoryScreen({
|
|
|
3009
3051
|
// dropped them. A refetch here would only re-request the page we can see.
|
|
3010
3052
|
});
|
|
3011
3053
|
const { pendingIds } = deferredDelete;
|
|
3012
|
-
const rows =
|
|
3013
|
-
() =>
|
|
3014
|
-
[
|
|
3054
|
+
const rows = useMemo10(
|
|
3055
|
+
() => savedGenerations.filter((item) => !pendingIds.has(item.id)),
|
|
3056
|
+
[pendingIds, savedGenerations]
|
|
3015
3057
|
);
|
|
3016
|
-
const selectedRows =
|
|
3058
|
+
const selectedRows = useMemo10(() => rows.filter((row) => selected.has(row.id)), [rows, selected]);
|
|
3017
3059
|
useEffect14(() => {
|
|
3018
3060
|
if (history.isLoadingFirst || history.isLoadingMore || !playback.activeId) return;
|
|
3019
3061
|
if (rows.some((row) => row.id === playback.activeId) || viewer?.id === playback.activeId) return;
|
|
@@ -3022,12 +3064,12 @@ function StudioHistoryScreen({
|
|
|
3022
3064
|
const sentinelRef = useInfiniteScroll(history.loadMore, {
|
|
3023
3065
|
enabled: history.hasMore && !history.isLoadingMore && !history.isLoadingFirst && !history.isError
|
|
3024
3066
|
});
|
|
3025
|
-
const exitSelectMode =
|
|
3067
|
+
const exitSelectMode = useCallback12(() => {
|
|
3026
3068
|
setSelectMode(false);
|
|
3027
3069
|
setSelected(/* @__PURE__ */ new Set());
|
|
3028
3070
|
setSaveOpen(false);
|
|
3029
3071
|
}, []);
|
|
3030
|
-
const toggleSelect =
|
|
3072
|
+
const toggleSelect = useCallback12((id) => {
|
|
3031
3073
|
if (!selectMode) {
|
|
3032
3074
|
stop2();
|
|
3033
3075
|
setSelectMode(true);
|
|
@@ -3053,18 +3095,19 @@ function StudioHistoryScreen({
|
|
|
3053
3095
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
3054
3096
|
}, [confirmTargets, exitSelectMode, selectMode, viewer]);
|
|
3055
3097
|
useEffect14(() => () => stop2(), [stop2]);
|
|
3056
|
-
const clearFilters =
|
|
3098
|
+
const clearFilters = useCallback12(() => {
|
|
3057
3099
|
setQuery("");
|
|
3058
3100
|
setDebouncedQuery("");
|
|
3059
3101
|
setType("all");
|
|
3060
3102
|
}, []);
|
|
3061
|
-
const onSaved =
|
|
3103
|
+
const onSaved = useCallback12((results) => {
|
|
3104
|
+
applySaveResults(results);
|
|
3062
3105
|
const path = results[0]?.vaultPath;
|
|
3063
3106
|
if (!path) return;
|
|
3064
3107
|
toast({
|
|
3065
3108
|
message: results.length > 1 ? `Saved ${results.length} items to vault \xB7 ${path}` : `Saved to vault \xB7 ${path}`
|
|
3066
3109
|
});
|
|
3067
|
-
}, [toast]);
|
|
3110
|
+
}, [applySaveResults, toast]);
|
|
3068
3111
|
function batchDownload() {
|
|
3069
3112
|
void (actions?.download ?? downloadGenerationsViaAnchor)(selectedRows);
|
|
3070
3113
|
exitSelectMode();
|