Add live ActiveAgentsPanel with real-time transcript feed, SidebarContext for responsive sidebar state, agent config form with reasoning effort, improved inbox with failed run alerts, enriched issue detail with project picker, and various component refinements across pages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { createContext, useCallback, useContext, useState, useEffect, type ReactNode } from "react";
|
|
|
|
interface SidebarContextValue {
|
|
sidebarOpen: boolean;
|
|
setSidebarOpen: (open: boolean) => void;
|
|
toggleSidebar: () => void;
|
|
isMobile: boolean;
|
|
}
|
|
|
|
const SidebarContext = createContext<SidebarContextValue | null>(null);
|
|
|
|
const MOBILE_BREAKPOINT = 768;
|
|
|
|
export function SidebarProvider({ children }: { children: ReactNode }) {
|
|
const [isMobile, setIsMobile] = useState(() => window.innerWidth < MOBILE_BREAKPOINT);
|
|
const [sidebarOpen, setSidebarOpen] = useState(() => window.innerWidth >= MOBILE_BREAKPOINT);
|
|
|
|
useEffect(() => {
|
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
const onChange = (e: MediaQueryListEvent) => {
|
|
setIsMobile(e.matches);
|
|
setSidebarOpen(!e.matches);
|
|
};
|
|
mql.addEventListener("change", onChange);
|
|
return () => mql.removeEventListener("change", onChange);
|
|
}, []);
|
|
|
|
const toggleSidebar = useCallback(() => setSidebarOpen((v) => !v), []);
|
|
|
|
return (
|
|
<SidebarContext.Provider value={{ sidebarOpen, setSidebarOpen, toggleSidebar, isMobile }}>
|
|
{children}
|
|
</SidebarContext.Provider>
|
|
);
|
|
}
|
|
|
|
export function useSidebar() {
|
|
const ctx = useContext(SidebarContext);
|
|
if (!ctx) {
|
|
throw new Error("useSidebar must be used within SidebarProvider");
|
|
}
|
|
return ctx;
|
|
}
|