Skip to content

Commit 9d22990

Browse files
committed
fix(web): inherit terminal size in simple typography
1 parent 4eaf5ef commit 9d22990

4 files changed

Lines changed: 38 additions & 3 deletions

File tree

‎apps/web/src/appearanceFonts.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
cssFontFamilies,
1212
resolveDefaultFamilyLabel,
1313
resolveTerminalFontPreference,
14+
resolveTerminalFontSizePreference,
1415
} from "./appearanceFonts";
1516

1617
describe("areFontAdvancesMonospace", () => {
@@ -97,6 +98,16 @@ describe("resolveTerminalFontPreference", () => {
9798
});
9899
});
99100

101+
describe("resolveTerminalFontSizePreference", () => {
102+
it("inherits the code font size in simple mode", () => {
103+
expect(resolveTerminalFontSizePreference({ advanced: false, code: 15, terminal: 12 })).toBe(15);
104+
});
105+
106+
it("keeps code and terminal font sizes independent in advanced mode", () => {
107+
expect(resolveTerminalFontSizePreference({ advanced: true, code: 15, terminal: 12 })).toBe(12);
108+
});
109+
});
110+
100111
describe("font size clamping", () => {
101112
it("keeps sizes inside the ranges the UI can absorb", () => {
102113
expect(clampInterfaceFontSize(16)).toBe(16);

‎apps/web/src/appearanceFonts.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ export function resolveTerminalFontPreference(input: {
4141
return input.code;
4242
}
4343

44+
export function resolveTerminalFontSizePreference(input: {
45+
readonly advanced: boolean;
46+
readonly code: number;
47+
readonly terminal: number;
48+
}): number {
49+
if (input.advanced) return input.terminal;
50+
return input.code;
51+
}
52+
4453
function quoteFontFamilyName(name: string): string {
4554
const bare = name.trim();
4655
if (bare.length === 0) return "";

‎apps/web/src/components/ThreadTerminalDrawer.tsx‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ import { terminalEnvironment } from "../state/terminal";
6666
import { openTerminalLinkInPreview } from "./preview/openTerminalLinkInPreview";
6767
import { useAtomCommand } from "../state/use-atom-command";
6868
import { preventTerminalCloseShortcut } from "../lib/terminalCloseShortcut";
69-
import { resolveTerminalFontPreference, TYPOGRAPHY_ADVANCED_STORAGE_KEY } from "../appearanceFonts";
69+
import {
70+
resolveTerminalFontPreference,
71+
resolveTerminalFontSizePreference,
72+
TYPOGRAPHY_ADVANCED_STORAGE_KEY,
73+
} from "../appearanceFonts";
7074

7175
const MIN_DRAWER_HEIGHT = 180;
7276
const MAX_DRAWER_HEIGHT_RATIO = 0.75;
@@ -341,7 +345,13 @@ export function TerminalViewport({
341345
terminal: settings.fontFamilyTerminal,
342346
}),
343347
);
344-
const terminalFontSize = useClientSettings((settings) => settings.fontSizeTerminal);
348+
const terminalFontSize = useClientSettings((settings) =>
349+
resolveTerminalFontSizePreference({
350+
advanced: advancedTypography,
351+
code: settings.fontSizeCode,
352+
terminal: settings.fontSizeTerminal,
353+
}),
354+
);
345355
const terminalFontRef = useRef({ family: terminalFontFamily, size: terminalFontSize });
346356
const terminalSession = useAttachedTerminalSession({
347357
environmentId,

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ import {
100100
isMonospaceFamily,
101101
resolveDefaultFamilyLabel,
102102
resolveTerminalFontPreference,
103+
resolveTerminalFontSizePreference,
103104
TYPOGRAPHY_ADVANCED_STORAGE_KEY,
104105
} from "../../appearanceFonts";
105106
import { CodeFontPreview, PromptFontPreview, TerminalFontPreview } from "./SettingsFontPreviews";
@@ -1272,7 +1273,11 @@ function SimpleFontRows() {
12721273
code: settings.fontFamilyCode,
12731274
terminal: settings.fontFamilyTerminal,
12741275
})}
1275-
size={settings.fontSizeTerminal}
1276+
size={resolveTerminalFontSizePreference({
1277+
advanced: false,
1278+
code: settings.fontSizeCode,
1279+
terminal: settings.fontSizeTerminal,
1280+
})}
12761281
/>
12771282
</>
12781283
}

0 commit comments

Comments
 (0)