Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

IntegrationsSettings.tsx

1,351 lines50.9 KB

1import { useScopedSettings, useUpdateScopedSettings } from "./useScopedSettings";
2import { ScopedSwitch } from "./ScopedSwitch";
3import { DeviceHostsSettings } from "./DeviceHostsSettings";
4/**
5 * Integrations settings - preferences for surfaces T3 Code embeds rather than
6 * owns. Browser is the first section: the defaults a preview tab opens at,
7 * applied to both hand-opened tabs and agent `preview_open` calls that don't
8 * state their own size.
9 *
10 * @module IntegrationsSettings
11 */
12import {
13 BrowserImportFailureReason,
14 BROWSER_PROFILE_MAX_COUNT,
15 type BrowserLinkTarget,
16 type BrowserProfile,
17 type EnvironmentId,
18 BROWSER_PROFILE_NAME_MAX_LENGTH,
19 BROWSER_RECORDING_FRAME_RATES,
20 DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW,
21 DEFAULT_BROWSER_PROFILE_ID,
22 DEFAULT_BROWSER_LINK_TARGET,
23 DEFAULT_BROWSER_RECORDING_FRAME_RATE,
24 DEFAULT_BROWSER_VIEWPORT,
25 DEFAULT_PREVIEW_APPEARANCE,
26 DEFAULT_PREVIEW_ZOOM_FACTOR,
27 FILL_PREVIEW_VIEWPORT,
28 PREVIEW_VIEWPORT_MAX_AREA,
29 PREVIEW_VIEWPORT_MAX_DIMENSION,
30 PREVIEW_VIEWPORT_MIN_DIMENSION,
31 PREVIEW_ZOOM_LEVELS,
32 findBrowserProfile,
33 isBuiltInBrowserProfileId,
34 resolveBrowserProfiles,
35 type BrowserImportSource,
36 type PreviewAppearancePreference,
37 type PreviewViewportSetting,
38} from "@t3tools/contracts";
39import { PREVIEW_VIEWPORT_PRESETS } from "@t3tools/shared/previewViewport";
40import { MoreVertical, Plus as PlusIcon } from "lucide-react";
41import { useCallback, useRef, useState } from "react";
42​
43import { ScreenRotationIcon } from "~/browser/ScreenRotationIcon";
44import { AnimatedHeight } from "~/components/AnimatedHeight";
45import { resolveEnvironmentOptionLabel } from "~/components/BranchToolbar.logic";
46import { previewBridge } from "~/components/preview/previewBridge";
47import { cn, randomUUID } from "~/lib/utils";
48import { useEnvironments, usePrimaryEnvironment } from "~/state/environments";
49import { deviceEnvironment, useDeviceState } from "~/state/device";
50import { useAtomCommand } from "~/state/use-atom-command";
51import {
52 AgentDeviceSetupStatus,
53 DeviceHubSetupStatus,
54 PlatformStatus,
55 platformSetupStatus,
56 deviceHubDescription,
57 agentDeviceDescription,
58} from "~/components/device/DeviceSetup";
59import { isElectron } from "../../env";
60​
61import { Badge } from "../ui/badge";
62import {
63 Menu,
64 MenuGroup,
65 MenuGroupLabel,
66 MenuItem,
67 MenuPopup,
68 MenuSeparator,
69 MenuTrigger,
70} from "../ui/menu";
71import { readLocalApi } from "~/localApi";
72​
73import { toastManager } from "../ui/toast";
74import {
75 AlertDialog,
76 AlertDialogClose,
77 AlertDialogDescription,
78 AlertDialogFooter,
79 AlertDialogHeader,
80 AlertDialogPopup,
81 AlertDialogTitle,
82} from "../ui/alert-dialog";
83import { Button } from "../ui/button";
84import { DraftInput } from "../ui/draft-input";
85import { NumberField, NumberFieldGroup, NumberFieldInput } from "../ui/number-field";
86import {
87 Select,
88 SelectGroup,
89 SelectGroupLabel,
90 SelectItem,
91 SelectPopup,
92 SelectTrigger,
93 SelectValue,
94} from "../ui/select";
95import { Switch } from "../ui/switch";
96import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
97import {
98 getClientSettings,
99 persistClientSettingsUpdate,
100 useClientSettings,
101 useClientSettingsHydrated,
102 useUpdatePrimarySettings,
103} from "~/hooks/useSettings";
104​
105import {
106 SettingsUnavailableGroup,
107 SettingResetButton,
108 SettingsPageContainer,
109 SettingsRow,
110 SettingsSection,
111} from "./settingsLayout";
112import { searchableSetting } from "./settingsSearch";
113import { ProjectDefaultsSettings } from "./ProjectDefaultsSettings";
114import { useSettingsScope } from "./SettingsScopeContext";
115import { BrowserImportWizard, type WizardTarget } from "./BrowserImportWizard";
116import type { ImportOutcome } from "./browserImportWizard.logic";
117​
118const FILL_VALUE = "fill";
119const RESPONSIVE_VALUE = "responsive";
120​
121type BrowserProfileDataBridge = Pick<
122 NonNullable<typeof previewBridge>,
123 "clearCookies" | "clearCache"
124>;
125​
126export async function clearBrowserProfileData(
127 bridge: BrowserProfileDataBridge | null,
128 environmentIds: ReadonlyArray<EnvironmentId>,
129 profileId: string,
130): Promise<void> {
131 if (bridge === null || environmentIds.length === 0) {
132 throw new Error("Browser profile data is not available to clear.");
133 }
134 await Promise.all(
135 environmentIds.flatMap((environmentId) => [
136 bridge.clearCookies(environmentId, profileId),
137 bridge.clearCache(environmentId, profileId),
138 ]),
139 );
141​
142export function browserProfileRemovalAvailable(
143 bridgeAvailable: boolean,
144 environmentsReady: boolean,
145 environmentCount: number,
146): boolean {
147 return bridgeAvailable && environmentsReady && environmentCount > 0;
149​
150/**
151 * The size a "Responsive" default falls back to when the user switches away
152 * from Fill and hasn't typed dimensions yet. Fill has no dimensions to carry
153 * over, so the picker needs something concrete to seed the inputs with.
154 */
155const RESPONSIVE_SEED_SIZE = { width: 1280, height: 800 } as const;
156​
157const NO_GROUPING: Intl.NumberFormatOptions = { useGrouping: false };
158​
159const APPEARANCE_LABELS: Readonly<Record<PreviewAppearancePreference, string>> = {
160 system: "System",
161 light: "Light",
162 dark: "Dark",
163};
164​
165const zoomLabel = (zoomFactor: number) => `${Math.round(zoomFactor * 100)}%`;
166​
167/**
168 * IPC flattens the failure to its message, so the reason token travels inside
169 * it. Anything unrecognised reads as a plain read failure rather than leaking
170 * the raw message into a toast.
171 */
172/** Thrown from the post-import settings updater when the cap was hit meanwhile. */
173class ProfileLimitReachedError extends Error {
174 constructor() {
175 super("Browser profile limit reached.");
176 this.name = "ProfileLimitReachedError";
177 }
179​
180export const importFailureReason = (cause: unknown): BrowserImportFailureReason => {
181 const message = String((cause as { message?: unknown } | undefined)?.message ?? "");
182 return (
183 BrowserImportFailureReason.literals.find((reason) => message.includes(`failed: ${reason}.`)) ??
184 "readFailed"
185 );
186};
187​
188const viewportSelectValue = (viewport: PreviewViewportSetting): string => {
189 if (viewport._tag === "fill") return FILL_VALUE;
190 if (
191 viewport._tag === "preset" &&
192 PREVIEW_VIEWPORT_PRESETS.some((preset) => preset.id === viewport.presetId)
193 ) {
194 return viewport.presetId;
195 }
196 return RESPONSIVE_VALUE;
197};
198​
199/**
200 * The trigger renders this rather than a bare `SelectValue`, which would fall
201 * back to printing the raw stored value ("fill") because the options are built
202 * inline instead of from an `items` map.
203 */
204const viewportSelectLabel = (viewport: PreviewViewportSetting): string => {
205 const value = viewportSelectValue(viewport);
206 if (value === FILL_VALUE) return "Fill panel";
207 if (value === RESPONSIVE_VALUE) return "Responsive";
208 return PREVIEW_VIEWPORT_PRESETS.find((preset) => preset.id === value)?.label ?? "Responsive";
209};
210​
211const isValidDimension = (value: number) =>
212 Number.isInteger(value) &&
213 value >= PREVIEW_VIEWPORT_MIN_DIMENSION &&
214 value <= PREVIEW_VIEWPORT_MAX_DIMENSION;
215​
216/**
217 * A sized viewport with width and height swapped. Presets keep their identity
218 * through a rotation — `resolvePreviewViewport` already stores rotated presets
219 * as the preset id plus swapped dimensions — so a rotated iPad is still an
220 * iPad, not an anonymous custom size.
221 */
222const rotateViewport = (
223 viewport: Exclude<PreviewViewportSetting, { readonly _tag: "fill" }>,
224): PreviewViewportSetting => ({
225 ...viewport,
226 width: viewport.height,
227 height: viewport.width,
228});
229​
230function BrowserViewportSetting({ disabled }: { readonly disabled: boolean }) {
231 const viewport = useClientSettings((settings) => settings.browserDefaultViewport);
232 const updateSettings = useUpdatePrimarySettings();
233​
234 const sized = viewport._tag === "fill" ? null : viewport;
235 const presentedSize = {
236 width: sized?.width ?? RESPONSIVE_SEED_SIZE.width,
237 height: sized?.height ?? RESPONSIVE_SEED_SIZE.height,
238 };
239​
240 const selectViewport = (value: string | null) => {
241 if (value === FILL_VALUE) {
242 updateSettings({ browserDefaultViewport: FILL_PREVIEW_VIEWPORT });
243 return;
244 }
245 if (value === RESPONSIVE_VALUE) {
246 updateSettings({
247 browserDefaultViewport: {
248 _tag: "freeform",
249 width: sized?.width ?? RESPONSIVE_SEED_SIZE.width,
250 height: sized?.height ?? RESPONSIVE_SEED_SIZE.height,
251 },
252 });
253 return;
254 }
255 const preset = PREVIEW_VIEWPORT_PRESETS.find((candidate) => candidate.id === value);
256 if (!preset) return;
257 updateSettings({
258 browserDefaultViewport: {
259 _tag: "preset",
260 width: preset.width,
261 height: preset.height,
262 presetId: preset.id,
263 },
264 });
265 };
266​
267 // Committed on blur rather than per keystroke: typing "2560" passes through
268 // "256", which is a legal dimension, so an onValueChange handler would
269 // persist that intermediate size and churn the settings file on every key.
270 const commitDimension = (axis: "width" | "height", value: number | null) => {
271 if (value === null || !isValidDimension(value)) return;
272 const next = { ...presentedSize, [axis]: value };
273 if (next.width * next.height > PREVIEW_VIEWPORT_MAX_AREA) return;
274 if (sized && next.width === sized.width && next.height === sized.height) return;
275 // Typing a size means the preset no longer describes it.
276 updateSettings({ browserDefaultViewport: { _tag: "freeform", ...next } });
277 };
278​
279 return (
280 <SettingsRow
281 {...searchableSetting("browser-default-viewport")}
282 description="Tab size for you and agents. Fill fits the panel; other sizes show the device toolbar."
283 resetAction={
284 !disabled && viewport._tag !== DEFAULT_BROWSER_VIEWPORT._tag ? (
285 <SettingResetButton
286 label="default browser viewport"
287 onClick={() => updateSettings({ browserDefaultViewport: DEFAULT_BROWSER_VIEWPORT })}
288 />
289 ) : null
290 }
291 control={
292 <div className="flex w-full flex-wrap items-center justify-end gap-2 sm:w-auto">
293 <Select
294 value={viewportSelectValue(viewport)}
295 onValueChange={selectViewport}
296 disabled={disabled}
297 >
298 <SelectTrigger
299 size="sm"
300 className="w-full min-w-0 sm:w-44"
301 aria-label="Default browser viewport"
302 >
303 <SelectValue>{viewportSelectLabel(viewport)}</SelectValue>
304 </SelectTrigger>
305 <SelectPopup align="end" alignItemWithTrigger={false} className="min-w-64">
306 <SelectItem value={FILL_VALUE}>Fill panel</SelectItem>
307 <SelectItem value={RESPONSIVE_VALUE}>Responsive</SelectItem>
308 <SelectGroup>
309 <SelectGroupLabel>Standard</SelectGroupLabel>
310 {PREVIEW_VIEWPORT_PRESETS.map((preset) => (
311 <SelectItem key={preset.id} value={preset.id}>
312 <span className="flex w-full items-center justify-between gap-5">
313 <span>{preset.label}</span>
314 <span className="text-xs tabular-nums text-muted-foreground">
315 {preset.detail}
316 </span>
317 </span>
318 </SelectItem>
319 ))}
320 </SelectGroup>
321 </SelectPopup>
322 </Select>
323​
324 {sized ? (
325 <div className="flex min-w-0 items-center gap-1">
326 <NumberField
327 value={presentedSize.width}
328 min={PREVIEW_VIEWPORT_MIN_DIMENSION}
329 max={PREVIEW_VIEWPORT_MAX_DIMENSION}
330 disabled={disabled}
331 // Pixel counts read as raw numbers; grouping would show "1,024".
332 format={NO_GROUPING}
333 size="sm"
334 className="w-20"
335 onValueCommitted={(value) => commitDimension("width", value)}
336 >
337 <NumberFieldGroup>
338 <NumberFieldInput aria-label="Default viewport width" />
339 </NumberFieldGroup>
340 </NumberField>
341 <span className="text-xs text-muted-foreground">×</span>
342 <NumberField
343 value={presentedSize.height}
344 min={PREVIEW_VIEWPORT_MIN_DIMENSION}
345 max={PREVIEW_VIEWPORT_MAX_DIMENSION}
346 disabled={disabled}
347 format={NO_GROUPING}
348 size="sm"
349 className="w-20"
350 onValueCommitted={(value) => commitDimension("height", value)}
351 >
352 <NumberFieldGroup>
353 <NumberFieldInput aria-label="Default viewport height" />
354 </NumberFieldGroup>
355 </NumberField>
356 <Tooltip>
357 <TooltipTrigger
358 render={
359 <Button
360 size="icon-sm"
361 variant="ghost-muted"
362 disabled={disabled}
363 aria-label={`Rotate to ${
364 presentedSize.height >= presentedSize.width ? "landscape" : "portrait"
365 }`}
366 onClick={() =>
367 updateSettings({ browserDefaultViewport: rotateViewport(sized) })
368 }
369 >
370 <ScreenRotationIcon />
371 </Button>
372 }
373 />
374 <TooltipPopup side="top">Rotate</TooltipPopup>
375 </Tooltip>
376 </div>
377 ) : null}
378 </div>
379 }
380 />
381 );
383​
384function BrowserZoomSetting({ disabled }: { readonly disabled: boolean }) {
385 const zoomFactor = useClientSettings((settings) => settings.browserDefaultZoomFactor);
386 const updateSettings = useUpdatePrimarySettings();
387​
388 return (
389 <SettingsRow
390 {...searchableSetting("browser-default-zoom")}
391 description="Page zoom applied to new browser tabs."
392 resetAction={
393 !disabled && zoomFactor !== DEFAULT_PREVIEW_ZOOM_FACTOR ? (
394 <SettingResetButton
395 label="default browser zoom"
396 onClick={() =>
397 updateSettings({ browserDefaultZoomFactor: DEFAULT_PREVIEW_ZOOM_FACTOR })
398 }
399 />
400 ) : null
401 }
402 control={
403 <Select
404 disabled={disabled}
405 value={String(zoomFactor)}
406 onValueChange={(value) => {
407 const next = PREVIEW_ZOOM_LEVELS.find((level) => String(level) === value);
408 if (next !== undefined) updateSettings({ browserDefaultZoomFactor: next });
409 }}
410 >
411 <SelectTrigger size="sm" className="w-full sm:w-40" aria-label="Default browser zoom">
412 <SelectValue>{zoomLabel(zoomFactor)}</SelectValue>
413 </SelectTrigger>
414 <SelectPopup align="end" alignItemWithTrigger={false}>
415 {PREVIEW_ZOOM_LEVELS.map((level) => (
416 <SelectItem hideIndicator key={level} value={String(level)}>
417 {zoomLabel(level)}
418 </SelectItem>
419 ))}
420 </SelectPopup>
421 </Select>
422 }
423 />
424 );
426​
427function BrowserAppearanceSetting({ disabled }: { readonly disabled: boolean }) {
428 const appearance = useClientSettings((settings) => settings.browserDefaultAppearance);
429 const updateSettings = useUpdatePrimarySettings();
430​
431 return (
432 <SettingsRow
433 {...searchableSetting("browser-default-appearance")}
434 description="The color scheme pages are told to prefer. System follows your OS setting."
435 resetAction={
436 !disabled && appearance !== DEFAULT_PREVIEW_APPEARANCE ? (
437 <SettingResetButton
438 label="default browser appearance"
439 onClick={() => updateSettings({ browserDefaultAppearance: DEFAULT_PREVIEW_APPEARANCE })}
440 />
441 ) : null
442 }
443 control={
444 <Select
445 disabled={disabled}
446 value={appearance}
447 onValueChange={(value) => {
448 if (value === "system" || value === "light" || value === "dark") {
449 updateSettings({ browserDefaultAppearance: value });
450 }
451 }}
452 >
453 <SelectTrigger
454 size="sm"
455 className="w-full sm:w-40"
456 aria-label="Default browser appearance"
457 >
458 <SelectValue>{APPEARANCE_LABELS[appearance]}</SelectValue>
459 </SelectTrigger>
460 <SelectPopup align="end" alignItemWithTrigger={false}>
461 {Object.entries(APPEARANCE_LABELS).map(([value, label]) => (
462 <SelectItem hideIndicator key={value} value={value}>
463 {label}
464 </SelectItem>
465 ))}
466 </SelectPopup>
467 </Select>
468 }
469 />
470 );
472​
473function BrowserRecordingFrameRateSetting({ disabled }: { readonly disabled: boolean }) {
474 const frameRate = useClientSettings((settings) => settings.browserRecordingFrameRate);
475 const updateSettings = useUpdatePrimarySettings();
476​
477 return (
478 <SettingsRow
479 {...searchableSetting("browser-recording-frame-rate")}
480 description="Maximum recording rate. 30 fps saves CPU and storage; 60 fps is smoother."
481 resetAction={
482 !disabled && frameRate !== DEFAULT_BROWSER_RECORDING_FRAME_RATE ? (
483 <SettingResetButton
484 label="browser recording frame rate"
485 onClick={() =>
486 updateSettings({ browserRecordingFrameRate: DEFAULT_BROWSER_RECORDING_FRAME_RATE })
487 }
488 />
489 ) : null
490 }
491 control={
492 <Select
493 disabled={disabled}
494 value={String(frameRate)}
495 onValueChange={(value) => {
496 const next = BROWSER_RECORDING_FRAME_RATES.find((rate) => String(rate) === value);
497 if (next !== undefined) {
498 updateSettings({ browserRecordingFrameRate: next });
499 }
500 }}
501 >
502 <SelectTrigger
503 size="sm"
504 className="w-full sm:w-40"
505 aria-label="Browser recording frame rate"
506 >
507 <SelectValue>{frameRate} fps</SelectValue>
508 </SelectTrigger>
509 <SelectPopup align="end" alignItemWithTrigger={false}>
510 {BROWSER_RECORDING_FRAME_RATES.map((rate) => (
511 <SelectItem hideIndicator key={rate} value={String(rate)}>
512 {rate} fps
513 </SelectItem>
514 ))}
515 </SelectPopup>
516 </Select>
517 }
518 />
519 );
521​
522const LINK_TARGET_LABELS: Readonly<Record<BrowserLinkTarget, string>> = {
523 system: "Your default browser",
524 app: "T3 Code",
525};
526​
527function BrowserLinkTargetSetting({ disabled }: { readonly disabled: boolean }) {
528 const linkTarget = useClientSettings((settings) => settings.browserLinkTarget);
529 const updateSettings = useUpdatePrimarySettings();
530​
531 return (
532 <SettingsRow
533 {...searchableSetting("browser-link-target")}
534 description="Where links in the chat and terminal open. Hold ⌘ or Ctrl while clicking a link to open it in your default browser either way."
535 resetAction={
536 !disabled && linkTarget !== DEFAULT_BROWSER_LINK_TARGET ? (
537 <SettingResetButton
538 label="link target"
539 onClick={() => updateSettings({ browserLinkTarget: DEFAULT_BROWSER_LINK_TARGET })}
540 />
541 ) : null
542 }
543 control={
544 <Select
545 disabled={disabled}
546 value={linkTarget}
547 onValueChange={(value) => {
548 if (value === "system" || value === "app") {
549 updateSettings({ browserLinkTarget: value });
550 }
551 }}
552 >
553 <SelectTrigger size="sm" className="w-full sm:w-40" aria-label="Open links in">
554 <SelectValue>{LINK_TARGET_LABELS[linkTarget]}</SelectValue>
555 </SelectTrigger>
556 <SelectPopup align="end" alignItemWithTrigger={false}>
557 {(Object.keys(LINK_TARGET_LABELS) as ReadonlyArray<BrowserLinkTarget>).map((target) => (
558 <SelectItem hideIndicator key={target} value={target}>
559 {LINK_TARGET_LABELS[target]}
560 </SelectItem>
561 ))}
562 </SelectPopup>
563 </Select>
564 }
565 />
566 );
568​
569function DeviceIntegrationSettings() {
570 const { search, environment: selected } = useSettingsScope();
571 const settings = useScopedSettings();
572 const connected = selected?.connection.phase === "connected" && selected.serverConfig !== null;
573 const environmentId = connected ? selected.environmentId : null;
574​
575 return (
576 <SettingsSection id="devices" title="Devices">
577 <DeviceIntegrationControls
578 key={`${environmentId}:${JSON.stringify(search)}`}
579 environmentId={environmentId}
580 enabled={settings.enableDeviceSupport}
581 agentAccessEnabled={settings.enableAgentDeviceAccess}
582 />
583 </SettingsSection>
584 );
586​
587function DeviceIntegrationControls({
588 environmentId,
589 enabled,
590 agentAccessEnabled,
591}: {
592 environmentId: EnvironmentId | null;
593 enabled: boolean;
594 agentAccessEnabled: boolean;
595}) {
596 const { state, loaded } = useDeviceState(environmentId);
597 const { scope, environments, connectedEnvironments } = useSettingsScope();
598 const updateSettings = useUpdateScopedSettings();
599 const projectScope = scope.kind === "project" || scope.kind === "checkout";
600 const anyHubEnabled = connectedEnvironments.some(
601 (environment) => environment.serverConfig?.settings.enableDeviceSupport,
602 );
603 const configure = useAtomCommand(deviceEnvironment.configure, { reportFailure: false });
604 const list = useAtomCommand(deviceEnvironment.list, { reportFailure: false });
605 const [pending, setPending] = useState<"hub" | "check" | "agent" | null>(null);
606 const busy = state.hostStatus === "installing" || state.hostStatus === "starting";
607 const [platformsRevealed, setPlatformsRevealed] = useState(false);
608 // Keep diagnostics visible through subsequent agent setup and refresh phases.
609 if (platformsRevealed && !enabled) setPlatformsRevealed(false);
610 if (enabled && !platformsRevealed && state.hostStatus === "ready" && pending !== "hub") {
611 setPlatformsRevealed(true);
612 }
613​
614 const update = async (
615 kind: NonNullable<typeof pending>,
616 input: { enabled?: boolean; agentAccessEnabled?: boolean },
617 ) => {
618 if (!environmentId) return;
619 setPending(kind);
620 try {
621 const results = await Promise.allSettled(
622 environments.map(async (environment) => {
623 if (environment.connection.phase !== "connected" || !environment.serverConfig) {
624 throw new Error("Environment disconnected");
625 }
626 return configure({
627 environmentId: environment.environmentId,
628 input: { ...input, ...(input.enabled ? { onboardingCompleted: true } : {}) },
629 });
630 }),
631 );
632 const failed = environments.filter((_, index) => {
633 const result = results[index];
634 return result?.status !== "fulfilled" || result.value._tag === "Failure";
635 });
636 if (failed.length > 0) {
637 toastManager.add({
638 type: "error",
639 title: "Device settings not saved on all environments",
640 description: `Could not update ${failed.map((environment) => environment.label).join(", ")}.`,
641 });
642 }
643 } finally {
644 setPending(null);
645 }
646 };
647​
648 return (
649 <>
650 <SettingsRow
651 {...searchableSetting("device-hub")}
652 serverScoped
653 settingKeys={["enableDeviceSupport"]}
654 description={deviceHubDescription}
655 control={
656 <>
657 {pending === "hub" ? <DeviceHubSetupStatus state={state} pending compact /> : null}
658 <ScopedSwitch
659 settingKeys={["enableDeviceSupport"]}
660 checked={enabled}
661 disabled={projectScope || !loaded || !environmentId || busy || pending !== null}
662 aria-label="Device hub"
663 onCheckedChange={(checked) =>
664 void update("hub", {
665 enabled: Boolean(checked),
666 ...(checked ? {} : { agentAccessEnabled: false }),
667 })
668 }
669 />
670 </>
671 }
672 />
673 <AnimatedHeight>
674 {platformsRevealed ? (
675 <SettingsRow
676 {...searchableSetting("device-platform-support")}
677 description={
678 connectedEnvironments.length > 1
679 ? `Status for ${connectedEnvironments.find((environment) => environment.environmentId === environmentId)?.label}. Select an environment to inspect its simulator support.`
680 : undefined
681 }
682 status={
683 <div className="flex flex-wrap gap-x-5 gap-y-2">
684 <PlatformStatus compact platform="iOS" status={platformSetupStatus(state, "ios")} />
685 <PlatformStatus
686 compact
687 platform="Android"
688 status={platformSetupStatus(state, "android")}
689 />
690 </div>
691 }
692 control={
693 <Button
694 size="sm"
695 variant="outline"
696 disabled={!environmentId || !enabled || busy || pending !== null}
697 onClick={() => {
698 if (!environmentId) return;
699 setPending("check");
700 void list({ environmentId, input: {} }).finally(() => setPending(null));
701 }}
702 >
703 {pending === "check" ? "Checking…" : "Refresh"}
704 </Button>
705 }
706 />
707 ) : null}
708 </AnimatedHeight>
709 <SettingsRow
710 {...searchableSetting("agent-device-access")}
711 serverScoped
712 settingKeys={["enableAgentDeviceAccess"]}
713 description={agentDeviceDescription}
714 control={
715 <>
716 {pending === "agent" ? <AgentDeviceSetupStatus state={state} pending compact /> : null}
717 <ScopedSwitch
718 settingKeys={["enableAgentDeviceAccess"]}
719 checked={agentAccessEnabled}
720 disabled={
721 connectedEnvironments.length === 0 ||
722 (!projectScope && (!loaded || !anyHubEnabled || busy)) ||
723 pending !== null
724 }
725 aria-label="Agent device access"
726 onCheckedChange={(checked) =>
727 projectScope
728 ? updateSettings({ enableAgentDeviceAccess: Boolean(checked) })
729 : void update("agent", { agentAccessEnabled: Boolean(checked) })
730 }
731 />
732 </>
733 }
734 />
735 {state.hostStatus === "failed" && state.hostStatusDetail ? (
736 <p role="alert" className="px-4 py-3 text-xs text-destructive">
737 {state.hostStatusDetail}
738 </p>
739 ) : null}
740 <DeviceHostsSettings environmentId={environmentId} />
741 </>
742 );
744​
745function BrowserAutoShowFloatingPreviewSetting({ disabled }: { readonly disabled: boolean }) {
746 const autoShow = useClientSettings((settings) => settings.browserAutoShowFloatingPreview);
747 const updateSettings = useUpdatePrimarySettings();
748​
749 return (
750 <SettingsRow
751 {...searchableSetting("browser-auto-show-floating-preview")}
752 description="Show the floating preview when an agent opens a browser or device unless the agent says otherwise."
753 resetAction={
754 !disabled && autoShow !== DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW ? (
755 <SettingResetButton
756 label="auto-show floating preview"
757 onClick={() =>
758 updateSettings({
759 browserAutoShowFloatingPreview: DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW,
760 })
761 }
762 />
763 ) : null
764 }
765 control={
766 <Switch
767 disabled={disabled}
768 checked={autoShow}
769 onCheckedChange={(checked) =>
770 updateSettings({ browserAutoShowFloatingPreview: Boolean(checked) })
771 }
772 aria-label="Auto-show floating preview"
773 />
774 }
775 />
776 );
778​
779/**
780 * Profile list, its header menu, and the import flow.
781 *
782 * One menu creates profiles and imports into them, because the two are the
783 * same decision from the user's side: "I want a profile that has my Helium
784 * logins in it". Import targets include "New profile" so that case does not
785 * require creating one first and then finding a second control.
786 *
787 * Built-ins render without a rename field: they are synthesized rather than
788 * stored, so there is nothing to rename and removing them would strand every
789 * tab that opened under them.
790 *
791 * Sources are listed lazily on open: detection touches the other browser's
792 * files, and the answer changes while the app is running (quitting the browser
793 * clears `browserRunning`), so a value cached at mount would go stale.
794 */
795function BrowserProfilesSetting({ disabled }: { readonly disabled: boolean }) {
796 const userProfiles = useClientSettings((settings) => settings.browserProfiles);
797 const defaultProfileId = useClientSettings((settings) => settings.browserDefaultProfileId);
798 const settingsHydrated = useClientSettingsHydrated();
799 const updateSettings = useUpdatePrimarySettings();
800 const { environments, isReady: environmentsReady } = useEnvironments();
801 const primaryEnvironment = usePrimaryEnvironment();
802 const [sources, setSources] = useState<ReadonlyArray<BrowserImportSource> | null>(null);
803 const [importSession, setImportSession] = useState<{
804 readonly source: BrowserImportSource;
805 readonly environmentId: EnvironmentId;
806 readonly environmentName: string;
807 } | null>(null);
808 const [profilePendingRemoval, setProfilePendingRemoval] = useState<BrowserProfile | null>(null);
809 const [profileRemovalError, setProfileRemovalError] = useState<string | null>(null);
810 const [profileRemovalInFlight, setProfileRemovalInFlight] = useState(false);
811 const removalAvailable = browserProfileRemovalAvailable(
812 previewBridge !== null,
813 environmentsReady,
814 environments.length,
815 );
816 const importInFlightRef = useRef(false);
817 const [importInFlight, setImportInFlight] = useState(false);
818 const profileWritesDisabled = disabled || !settingsHydrated;
819​
820 const profiles = resolveBrowserProfiles(userProfiles);
821 // Incognito is deliberately not a row — it holds nothing to manage — so the
822 // default has to resolve against the list that renders. A stored
823 // `browserDefaultProfileId` of "incognito" would otherwise leave the section
824 // with no Default badge at all.
825 const listedProfiles = profiles.filter((profile) => profile.kind !== "incognito");
826 const resolvedDefaultId =
827 findBrowserProfile(listedProfiles, defaultProfileId)?.id ?? DEFAULT_BROWSER_PROFILE_ID;
828​
829 const createProfile = (baseName: string) => {
830 if (!settingsHydrated || importInFlightRef.current) return undefined;
831 const currentProfiles = getClientSettings().browserProfiles;
832 // Checked against the live settings, not the rendered list: two clicks
833 // before a re-render would otherwise both pass the disabled control.
834 if (currentProfiles.length >= BROWSER_PROFILE_MAX_COUNT) return undefined;
835 const resolvedProfiles = resolveBrowserProfiles(currentProfiles);
836 const taken = new Set(resolvedProfiles.map((profile) => profile.name));
837 let name = baseName;
838 for (let index = 2; taken.has(name); index += 1) name = `${baseName} ${index}`;
839 const profile = { id: `profile-${randomUUID()}`, name, kind: "persistent" as const };
840 updateSettings({ browserProfiles: [...currentProfiles, profile] });
841 return profile;
842 };
843​
844 const renameProfile = (id: string, next: string) => {
845 if (!settingsHydrated || importInFlightRef.current) return;
846 const name = next.trim().slice(0, BROWSER_PROFILE_NAME_MAX_LENGTH);
847 if (name === "") return;
848 const currentProfiles = getClientSettings().browserProfiles;
849 updateSettings({
850 browserProfiles: currentProfiles.map((profile) =>
851 profile.id === id ? { ...profile, name } : profile,
852 ),
853 });
854 };
855​
856 const clearProfileData = (id: string, name: string) => {
857 if (!settingsHydrated || importInFlightRef.current) return;
858 if (!previewBridge || !environmentsReady || environments.length === 0) {
859 toastManager.add({
860 type: "error",
861 title: `Could not clear ${name}'s data`,
862 description: "You're not connected to a server yet.",
863 });
864 return;
865 }
866 void clearBrowserProfileData(
867 previewBridge,
868 environments.map((environment) => environment.environmentId),
869 id,
870 )
871 .then(() => {
872 toastManager.add({ type: "success", title: `Cleared ${name}'s cookies and cache` });
873 })
874 .catch(() => {
875 toastManager.add({ type: "error", title: `Could not clear ${name}'s data` });
876 });
877 };
878​
879 const removeProfile = async (id: string) => {
880 if (!settingsHydrated || importInFlightRef.current) return;
881 if (!removalAvailable) {
882 setProfileRemovalError("Connect to an environment before removing this profile.");
883 return;
884 }
885 setProfileRemovalError(null);
886 setProfileRemovalInFlight(true);
887 // Drop the partition's data too, otherwise a removed profile's cookies
888 // stay on disk with nothing in the UI pointing at them.
889 try {
890 await clearBrowserProfileData(
891 previewBridge,
892 environmentsReady ? environments.map((environment) => environment.environmentId) : [],
893 id,
894 );
895 } catch {
896 setProfileRemovalError("Profile data could not be deleted. Try again.");
897 setProfileRemovalInFlight(false);
898 return;
899 }
900 const currentSettings = getClientSettings();
901 updateSettings({
902 browserProfiles: currentSettings.browserProfiles.filter((profile) => profile.id !== id),
903 // Reassign the default rather than leaving it pointing at nothing.
904 ...(currentSettings.browserDefaultProfileId === id
905 ? { browserDefaultProfileId: DEFAULT_BROWSER_PROFILE_ID }
906 : {}),
907 });
908 setProfileRemovalInFlight(false);
909 setProfilePendingRemoval(null);
910 };
911​
912 // A browser that is not on this machine is left out rather than listed as a
913 // dead row: there is nothing to act on, and the menu is a list of things you
914 // can import from. An unsupported one is left out for the same reason — the
915 // blocked wizard step can't be fixed from here. Every other unavailable
916 // reason stays, since each names a step the user can take.
917 const importableSources = (sources ?? []).filter(
918 (source) =>
919 source.unavailable !== "notInstalled" && source.unavailable !== "unsupportedPlatform",
920 );
921​
922 // Refreshed without blanking the last result: the menu shows the cached list
923 // straight away so it doesn't reflow on open, and the source list is stable
924 // (names only) since choosing what to import happens in the wizard, not here.
925 const loadSources = useCallback(() => {
926 if (!previewBridge) return;
927 void previewBridge
928 .listBrowserImportSources()
929 .then(setSources)
930 .catch(() => setSources((previous) => previous ?? []));
931 }, []);
932​
933 // Runs one import for the wizard. A new profile is registered only once the
934 // import succeeds — the cookies land in its partition first — so a blocked
935 // attempt never leaves an empty profile behind.
936 const runWizardImport = async (
937 source: BrowserImportSource,
938 environmentId: EnvironmentId,
939 input: { readonly sourceProfileDirectory: string; readonly target: WizardTarget },
940 ): Promise<ImportOutcome> => {
941 if (!previewBridge) return { kind: "blocked", reason: "sessionUnavailable" };
942 if (!settingsHydrated) return { kind: "blocked", reason: "sessionUnavailable" };
943 if (
944 input.target.kind === "existing" &&
945 !resolveBrowserProfiles(getClientSettings().browserProfiles).some(
946 (profile) => profile.id === input.target.profileId,
947 )
948 ) {
949 return { kind: "blocked", reason: "readFailed" };
950 }
951 if (importInFlightRef.current) return { kind: "blocked", reason: "readFailed" };
952 importInFlightRef.current = true;
953 setImportInFlight(true);
954 try {
955 const result = await previewBridge.importBrowserCookies({
956 environmentId,
957 sourceId: source.id,
958 sourceProfileDirectory: input.sourceProfileDirectory,
959 targetProfileId: input.target.profileId,
960 });
961 if (
962 input.target.kind === "existing" &&
963 !resolveBrowserProfiles(getClientSettings().browserProfiles).some(
964 (profile) => profile.id === input.target.profileId,
965 )
966 ) {
967 return { kind: "blocked", reason: "readFailed" };
968 }
969 let targetName: string;
970 if (input.target.kind === "new") {
971 // Registered only when something actually came over: an import that
972 // found no cookies should not leave a new, empty profile behind.
973 if (result.imported > 0) {
974 try {
975 const persisted = await persistClientSettingsUpdate((current) => {
976 const existing = current.browserProfiles.find(
977 (profile) => profile.id === input.target.profileId,
978 );
979 if (existing) return current;
980 // The wizard refuses a new target at the cap, but the cap can be
981 // reached while the import runs; the updater sees the newest
982 // settings, so this is the check that holds.
983 if (current.browserProfiles.length >= BROWSER_PROFILE_MAX_COUNT) {
984 throw new ProfileLimitReachedError();
985 }
986 const taken = new Set(
987 resolveBrowserProfiles(current.browserProfiles).map((profile) => profile.name),
988 );
989 let name = source.name;
990 for (let index = 2; taken.has(name); index += 1) name = `${source.name} ${index}`;
991 return {
992 ...current,
993 browserProfiles: [
994 ...current.browserProfiles,
995 { id: input.target.profileId, name, kind: "persistent" as const },
996 ],
997 };
998 });
999 targetName =
1000 persisted.browserProfiles.find((profile) => profile.id === input.target.profileId)
1001 ?.name ?? source.name;
1002 } catch (cause) {
1003 // This target id belongs only to the attempted new profile. Clear
1004 // its partition so a failed registration cannot strand imported
1005 // cookies behind a profile that disappears on restart.
1006 await clearBrowserProfileData(
1007 previewBridge,
1008 [environmentId],
1009 input.target.profileId,
1010 ).catch(() => undefined);
1011 // Not a read failure: the cookies came over and were cleared again
1012 // because the profile could not be kept. Name that, in the same
1013 // token form `importFailureReason` recovers from a bridge error.
1014 const reason =
1015 cause instanceof ProfileLimitReachedError ? "profileLimitReached" : "profileNotSaved";
1016 throw new Error(`Importing cookies from ${source.id} failed: ${reason}.`, { cause });
1018 } else {
1019 targetName = source.name;
1021 } else {
1022 targetName = input.target.name;
1024 return {
1025 kind: "imported",
1026 imported: result.imported,
1027 skipped: result.skipped,
1028 skippedDomains: result.skippedDomains,
1029 targetName,
1030 };
1031 } catch (cause) {
1032 return { kind: "blocked", reason: importFailureReason(cause) };
1033 } finally {
1034 importInFlightRef.current = false;
1035 setImportInFlight(false);
1037 };
1038​
1039 // Re-checks a source's availability after the user quits the browser, and
1040 // keeps the cached list in step so the menu reflects it too.
1041 const refreshImportSource = async (
1042 sourceId: BrowserImportSource["id"],
1043 ): Promise<BrowserImportSource | undefined> => {
1044 if (!previewBridge) return undefined;
1045 try {
1046 const latest = await previewBridge.listBrowserImportSources();
1047 setSources(latest);
1048 return latest.find((source) => source.id === sourceId);
1049 } catch {
1050 return undefined;
1052 };
1053​
1054 const atProfileLimit = userProfiles.length >= BROWSER_PROFILE_MAX_COUNT;
1055​
1056 return (
1057 <SettingsRow
1058 {...searchableSetting("browser-profiles")}
1059 description="Profiles separate cookies and logins. Incognito data is cleared when the app closes."
1060 control={
1061 <Menu onOpenChange={(open) => open && loadSources()}>
1062 <MenuTrigger
1063 render={
1064 <Button
1065 size="sm"
1066 variant="outline"
1067 disabled={profileWritesDisabled || importInFlight}
1068 />
1071 <PlusIcon />
1072 Add profile
1073 </MenuTrigger>
1074 <MenuPopup align="end" className="min-w-56">
1075 <MenuItem
1076 disabled={!settingsHydrated || atProfileLimit}
1077 onClick={() => createProfile("New profile")}
1079 Blank profile
1080 </MenuItem>
1081 {atProfileLimit ? (
1082 <MenuItem disabled>You&rsquo;ve reached the profile limit</MenuItem>
1083 ) : null}
1084 <MenuSeparator />
1085 <MenuGroup>
1086 <MenuGroupLabel>Import from</MenuGroupLabel>
1087 {sources === null ? (
1088 <MenuItem disabled>Looking for browsers…</MenuItem>
1089 ) : importableSources.length === 0 ? (
1090 <MenuItem disabled>No supported browsers found</MenuItem>
1091 ) : (
1092 // Every source is a plain row — running, needs-permission and
1093 // ready all look the same here. The wizard picks up whatever
1094 // state the source is in and walks the user forward from there.
1095 <>
1096 {importableSources.map((source) => (
1097 <MenuItem
1098 key={source.id}
1099 disabled={!settingsHydrated || primaryEnvironment == null}
1100 onClick={() => {
1101 if (!settingsHydrated || primaryEnvironment == null) return;
1102 setImportSession({
1103 source,
1104 environmentId: primaryEnvironment.environmentId,
1105 environmentName: resolveEnvironmentOptionLabel({
1106 isPrimary: true,
1107 environmentId: primaryEnvironment.environmentId,
1108 runtimeLabel: primaryEnvironment.label,
1109 }),
1110 });
1111 }}
1113 {source.name}
1114 </MenuItem>
1115 ))}
1116 {primaryEnvironment == null ? (
1117 <MenuItem disabled>Connect to an environment to import cookies</MenuItem>
1118 ) : null}
1119 </>
1120 )}
1121 </MenuGroup>
1122 </MenuPopup>
1123 </Menu>
1126 {/*
1127 The bordered container groups rows unambiguously at any width, and
1128 carries the bottom spacing `SettingsRow` leaves to its children
1129 (`pt-3 pb-1`).
1130 */}
1131 <div className="mt-2 mb-2 overflow-hidden rounded-lg border border-border/60">
1132 {listedProfiles.map((profile, index) => {
1133 const builtIn = isBuiltInBrowserProfileId(profile.id);
1134 const isDefault = profile.id === resolvedDefaultId;
1135 return (
1136 <div
1137 key={profile.id}
1138 className={cn(
1139 "flex items-center gap-3 px-3 py-2",
1140 index > 0 && "border-t border-border/60",
1141 )}
1143 <span className="flex min-w-0 flex-1 items-center gap-2">
1144 {builtIn ? (
1145 // Dimmed here rather than on the table: a wrapper-level dim
1146 // stacks with the rename field's and the row menu button's
1147 // own, landing them near 0.41 while every other disabled
1148 // control in the block sits at 0.64.
1149 <span
1150 className={cn(
1151 "truncate text-sm text-foreground",
1152 profileWritesDisabled && "opacity-64",
1153 )}
1155 {profile.name}
1156 </span>
1157 ) : (
1158 <DraftInput
1159 nativeInput
1160 size="sm"
1161 className="w-full max-w-56"
1162 aria-label={`Rename ${profile.name}`}
1163 disabled={profileWritesDisabled || importInFlight}
1164 maxLength={BROWSER_PROFILE_NAME_MAX_LENGTH}
1165 value={profile.name}
1166 onCommit={(next) => renameProfile(profile.id, next)}
1167 />
1168 )}
1169 {/*
1170 Dimmed with the rest of the row: a `Badge` has no disabled
1171 treatment of its own, so a solid `bg-primary` pill would
1172 otherwise sit at full strength beside a name, rename field
1173 and menu button that are all at 0.64.
1174 */}
1175 {isDefault ? (
1176 <Badge className={cn(profileWritesDisabled && "opacity-64")}>Default</Badge>
1177 ) : null}
1178 </span>
1179 <Menu>
1180 <MenuTrigger
1181 render={
1182 <Button
1183 size="icon-xs"
1184 variant="ghost-muted"
1185 disabled={profileWritesDisabled || importInFlight}
1186 aria-label={`${profile.name} options`}
1187 />
1190 <MoreVertical />
1191 </MenuTrigger>
1192 <MenuPopup align="end" className="min-w-44">
1193 <MenuItem
1194 disabled={!settingsHydrated || isDefault}
1195 onClick={() => {
1196 if (settingsHydrated) {
1197 updateSettings({ browserDefaultProfileId: profile.id });
1199 }}
1201 Set as default
1202 </MenuItem>
1203 <MenuItem
1204 disabled={!settingsHydrated || !removalAvailable}
1205 onClick={() => clearProfileData(profile.id, profile.name)}
1207 Clear cookies and cache
1208 </MenuItem>
1209 {builtIn ? null : (
1210 <MenuItem
1211 variant="destructive"
1212 disabled={!settingsHydrated || !removalAvailable}
1213 onClick={() => {
1214 if (settingsHydrated) setProfilePendingRemoval(profile);
1215 }}
1217 Remove profile and data
1218 </MenuItem>
1219 )}
1220 {!removalAvailable ? (
1221 <>
1222 <MenuSeparator />
1223 <MenuItem disabled>
1224 {environmentsReady
1225 ? "Connect to an environment to clear profile data"
1226 : "Checking environments…"}
1227 </MenuItem>
1228 </>
1229 ) : null}
1230 </MenuPopup>
1231 </Menu>
1232 </div>
1233 );
1234 })}
1235 </div>
1236 <AlertDialog
1237 open={profilePendingRemoval !== null}
1238 onOpenChange={(open) => {
1239 if (!open && !profileRemovalInFlight) {
1240 setProfilePendingRemoval(null);
1241 setProfileRemovalError(null);
1243 }}
1245 <AlertDialogPopup>
1246 <AlertDialogHeader>
1247 <AlertDialogTitle>Remove “{profilePendingRemoval?.name}”?</AlertDialogTitle>
1248 <AlertDialogDescription>
1249 Its cookies and logins are deleted. Tabs already open in this profile stay open until
1250 you close them.
1251 </AlertDialogDescription>
1252 {profileRemovalError ? (
1253 <p aria-live="polite" className="text-sm text-destructive">
1254 {profileRemovalError}
1255 </p>
1256 ) : null}
1257 {!removalAvailable ? (
1258 <p className="text-sm text-muted-foreground">
1259 Connect to an environment to remove this profile and its data.
1260 </p>
1261 ) : null}
1262 </AlertDialogHeader>
1263 <AlertDialogFooter>
1264 <AlertDialogClose
1265 disabled={profileRemovalInFlight}
1266 render={<Button variant="outline" disabled={profileRemovalInFlight} />}
1268 Cancel
1269 </AlertDialogClose>
1270 <Button
1271 variant="destructive"
1272 disabled={profileRemovalInFlight || !settingsHydrated || !removalAvailable}
1273 onClick={() => {
1274 if (profilePendingRemoval && settingsHydrated && removalAvailable) {
1275 void removeProfile(profilePendingRemoval.id);
1277 }}
1279 {profileRemovalInFlight ? "Removing…" : "Remove profile"}
1280 </Button>
1281 </AlertDialogFooter>
1282 </AlertDialogPopup>
1283 </AlertDialog>
1284 {importSession ? (
1285 <BrowserImportWizard
1286 source={importSession.source}
1287 destinationEnvironmentName={importSession.environmentName}
1288 targetProfiles={listedProfiles.map((profile) => ({ id: profile.id, name: profile.name }))}
1289 canCreateProfile={settingsHydrated && !atProfileLimit}
1290 onImport={(input) =>
1291 runWizardImport(importSession.source, importSession.environmentId, input)
1293 onRefreshSource={() => refreshImportSource(importSession.source.id)}
1294 onCheckFullDiskAccess={
1295 window.desktopBridge?.checkSystemPermission
1296 ? () => window.desktopBridge!.checkSystemPermission!("full-disk-access")
1297 : undefined
1299 onOpenFullDiskAccessSettings={async () => {
1300 // Rejects outside the desktop shell (and on shells that predate the
1301 // method), so the one toast covers every way the link can fail.
1302 await readLocalApi()
1303 ?.shell.openSystemSettings("full-disk-access")
1304 .catch(() => {
1305 toastManager.add({
1306 type: "error",
1307 title: "Could not open System Settings",
1308 description: "Open Privacy & Security → Full Disk Access manually.",
1309 });
1310 });
1311 }}
1312 onClose={() => setImportSession(null)}
1313 />
1314 ) : null}
1315 </SettingsRow>
1316 );
1318​
1319export function IntegrationsSettingsPanel() {
1320 // Client-local preview defaults are editable only where the preview exists.
1321 const previewDefaultsDisabled = !isElectron;
1322 const previewDefaults = (
1323 <>
1324 <BrowserProfilesSetting disabled={previewDefaultsDisabled} />
1325 <BrowserViewportSetting disabled={previewDefaultsDisabled} />
1326 <BrowserZoomSetting disabled={previewDefaultsDisabled} />
1327 <BrowserAppearanceSetting disabled={previewDefaultsDisabled} />
1328 <BrowserRecordingFrameRateSetting disabled={previewDefaultsDisabled} />
1329 <BrowserLinkTargetSetting disabled={previewDefaultsDisabled} />
1330 <BrowserAutoShowFloatingPreviewSetting disabled={previewDefaultsDisabled} />
1331 </>
1332 );
1333​
1334 return (
1335 <SettingsPageContainer>
1336 {/* Server-authoritative agent access is scoped by the header selection;
1337 the preview defaults below are device-local and ignore it. */}
1338 <ProjectDefaultsSettings category="integrations" />
1339 <SettingsSection id="browser" title="Browser">
1340 {previewDefaultsDisabled ? (
1341 <SettingsUnavailableGroup message="Only available in the desktop app.">
1342 {previewDefaults}
1343 </SettingsUnavailableGroup>
1344 ) : (
1345 previewDefaults
1346 )}
1347 </SettingsSection>
1348 <DeviceIntegrationSettings />
1349 </SettingsPageContainer>
1350 );