@devries-cameron20 / t3code-1 / commits / c2cfe59ac3
Fork 0

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

fix(web): defer browser discovery in integrations (#9797)

Zortos committed Sep 6, 2026 at 00:59 UTC c2cfe59ac356768deb2a7d3e3461c715aa50a7a1
2 files changed +66 -6
apps/web/src/components/settings/IntegrationsSettings.test.tsx new
+65
@@ -0,0 +1,65 @@
1 +import { DEFAULT_CLIENT_SETTINGS, DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts";
2 +import { act, StrictMode, type ReactNode } from "react";
3 +import { create, type ReactTestRenderer } from "react-test-renderer";
4 +import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
5 +
6 +const { listBrowserImportSources } = vi.hoisted(() => ({
7 + listBrowserImportSources: vi.fn().mockResolvedValue([]),
8 +}));
9 +
10 +vi.mock("../preview/previewBridge", () => ({
11 + previewBridge: { listBrowserImportSources },
12 +}));
13 +vi.mock("../../env", () => ({ isElectron: true }));
14 +vi.mock("../../state/environments", () => ({
15 + useEnvironments: () => ({ environments: [], isReady: true }),
16 + usePrimaryEnvironment: () => null,
17 +}));
18 +vi.mock("../../hooks/useSettings", () => ({
19 + PRIMARY_SETTINGS_UNAVAILABLE_MESSAGE: "Connect to an environment",
20 + useClientSettings: (selector: (settings: typeof DEFAULT_CLIENT_SETTINGS) => unknown) =>
21 + selector(DEFAULT_CLIENT_SETTINGS),
22 + useClientSettingsHydrated: () => true,
23 + usePrimarySettingsAvailable: () => true,
24 + usePrimarySettings: () => DEFAULT_UNIFIED_SETTINGS,
25 + useUpdatePrimarySettings: () => vi.fn(),
26 +}));
27 +vi.mock("./settingsLayout", async (importOriginal) => ({
28 + ...(await importOriginal<typeof import("./settingsLayout")>()),
29 + SettingsPageContainer: ({ children }: { children: ReactNode }) => children,
30 +}));
31 +
32 +import { IntegrationsSettingsPanel } from "./IntegrationsSettings";
33 +
34 +let renderer: ReactTestRenderer | undefined;
35 +
36 +beforeEach(() => {
37 + vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
38 + listBrowserImportSources.mockClear();
39 +});
40 +
41 +afterEach(async () => {
42 + await act(() => renderer?.unmount());
43 + vi.unstubAllGlobals();
44 +});
45 +
46 +async function openSettings() {
47 + await act(() => {
48 + renderer = create(
49 + <StrictMode>
50 + <IntegrationsSettingsPanel />
51 + </StrictMode>,
52 + );
53 + });
54 +}
55 +
56 +describe("Integrations browser discovery", () => {
57 + it("does not scan browser files when entering or revisiting settings", async () => {
58 + await openSettings();
59 + expect(listBrowserImportSources).not.toHaveBeenCalled();
60 +
61 + await act(() => renderer?.unmount());
62 + await openSettings();
63 + expect(listBrowserImportSources).not.toHaveBeenCalled();
64 + });
65 +});
apps/web/src/components/settings/IntegrationsSettings.tsx
+1 -6
@@ -36,7 +36,7 @@ import {
36 } from "@t3tools/contracts";
37 import { PREVIEW_VIEWPORT_PRESETS } from "@t3tools/shared/previewViewport";
38 import { InfoIcon, MoreVertical, Plus as PlusIcon } from "lucide-react";
39 -import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
39 +import { useCallback, useRef, useState, type ReactNode } from "react";
40
41 import { ScreenRotationIcon } from "~/browser/ScreenRotationIcon";
42 import { resolveEnvironmentOptionLabel } from "~/components/BranchToolbar.logic";
@@ -804,11 +804,6 @@ function BrowserProfilesSetting({ disabled }: { readonly disabled: boolean }) {
804 .catch(() => setSources((previous) => previous ?? []));
805 }, []);
806
807 - // Loaded once so the first open is instant instead of flashing a spinner.
808 - useEffect(() => {
809 - loadSources();
810 - }, [loadSources]);
811 -
807 // Runs one import for the wizard. A new profile is registered only once the
808 // import succeeds — the cookies land in its partition first — so a blocked
809 // attempt never leaves an empty profile behind.