From 2dbf28111714790a02693da6a7079a257c8f9b3a Mon Sep 17 00:00:00 2001 From: Nexus Dev Date: Sat, 11 Apr 2026 11:31:05 +0000 Subject: [PATCH] refactor(nexus): apply Task 6 code-quality fixes to Layout.tsx (phase 8) Three cleanups from the Task 6 code-quality review: 1. Delete dead instanceSettingsTarget state and supporting code. The useState, the readRememberedInstanceSettingsPath helper, the INSTANCE_SETTINGS_MEMORY_KEY constant, and the localStorage-writing effect were all residue from the old footer sidebar buttons that Task 6 deleted. Verified via grep that no other file in ui/src reads paperclip.lastInstanceSettingsPath. 2. Consolidate two near-identical mobile-nav-visibility effects into one. The standalone isMobile-reset effect was a strict subset of the scroll-listener effect's early-return branch. 3. Drop onToggleSidebar / onTogglePanel stub callbacks. useKeyboardShortcuts declares these as optional and uses optional chaining internally; the stubs were "type contract satisfaction" the contract did not actually require. No behavioral change. 38 frame tests still pass. Co-Authored-By: Claude Opus 4.6 (1M context) --- ui/src/components/Layout.tsx | 53 ++---------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/ui/src/components/Layout.tsx b/ui/src/components/Layout.tsx index 97be4990..dbd69a5e 100644 --- a/ui/src/components/Layout.tsx +++ b/ui/src/components/Layout.tsx @@ -23,25 +23,10 @@ import { useCompanyPageMemory } from "../hooks/useCompanyPageMemory"; import { healthApi } from "../api/health"; import { instanceSettingsApi } from "../api/instanceSettings"; import { shouldSyncCompanySelectionFromRoute } from "../lib/company-selection"; -import { - DEFAULT_INSTANCE_SETTINGS_PATH, - normalizeRememberedInstanceSettingsPath, -} from "../lib/instance-settings"; import { queryKeys } from "../lib/queryKeys"; import { cn } from "../lib/utils"; import { NotFoundPage } from "../pages/NotFound"; -const INSTANCE_SETTINGS_MEMORY_KEY = "paperclip.lastInstanceSettingsPath"; - -function readRememberedInstanceSettingsPath(): string { - if (typeof window === "undefined") return DEFAULT_INSTANCE_SETTINGS_PATH; - try { - return normalizeRememberedInstanceSettingsPath(window.localStorage.getItem(INSTANCE_SETTINGS_MEMORY_KEY)); - } catch { - return DEFAULT_INSTANCE_SETTINGS_PATH; - } -} - export function Layout() { const { isMobile } = useSidebar(); const { openNewIssue, openOnboarding } = useDialog(); @@ -59,7 +44,6 @@ export function Layout() { const onboardingTriggered = useRef(false); const lastMainScrollTop = useRef(0); const [mobileNavVisible, setMobileNavVisible] = useState(true); - const [, setInstanceSettingsTarget] = useState(() => readRememberedInstanceSettingsPath()); const matchedCompany = useMemo(() => { if (!companyPrefix) return null; @@ -144,13 +128,6 @@ export function Layout() { useKeyboardShortcuts({ enabled: keyboardShortcutsEnabled, onNewIssue: () => openNewIssue(), - onToggleSidebar: () => { - // Phase 8: sidebar toggle is a no-op from keyboard — the rail is fixed. - // Kept as a stub so useKeyboardShortcuts' type contract is satisfied. - }, - onTogglePanel: () => { - // Phase 8: PropertiesPanel is no longer mounted globally. - }, onSearch: () => { // Phase 8: open the command palette via synthetic keydown, mirroring // the CmdKButton shim. Phase 14 replaces with a real palette context. @@ -158,15 +135,6 @@ export function Layout() { }, }); - useEffect(() => { - if (!isMobile) { - setMobileNavVisible(true); - return; - } - lastMainScrollTop.current = 0; - setMobileNavVisible(true); - }, [isMobile]); - const updateMobileNavVisibility = useCallback((currentTop: number) => { const delta = currentTop - lastMainScrollTop.current; if (currentTop <= 24) setMobileNavVisible(true); @@ -176,11 +144,9 @@ export function Layout() { }, []); useEffect(() => { - if (!isMobile) { - setMobileNavVisible(true); - lastMainScrollTop.current = 0; - return; - } + lastMainScrollTop.current = 0; + setMobileNavVisible(true); + if (!isMobile) return; const onScroll = () => { updateMobileNavVisibility(window.scrollY || document.documentElement.scrollTop || 0); }; @@ -197,19 +163,6 @@ export function Layout() { }; }, [isMobile]); - useEffect(() => { - if (!location.pathname.startsWith("/instance/settings/")) return; - const nextPath = normalizeRememberedInstanceSettingsPath( - `${location.pathname}${location.search}${location.hash}`, - ); - setInstanceSettingsTarget(nextPath); - try { - window.localStorage.setItem(INSTANCE_SETTINGS_MEMORY_KEY, nextPath); - } catch { - // Ignore storage failures in restricted environments. - } - }, [location.hash, location.pathname, location.search]); - return (