GeezerVison is showing github.com — feat(web): configurable browser defaults in Settings → Integrations by juliusmarminge · Pull Request #7082 · pingdotgg/t3code
feat(web): configurable browser defaults in Settings → Integrations
#7082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
de4c1ee
feat(web): configurable browser defaults in Settings → Integrations
juliusmarminge Aug 15, 2026
86975b8
feat(web): proper number fields, orientation, and floating-preview to…
juliusmarminge Aug 15, 2026
839966a
fix(web): disable desktop-only browser defaults on web clients
juliusmarminge Aug 15, 2026
f4c628c
fix(web): frame the desktop-only browser defaults as one disabled block
juliusmarminge Aug 15, 2026
b4777da
fix(web): tighten the desktop-only browser notice copy
juliusmarminge Aug 15, 2026
cca9dc8
test(web): update preview tests for the new open and createTab shapes
juliusmarminge Aug 15, 2026
bb0492d
fix(web): address UI-consistency findings on the browser defaults row
juliusmarminge Aug 15, 2026
6489255
fix(web): honour browser defaults on the paths that were skipping them
juliusmarminge Aug 16, 2026
File filter
Filter by extension
.ts
(23)
.tsx
(9)
All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -14,6 +14,7 @@ import {
DesktopPreviewRegisterWebviewInputSchema,
DesktopPreviewScreenshotArtifactSchema,
DesktopPreviewSetColorSchemeInputSchema,
DesktopPreviewCreateTabInputSchema,
DesktopPreviewTabInputSchema,
DesktopPreviewWebviewConfigSchema,
PreviewAnnotationSubmissionResultSchema,
Expand Down
Expand Up
@@ -48,11 +49,15 @@ export const installPreviewEventForwarding = Effect.fn(
export const createTab = DesktopIpc.makeIpcMethod({
channel: IpcChannels.PREVIEW_CREATE_TAB_CHANNEL,
payload: DesktopPreviewTabInputSchema ,
payload: DesktopPreviewCreateTabInputSchema ,
result: Schema.Void,
handler: Effect.fn("desktop.ipc.preview.createTab")(function* ({ tabId }) {
handler: Effect.fn("desktop.ipc.preview.createTab")(function* ({
tabId,
zoomFactor,
colorScheme,
}) {
const manager = yield* PreviewManager.PreviewManager;
yield* manager.createTab(tabId);
yield* manager.createTab(tabId, { zoomFactor, colorScheme } );
}),
});
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -163,7 +163,12 @@ contextBridge.exposeInMainWorld("desktopBridge", {
};
},
preview: {
createTab: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_CREATE_TAB_CHANNEL, { tabId }),
createTab: (tabId, defaults) =>
ipcRenderer.invoke(IpcChannels.PREVIEW_CREATE_TAB_CHANNEL, {
tabId,
zoomFactor: defaults?.zoomFactor,
colorScheme: defaults?.colorScheme,
}),
closeTab: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_CLOSE_TAB_CHANNEL, { tabId }),
registerWebview: (tabId, webContentsId) =>
ipcRenderer.invoke(IpcChannels.PREVIEW_REGISTER_WEBVIEW_CHANNEL, { tabId, webContentsId }),
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -16,6 +16,7 @@ import type {
DesktopPreviewRecordingArtifact,
DesktopPreviewRecordingFrame,
DesktopPreviewScreenshotArtifact,
DesktopPreviewTabDefaults,
PreviewAutomationClickInput,
PreviewAutomationActionEvent,
PreviewAutomationConsoleEntry,
Expand Down
Expand Up
@@ -334,6 +335,21 @@ const findZoomStep = (current: number): number => {
return Math.abs(ZOOM_LEVELS[index]! - current) < ZOOM_EPSILON ? index : index - 1;
};
/**
* Clamp a client-supplied zoom factor onto the discrete ladder. The setting is
* chosen from the same ladder, but it arrives over IPC from a schema that only
* guarantees a positive number, so an out-of-band value snaps to the nearest
* step rather than leaving the guest at a zoom the zoom controls can't reach.
*/
const normalizeZoomFactor = (value: number | undefined): number => {
if (value === undefined || !Number.isFinite(value)) return DEFAULT_ZOOM_FACTOR;
let closest = ZOOM_LEVELS[0]!;
for (const level of ZOOM_LEVELS) {
if (Math.abs(level - value) < Math.abs(closest - value)) closest = level;
}
return closest;
};
const nextZoomLevel = (current: number, direction: "in" | "out"): number => {
const step = findZoomStep(current);
if (direction === "in") {
Expand Down
Expand Up
@@ -1614,6 +1630,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
const createTabUnlocked = Effect.fn("PreviewManager.createTabUnlocked")(function* (
tabId: string,
defaults?: DesktopPreviewTabDefaults,
) {
const updatedAt = yield* currentIso;
const result = yield* SynchronizedRef.modify(
Expand All
@@ -1632,9 +1649,9 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
navStatus: { kind: "Idle" },
canGoBack: false,
canGoForward: false,
zoomFactor: DEFAULT_ZOOM_FACTOR ,
zoomFactor: normalizeZoomFactor(defaults?.zoomFactor) ,
pictureInPicture: false,
colorScheme: "system",
colorScheme: defaults?.colorScheme ?? "system",
controller: "none",
updatedAt,
};
Expand All
@@ -1653,8 +1670,11 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
return result.state;
});
const createTab = Effect.fn("PreviewManager.createTab")(function* (tabId: string) {
return yield* withTabLifecycleLock(tabId, createTabUnlocked(tabId));
const createTab = Effect.fn("PreviewManager.createTab")(function* (
tabId: string,
defaults?: DesktopPreviewTabDefaults,
) {
return yield* withTabLifecycleLock(tabId, createTabUnlocked(tabId, defaults));
});
const closeTabUnlocked = Effect.fn("PreviewManager.closeTabUnlocked")(function* (tabId: string) {
Expand Down
Expand Up
@@ -3802,7 +3822,10 @@ export class PreviewManager extends Context.Service<
readonly setMainWindow: (window: BrowserWindow) => Effect.Effect<void, PreviewManagerError>;
readonly getBrowserSession: (scope?: string) => Effect.Effect<Session, PreviewManagerError>;
readonly isBrowserPartition: (partition: string) => boolean;
readonly createTab: (tabId: string) => Effect.Effect<PreviewTabState, PreviewManagerError>;
readonly createTab: (
tabId: string,
defaults?: DesktopPreviewTabDefaults,
) => Effect.Effect<PreviewTabState, PreviewManagerError>;
readonly closeTab: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
readonly registerWebview: (
tabId: string,
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -13,6 +13,10 @@ import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
import * as DesktopClientSettings from "./DesktopClientSettings.ts";
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,
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -3,12 +3,10 @@ import { describe, expect, it } from "vite-plus/test";
import { normalizePreviewOpenInput } from "./handlers.ts";
describe("normalizePreviewOpenInput", () => {
it("opens the inline preview and reuses the current tab by default", () => {
expect(normalizePreviewOpenInput({})).toEqual({
open: true,
reuseExistingTab: true,
show: true,
});
it("leaves an unstated visibility for the client preference to decide", () => {
// Filling `open` in here would outrank `browserAutoShowFloatingPreview`,
// which is desktop-local and cannot be read from the server.
expect(normalizePreviewOpenInput({})).toEqual({ reuseExistingTab: true });
});
it("preserves an explicit background-only opt-out", () => {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -15,14 +15,21 @@ import * as McpInvocationContext from "../../McpInvocationContext.ts";
import * as PreviewAutomationBroker from "../../PreviewAutomationBroker.ts";
import { PreviewSnapshotToolkit, PreviewStandardToolkit, PreviewToolkit } from "./tools.ts";
/**
* Collapses the `show` alias onto `open` and defaults tab reuse.
*
* Deliberately leaves an unstated `open` unstated. Whether a preview the agent
* said nothing about surfaces is the user's `browserAutoShowFloatingPreview`
* preference, which is desktop-local and unreadable from here — filling in
* `true` would silently override it for every `preview_open`.
*/
export function normalizePreviewOpenInput(
input: PreviewAutomationOpenInput,
): PreviewAutomationOpenInput {
const open = input.open ?? input.show ?? true ;
const open = input.open ?? input.show;
return {
...input,
open,
show: open,
...(open === undefined ? {} : { open, show: open }),
reuseExistingTab: input.reuseExistingTab ?? true,
};
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -24,6 +24,7 @@ import {
FILL_PREVIEW_VIEWPORT,
PreviewSessionLookupError,
type PreviewSessionSnapshot,
type PreviewViewportSetting,
} from "@t3tools/contracts";
import {
isPreviewUrlNormalizationError,
Expand Down
Expand Up
@@ -121,28 +122,30 @@ const buildLoadingSnapshot = (input: {
readonly tabId: string;
readonly url: string;
readonly title: string;
readonly viewport: PreviewViewportSetting;
readonly updatedAt: string;
}): PreviewSessionSnapshot => ({
threadId: input.threadId,
tabId: input.tabId,
navStatus: { _tag: "Loading", url: input.url, title: input.title },
canGoBack: false,
canGoForward: false,
viewport: FILL_PREVIEW_VIEWPORT ,
viewport: input.viewport ,
updatedAt: input.updatedAt,
});
const buildIdleSnapshot = (input: {
readonly threadId: string;
readonly tabId: string;
readonly viewport: PreviewViewportSetting;
readonly updatedAt: string;
}): PreviewSessionSnapshot => ({
threadId: input.threadId,
tabId: input.tabId,
navStatus: { _tag: "Idle" },
canGoBack: false,
canGoForward: false,
viewport: FILL_PREVIEW_VIEWPORT ,
viewport: input.viewport ,
updatedAt: input.updatedAt,
});
Expand Down
Expand Up
@@ -215,15 +218,20 @@ export const make = Effect.gen(function* PreviewManagerMake() {
function* (input) {
const tabId = newPreviewTabId();
const updatedAt = yield* currentIsoTimestamp;
// Clients with a configured default send the viewport up front so the
// session is born at the right size; older clients omit it and keep the
// historical fill-panel behaviour.
const viewport = input.viewport ?? FILL_PREVIEW_VIEWPORT;
const snapshot = input.url
? buildLoadingSnapshot({
threadId: input.threadId,
tabId,
url: yield* normalizeUrl(input.url),
title: "",
viewport,
updatedAt,
})
: buildIdleSnapshot({ threadId: input.threadId, tabId, updatedAt });
: buildIdleSnapshot({ threadId: input.threadId, tabId, viewport, updatedAt });
yield* SynchronizedRef.modifyEffect(stateRef, (state) =>
Effect.gen(function* () {
const revision = state.revision + 1;
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -25,33 +25,14 @@ 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 = [
{ value: RESPONSIVE_VALUE, label: "Responsive" },
...PREVIEW_VIEWPORT_PRESETS.map((preset) => ({ value: preset.id, label: preset.label })),
];
function ScreenRotationIcon() {
return (
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<rect x="7.25" y="7.25" width="9.5" height="9.5" rx="1.4" transform="rotate(-45 12 12)" />
<path d="M12.5 2a10 10 0 0 1 8.4 5.4" />
<path d="M20.8 3.5v4h-4" />
<path d="M11.5 22a10 10 0 0 1-8.4-5.4" />
<path d="M3.2 20.5v-4h4" />
</svg>
);
}
interface Props {
readonly setting: Exclude<PreviewViewportSetting, { readonly _tag: "fill" }>;
readonly width: number;
Expand Down
Original file line number
Diff line number
Diff line change
@@ -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 (
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<rect x="7.25" y="7.25" width="9.5" height="9.5" rx="1.4" transform="rotate(-45 12 12)" />
<path d="M12.5 2a10 10 0 0 1 8.4 5.4" />
<path d="M20.8 3.5v4h-4" />
<path d="M11.5 22a10 10 0 0 1-8.4-5.4" />
<path d="M3.2 20.5v-4h4" />
</svg>
);
}
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.