Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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) => {
Expand Down
10 changes: 0 additions & 10 deletions apps/mobile/src/features/terminal/terminalUiState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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"),
Expand Down
14 changes: 0 additions & 14 deletions apps/mobile/src/features/terminal/terminalUiState.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
Expand All @@ -47,6 +34,5 @@ export function cacheTerminalGridSize(
}

export function resetTerminalUiStateCaches() {
cachedTerminalFontSize = null;
terminalGridSizeCache.clear();
}
Loading