Skip to content

Commit bc0ce40

Browse files
refactor(mobile): remove write-only terminal font cache
1 parent a98dad7 commit bc0ce40

3 files changed

Lines changed: 1 addition & 27 deletions

File tree

‎apps/mobile/src/features/settings/appearance/AppearancePreferencesProvider.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import {
3737
getMobileUniwindThemeName,
3838
type MobileThemeRuntimeState,
3939
} from "../../../lib/mobileThemeRuntime";
40-
import { cacheTerminalFontSize } from "../../terminal/terminalUiState";
4140

4241
interface AppearancePreferencesContextValue {
4342
/** Effective values with base-size derivation applied. Use this for rendering. */
@@ -143,8 +142,7 @@ export function AppearancePreferencesProvider(props: { readonly children: ReactN
143142
useLayoutEffect(() => {
144143
selectedThemeIdsRef.current = themeIds;
145144
syncThemeRuntime(runtimeState);
146-
cacheTerminalFontSize(appearance.terminalFontSize);
147-
}, [appearance.terminalFontSize, runtimeState, syncThemeRuntime, themeIds]);
145+
}, [runtimeState, syncThemeRuntime, themeIds]);
148146

149147
const setThemeIdForAppearance = useCallback(
150148
(appearance: MobileThemeAppearance, value: MobileThemeId) => {

‎apps/mobile/src/features/terminal/terminalUiState.test.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { beforeEach, describe, expect, it } from "vite-plus/test";
22
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
33

44
import {
5-
cacheTerminalFontSize,
65
cacheTerminalGridSize,
7-
getCachedTerminalFontSize,
86
getCachedTerminalGridSize,
97
resetTerminalUiStateCaches,
108
} from "./terminalUiState";
@@ -14,14 +12,6 @@ describe("terminalUiState", () => {
1412
resetTerminalUiStateCaches();
1513
});
1614

17-
it("caches terminal font size using the shared normalization rules", () => {
18-
expect(getCachedTerminalFontSize()).toBeNull();
19-
expect(cacheTerminalFontSize(8.5)).toBe(8.5);
20-
expect(getCachedTerminalFontSize()).toBe(8.5);
21-
expect(cacheTerminalFontSize(100)).toBe(14);
22-
expect(getCachedTerminalFontSize()).toBe(14);
23-
});
24-
2515
it("stores terminal grid sizes per terminal target", () => {
2616
const primaryTarget = {
2717
environmentId: EnvironmentId.make("env-1"),

‎apps/mobile/src/features/terminal/terminalUiState.ts‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
22

3-
import { DEFAULT_TERMINAL_FONT_SIZE, normalizeTerminalFontSize } from "./terminalPreferences";
4-
53
export interface TerminalGridSize {
64
readonly cols: number;
75
readonly rows: number;
@@ -14,22 +12,11 @@ export interface TerminalUiStateTarget {
1412
}
1513

1614
const terminalGridSizeCache = new Map<string, TerminalGridSize>();
17-
let cachedTerminalFontSize: number | null = null;
1815

1916
function terminalUiStateKey(target: TerminalUiStateTarget): string {
2017
return `${target.environmentId}:${target.threadId}:${target.terminalId}`;
2118
}
2219

23-
export function getCachedTerminalFontSize(): number | null {
24-
return cachedTerminalFontSize;
25-
}
26-
27-
export function cacheTerminalFontSize(value: number | null | undefined): number {
28-
const normalized = normalizeTerminalFontSize(value ?? DEFAULT_TERMINAL_FONT_SIZE);
29-
cachedTerminalFontSize = normalized;
30-
return normalized;
31-
}
32-
3320
export function getCachedTerminalGridSize(target: TerminalUiStateTarget): TerminalGridSize | null {
3421
return terminalGridSizeCache.get(terminalUiStateKey(target)) ?? null;
3522
}
@@ -47,6 +34,5 @@ export function cacheTerminalGridSize(
4734
}
4835

4936
export function resetTerminalUiStateCaches() {
50-
cachedTerminalFontSize = null;
5137
terminalGridSizeCache.clear();
5238
}

0 commit comments

Comments
 (0)