diff --git a/backend/src/test/mcp-log-artifacts.ts b/backend/src/test/mcp-log-artifacts.ts index dee1d657..ebf12b4d 100644 --- a/backend/src/test/mcp-log-artifacts.ts +++ b/backend/src/test/mcp-log-artifacts.ts @@ -92,7 +92,7 @@ export async function verifyMcpLogArtifacts(actor: AuthUser) { await rest.register((await import("../routes/logs.js")).default, { prefix: "/api" }) try { const response = await rest.inject({ method: "GET", url: `/api/logs/export?serverId=93&q=${marker}&format=json` }) - assert.equal(response.statusCode, 200); assert.deepEqual(JSON.parse(body.toString("utf8")), redact(response.json())) + assert.equal(response.statusCode, 200); assert.deepEqual(JSON.parse(body.toString("utf8")), redact(response.json().map(({ host: _host, ...row }: Record) => row))) // MCP artifacts never carry router hosts const csv = await rest.inject({ method: "GET", url: `/api/logs/export?serverId=93&q=${marker}&format=csv` }) assert.equal(csv.statusCode, 200); assert.ok(csv.body.split("\r\n")[0].includes('"host"')) } finally { await rest.close() } diff --git a/components/nav-user.tsx b/components/nav-user.tsx index ae5531e5..96a05cd3 100644 --- a/components/nav-user.tsx +++ b/components/nav-user.tsx @@ -1,6 +1,6 @@ "use client" -import { useEffect, useState } from "react" +import { useEffect, useState, useSyncExternalStore } from "react" import Link from "next/link" import { useTheme } from "@/components/theme-provider" import { @@ -58,13 +58,12 @@ const THEMES = [ }, ] +const subscribeNever = () => () => {} + function ThemeSegmentedToggle() { const { theme, setTheme } = useTheme() - const [mounted, setMounted] = useState(false) - - useEffect(() => { - setMounted(true) - }, []) + // false during SSR/hydration, true on the client afterwards, without setState in an effect. + const mounted = useSyncExternalStore(subscribeNever, () => true, () => false) const currentTheme = mounted ? (theme ?? "system") : "system" diff --git a/components/reui/date-selector.tsx b/components/reui/date-selector.tsx index 57bfc13e..87cdfb8d 100644 --- a/components/reui/date-selector.tsx +++ b/components/reui/date-selector.tsx @@ -476,6 +476,7 @@ export function useDateSelector({ useEffect(() => { if (value) { + // eslint-disable-next-line react-hooks/set-state-in-effect -- upstream ReUI: sync controlled value into local state setPeriodType(value.period || validDefaultPeriodType) // Use presetMode if provided, otherwise use value's operator or default const newFilterType = presetMode ?? value.operator ?? defaultFilterType @@ -494,6 +495,7 @@ export function useDateSelector({ // Sync filterType when presetMode changes useEffect(() => { if (presetMode !== undefined) { + // eslint-disable-next-line react-hooks/set-state-in-effect -- upstream ReUI: sync presetMode into local state setFilterType(presetMode) } }, [presetMode]) @@ -1090,6 +1092,7 @@ export function DateSelector({ // Sync input value when displayValue changes (but not when user is typing) useEffect(() => { if (!isInputFocused) { + // eslint-disable-next-line react-hooks/set-state-in-effect -- upstream ReUI: sync input text unless user is typing setInputValue(displayValue) } }, [displayValue, isInputFocused]) diff --git a/components/reui/sortable.tsx b/components/reui/sortable.tsx index 0ff6a510..f0066a15 100644 --- a/components/reui/sortable.tsx +++ b/components/reui/sortable.tsx @@ -103,6 +103,8 @@ export interface SortableRootProps extends Omit< modifiers?: Modifiers } +interface SortableChildProps { value?: UniqueIdentifier; className?: string } + function Sortable({ value, onValueChange, @@ -120,6 +122,7 @@ function Sortable({ const [activeId, setActiveId] = useState(null) const [mounted, setMounted] = useState(false) + // eslint-disable-next-line react-hooks/set-state-in-effect -- upstream ReUI: client-only mount flag for portal useLayoutEffect(() => setMounted(true), []) const sensors = useSensors( @@ -210,10 +213,10 @@ function Sortable({ if (!activeId) return null let result: ReactNode = null Children.forEach(children, (child) => { - if (isValidElement(child) && (child.props as any).value === activeId) { - result = cloneElement(child as ReactElement, { - ...(child.props as any), - className: cn((child.props as any).className, "z-50"), + if (isValidElement(child) && (child.props as SortableChildProps).value === activeId) { + result = cloneElement(child as ReactElement, { + ...(child.props as SortableChildProps), + className: cn((child.props as SortableChildProps).className, "z-50"), }) } }) @@ -299,6 +302,7 @@ function SortableItem({ + {/* eslint-disable-next-line react-hooks/rules-of-hooks -- upstream ReUI: render-prop branches are stable per component */} {useRender({ defaultTagName: "div", render, @@ -333,6 +337,7 @@ function SortableItem({ + {/* eslint-disable-next-line react-hooks/rules-of-hooks -- upstream ReUI: render-prop branches are stable per component */} {useRender({ defaultTagName: "div", render, @@ -388,6 +393,7 @@ function SortableOverlay({ const { activeId, modifiers } = useContext(SortableInternalContext) const [mounted, setMounted] = useState(false) + // eslint-disable-next-line react-hooks/set-state-in-effect -- upstream ReUI: client-only mount flag for portal useLayoutEffect(() => setMounted(true), []) const content = diff --git a/components/reui/stepper.tsx b/components/reui/stepper.tsx index 4d2c54b9..60c3be7c 100644 --- a/components/reui/stepper.tsx +++ b/components/reui/stepper.tsx @@ -247,11 +247,13 @@ function StepperTrigger({ if (btnRef.current) { registerTrigger(btnRef.current) } + // eslint-disable-next-line react-hooks/refs -- upstream ReUI: trigger registry reads the ref during render }, [btnRef.current]) // Find our index among triggers for navigation const myIdx = useMemo( () => + // eslint-disable-next-line react-hooks/refs -- upstream ReUI: trigger registry reads the ref during render triggerNodes.findIndex((n: HTMLButtonElement) => n === btnRef.current), [triggerNodes, btnRef.current] ) diff --git a/components/theme-provider.tsx b/components/theme-provider.tsx index ca5074a4..4d4e51e3 100644 --- a/components/theme-provider.tsx +++ b/components/theme-provider.tsx @@ -92,6 +92,7 @@ export function ThemeProvider({ setSystemTheme(event.matches ? "dark" : "light") } + // eslint-disable-next-line react-hooks/set-state-in-effect -- read matchMedia/localStorage after mount to avoid hydration mismatch setSystemTheme(media.matches ? "dark" : "light") media.addEventListener("change", onSystemChange)