| author | |
| committer | |
| log | 5b7f6bcfbcd5f150a67f323e0ec5aeb70b3c4009 |
| tree | 17e98514b2f9554b33936dfeaa57cd5fe4fe7f5d |
| parent | 45f5a5ffb3257d510f249b14c36a514beff2868a |
| signature | Signed by PGP key B5690EEEBB952194 |
3 files changed, 1 insertions(+), 27 deletions(-)
apps/mobile/src/features/settings/appearance/AppearancePreferencesProvider.tsx+1-3| ... | @@ -37,7 +37,6 @@ import { | ... | @@ -37,7 +37,6 @@ import { |
| 37 | getMobileUniwindThemeName, | 37 | getMobileUniwindThemeName, |
| 38 | type MobileThemeRuntimeState, | 38 | type MobileThemeRuntimeState, |
| 39 | } from "../../../lib/mobileThemeRuntime"; | 39 | } from "../../../lib/mobileThemeRuntime"; |
| 40 | import { cacheTerminalFontSize } from "../../terminal/terminalUiState"; | ||
| 41 | 40 | ||
| 42 | interface AppearancePreferencesContextValue { | 41 | interface AppearancePreferencesContextValue { |
| 43 | /** Effective values with base-size derivation applied. Use this for rendering. */ | 42 | /** Effective values with base-size derivation applied. Use this for rendering. */ |
| ... | @@ -143,8 +142,7 @@ export function AppearancePreferencesProvider(props: { readonly children: ReactN | ... | @@ -143,8 +142,7 @@ export function AppearancePreferencesProvider(props: { readonly children: ReactN |
| 143 | useLayoutEffect(() => { | 142 | useLayoutEffect(() => { |
| 144 | selectedThemeIdsRef.current = themeIds; | 143 | selectedThemeIdsRef.current = themeIds; |
| 145 | syncThemeRuntime(runtimeState); | 144 | syncThemeRuntime(runtimeState); |
| 146 | cacheTerminalFontSize(appearance.terminalFontSize); | 145 | }, [runtimeState, syncThemeRuntime, themeIds]); |
| 147 | }, [appearance.terminalFontSize, runtimeState, syncThemeRuntime, themeIds]); | ||
| 148 | 146 | ||
| 149 | const setThemeIdForAppearance = useCallback( | 147 | const setThemeIdForAppearance = useCallback( |
| 150 | (appearance: MobileThemeAppearance, value: MobileThemeId) => { | 148 | (appearance: MobileThemeAppearance, value: MobileThemeId) => { |
apps/mobile/src/features/terminal/terminalUiState.test.ts-10| ... | @@ -2,9 +2,7 @@ import { beforeEach, describe, expect, it } from "vite-plus/test"; | ... | @@ -2,9 +2,7 @@ import { beforeEach, describe, expect, it } from "vite-plus/test"; |
| 2 | import { EnvironmentId, ThreadId } from "@t3tools/contracts"; | 2 | import { EnvironmentId, ThreadId } from "@t3tools/contracts"; |
| 3 | 3 | ||
| 4 | import { | 4 | import { |
| 5 | cacheTerminalFontSize, | ||
| 6 | cacheTerminalGridSize, | 5 | cacheTerminalGridSize, |
| 7 | getCachedTerminalFontSize, | ||
| 8 | getCachedTerminalGridSize, | 6 | getCachedTerminalGridSize, |
| 9 | resetTerminalUiStateCaches, | 7 | resetTerminalUiStateCaches, |
| 10 | } from "./terminalUiState"; | 8 | } from "./terminalUiState"; |
| ... | @@ -14,14 +12,6 @@ describe("terminalUiState", () => { | ... | @@ -14,14 +12,6 @@ describe("terminalUiState", () => { |
| 14 | resetTerminalUiStateCaches(); | 12 | resetTerminalUiStateCaches(); |
| 15 | }); | 13 | }); |
| 16 | 14 | ||
| 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 | |||
| 25 | it("stores terminal grid sizes per terminal target", () => { | 15 | it("stores terminal grid sizes per terminal target", () => { |
| 26 | const primaryTarget = { | 16 | const primaryTarget = { |
| 27 | environmentId: EnvironmentId.make("env-1"), | 17 | environmentId: EnvironmentId.make("env-1"), |
apps/mobile/src/features/terminal/terminalUiState.ts-14| ... | @@ -1,7 +1,5 @@ | ... | @@ -1,7 +1,5 @@ |
| 1 | import type { EnvironmentId, ThreadId } from "@t3tools/contracts"; | 1 | import type { EnvironmentId, ThreadId } from "@t3tools/contracts"; |
| 2 | 2 | ||
| 3 | import { DEFAULT_TERMINAL_FONT_SIZE, normalizeTerminalFontSize } from "./terminalPreferences"; | ||
| 4 | |||
| 5 | export interface TerminalGridSize { | 3 | export interface TerminalGridSize { |
| 6 | readonly cols: number; | 4 | readonly cols: number; |
| 7 | readonly rows: number; | 5 | readonly rows: number; |
| ... | @@ -14,22 +12,11 @@ export interface TerminalUiStateTarget { | ... | @@ -14,22 +12,11 @@ export interface TerminalUiStateTarget { |
| 14 | } | 12 | } |
| 15 | 13 | ||
| 16 | const terminalGridSizeCache = new Map<string, TerminalGridSize>(); | 14 | const terminalGridSizeCache = new Map<string, TerminalGridSize>(); |
| 17 | let cachedTerminalFontSize: number | null = null; | ||
| 18 | 15 | ||
| 19 | function terminalUiStateKey(target: TerminalUiStateTarget): string { | 16 | function terminalUiStateKey(target: TerminalUiStateTarget): string { |
| 20 | return `${target.environmentId}:${target.threadId}:${target.terminalId}`; | 17 | return `${target.environmentId}:${target.threadId}:${target.terminalId}`; |
| 21 | } | 18 | } |
| 22 | 19 | ||
| 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 | |||
| 33 | export function getCachedTerminalGridSize(target: TerminalUiStateTarget): TerminalGridSize | null { | 20 | export function getCachedTerminalGridSize(target: TerminalUiStateTarget): TerminalGridSize | null { |
| 34 | return terminalGridSizeCache.get(terminalUiStateKey(target)) ?? null; | 21 | return terminalGridSizeCache.get(terminalUiStateKey(target)) ?? null; |
| 35 | } | 22 | } |
| ... | @@ -47,6 +34,5 @@ export function cacheTerminalGridSize( | ... | @@ -47,6 +34,5 @@ export function cacheTerminalGridSize( |
| 47 | } | 34 | } |
| 48 | 35 | ||
| 49 | export function resetTerminalUiStateCaches() { | 36 | export function resetTerminalUiStateCaches() { |
| 50 | cachedTerminalFontSize = null; | ||
| 51 | terminalGridSizeCache.clear(); | 37 | terminalGridSizeCache.clear(); |
| 52 | } | 38 | } |