From da0eaff9d4e5b95405f60bcb0f2a433355da7423 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 25 Mar 2026 16:17:49 -0700 Subject: [PATCH] rm reexport shi --- apps/web/src/appSettings.ts | 47 ------------------- apps/web/src/components/ChatView.tsx | 4 +- apps/web/src/components/DiffPanel.tsx | 4 +- apps/web/src/components/PlanSidebar.tsx | 2 +- apps/web/src/components/Sidebar.logic.ts | 2 +- apps/web/src/components/Sidebar.tsx | 10 ++-- .../src/components/chat/MessagesTimeline.tsx | 2 +- apps/web/src/composerDraftStore.ts | 2 +- apps/web/src/modelSelection.ts | 2 +- apps/web/src/routes/_chat.settings.tsx | 5 +- apps/web/src/routes/_chat.tsx | 4 +- apps/web/src/timestampFormat.ts | 2 +- 12 files changed, 19 insertions(+), 67 deletions(-) delete mode 100644 apps/web/src/appSettings.ts diff --git a/apps/web/src/appSettings.ts b/apps/web/src/appSettings.ts deleted file mode 100644 index 55c1a04789..0000000000 --- a/apps/web/src/appSettings.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * App Settings - Backward-compatible shim. - * - * Re-exports the unified settings hook (`useSettings` / `useUpdateSettings`) - * as `useAppSettings()` so existing consumers continue to work without - * modification. New code should import from `~/hooks/useSettings` directly. - * - * Also re-exports type aliases and schema constants consumed by components - * that only need the type (e.g. `TimestampFormat`). - */ -import { useSettings, useUpdateSettings, type UnifiedSettings } from "./hooks/useSettings"; -import { - type TimestampFormat, - type SidebarProjectSortOrder, - type SidebarThreadSortOrder, - DEFAULT_TIMESTAMP_FORMAT, - DEFAULT_SIDEBAR_PROJECT_SORT_ORDER, - DEFAULT_SIDEBAR_THREAD_SORT_ORDER, -} from "./clientSettings"; - -// ── Re-exports for downstream type consumers ───────────────────────── - -export type { TimestampFormat, SidebarProjectSortOrder, SidebarThreadSortOrder }; -export { - DEFAULT_TIMESTAMP_FORMAT, - DEFAULT_SIDEBAR_PROJECT_SORT_ORDER, - DEFAULT_SIDEBAR_THREAD_SORT_ORDER, -}; -export type { UnifiedSettings }; - -// ── Backward-compat type alias ─────────────────────────────────────── - -export type AppSettings = UnifiedSettings; - -// ── Backward-compat hook ───────────────────────────────────────────── - -export function useAppSettings() { - const settings = useSettings(); - const { updateSettings, resetSettings, defaults } = useUpdateSettings(); - - return { - settings, - updateSettings: (patch: Partial) => updateSettings(patch), - resetSettings, - defaults, - } as const; -} diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 6b387fd3eb..5767286d85 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -120,7 +120,7 @@ import { import { SidebarTrigger } from "./ui/sidebar"; import { newCommandId, newMessageId, newThreadId } from "~/lib/utils"; import { readNativeApi } from "~/nativeApi"; -import { useAppSettings } from "../appSettings"; +import { useSettings } from "../hooks/useSettings"; import { getCustomModelOptionsByProvider, resolveAppModelSelection } from "../modelSelection"; import { isTerminalFocused } from "../lib/terminalFocus"; import { @@ -245,7 +245,7 @@ export default function ChatView({ threadId }: ChatViewProps) { const syncServerReadModel = useStore((store) => store.syncServerReadModel); const setStoreThreadError = useStore((store) => store.setError); const setStoreThreadBranch = useStore((store) => store.setThreadBranch); - const { settings } = useAppSettings(); + const settings = useSettings(); const setStickyComposerModelSelection = useComposerDraftStore( (store) => store.setStickyModelSelection, ); diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsx index 96e0219872..fadb8cb69d 100644 --- a/apps/web/src/components/DiffPanel.tsx +++ b/apps/web/src/components/DiffPanel.tsx @@ -30,7 +30,7 @@ import { buildPatchCacheKey } from "../lib/diffRendering"; import { resolveDiffThemeName } from "../lib/diffRendering"; import { useTurnDiffSummaries } from "../hooks/useTurnDiffSummaries"; import { useStore } from "../store"; -import { useAppSettings } from "../appSettings"; +import { useSettings } from "../hooks/useSettings"; import { formatShortTimestamp } from "../timestampFormat"; import { DiffPanelLoadingState, DiffPanelShell, type DiffPanelMode } from "./DiffPanelShell"; import { ToggleGroup, Toggle } from "./ui/toggle-group"; @@ -166,7 +166,7 @@ export { DiffWorkerPoolProvider } from "./DiffWorkerPoolProvider"; export default function DiffPanel({ mode = "inline" }: DiffPanelProps) { const navigate = useNavigate(); const { resolvedTheme } = useTheme(); - const { settings } = useAppSettings(); + const settings = useSettings(); const [diffRenderMode, setDiffRenderMode] = useState("stacked"); const [diffWordWrap, setDiffWordWrap] = useState(settings.diffWordWrap); const patchViewportRef = useRef(null); diff --git a/apps/web/src/components/PlanSidebar.tsx b/apps/web/src/components/PlanSidebar.tsx index 47bee930cc..a565c09c2e 100644 --- a/apps/web/src/components/PlanSidebar.tsx +++ b/apps/web/src/components/PlanSidebar.tsx @@ -1,5 +1,5 @@ import { memo, useState, useCallback } from "react"; -import { type TimestampFormat } from "../appSettings"; +import { type TimestampFormat } from "../clientSettings"; import { Badge } from "./ui/badge"; import { Button } from "./ui/button"; import { ScrollArea } from "./ui/scroll-area"; diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts index de5859af92..b77d34b02a 100644 --- a/apps/web/src/components/Sidebar.logic.ts +++ b/apps/web/src/components/Sidebar.logic.ts @@ -1,4 +1,4 @@ -import type { SidebarProjectSortOrder, SidebarThreadSortOrder } from "../appSettings"; +import type { SidebarProjectSortOrder, SidebarThreadSortOrder } from "../clientSettings"; import type { Thread } from "../types"; import { cn } from "../lib/utils"; import { diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 923c30b2f9..c8c352ae0e 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -38,11 +38,7 @@ import { } from "@t3tools/contracts"; import { useMutation, useQueries, useQuery, useQueryClient } from "@tanstack/react-query"; import { useLocation, useNavigate, useParams } from "@tanstack/react-router"; -import { - type SidebarProjectSortOrder, - type SidebarThreadSortOrder, - useAppSettings, -} from "../appSettings"; +import { type SidebarProjectSortOrder, type SidebarThreadSortOrder } from "../clientSettings"; import { isElectron } from "../env"; import { APP_STAGE_LABEL, APP_VERSION } from "../branding"; import { isLinuxPlatform, isMacPlatform, newCommandId, newProjectId } from "../lib/utils"; @@ -102,6 +98,7 @@ import { sortThreadsForSidebar, } from "./Sidebar.logic"; import { useCopyToClipboard } from "~/hooks/useCopyToClipboard"; +import { useSettings, useUpdateSettings } from "~/hooks/useSettings"; const EMPTY_KEYBINDINGS: ResolvedKeybindingsConfig = []; const THREAD_PREVIEW_LIMIT = 6; @@ -381,7 +378,8 @@ export default function Sidebar() { ); const navigate = useNavigate(); const isOnSettings = useLocation({ select: (loc) => loc.pathname === "/settings" }); - const { settings: appSettings, updateSettings } = useAppSettings(); + const appSettings = useSettings(); + const { updateSettings } = useUpdateSettings(); const { handleNewThread } = useHandleNewThread(); const routeThreadId = useParams({ strict: false, diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx index f3e462f7fe..5295d42af1 100644 --- a/apps/web/src/components/chat/MessagesTimeline.tsx +++ b/apps/web/src/components/chat/MessagesTimeline.tsx @@ -48,7 +48,7 @@ import { type ParsedTerminalContextEntry, } from "~/lib/terminalContext"; import { cn } from "~/lib/utils"; -import { type TimestampFormat } from "../../appSettings"; +import { type TimestampFormat } from "../../clientSettings"; import { formatTimestamp } from "../../timestampFormat"; import { buildInlineTerminalContextText, diff --git a/apps/web/src/composerDraftStore.ts b/apps/web/src/composerDraftStore.ts index 7cd40f4b18..5819813997 100644 --- a/apps/web/src/composerDraftStore.ts +++ b/apps/web/src/composerDraftStore.ts @@ -31,7 +31,7 @@ import { import { create } from "zustand"; import { createJSONStorage, persist } from "zustand/middleware"; import { createDebouncedStorage, createMemoryStorage } from "./lib/storage"; -import { UnifiedSettings } from "./appSettings"; +import { UnifiedSettings } from "./hooks/useSettings"; export const COMPOSER_DRAFT_STORAGE_KEY = "t3code:composer-drafts:v1"; const COMPOSER_DRAFT_STORAGE_VERSION = 3; diff --git a/apps/web/src/modelSelection.ts b/apps/web/src/modelSelection.ts index 28859bc6cd..9c96cb065b 100644 --- a/apps/web/src/modelSelection.ts +++ b/apps/web/src/modelSelection.ts @@ -10,7 +10,7 @@ import { resolveSelectableModel, } from "@t3tools/shared/model"; import { getComposerProviderState } from "./components/chat/composerProviderRegistry"; -import { UnifiedSettings } from "./appSettings"; +import { UnifiedSettings } from "./hooks/useSettings"; const MAX_CUSTOM_MODEL_COUNT = 32; export const MAX_CUSTOM_MODEL_LENGTH = 256; diff --git a/apps/web/src/routes/_chat.settings.tsx b/apps/web/src/routes/_chat.settings.tsx index 98da7583a6..bd7bcaca7a 100644 --- a/apps/web/src/routes/_chat.settings.tsx +++ b/apps/web/src/routes/_chat.settings.tsx @@ -4,7 +4,7 @@ import { ChevronDownIcon, PlusIcon, RotateCcwIcon, Undo2Icon, XIcon } from "luci import { type ReactNode, useCallback, useState } from "react"; import { type ProviderKind } from "@t3tools/contracts"; import { getModelOptions, normalizeModelSlug } from "@t3tools/shared/model"; -import { useAppSettings } from "../appSettings"; +import { useSettings, useUpdateSettings } from "../hooks/useSettings"; import { getCustomModelOptionsByProvider, MAX_CUSTOM_MODEL_LENGTH, @@ -184,7 +184,8 @@ function SettingResetButton({ label, onClick }: { label: string; onClick: () => function SettingsRouteView() { const { theme, setTheme } = useTheme(); - const { settings, defaults, updateSettings, resetSettings } = useAppSettings(); + const settings = useSettings(); + const { updateSettings, resetSettings, defaults } = useUpdateSettings(); const serverConfigQuery = useQuery(serverConfigQueryOptions()); const [isOpeningKeybindings, setIsOpeningKeybindings] = useState(false); const [openKeybindingsError, setOpenKeybindingsError] = useState(null); diff --git a/apps/web/src/routes/_chat.tsx b/apps/web/src/routes/_chat.tsx index 7cb377056b..80525f556e 100644 --- a/apps/web/src/routes/_chat.tsx +++ b/apps/web/src/routes/_chat.tsx @@ -11,7 +11,7 @@ import { resolveShortcutCommand } from "../keybindings"; import { selectThreadTerminalState, useTerminalStateStore } from "../terminalStateStore"; import { useThreadSelectionStore } from "../threadSelectionStore"; import { resolveSidebarNewThreadEnvMode } from "~/components/Sidebar.logic"; -import { useAppSettings } from "~/appSettings"; +import { useSettings } from "~/hooks/useSettings"; import { Sidebar, SidebarProvider, SidebarRail } from "~/components/ui/sidebar"; const EMPTY_KEYBINDINGS: ResolvedKeybindingsConfig = []; @@ -31,7 +31,7 @@ function ChatRouteGlobalShortcuts() { ? selectThreadTerminalState(state.terminalStateByThreadId, routeThreadId).terminalOpen : false, ); - const { settings: appSettings } = useAppSettings(); + const appSettings = useSettings(); useEffect(() => { const onWindowKeyDown = (event: KeyboardEvent) => { diff --git a/apps/web/src/timestampFormat.ts b/apps/web/src/timestampFormat.ts index d4ffa3c376..1687f58c73 100644 --- a/apps/web/src/timestampFormat.ts +++ b/apps/web/src/timestampFormat.ts @@ -1,4 +1,4 @@ -import { type TimestampFormat } from "./appSettings"; +import { type TimestampFormat } from "./clientSettings"; export function getTimestampFormatOptions( timestampFormat: TimestampFormat,