whitebox-plugin-transfer-manager 0.1.0__py3-none-any.whl

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.
Files changed (29) hide show
  1. whitebox_plugin_transfer_manager/__init__.py +0 -0
  2. whitebox_plugin_transfer_manager/adapter.py +104 -0
  3. whitebox_plugin_transfer_manager/apps.py +14 -0
  4. whitebox_plugin_transfer_manager/jsx/TransferPanel.jsx +163 -0
  5. whitebox_plugin_transfer_manager/jsx/TransferServiceComponent.jsx +50 -0
  6. whitebox_plugin_transfer_manager/jsx/stores/transfer.js +63 -0
  7. whitebox_plugin_transfer_manager/jsx/stores/transfer.test.js +211 -0
  8. whitebox_plugin_transfer_manager/management/__init__.py +0 -0
  9. whitebox_plugin_transfer_manager/management/commands/__init__.py +0 -0
  10. whitebox_plugin_transfer_manager/management/commands/daemon_transfer_manager.py +198 -0
  11. whitebox_plugin_transfer_manager/manager.py +770 -0
  12. whitebox_plugin_transfer_manager/migrations/0001_initial.py +181 -0
  13. whitebox_plugin_transfer_manager/migrations/0002_transfer_retry_after_alter_transfer_max_retries.py +29 -0
  14. whitebox_plugin_transfer_manager/migrations/__init__.py +0 -0
  15. whitebox_plugin_transfer_manager/models.py +189 -0
  16. whitebox_plugin_transfer_manager/pyproject.toml +33 -0
  17. whitebox_plugin_transfer_manager/tasks.py +289 -0
  18. whitebox_plugin_transfer_manager/whitebox_plugin_transfer_manager.py +44 -0
  19. whitebox_plugin_transfer_manager-0.1.0.dist-info/LICENSE +661 -0
  20. whitebox_plugin_transfer_manager-0.1.0.dist-info/METADATA +168 -0
  21. whitebox_plugin_transfer_manager-0.1.0.dist-info/RECORD +29 -0
  22. whitebox_plugin_transfer_manager-0.1.0.dist-info/WHEEL +4 -0
  23. whitebox_plugin_transfer_manager-0.1.0.dist-info/entry_points.txt +3 -0
  24. whitebox_test_plugin_transfer_manager/__init__.py +3 -0
  25. whitebox_test_plugin_transfer_manager/test_daemon_transfer_manager.py +281 -0
  26. whitebox_test_plugin_transfer_manager/test_manager.py +607 -0
  27. whitebox_test_plugin_transfer_manager/test_models.py +99 -0
  28. whitebox_test_plugin_transfer_manager/test_plugin.py +41 -0
  29. whitebox_test_plugin_transfer_manager/test_tasks.py +528 -0
