refactor(mobile): remove write-only terminal font cache (#10058)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-09-05 01:49:06 -07:00
1 parent 45f5a5ffb3
commit 5b7f6bcfbc
3 files changed
+1 -27

No files matched your search

@@ -37,7 +37,6 @@ import {
getMobileUniwindThemeName,
type MobileThemeRuntimeState,
} from "../../../lib/mobileThemeRuntime";
import { cacheTerminalFontSize } from "../../terminal/terminalUiState";
interface AppearancePreferencesContextValue {
/** Effective values with base-size derivation applied. Use this for rendering. */
@@ -143,8 +142,7 @@ export function AppearancePreferencesProvider(props: { readonly children: ReactN
useLayoutEffect(() => {
selectedThemeIdsRef.current = themeIds;
syncThemeRuntime(runtimeState);
cacheTerminalFontSize(appearance.terminalFontSize);
}, [appearance.terminalFontSize, runtimeState, syncThemeRuntime, themeIds]);
}, [runtimeState, syncThemeRuntime, themeIds]);
const setThemeIdForAppearance = useCallback(
(appearance: MobileThemeAppearance, value: MobileThemeId) => {
@@ -2,9 +2,7 @@ import { beforeEach, describe, expect, it } from "vite-plus/test";
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
import {
cacheTerminalFontSize,
cacheTerminalGridSize,
getCachedTerminalFontSize,
getCachedTerminalGridSize,
resetTerminalUiStateCaches,
} from "./terminalUiState";
@@ -14,14 +12,6 @@ describe("terminalUiState", () => {
resetTerminalUiStateCaches();
});
it("caches terminal font size using the shared normalization rules", () => {
expect(getCachedTerminalFontSize()).toBeNull();
expect(cacheTerminalFontSize(8.5)).toBe(8.5);
expect(getCachedTerminalFontSize()).toBe(8.5);
expect(cacheTerminalFontSize(100)).toBe(14);
expect(getCachedTerminalFontSize()).toBe(14);
});
it("stores terminal grid sizes per terminal target", () => {
const primaryTarget = {
environmentId: EnvironmentId.make("env-1"),
@@ -1,7 +1,5 @@
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
import { DEFAULT_TERMINAL_FONT_SIZE, normalizeTerminalFontSize } from "./terminalPreferences";
export interface TerminalGridSize {
readonly cols: number;
readonly rows: number;
@@ -14,22 +12,11 @@ export interface TerminalUiStateTarget {
}
const terminalGridSizeCache = new Map<string, TerminalGridSize>();
let cachedTerminalFontSize: number | null = null;
function terminalUiStateKey(target: TerminalUiStateTarget): string {
return `${target.environmentId}:${target.threadId}:${target.terminalId}`;
}
export function getCachedTerminalFontSize(): number | null {
return cachedTerminalFontSize;
}
export function cacheTerminalFontSize(value: number | null | undefined): number {
const normalized = normalizeTerminalFontSize(value ?? DEFAULT_TERMINAL_FONT_SIZE);
cachedTerminalFontSize = normalized;
return normalized;
}
export function getCachedTerminalGridSize(target: TerminalUiStateTarget): TerminalGridSize | null {
return terminalGridSizeCache.get(terminalUiStateKey(target)) ?? null;
}
@@ -47,6 +34,5 @@ export function cacheTerminalGridSize(
}
export function resetTerminalUiStateCaches() {
cachedTerminalFontSize = null;
terminalGridSizeCache.clear();
}