@devries-cameron20 / t3code Mirror · read-only / commits / d5fb0b16f2
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 00:30 UTC

fix(web): keep snapshots quiet while disabled (#15638)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

maria committed Oct 20, 2026 at 02:48 UTC d5fb0b16f2f1289949424398886e819dfe8050c2
2 files changed +374 -36
apps/web/src/components/desktop/SnapShotCoordinator.browser.test.ts renamed
+341 -28
@@ -1,14 +1,23 @@
1 import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
2 import {
3 + type ClientSettings,
4 type DesktopPendingSnapShot,
5 + type DesktopSnapShotEvent,
6 + DEFAULT_CLIENT_SETTINGS,
7 EnvironmentId,
8 ProjectId,
9 ThreadId,
10 } from "@t3tools/contracts";
11 +import { act, createElement } from "react";
12 +import { createRoot, type Root } from "react-dom/client";
13 import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
14
15 import { DraftId, useComposerDraftStore } from "../../composerDraftStore";
16 import type { DesktopSnapShotBridge } from "../../lib/desktopSnapShot";
17 +import * as settings from "../../hooks/useSettings";
18 +import * as newThread from "../../hooks/useHandleNewThread";
19 +import * as snapShotSound from "../../lib/snapShotSound";
20 +import { toastManager } from "../ui/toast";
21 import {
22 beginSnapShotAnimationWhenReady,
23 deliverSnapShot,
@@ -16,6 +25,7 @@ import {
25 resolveExistingSnapShotTarget,
26 resolveSnapShotTargetOnce,
27 resolveSnapShotDeliveryTarget,
28 + SnapShotCoordinator,
29 } from "./SnapShotCoordinator";
30 import {
31 beginSnapShotAnimation,
@@ -25,6 +35,10 @@ import {
35 scheduleSnapShotAnimationDestination,
36 } from "../../lib/snapShotAnimation";
37
38 +vi.mock(import("../../hooks/useSettings"), { spy: true });
39 +vi.mock(import("../../hooks/useHandleNewThread"), { spy: true });
40 +vi.mock(import("../../lib/snapShotSound"), { spy: true });
41 +
42 const storage = vi.hoisted(() => {
43 const values = new Map<string, string>();
44 const storage = {
@@ -60,6 +74,7 @@ afterEach(() => {
74 dismissAllSnapShotAnimations();
75 vi.useRealTimers();
76 vi.unstubAllGlobals();
77 + vi.restoreAllMocks();
78 });
79
80 describe("window capture failures", () => {
@@ -68,19 +83,16 @@ describe("window capture failures", () => {
83 const pendingStarts = new Set<string>();
84 const soundedIds = new Set(["older", "newer"]);
85 const dismissSnapShotAnimation = vi.fn(async () => undefined);
71 - vi.stubGlobal("window", {
72 - localStorage: storage,
73 - desktopBridge: {
74 - requestSnapShotPermissions: vi.fn(),
75 - getSnapShotState: vi.fn(),
76 - checkSnapShotShortcut: vi.fn(),
77 - setSnapShotShortcutSuppressed: vi.fn(),
78 - listPendingSnapShots: vi.fn(),
79 - readSnapShot: vi.fn(),
80 - acknowledgeSnapShot: vi.fn(),
81 - onSnapShotEvent: vi.fn(() => () => undefined),
82 - dismissSnapShotAnimation,
83 - },
86 + vi.stubGlobal("desktopBridge", {
87 + requestSnapShotPermissions: vi.fn(),
88 + getSnapShotState: vi.fn(),
89 + checkSnapShotShortcut: vi.fn(),
90 + setSnapShotShortcutSuppressed: vi.fn(),
91 + listPendingSnapShots: vi.fn(),
92 + readSnapShot: vi.fn(),
93 + acknowledgeSnapShot: vi.fn(),
94 + onSnapShotEvent: vi.fn(() => () => undefined),
95 + dismissSnapShotAnimation,
96 });
97 await beginSnapShotAnimationWhenReady("older", Promise.resolve(target), pendingStarts);
98 await beginSnapShotAnimationWhenReady("newer", Promise.resolve(target), pendingStarts);
@@ -133,6 +145,305 @@ describe("window capture failures", () => {
145 });
146 });
147
148 +describe("pending snapshot processing", () => {
149 + const capture = {
150 + id: "12345678-1234-1234-1234-123456789abc",
151 + name: "window.png",
152 + mimeType: "image/png" as const,
153 + sizeBytes: 3,
154 + dataUrl: "data:image/png;base64,AQID",
155 + source: {
156 + kind: "snap-shot" as const,
157 + capturedAt: "2026-09-01T00:00:00.000Z",
158 + appName: "Editor",
159 + windowTitle: "main.ts",
160 + },
161 + };
162 + const target = scopeThreadRef(environmentId, ThreadId.make("enabled-thread"));
163 + let root: Root;
164 + let container: HTMLDivElement;
165 +
166 + function setup(routeThreadRef: typeof target | null = target) {
167 + let currentSettings = {
168 + ...DEFAULT_CLIENT_SETTINGS,
169 + snapShotEnabled: true,
170 + snapShotPlaySound: true,
171 + snapShotAnimations: false,
172 + };
173 + const listeners = new Set<(event: DesktopSnapShotEvent) => void>();
174 + let pending = [capture];
175 + const bridge = {
176 + requestSnapShotPermissions: vi.fn(),
177 + getSnapShotState: vi.fn(),
178 + checkSnapShotShortcut: vi.fn(),
179 + setSnapShotShortcutSuppressed: vi.fn(),
180 + onSnapShotEvent: vi.fn((listener: (event: DesktopSnapShotEvent) => void) => {
181 + listeners.add(listener);
182 + return () => listeners.delete(listener);
183 + }),
184 + listPendingSnapShots: vi.fn(async () => pending),
185 + readSnapShot: vi.fn(async () => capture),
186 + acknowledgeSnapShot: vi.fn(async (id: string) => {
187 + pending = pending.filter((item) => item.id !== id);
188 + }),
189 + };
190 + vi.spyOn(settings, "getClientSettings").mockImplementation(() => currentSettings);
191 + vi.spyOn(settings, "useClientSettings").mockImplementation(
192 + <T = ClientSettings>(selector?: (value: ClientSettings) => T) =>
193 + selector ? selector(currentSettings) : (currentSettings as T),
194 + );
195 + const route = {
196 + activeDraftThread: null,
197 + activeThread: null,
198 + defaultProjectRef: routeThreadRef ? projectRef : null,
199 + handleNewThread: vi.fn<ReturnType<typeof newThread.useHandleNewThread>["handleNewThread"]>(),
200 + routeDraftId: null,
201 + routeThreadRef,
202 + };
203 + vi.spyOn(newThread, "useHandleNewThread").mockImplementation(() => ({ ...route }));
204 + const sound = vi.spyOn(snapShotSound, "playSnapShotSound").mockImplementation(() => undefined);
205 + const toast = vi.spyOn(toastManager, "add").mockReturnValue("toast-id");
206 + vi.stubGlobal("desktopBridge", bridge);
207 + vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
208 + container = document.createElement("div");
209 + document.body.append(container);
210 + root = createRoot(container);
211 + const render = () => act(async () => root.render(createElement(SnapShotCoordinator)));
212 + return {
213 + bridge,
214 + route,
215 + sound,
216 + toast,
217 + render,
218 + setPending: (items: typeof pending) => {
219 + pending = items;
220 + },
221 + setEnabled: async (snapShotEnabled: boolean) => {
222 + currentSettings = { ...currentSettings, snapShotEnabled };
223 + await render();
224 + },
225 + emit: (event: DesktopSnapShotEvent) =>
226 + act(async () => {
227 + for (const listener of listeners) listener(event);
228 + }),
229 + };
230 + }
231 +
232 + afterEach(async () => {
233 + await act(async () => root?.unmount());
234 + container?.remove();
235 + });
236 +
237 + const focus = () =>
238 + act(async () => {
239 + window.dispatchEvent(new Event("focus"));
240 + });
241 +
242 + it("leaves captures untouched while disabled and resumes them when enabled again", async () => {
243 + const fixture = setup();
244 + const { bridge, sound, toast } = fixture;
245 + await fixture.setEnabled(false);
246 + await focus();
247 + await act(async () => {
248 + document.dispatchEvent(new Event("visibilitychange"));
249 + });
250 + expect(bridge.onSnapShotEvent).not.toHaveBeenCalled();
251 + expect(bridge.listPendingSnapShots).not.toHaveBeenCalled();
252 + expect(bridge.readSnapShot).not.toHaveBeenCalled();
253 + expect(sound).not.toHaveBeenCalled();
254 + expect(toast).not.toHaveBeenCalled();
255 +
256 + await fixture.setEnabled(true);
257 + await vi.waitFor(() =>
258 + expect(bridge.acknowledgeSnapShot).toHaveBeenCalledExactlyOnceWith(capture.id),
259 + );
260 + expect(useComposerDraftStore.getState().getComposerDraft(target)?.images).toHaveLength(1);
261 + expect(sound).toHaveBeenCalledOnce();
262 +
263 + await fixture.setEnabled(false);
264 + const another = { ...capture, id: "another-capture" };
265 + fixture.setPending([another]);
266 + bridge.listPendingSnapShots.mockClear();
267 + await fixture.emit({ type: "started", id: another.id });
268 + await fixture.emit({ type: "ready", id: another.id });
269 + await fixture.emit({ type: "failed", id: another.id });
270 + await focus();
271 + await act(async () => {
272 + document.dispatchEvent(new Event("visibilitychange"));
273 + });
274 + expect(bridge.listPendingSnapShots).not.toHaveBeenCalled();
275 + expect(bridge.getSnapShotState).not.toHaveBeenCalled();
276 + expect(bridge.readSnapShot).toHaveBeenCalledOnce();
277 + expect(sound).toHaveBeenCalledOnce();
278 + expect(toast).not.toHaveBeenCalled();
279 + });
280 +
281 + it("reports each pending capture failure once, allows a new failure kind, and resets after success", async () => {
282 + const fixture = setup(null);
283 + const { bridge, sound, toast, route } = fixture;
284 + await fixture.render();
285 + await focus();
286 + expect(toast).toHaveBeenCalledExactlyOnceWith(
287 + expect.objectContaining({
288 + title: "Snapshot taken, but no project is available",
289 + }),
290 + );
291 + expect(sound).toHaveBeenCalledOnce();
292 + expect(bridge.acknowledgeSnapShot).not.toHaveBeenCalled();
293 +
294 + route.routeThreadRef = target;
295 + bridge.readSnapShot.mockRejectedValue(new Error("Capture unavailable"));
296 + await fixture.render();
297 + await focus();
298 + await fixture.emit({ type: "ready", id: capture.id });
299 + expect(toast.mock.calls.map(([value]) => value.title)).toEqual([
300 + "Snapshot taken, but no project is available",
301 + "Snapshot failed",
302 + ]);
303 + expect(sound).toHaveBeenCalledOnce();
304 + expect(bridge.acknowledgeSnapShot).not.toHaveBeenCalled();
305 +
306 + route.routeThreadRef = null;
307 + await fixture.render();
308 + await focus();
309 + expect(toast).toHaveBeenCalledTimes(2);
310 + route.routeThreadRef = target;
311 + await fixture.render();
312 +
313 + bridge.readSnapShot.mockResolvedValue(capture);
314 + await focus();
315 + await vi.waitFor(() =>
316 + expect(bridge.acknowledgeSnapShot).toHaveBeenCalledExactlyOnceWith(capture.id),
317 + );
318 + expect(useComposerDraftStore.getState().getComposerDraft(target)?.images).toHaveLength(1);
319 + fixture.setPending([capture]);
320 + bridge.readSnapShot.mockRejectedValue(new Error("Capture unavailable again"));
321 + await focus();
322 + await focus();
323 + expect(sound).toHaveBeenCalledTimes(2);
324 + expect(toast.mock.calls.map(([value]) => value.title)).toEqual([
325 + "Snapshot taken, but no project is available",
326 + "Snapshot failed",
327 + "Snapshot failed",
328 + ]);
329 + });
330 +
331 + it("suppresses deferred failures while disabled and reports fresh failures after re-enable", async () => {
332 + const fixture = setup();
333 + const { bridge, sound, toast } = fixture;
334 + let rejectRead: ((error: Error) => void) | undefined;
335 + bridge.readSnapShot.mockReturnValueOnce(
336 + new Promise((_resolve, reject) => {
337 + rejectRead = reject;
338 + }),
339 + );
340 + await fixture.render();
341 + expect(bridge.readSnapShot).toHaveBeenCalledExactlyOnceWith(capture.id);
342 + await fixture.setEnabled(false);
343 + await act(async () => rejectRead?.(new Error("Capture unavailable")));
344 + expect(toast).not.toHaveBeenCalled();
345 + expect(bridge.acknowledgeSnapShot).not.toHaveBeenCalled();
346 +
347 + bridge.readSnapShot.mockRejectedValue(new Error("Capture unavailable"));
348 + await fixture.setEnabled(true);
349 + await focus();
350 + expect(toast).toHaveBeenCalledExactlyOnceWith(
351 + expect.objectContaining({ description: `Capture ${capture.id}: Capture unavailable` }),
352 + );
353 + expect(sound).toHaveBeenCalledOnce();
354 +
355 + await fixture.setEnabled(false);
356 + let rejectList: ((error: Error) => void) | undefined;
357 + bridge.listPendingSnapShots.mockReturnValueOnce(
358 + new Promise((_resolve, reject) => {
359 + rejectList = reject;
360 + }),
361 + );
362 + await fixture.setEnabled(true);
363 + await fixture.setEnabled(false);
364 + await act(async () => rejectList?.(new Error("Pending captures unavailable")));
365 + expect(toast).toHaveBeenCalledOnce();
366 +
367 + bridge.listPendingSnapShots.mockRejectedValueOnce(new Error("Pending captures unavailable"));
368 + await fixture.setEnabled(true);
369 + expect(toast).toHaveBeenCalledTimes(2);
370 + expect(toast).toHaveBeenLastCalledWith(
371 + expect.objectContaining({ description: "Pending captures unavailable" }),
372 + );
373 +
374 + fixture.setPending([]);
375 + let resolveState: ((state: { message: string }) => void) | undefined;
376 + bridge.getSnapShotState.mockReturnValueOnce(
377 + new Promise<{ message: string }>((resolve) => {
378 + resolveState = resolve;
379 + }),
380 + );
381 + await fixture.emit({ type: "failed", id: "native-capture" });
382 + expect(bridge.getSnapShotState).toHaveBeenCalledOnce();
383 + await fixture.setEnabled(false);
384 + await act(async () => resolveState?.({ message: "Native capture unavailable" }));
385 + expect(toast).toHaveBeenCalledTimes(2);
386 +
387 + bridge.getSnapShotState.mockResolvedValue({ message: "Native capture unavailable" });
388 + await fixture.setEnabled(true);
389 + await fixture.emit({ type: "failed", id: "native-capture" });
390 + expect(toast).toHaveBeenCalledTimes(3);
391 + expect(toast).toHaveBeenLastCalledWith(
392 + expect.objectContaining({ description: "Native capture unavailable" }),
393 + );
394 + expect(sound).toHaveBeenCalledOnce();
395 + expect(bridge.acknowledgeSnapShot).not.toHaveBeenCalled();
396 + });
397 +
398 + it("keeps a capture pending when disabled during target resolution, then retries on re-enable", async () => {
399 + const fixture = setup(null);
400 + const { bridge, route } = fixture;
401 + route.defaultProjectRef = projectRef;
402 + const draftId = DraftId.make("resolving-snapshot");
403 + const threadId = ThreadId.make("resolving-snapshot-thread");
404 + let resolveTarget: ((target: { draftId: DraftId; threadId: ThreadId }) => void) | undefined;
405 + const resolution = new Promise<{ draftId: DraftId; threadId: ThreadId }>((resolve) => {
406 + resolveTarget = resolve;
407 + });
408 + route.handleNewThread.mockReturnValue(resolution);
409 + await fixture.render();
410 + expect(route.handleNewThread).toHaveBeenCalledOnce();
411 + await fixture.setEnabled(false);
412 + await act(async () => {
413 + useComposerDraftStore.getState().setProjectDraftThreadId(projectRef, draftId, { threadId });
414 + resolveTarget?.({ draftId, threadId });
415 + });
416 + expect(bridge.readSnapShot).not.toHaveBeenCalled();
417 + expect(bridge.acknowledgeSnapShot).not.toHaveBeenCalled();
418 + expect(useComposerDraftStore.getState().getComposerDraft(draftId)?.images ?? []).toEqual([]);
419 + await fixture.setEnabled(true);
420 + await vi.waitFor(() =>
421 + expect(bridge.acknowledgeSnapShot).toHaveBeenCalledExactlyOnceWith(capture.id),
422 + );
423 + expect(useComposerDraftStore.getState().getComposerDraft(draftId)?.images).toHaveLength(1);
424 + });
425 +
426 + it("finishes and acknowledges delivery already reading when disabled", async () => {
427 + const fixture = setup();
428 + let finishReading: ((value: typeof capture) => void) | undefined;
429 + const reading = new Promise<typeof capture>((resolve) => {
430 + finishReading = resolve;
431 + });
432 + fixture.bridge.readSnapShot.mockReturnValue(reading);
433 + await fixture.render();
434 + expect(fixture.bridge.readSnapShot).toHaveBeenCalledExactlyOnceWith(capture.id);
435 + await fixture.setEnabled(false);
436 + await act(async () => {
437 + finishReading?.(capture);
438 + });
439 + await vi.waitFor(() =>
440 + expect(fixture.bridge.acknowledgeSnapShot).toHaveBeenCalledExactlyOnceWith(capture.id),
441 + );
442 + expect(useComposerDraftStore.getState().getComposerDraft(target)?.images).toHaveLength(1);
443 + expect(fixture.toast).not.toHaveBeenCalled();
444 + });
445 +});
446 +
447 describe("window capture delivery", () => {
448 it.each([
449 { target: DraftId.make("snap-shot-draft"), accessibleText: undefined },
@@ -190,20 +501,14 @@ describe("window capture delivery", () => {
501 ...(accessibleText ? { accessibleText } : {}),
502 },
503 };
193 - vi.stubGlobal("window", {
194 - localStorage: storage,
195 - desktopBridge: bridge,
196 - setTimeout,
197 - clearTimeout,
198 - matchMedia: () => ({ matches: false }),
199 - getComputedStyle: () => ({
200 - backgroundColor: "rgb(0, 0, 0)",
201 - borderTopColor: "rgb(255, 255, 255)",
202 - borderTopLeftRadius: "8px",
203 - borderTopWidth: "1px",
204 - }),
205 - dispatchEvent: vi.fn(),
206 - });
504 + vi.stubGlobal("desktopBridge", bridge);
505 + vi.spyOn(window, "matchMedia").mockReturnValue({ matches: false } as MediaQueryList);
506 + vi.spyOn(window, "getComputedStyle").mockReturnValue({
507 + backgroundColor: "rgb(0, 0, 0)",
508 + borderTopColor: "rgb(255, 255, 255)",
509 + borderTopLeftRadius: "8px",
510 + borderTopWidth: "1px",
511 + } as CSSStyleDeclaration);
512 vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => {
513 animationFrames.push(callback);
514 return animationFrames.length;
@@ -224,7 +529,16 @@ describe("window capture delivery", () => {
529 item.source,
530 );
531
532 + const persisted = new Promise<void>((resolve) => {
533 + const unsubscribe = useComposerDraftStore.subscribe((state) => {
534 + if (state.getComposerDraft(target)?.persistedAttachments.length) {
535 + unsubscribe();
536 + resolve();
537 + }
538 + });
539 + });
540 const delivery = deliverSnapShot(bridge, item, target);
541 + await persisted;
542 await vi.advanceTimersByTimeAsync(0);
543
544 const draft = useComposerDraftStore.getState().getComposerDraft(target);
@@ -314,7 +628,6 @@ describe("durable snapshot delivery", () => {
628 readSnapShot: async () => capture,
629 acknowledgeSnapShot,
630 } as unknown as DesktopSnapShotBridge;
317 - vi.stubGlobal("window", { localStorage: storage, dispatchEvent: vi.fn() });
631 const write = storage.setItem.getMockImplementation()!;
632 storage.setItem.mockImplementation(() => {
633 throw new Error("QuotaExceededError");
apps/web/src/components/desktop/SnapShotCoordinator.tsx
+33 -8
@@ -13,7 +13,7 @@ import {
13 } from "../../composerDraftStore";
14 import { useHandleNewThread } from "../../hooks/useHandleNewThread";
15 import { useStableCallback } from "../../hooks/useStableCallback";
16 -import { useClientSettings } from "../../hooks/useSettings";
16 +import { getClientSettings, useClientSettings } from "../../hooks/useSettings";
17 import { readThreadShell } from "../../state/entities";
18 import { compressImageToByteLimit, dataUrlToFile } from "../../lib/imageCompression";
19 import { resolveThreadActionProjectRef } from "../../lib/chatThreadActions";
@@ -37,6 +37,7 @@ import { readFileAsDataUrl } from "../ChatView.logic";
37 import { stackedThreadToast, toastManager } from "../ui/toast";
38
39 type CaptureTarget = DraftId | ScopedThreadRef;
40 +type CaptureFailure = "missing-project" | "delivery";
41
42 function isSameCaptureTarget(a: CaptureTarget, b: CaptureTarget): boolean {
43 if (typeof a === "string" || typeof b === "string") return a === b;
@@ -213,11 +214,13 @@ export function SnapShotCoordinator() {
214 settings.snapShotPlaySound ? settings.snapShotSound : null,
215 );
216 const animateCaptures = useClientSettings((settings) => settings.snapShotAnimations);
217 + const enabled = useClientSettings((settings) => settings.snapShotEnabled);
218 const captureTargetsRef = useRef(new Map<string, Promise<CaptureTarget | null>>());
219 const targetResolutionRef = useRef<Promise<CaptureTarget | null> | null>(null);
220 const drainingRef = useRef<Promise<void> | null>(null);
221 const rerunRequestedRef = useRef(false);
222 const soundedCaptureIdsRef = useRef(new Set<string>());
223 + const reportedCaptureFailuresRef = useRef(new Map<string, Set<CaptureFailure>>());
224 const pendingAnimationStartsRef = useRef(new Set<string>());
225
226 // Captures go to the last thread or draft on screen, even from routes that show neither.
@@ -280,7 +283,21 @@ export function SnapShotCoordinator() {
283 } catch {}
284 };
285
286 + const reportOnce = (
287 + id: string,
288 + failure: CaptureFailure,
289 + toast: Parameters<typeof toastManager.add>[0],
290 + ) => {
291 + if (!getClientSettings().snapShotEnabled) return;
292 + const failures = reportedCaptureFailuresRef.current.get(id) ?? new Set<CaptureFailure>();
293 + if (failures.has(failure)) return;
294 + failures.add(failure);
295 + reportedCaptureFailuresRef.current.set(id, failures);
296 + toastManager.add(toast);
297 + };
298 +
299 const drain = async () => {
300 + if (!getClientSettings().snapShotEnabled) return;
301 const bridge = getDesktopSnapShotBridge();
302 if (!bridge) return;
303 if (drainingRef.current) {
@@ -293,19 +310,22 @@ export function SnapShotCoordinator() {
310 rerunRequestedRef.current = false;
311 const pending = await bridge.listPendingSnapShots();
312 for (const item of pending) {
313 + if (!getClientSettings().snapShotEnabled) return;
314 playCaptureSound(item.id);
315 const capturedTarget = await resolveSnapShotDeliveryTarget(
316 captureTargetsRef.current,
317 item.id,
318 resolveCaptureTarget,
319 );
320 + if (!getClientSettings().snapShotEnabled) return;
321 const target = capturedTarget
322 ? resolveExistingSnapShotTarget(capturedTarget, routeThreadRef)
323 : null;
324 if (!target) {
325 await dismissSnapShotAnimation(item.id);
307 - soundedCaptureIdsRef.current.delete(item.id);
308 - toastManager.add(
326 + reportOnce(
327 + item.id,
328 + "missing-project",
329 stackedThreadToast({
330 type: "error",
331 title: "Snapshot taken, but no project is available",
@@ -319,10 +339,12 @@ export function SnapShotCoordinator() {
339 await deliverSnapShot(bridge, item, target);
340 captureTargetsRef.current.delete(item.id);
341 soundedCaptureIdsRef.current.delete(item.id);
342 + reportedCaptureFailuresRef.current.delete(item.id);
343 } catch (error) {
344 await dismissSnapShotAnimation(item.id);
324 - soundedCaptureIdsRef.current.delete(item.id);
325 - toastManager.add(
345 + reportOnce(
346 + item.id,
347 + "delivery",
348 stackedThreadToast({
349 type: "error",
350 title: "Snapshot failed",
@@ -333,10 +355,11 @@ export function SnapShotCoordinator() {
355 );
356 }
357 }
336 - } while (rerunRequestedRef.current);
358 + } while (rerunRequestedRef.current && getClientSettings().snapShotEnabled);
359 })()
360 .catch((error: unknown) => {
361 dismissAllSnapShotAnimations();
362 + if (!getClientSettings().snapShotEnabled) return;
363 toastManager.add(
364 stackedThreadToast({
365 type: "error",
@@ -357,6 +380,7 @@ export function SnapShotCoordinator() {
380 const drainPending = useEffectEvent(() => drain());
381 const handleSnapShotEvent = useEffectEvent(
382 (bridge: DesktopSnapShotBridge, event: DesktopSnapShotEvent) => {
383 + if (!getClientSettings().snapShotEnabled) return;
384 switch (event.type) {
385 case "requested": {
386 const current = readSettledTarget(readLastRouteTarget());
@@ -395,6 +419,7 @@ export function SnapShotCoordinator() {
419 pendingAnimationStartsRef.current,
420 );
421 void bridge.getSnapShotState().then((state) => {
422 + if (!getClientSettings().snapShotEnabled) return;
423 toastManager.add(
424 stackedThreadToast({
425 type: "error",
@@ -412,10 +437,10 @@ export function SnapShotCoordinator() {
437 );
438 useEffect(() => {
439 const bridge = getDesktopSnapShotBridge();
415 - if (!bridge) return;
440 + if (!bridge || !enabled) return;
441 void drainPending();
442 return bridge.onSnapShotEvent((event) => handleSnapShotEvent(bridge, event));
418 - }, []);
443 + }, [enabled]);
444
445 useEffect(() => {
446 const dismissOnBlur = () => {