diff --git a/apps/desktop/src/settings/DesktopClientSettings.test.ts b/apps/desktop/src/settings/DesktopClientSettings.test.ts
index 96401f3388..1c17d58215 100644
--- a/apps/desktop/src/settings/DesktopClientSettings.test.ts
+++ b/apps/desktop/src/settings/DesktopClientSettings.test.ts
@@ -16,6 +16,7 @@ const clientSettings: ClientSettings = {
browserDefaultViewport: { _tag: "preset", width: 1024, height: 600, presetId: "nest-hub" },
browserDefaultZoomFactor: 1.25,
browserDefaultAppearance: "dark",
+ browserAutoShowFloatingPreview: false,
confirmQuit: true,
confirmThreadArchive: true,
confirmThreadDelete: false,
diff --git a/apps/web/src/browser/BrowserDeviceToolbar.tsx b/apps/web/src/browser/BrowserDeviceToolbar.tsx
index cd33bd216d..e46278d535 100644
--- a/apps/web/src/browser/BrowserDeviceToolbar.tsx
+++ b/apps/web/src/browser/BrowserDeviceToolbar.tsx
@@ -25,6 +25,7 @@ import { cn } from "~/lib/utils";
import { BROWSER_DEVICE_TOOLBAR_HEIGHT, resizeFreeformViewport } from "./browserViewportLayout";
import { commitViewportAndAspectRatio } from "./browserDeviceToolbarState";
+import { ScreenRotationIcon } from "./ScreenRotationIcon";
const RESPONSIVE_VALUE = "responsive";
const SELECT_ITEMS = [
@@ -32,26 +33,6 @@ const SELECT_ITEMS = [
...PREVIEW_VIEWPORT_PRESETS.map((preset) => ({ value: preset.id, label: preset.label })),
];
-function ScreenRotationIcon() {
- return (
-
- );
-}
-
interface Props {
readonly setting: Exclude;
readonly width: number;
diff --git a/apps/web/src/browser/ScreenRotationIcon.tsx b/apps/web/src/browser/ScreenRotationIcon.tsx
new file mode 100644
index 0000000000..6e6bf74833
--- /dev/null
+++ b/apps/web/src/browser/ScreenRotationIcon.tsx
@@ -0,0 +1,26 @@
+/**
+ * Screen-rotation glyph shared by the in-browser device toolbar and the
+ * default-viewport setting, so the orientation control reads the same in both
+ * places.
+ *
+ * @module ScreenRotationIcon
+ */
+export function ScreenRotationIcon() {
+ return (
+
+ );
+}
diff --git a/apps/web/src/browser/browserDefaults.ts b/apps/web/src/browser/browserDefaults.ts
index 11d9f6baf4..dc07536ecb 100644
--- a/apps/web/src/browser/browserDefaults.ts
+++ b/apps/web/src/browser/browserDefaults.ts
@@ -27,16 +27,19 @@ export interface BrowserDefaults {
readonly viewport: PreviewViewportSetting;
readonly zoomFactor: number;
readonly appearance: PreviewAppearancePreference;
+ readonly autoShowFloatingPreview: boolean;
}
const toBrowserDefaults = (settings: {
readonly browserDefaultViewport: PreviewViewportSetting;
readonly browserDefaultZoomFactor: number;
readonly browserDefaultAppearance: PreviewAppearancePreference;
+ readonly browserAutoShowFloatingPreview: boolean;
}): BrowserDefaults => ({
viewport: settings.browserDefaultViewport,
zoomFactor: settings.browserDefaultZoomFactor,
appearance: settings.browserDefaultAppearance,
+ autoShowFloatingPreview: settings.browserAutoShowFloatingPreview,
});
/** Non-hook accessor for imperative open paths (menu actions, automation hosts). */
diff --git a/apps/web/src/components/preview/PreviewAutomationHosts.tsx b/apps/web/src/components/preview/PreviewAutomationHosts.tsx
index 706dc774b1..9a9c79d724 100644
--- a/apps/web/src/components/preview/PreviewAutomationHosts.tsx
+++ b/apps/web/src/components/preview/PreviewAutomationHosts.tsx
@@ -38,7 +38,7 @@ import {
} from "~/browser/browserRecording";
import { resolveBrowserRecordingStopTarget } from "~/browser/browserRecordingScope";
import { useBrowserSurfaceStore } from "~/browser/browserSurfaceStore";
-import { browserDefaultOpenViewport } from "~/browser/browserDefaults";
+import { browserDefaultOpenViewport, getBrowserDefaults } from "~/browser/browserDefaults";
import { runBrowserViewportMutation } from "~/browser/browserViewportActions";
import { previewRuntimeTabId } from "~/browser/previewRuntimeTabId";
import { isElectron } from "~/env";
@@ -432,7 +432,10 @@ function PreviewAutomationHost(props: { readonly environmentId: EnvironmentId })
updatePreviewServerSnapshot(threadRef, resizeResult.value);
}
}
- const shouldPresentPreview = shouldOpenPreviewMiniPlayer(input);
+ const shouldPresentPreview = shouldOpenPreviewMiniPlayer(
+ input,
+ getBrowserDefaults().autoShowFloatingPreview,
+ );
if (shouldPresentPreview) {
usePreviewMiniPlayerStore.getState().open(threadRef, activeTabId);
}
diff --git a/apps/web/src/components/preview/previewAutomationOpenReadiness.ts b/apps/web/src/components/preview/previewAutomationOpenReadiness.ts
index 2119206a12..7f525b4255 100644
--- a/apps/web/src/components/preview/previewAutomationOpenReadiness.ts
+++ b/apps/web/src/components/preview/previewAutomationOpenReadiness.ts
@@ -17,8 +17,16 @@ export const DEFAULT_PREVIEW_AUTOMATION_VIEWPORT = {
height: 800,
} as const satisfies PreviewViewportSetting;
-export function shouldOpenPreviewMiniPlayer(input: PreviewAutomationOpenInput): boolean {
- return input.open ?? input.show ?? true;
+/**
+ * An explicit `open`/`show` is the agent deliberately surfacing or suppressing
+ * its work, so it outranks the preference; the setting only decides what
+ * happens when the agent said nothing either way.
+ */
+export function shouldOpenPreviewMiniPlayer(
+ input: PreviewAutomationOpenInput,
+ autoShowFloatingPreview = true,
+): boolean {
+ return input.open ?? input.show ?? autoShowFloatingPreview;
}
export function previewAutomationOpenNeedsOverlay(
diff --git a/apps/web/src/components/settings/IntegrationsSettings.tsx b/apps/web/src/components/settings/IntegrationsSettings.tsx
index acc56f089b..8aa0b15708 100644
--- a/apps/web/src/components/settings/IntegrationsSettings.tsx
+++ b/apps/web/src/components/settings/IntegrationsSettings.tsx
@@ -7,6 +7,7 @@
* @module IntegrationsSettings
*/
import {
+ DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW,
DEFAULT_BROWSER_VIEWPORT,
DEFAULT_PREVIEW_APPEARANCE,
DEFAULT_PREVIEW_ZOOM_FACTOR,
@@ -19,9 +20,11 @@ import {
type PreviewViewportSetting,
} from "@t3tools/contracts";
import { PREVIEW_VIEWPORT_PRESETS } from "@t3tools/shared/previewViewport";
-import { useState } from "react";
-import { Input } from "../ui/input";
+import { ScreenRotationIcon } from "~/browser/ScreenRotationIcon";
+
+import { Button } from "../ui/button";
+import { NumberField, NumberFieldGroup, NumberFieldInput } from "../ui/number-field";
import {
Select,
SelectGroup,
@@ -31,6 +34,8 @@ import {
SelectTrigger,
SelectValue,
} from "../ui/select";
+import { Switch } from "../ui/switch";
+import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { useClientSettings, useUpdatePrimarySettings } from "~/hooks/useSettings";
import {
@@ -51,6 +56,8 @@ const RESPONSIVE_VALUE = "responsive";
*/
const RESPONSIVE_SEED_SIZE = { width: 1280, height: 800 } as const;
+const NO_GROUPING: Intl.NumberFormatOptions = { useGrouping: false };
+
const APPEARANCE_LABELS: Readonly> = {
system: "System",
light: "Light",
@@ -87,21 +94,31 @@ const isValidDimension = (value: number) =>
value >= PREVIEW_VIEWPORT_MIN_DIMENSION &&
value <= PREVIEW_VIEWPORT_MAX_DIMENSION;
+/**
+ * A sized viewport with width and height swapped. Presets keep their identity
+ * through a rotation — `resolvePreviewViewport` already stores rotated presets
+ * as the preset id plus swapped dimensions — so a rotated iPad is still an
+ * iPad, not an anonymous custom size.
+ */
+const rotateViewport = (
+ viewport: Exclude,
+): PreviewViewportSetting => ({
+ ...viewport,
+ width: viewport.height,
+ height: viewport.width,
+});
+
function BrowserViewportSetting() {
const viewport = useClientSettings((settings) => settings.browserDefaultViewport);
const updateSettings = useUpdatePrimarySettings();
- // Held while typing so a half-entered width (e.g. "12") isn't persisted as a
- // rejected value; committed on blur/Enter once both dimensions are valid.
- const [draftSize, setDraftSize] = useState<{ width: string; height: string } | null>(null);
const sized = viewport._tag === "fill" ? null : viewport;
- const presentedSize = draftSize ?? {
- width: String(sized?.width ?? RESPONSIVE_SEED_SIZE.width),
- height: String(sized?.height ?? RESPONSIVE_SEED_SIZE.height),
+ const presentedSize = {
+ width: sized?.width ?? RESPONSIVE_SEED_SIZE.width,
+ height: sized?.height ?? RESPONSIVE_SEED_SIZE.height,
};
const selectViewport = (value: string | null) => {
- setDraftSize(null);
if (value === FILL_VALUE) {
updateSettings({ browserDefaultViewport: FILL_PREVIEW_VIEWPORT });
return;
@@ -128,21 +145,16 @@ function BrowserViewportSetting() {
});
};
- const commitDraftSize = () => {
- if (!draftSize) return;
- const width = Number(draftSize.width);
- const height = Number(draftSize.height);
- setDraftSize(null);
- if (
- !isValidDimension(width) ||
- !isValidDimension(height) ||
- width * height > PREVIEW_VIEWPORT_MAX_AREA
- ) {
- return;
- }
- if (sized && width === sized.width && height === sized.height) return;
+ // Committed on blur rather than per keystroke: typing "2560" passes through
+ // "256", which is a legal dimension, so an onValueChange handler would
+ // persist that intermediate size and churn the settings file on every key.
+ const commitDimension = (axis: "width" | "height", value: number | null) => {
+ if (value === null || !isValidDimension(value)) return;
+ const next = { ...presentedSize, [axis]: value };
+ if (next.width * next.height > PREVIEW_VIEWPORT_MAX_AREA) return;
+ if (sized && next.width === sized.width && next.height === sized.height) return;
// Typing a size means the preset no longer describes it.
- updateSettings({ browserDefaultViewport: { _tag: "freeform", width, height } });
+ updateSettings({ browserDefaultViewport: { _tag: "freeform", ...next } });
};
return (
@@ -153,10 +165,7 @@ function BrowserViewportSetting() {
viewport._tag !== DEFAULT_BROWSER_VIEWPORT._tag ? (
{
- setDraftSize(null);
- updateSettings({ browserDefaultViewport: DEFAULT_BROWSER_VIEWPORT });
- }}
+ onClick={() => updateSettings({ browserDefaultViewport: DEFAULT_BROWSER_VIEWPORT })}
/>
) : null
}
@@ -186,42 +195,55 @@ function BrowserViewportSetting() {
{sized ? (
-
+ min={PREVIEW_VIEWPORT_MIN_DIMENSION}
+ max={PREVIEW_VIEWPORT_MAX_DIMENSION}
+ format={NO_GROUPING}
+ size="sm"
+ className="w-24"
+ onValueCommitted={(value) => commitDimension("height", value)}
+ >
+
+
+
+
+
+ = presentedSize.width ? "landscape" : "portrait"
+ }`}
+ onClick={() =>
+ updateSettings({ browserDefaultViewport: rotateViewport(sized) })
+ }
+ >
+
+
+ }
+ />
+ Rotate
+
+
) : null}
}
@@ -312,6 +334,39 @@ function BrowserAppearanceSetting() {
);
}
+function BrowserAutoShowFloatingPreviewSetting() {
+ const autoShow = useClientSettings((settings) => settings.browserAutoShowFloatingPreview);
+ const updateSettings = useUpdatePrimarySettings();
+
+ return (
+
+ updateSettings({
+ browserAutoShowFloatingPreview: DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW,
+ })
+ }
+ />
+ ) : null
+ }
+ control={
+
+ updateSettings({ browserAutoShowFloatingPreview: Boolean(checked) })
+ }
+ aria-label="Auto-show floating preview"
+ />
+ }
+ />
+ );
+}
+
export function IntegrationsSettingsPanel() {
return (
@@ -319,6 +374,7 @@ export function IntegrationsSettingsPanel() {
+
);
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts
index b0915233e0..83cf3de75d 100644
--- a/apps/web/src/components/settings/settingsSearch.ts
+++ b/apps/web/src/components/settings/settingsSearch.ts
@@ -215,6 +215,12 @@ export const SETTINGS_SEARCH_ITEMS = [
to: "/settings/integrations",
targetId: "browser",
},
+ {
+ id: "browser-auto-show-floating-preview",
+ title: "Auto-show floating preview",
+ to: "/settings/integrations",
+ targetId: "browser",
+ },
{
id: "source-control",
title: "Source control",
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index 12760682a7..2410274f8f 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -126,6 +126,7 @@ export type FontFamilyPreference = typeof FontFamilyPreference.Type;
* because the Chromium guest they configure is desktop-local.
*/
export const DEFAULT_BROWSER_VIEWPORT: PreviewViewportSetting = FILL_PREVIEW_VIEWPORT;
+export const DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW = true;
export const ClientSettingsSchema = Schema.Struct({
browserDefaultViewport: PreviewViewportSetting.pipe(
@@ -137,6 +138,15 @@ export const ClientSettingsSchema = Schema.Struct({
browserDefaultAppearance: PreviewAppearancePreference.pipe(
Schema.withDecodingDefault(Effect.succeed(DEFAULT_PREVIEW_APPEARANCE)),
),
+ /**
+ * Whether an agent opening a preview pops the floating mini player into
+ * view. Only applies when the agent didn't ask either way — an explicit
+ * `open`/`show` on `preview_open` still wins, since that is the agent
+ * deliberately showing or hiding its work.
+ */
+ browserAutoShowFloatingPreview: Schema.Boolean.pipe(
+ Schema.withDecodingDefault(Effect.succeed(DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW)),
+ ),
// Desktop-only: require holding the quit shortcut (Cmd/Ctrl+Q) before the
// app quits; a quick tap only shows a hint. Browser clients ignore it.
confirmQuit: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
@@ -787,6 +797,7 @@ export const ClientSettingsPatch = Schema.Struct({
browserDefaultViewport: Schema.optionalKey(PreviewViewportSetting),
browserDefaultZoomFactor: Schema.optionalKey(PreviewZoomFactor),
browserDefaultAppearance: Schema.optionalKey(PreviewAppearancePreference),
+ browserAutoShowFloatingPreview: Schema.optionalKey(Schema.Boolean),
confirmQuit: Schema.optionalKey(Schema.Boolean),
confirmThreadArchive: Schema.optionalKey(Schema.Boolean),
confirmThreadDelete: Schema.optionalKey(Schema.Boolean),