File without changes
@@ -0,0 +1,104 @@
1
+ import threading
2
+ from dataclasses import dataclass, field
3
+ from datetime import datetime
4
+ from pathlib import Path
5
+ from typing import Callable, Protocol, runtime_checkable
6
+
7
+
8
+ @dataclass
9
+ class RemoteFile:
10
+ """Represents a file on a remote device."""
11
+
12
+ path: str
13
+ size: int | None = None
14
+ created_at: datetime | None = None
15
+ checksum: str | None = None
16
+ metadata: dict = field(default_factory=dict)
17
+
18
+
19
+ @runtime_checkable
20
+ class TransferAdapter(Protocol):
21
+ """
22
+ Protocol for device-specific file transfer implementations.
23
+
24
+ Device plugins implement this to handle downloading and processing
25
+ files from their specific device types.
26
+ """
27
+
28
+ def list_files(self, device_connection) -> list[RemoteFile]:
29
+ """
30
+ List files available on device.
31
+
32
+ Args:
33
+ device_connection: DeviceConnection model instance
34
+
35
+ Returns:
36
+ List of RemoteFile objects representing available files
37
+ """
38
+ ...
39
+
40
+ def get_file_info(self, device_connection, path: str) -> RemoteFile:
41
+ """
42
+ Get metadata for a specific file on the device.
43
+
44
+ Args:
45
+ device_connection: DeviceConnection model instance
46
+ path: Path to file on device
47
+
48
+ Returns:
49
+ RemoteFile with metadata
50
+ """
51
+ ...
52
+
53
+ def download_file(
54
+ self,
55
+ device_connection,
56
+ source_path: str,
57
+ destination_path: Path,
58
+ progress_callback: Callable[[int, int | None], None],
59
+ cancel_event: threading.Event,
60
+ ) -> bool:
61
+ """
62
+ Download file from device with progress reporting.
63
+
64
+ Args:
65
+ device_connection: DeviceConnection model instance
66
+ source_path: Path on device
67
+ destination_path: Local path to save file
68
+ progress_callback: Called with (bytes_so_far, total_bytes)
69
+ cancel_event: Set when download should be aborted
70
+
71
+ Returns:
72
+ True on success, False on failure
73
+ """
74
+ ...
75
+
76
+ def supports_resume(self) -> bool:
77
+ """
78
+ Whether device supports HTTP range requests for resume.
79
+
80
+ Returns:
81
+ True if partial downloads can be resumed
82
+ """
83
+ ...
84
+
85
+ def process_file(
86
+ self,
87
+ source_path: Path,
88
+ destination_path: Path,
89
+ progress_callback: Callable[[int, str | None], None],
90
+ cancel_event: threading.Event,
91
+ ) -> bool:
92
+ """
93
+ Process downloaded file (transcode, stitch, etc.).
94
+
95
+ Args:
96
+ source_path: Path to downloaded raw file
97
+ destination_path: Path for processed output
98
+ progress_callback: Called with (percent_complete, step_description)
99
+ cancel_event: Set when processing should be aborted
100
+
101
+ Returns:
102
+ True on success, False on failure
103
+ """
104
+ ...
@@ -0,0 +1,14 @@
1
+ from django.apps import AppConfig
2
+
3
+ from plugin.registry import model_registry
4
+
5
+
6
+ class TransferManagerConfig(AppConfig):
7
+ default_auto_field = "django.db.models.BigAutoField"
8
+ name = "whitebox_plugin_transfer_manager"
9
+ verbose_name = "Transfer Manager"
10
+
11
+ def ready(self):
12
+ from .models import Transfer
13
+
14
+ model_registry.register("transfer.Transfer", Transfer)
@@ -0,0 +1,163 @@
1
+ import { useState } from "react";
2
+ import useTransferStore, { ACTIVE_STATUSES } from "./stores/transfer";
3
+
4
+ const { importWhiteboxComponent } = Whitebox;
5
+
6
+ const IconClose = importWhiteboxComponent("icons.close");
7
+ const IconChevronDown = importWhiteboxComponent("icons.chevron-down");
8
+ const IconChevronUp = importWhiteboxComponent("icons.chevron-up");
9
+
10
+ const formatSpeed = (bytesPerSec) => {
11
+ if (!bytesPerSec) return "";
12
+ if (bytesPerSec > 1024 * 1024) {
13
+ return `${(bytesPerSec / (1024 * 1024)).toFixed(1)} MB/s`;
14
+ }
15
+ if (bytesPerSec > 1024) {
16
+ return `${(bytesPerSec / 1024).toFixed(0)} KB/s`;
17
+ }
18
+ return `${bytesPerSec.toFixed(0)} B/s`;
19
+ };
20
+
21
+ const getFilename = (sourcePath) => {
22
+ if (!sourcePath) return "Unknown";
23
+ return sourcePath.split("/").pop();
24
+ };
25
+
26
+ const getProgress = (transfer) => {
27
+ const status = transfer.status_display;
28
+ if (status === "Download Started") return transfer.download_percent || 0;
29
+ if (status === "Processing Started") return transfer.processing_percent || 0;
30
+ if (status === "Download Completed" || status === "Processing Completed") return 100;
31
+ return 0;
32
+ };
33
+
34
+ const getPhaseLabel = (status) => {
35
+ switch (status) {
36
+ case "Pending": return "Queued";
37
+ case "Download Started": return "Downloading";
38
+ case "Download Completed": return "Downloaded";
39
+ case "Processing Started": return "Processing";
40
+ case "Processing Completed": return "Complete";
41
+ case "Failed": return "Failed";
42
+ case "Cancelled": return "Cancelled";
43
+ case "Paused": return "Paused";
44
+ default: return status;
45
+ }
46
+ };
47
+
48
+ const TransferItem = ({ transfer }) => {
49
+ const filename = getFilename(transfer.source_path);
50
+ const status = transfer.status_display;
51
+ const label = getPhaseLabel(status);
52
+ const progress = getProgress(transfer);
53
+ const isActive = ACTIVE_STATUSES.includes(status);
54
+ const isFailed = status === "Failed";
55
+ const isComplete = status === "Processing Completed";
56
+ const showSpeed = status === "Download Started" && transfer.download_speed;
57
+
58
+ return (
59
+ <div className="px-5 py-3">
60
+ <div className="flex items-center justify-between">
61
+ <span className="text-sm font-medium truncate flex-1 mr-3" title={filename}>
62
+ {filename}
63
+ </span>
64
+ <span className={`text-xs whitespace-nowrap ${
65
+ isFailed ? "text-error" :
66
+ isComplete ? "text-success" :
67
+ "text-gray-4"
68
+ }`}>
69
+ {label}
70
+ {showSpeed && ` \u00b7 ${formatSpeed(transfer.download_speed)}`}
71
+ </span>
72
+ </div>
73
+
74
+ {isActive && (
75
+ <div className="mt-2 w-full bg-gray-6 rounded-full h-1.5">
76
+ <div
77
+ className={`h-1.5 rounded-full transition-all duration-500 ${
78
+ status === "Processing Started" ? "bg-warning" : "bg-surface-primary"
79
+ }`}
80
+ style={{ width: `${progress}%` }}
81
+ />
82
+ </div>
83
+ )}
84
+ </div>
85
+ );
86
+ };
87
+
88
+ const TransferPanel = () => {
89
+ const transfers = useTransferStore((state) => state.transfers);
90
+ const activeCount = useTransferStore((state) => state.activeCount);
91
+ const dismissAll = useTransferStore((state) => state.dismissAll);
92
+ const [minimized, setMinimized] = useState(false);
93
+ const allDone = activeCount === 0;
94
+
95
+ const transferList = Object.values(transfers).sort((a, b) => {
96
+ if (!a.queued_at || !b.queued_at) return 0;
97
+ return new Date(b.queued_at) - new Date(a.queued_at);
98
+ });
99
+
100
+ if (transferList.length === 0) return null;
101
+
102
+ return (
103
+ <div
104
+ className="fixed bottom-6 right-4 z-50 bg-white rounded-2xl overflow-hidden"
105
+ style={{
106
+ width: 360,
107
+ maxHeight: minimized ? "auto" : 320,
108
+ boxShadow: "0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04)",
109
+ }}
110
+ >
111
+ {/* Header */}
112
+ <div
113
+ className="flex items-center justify-between px-5 py-3.5 cursor-pointer select-none"
114
+ onClick={() => setMinimized(!minimized)}
115
+ >
116
+ <span className="text-base font-bold">
117
+ Transfers
118
+ {activeCount > 0 && (
119
+ <span className="font-normal text-gray-3 ml-1.5 text-sm">
120
+ {activeCount} active
121
+ </span>
122
+ )}
123
+ </span>
124
+ <div className="flex items-center gap-1">
125
+ {allDone && (
126
+ <button
127
+ className="text-gray-3 hover:text-gray-1 p-0.5"
128
+ onClick={(e) => { e.stopPropagation(); dismissAll(); }}
129
+ title="Dismiss"
130
+ >
131
+ <IconClose
132
+ width={20}
133
+ height={20}
134
+ className="fill-gray-3"
135
+ />
136
+ </button>
137
+ )}
138
+ <span className="text-gray-3">
139
+ {minimized
140
+ ? <IconChevronUp width={20} height={20} className="fill-gray-3" />
141
+ : <IconChevronDown width={20} height={20} className="fill-gray-3" />
142
+ }
143
+ </span>
144
+ </div>
145
+ </div>
146
+
147
+ {/* Transfer list */}
148
+ {!minimized && (
149
+ <div
150
+ className="overflow-y-auto divide-y divide-gray-6 border-t border-gray-5"
151
+ style={{ maxHeight: 260 }}
152
+ >
153
+ {transferList.map((transfer) => (
154
+ <TransferItem key={transfer.id} transfer={transfer} />
155
+ ))}
156
+ </div>
157
+ )}
158
+ </div>
159
+ );
160
+ };
161
+
162
+ export { TransferPanel };
163
+ export default TransferPanel;
@@ -0,0 +1,50 @@
1
+ import { useEffect } from "react";
2
+ import useTransferStore from "./stores/transfer";
3
+
4
+ const { importWhiteboxStateStore, withStateStore } = Whitebox;
5
+
6
+ const TransferServiceComponentToWrap = () => {
7
+ const upsertTransfer = useTransferStore((state) => state.upsertTransfer);
8
+ const useMissionControlStore = importWhiteboxStateStore("flight.mission-control");
9
+ const fetchFlightSessions = useMissionControlStore(
10
+ (state) => state.fetchFlightSessions
11
+ );
12
+
13
+ useEffect(() => {
14
+ const removeListener = Whitebox.sockets.addEventListener(
15
+ "management",
16
+ "message",
17
+ (event) => {
18
+ const data = JSON.parse(event.data);
19
+
20
+ if (!data.type?.startsWith("observation.transfer.")) return;
21
+
22
+ upsertTransfer(data.data);
23
+
24
+ const filename =
25
+ data.data?.source_path?.split("/").pop() || "file";
26
+
27
+ if (data.type === "observation.transfer.download.started") {
28
+ Whitebox.toasts.info(`Downloading ${filename}...`);
29
+ } else if (data.type === "observation.transfer.processing.completed") {
30
+ Whitebox.toasts.success(`Transfer complete: ${filename}`);
31
+ fetchFlightSessions();
32
+ } else if (data.type.endsWith(".failed")) {
33
+ Whitebox.toasts.error(`Transfer failed: ${filename}`);
34
+ }
35
+ }
36
+ );
37
+
38
+ return removeListener;
39
+ }, []);
40
+
41
+ return null;
42
+ };
43
+
44
+ const TransferServiceComponent = withStateStore(
45
+ TransferServiceComponentToWrap,
46
+ ["flight.mission-control"]
47
+ );
48
+
49
+ export { TransferServiceComponent };
50
+ export default TransferServiceComponent;
@@ -0,0 +1,63 @@
1
+ import { create } from "zustand";
2
+
3
+ const ACTIVE_STATUSES = [
4
+ "Download Started",
5
+ "Download Completed",
6
+ "Processing Started",
7
+ ];
8
+
9
+ const COMPLETED_STATUSES = [
10
+ "Processing Completed",
11
+ ];
12
+
13
+ const createTransferSlice = (set, get) => ({
14
+ transfers: {},
15
+ activeCount: 0,
16
+
17
+ upsertTransfer: (data) => {
18
+ set((state) => {
19
+ const transfers = { ...state.transfers, [data.id]: data };
20
+ const activeCount = Object.values(transfers).filter((t) =>
21
+ ACTIVE_STATUSES.includes(t.status_display)
22
+ ).length;
23
+ return { transfers, activeCount };
24
+ });
25
+ },
26
+
27
+ removeTransfer: (id) => {
28
+ set((state) => {
29
+ const transfers = { ...state.transfers };
30
+ delete transfers[id];
31
+ const activeCount = Object.values(transfers).filter((t) =>
32
+ ACTIVE_STATUSES.includes(t.status_display)
33
+ ).length;
34
+ return { transfers, activeCount };
35
+ });
36
+ },
37
+
38
+ clearCompleted: () => {
39
+ set((state) => {
40
+ const transfers = {};
41
+ for (const [id, transfer] of Object.entries(state.transfers)) {
42
+ if (!COMPLETED_STATUSES.includes(transfer.status_display)) {
43
+ transfers[id] = transfer;
44
+ }
45
+ }
46
+ const activeCount = Object.values(transfers).filter((t) =>
47
+ ACTIVE_STATUSES.includes(t.status_display)
48
+ ).length;
49
+ return { transfers, activeCount };
50
+ });
51
+ },
52
+
53
+ dismissAll: () => {
54
+ set({ transfers: {}, activeCount: 0 });
55
+ },
56
+ });
57
+
58
+ const useTransferStore = create((...a) => ({
59
+ ...createTransferSlice(...a),
60
+ }));
61
+
62
+ export { ACTIVE_STATUSES, COMPLETED_STATUSES };
63
+ export default useTransferStore;
@@ -0,0 +1,211 @@
1
+ import useTransferStore, { ACTIVE_STATUSES, COMPLETED_STATUSES } from "./transfer";
2
+
3
+ describe("useTransferStore", () => {
4
+ beforeEach(() => {
5
+ useTransferStore.setState({ transfers: {}, activeCount: 0 });
6
+ });
7
+
8
+ describe("Initial State", () => {
9
+ test("should have empty transfers and zero activeCount", () => {
10
+ const state = useTransferStore.getState();
11
+
12
+ expect(state.transfers).toEqual({});
13
+ expect(state.activeCount).toBe(0);
14
+ });
15
+
16
+ test("should have all required methods", () => {
17
+ const state = useTransferStore.getState();
18
+
19
+ expect(typeof state.upsertTransfer).toBe("function");
20
+ expect(typeof state.removeTransfer).toBe("function");
21
+ expect(typeof state.clearCompleted).toBe("function");
22
+ expect(typeof state.dismissAll).toBe("function");
23
+ });
24
+ });
25
+
26
+ describe("Constants", () => {
27
+ test("ACTIVE_STATUSES should contain expected values", () => {
28
+ expect(ACTIVE_STATUSES).toContain("Download Started");
29
+ expect(ACTIVE_STATUSES).toContain("Download Completed");
30
+ expect(ACTIVE_STATUSES).toContain("Processing Started");
31
+ expect(ACTIVE_STATUSES).toHaveLength(3);
32
+ });
33
+
34
+ test("COMPLETED_STATUSES should contain expected values", () => {
35
+ expect(COMPLETED_STATUSES).toContain("Processing Completed");
36
+ expect(COMPLETED_STATUSES).toHaveLength(1);
37
+ });
38
+ });
39
+
40
+ describe("upsertTransfer", () => {
41
+ test("should add a new transfer", () => {
42
+ const { upsertTransfer } = useTransferStore.getState();
43
+
44
+ upsertTransfer({
45
+ id: "t1",
46
+ status_display: "Pending",
47
+ source_path: "/DCIM/file.insv",
48
+ });
49
+
50
+ const state = useTransferStore.getState();
51
+ expect(Object.keys(state.transfers)).toHaveLength(1);
52
+ expect(state.transfers["t1"].source_path).toBe("/DCIM/file.insv");
53
+ });
54
+
55
+ test("should update an existing transfer", () => {
56
+ const { upsertTransfer } = useTransferStore.getState();
57
+
58
+ upsertTransfer({ id: "t1", status_display: "Pending" });
59
+ upsertTransfer({ id: "t1", status_display: "Download Started" });
60
+
61
+ const state = useTransferStore.getState();
62
+ expect(Object.keys(state.transfers)).toHaveLength(1);
63
+ expect(state.transfers["t1"].status_display).toBe("Download Started");
64
+ });
65
+
66
+ test("should preserve other transfers on update", () => {
67
+ const { upsertTransfer } = useTransferStore.getState();
68
+
69
+ upsertTransfer({ id: "t1", status_display: "Pending" });
70
+ upsertTransfer({ id: "t2", status_display: "Pending" });
71
+ upsertTransfer({ id: "t1", status_display: "Download Started" });
72
+
73
+ const state = useTransferStore.getState();
74
+ expect(Object.keys(state.transfers)).toHaveLength(2);
75
+ expect(state.transfers["t2"].status_display).toBe("Pending");
76
+ });
77
+
78
+ test("should recalculate activeCount for active transfer", () => {
79
+ const { upsertTransfer } = useTransferStore.getState();
80
+
81
+ upsertTransfer({ id: "t1", status_display: "Download Started" });
82
+
83
+ const state = useTransferStore.getState();
84
+ expect(state.activeCount).toBe(1);
85
+ });
86
+
87
+ test("should not count completed transfers as active", () => {
88
+ const { upsertTransfer } = useTransferStore.getState();
89
+
90
+ upsertTransfer({ id: "t1", status_display: "Processing Completed" });
91
+
92
+ const state = useTransferStore.getState();
93
+ expect(state.activeCount).toBe(0);
94
+ });
95
+
96
+ test("should count all active statuses correctly", () => {
97
+ const { upsertTransfer } = useTransferStore.getState();
98
+
99
+ upsertTransfer({ id: "t1", status_display: "Download Started" });
100
+ upsertTransfer({ id: "t2", status_display: "Download Completed" });
101
+ upsertTransfer({ id: "t3", status_display: "Processing Started" });
102
+
103
+ const state = useTransferStore.getState();
104
+ expect(state.activeCount).toBe(3);
105
+ });
106
+
107
+ test("should decrement activeCount when status changes to inactive", () => {
108
+ const { upsertTransfer } = useTransferStore.getState();
109
+
110
+ upsertTransfer({ id: "t1", status_display: "Download Started" });
111
+ expect(useTransferStore.getState().activeCount).toBe(1);
112
+
113
+ upsertTransfer({ id: "t1", status_display: "Processing Completed" });
114
+ expect(useTransferStore.getState().activeCount).toBe(0);
115
+ });
116
+ });
117
+
118
+ describe("removeTransfer", () => {
119
+ test("should remove a transfer by id", () => {
120
+ const { upsertTransfer, removeTransfer } = useTransferStore.getState();
121
+
122
+ upsertTransfer({ id: "t1", status_display: "Pending" });
123
+ upsertTransfer({ id: "t2", status_display: "Pending" });
124
+ removeTransfer("t1");
125
+
126
+ const state = useTransferStore.getState();
127
+ expect(Object.keys(state.transfers)).toHaveLength(1);
128
+ expect(state.transfers["t1"]).toBeUndefined();
129
+ expect(state.transfers["t2"]).toBeDefined();
130
+ });
131
+
132
+ test("should be a noop for unknown id", () => {
133
+ const { upsertTransfer, removeTransfer } = useTransferStore.getState();
134
+
135
+ upsertTransfer({ id: "t1", status_display: "Pending" });
136
+ removeTransfer("nonexistent");
137
+
138
+ const state = useTransferStore.getState();
139
+ expect(Object.keys(state.transfers)).toHaveLength(1);
140
+ });
141
+
142
+ test("should recalculate activeCount after removal", () => {
143
+ const { upsertTransfer, removeTransfer } = useTransferStore.getState();
144
+
145
+ upsertTransfer({ id: "t1", status_display: "Download Started" });
146
+ upsertTransfer({ id: "t2", status_display: "Processing Started" });
147
+ expect(useTransferStore.getState().activeCount).toBe(2);
148
+
149
+ removeTransfer("t1");
150
+ expect(useTransferStore.getState().activeCount).toBe(1);
151
+ });
152
+ });
153
+
154
+ describe("clearCompleted", () => {
155
+ test("should remove only completed transfers", () => {
156
+ const { upsertTransfer, clearCompleted } = useTransferStore.getState();
157
+
158
+ upsertTransfer({ id: "t1", status_display: "Download Started" });
159
+ upsertTransfer({ id: "t2", status_display: "Processing Completed" });
160
+ upsertTransfer({ id: "t3", status_display: "Failed" });
161
+
162
+ clearCompleted();
163
+
164
+ const state = useTransferStore.getState();
165
+ expect(Object.keys(state.transfers)).toHaveLength(2);
166
+ expect(state.transfers["t1"]).toBeDefined();
167
+ expect(state.transfers["t2"]).toBeUndefined();
168
+ expect(state.transfers["t3"]).toBeDefined();
169
+ });
170
+
171
+ test("should be a noop when no completed transfers", () => {
172
+ const { upsertTransfer, clearCompleted } = useTransferStore.getState();
173
+
174
+ upsertTransfer({ id: "t1", status_display: "Download Started" });
175
+ upsertTransfer({ id: "t2", status_display: "Failed" });
176
+
177
+ clearCompleted();
178
+
179
+ const state = useTransferStore.getState();
180
+ expect(Object.keys(state.transfers)).toHaveLength(2);
181
+ });
182
+
183
+ test("should recalculate activeCount correctly", () => {
184
+ const { upsertTransfer, clearCompleted } = useTransferStore.getState();
185
+
186
+ upsertTransfer({ id: "t1", status_display: "Download Started" });
187
+ upsertTransfer({ id: "t2", status_display: "Processing Completed" });
188
+
189
+ clearCompleted();
190
+
191
+ const state = useTransferStore.getState();
192
+ expect(state.activeCount).toBe(1);
193
+ });
194
+ });
195
+
196
+ describe("dismissAll", () => {
197
+ test("should clear everything", () => {
198
+ const { upsertTransfer, dismissAll } = useTransferStore.getState();
199
+
200
+ upsertTransfer({ id: "t1", status_display: "Download Started" });
201
+ upsertTransfer({ id: "t2", status_display: "Processing Completed" });
202
+ upsertTransfer({ id: "t3", status_display: "Failed" });
203
+
204
+ dismissAll();
205
+
206
+ const state = useTransferStore.getState();
207
+ expect(state.transfers).toEqual({});
208
+ expect(state.activeCount).toBe(0);
209
+ });
210
+ });
211
+ });