File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import { getLocalStorageItem } from "../hooks/useLocalStorage";
1414import { resolveShortcutCommand , shortcutLabelForCommand } from "../keybindings" ;
1515import { cn , isMacPlatform } from "../lib/utils" ;
1616import { primaryServerKeybindingsAtom } from "../state/server" ;
17- import { useClientSettings , useSidebarV2Enabled } from "../hooks/useSettings" ;
17+ import { useEnvironmentIdentificationMode , useSidebarV2Enabled } from "../hooks/useSettings" ;
1818import ThreadSidebar from "./Sidebar" ;
1919import ThreadSidebarV2 from "./SidebarV2" ;
2020import { useSidebarStageBackdropVariant } from "./SidebarStageBackdrop" ;
@@ -62,9 +62,7 @@ function SidebarControl() {
6262 const keybindings = useAtomValue ( primaryServerKeybindingsAtom ) ;
6363 const { toggleSidebar } = useSidebar ( ) ;
6464 const isSidebarVisible = useSidebarVisibility ( ) ;
65- const environmentIdentificationMode = useClientSettings (
66- ( settings ) => settings . environmentIdentificationMode ,
67- ) ;
65+ const environmentIdentificationMode = useEnvironmentIdentificationMode ( ) ;
6866 const stageBackdropVariant = useSidebarStageBackdropVariant (
6967 environmentIdentificationMode === "artwork" ,
7068 ) ;
Original file line number Diff line number Diff line change 11import { memo , type PointerEventHandler } from "react" ;
22import { ChevronDownIcon , ChevronLeftIcon } from "lucide-react" ;
3- import { useClientSettings } from "~/hooks/useSettings" ;
3+ import { useEnvironmentIdentificationMode } from "~/hooks/useSettings" ;
44import { cn } from "~/lib/utils" ;
55import { StageBackdropButtonArt , useSidebarStageBackdropVariant } from "../SidebarStageBackdrop" ;
66import { Button } from "../ui/button" ;
@@ -73,9 +73,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
7373 const pointerFocusProps = preserveComposerFocusOnPointerDown
7474 ? { onPointerDown : preventPointerFocus }
7575 : undefined ;
76- const environmentIdentificationMode = useClientSettings (
77- ( settings ) => settings . environmentIdentificationMode ,
78- ) ;
76+ const environmentIdentificationMode = useEnvironmentIdentificationMode ( ) ;
7977 const stageBackdropVariant = useSidebarStageBackdropVariant (
8078 environmentIdentificationMode === "artwork" ,
8179 ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { SettingsIcon } from "lucide-react";
22import { memo , useCallback } from "react" ;
33import { Link , useNavigate } from "@tanstack/react-router" ;
44
5- import { useClientSettings } from "../../hooks/useSettings" ;
5+ import { useEnvironmentIdentificationMode } from "../../hooks/useSettings" ;
66import { cn } from "../../lib/utils" ;
77import {
88 resolveEnvironmentIdentificationPillLabel ,
@@ -29,9 +29,7 @@ export const SidebarChromeHeader = memo(function SidebarChromeHeader({
2929 isElectron : boolean ;
3030} ) {
3131 const stageLabel = useEnvironmentStageLabel ( ) ;
32- const environmentIdentificationMode = useClientSettings (
33- ( settings ) => settings . environmentIdentificationMode ,
34- ) ;
32+ const environmentIdentificationMode = useEnvironmentIdentificationMode ( ) ;
3533 const backdropVariant = resolveSidebarStageBackdropVariant (
3634 stageLabel ,
3735 environmentIdentificationMode === "artwork" ,
Original file line number Diff line number Diff line change @@ -6,7 +6,18 @@ import {
66import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings" ;
77import { describe , expect , it } from "vite-plus/test" ;
88
9- import { mergeEnvironmentSettings } from "./useSettings" ;
9+ import { mergeEnvironmentSettings , resolveEnvironmentIdentificationMode } from "./useSettings" ;
10+
11+ describe ( "resolveEnvironmentIdentificationMode" , ( ) => {
12+ it ( "keeps identification hidden until client settings hydrate" , ( ) => {
13+ expect ( resolveEnvironmentIdentificationMode ( { mode : "artwork" , settingsHydrated : false } ) ) . toBe (
14+ "none" ,
15+ ) ;
16+ expect ( resolveEnvironmentIdentificationMode ( { mode : "pill" , settingsHydrated : true } ) ) . toBe (
17+ "pill" ,
18+ ) ;
19+ } ) ;
20+ } ) ;
1021
1122describe ( "mergeEnvironmentSettings" , ( ) => {
1223 it ( "combines the selected environment's server settings with client preferences" , ( ) => {
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {
2121 type ClientSettingsPatch ,
2222 type ClientSettings ,
2323 DEFAULT_CLIENT_SETTINGS ,
24+ type EnvironmentIdentificationMode ,
2425 type UnifiedSettings ,
2526} from "@t3tools/contracts/settings" ;
2627import { safeErrorLogAttributes } from "@t3tools/client-runtime/errors" ;
@@ -222,6 +223,20 @@ export function useClientSettings<T = ClientSettings>(
222223 return useMemo ( ( ) => ( selector ? selector ( settings ) : ( settings as T ) ) , [ selector , settings ] ) ;
223224}
224225
226+ export function resolveEnvironmentIdentificationMode ( input : {
227+ mode : EnvironmentIdentificationMode ;
228+ settingsHydrated : boolean ;
229+ } ) : EnvironmentIdentificationMode {
230+ // Avoid briefly rendering the default artwork before a persisted pill/none choice loads.
231+ return input . settingsHydrated ? input . mode : "none" ;
232+ }
233+
234+ export function useEnvironmentIdentificationMode ( ) : EnvironmentIdentificationMode {
235+ const settingsHydrated = useClientSettingsHydrated ( ) ;
236+ const mode = useClientSettingsValue ( ) . environmentIdentificationMode ;
237+ return resolveEnvironmentIdentificationMode ( { mode, settingsHydrated } ) ;
238+ }
239+
225240/**
226241 * Resolved sidebar v2 state: an explicit choice in Settings → Beta if the user
227242 * has made one, otherwise the default for this build stage (on for nightly and
You can’t perform that action at this time.
0 commit comments