Skip to content

Commit 3e32a18

Browse files
committed
show console in dev only
1 parent aea096f commit 3e32a18

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

packages/react/src/providers/CopilotKitProvider.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface CopilotKitProviderProps {
4141
renderCustomMessages?: ReactCustomMessageRenderer[];
4242
frontendTools?: ReactFrontendTool[];
4343
humanInTheLoop?: ReactHumanInTheLoop[];
44+
showDevConsole?: boolean | "auto";
4445
}
4546

4647
// Small helper to normalize array props to a stable reference and warn
@@ -77,18 +78,31 @@ export const CopilotKitProvider: React.FC<CopilotKitProviderProps> = ({
7778
renderCustomMessages,
7879
frontendTools,
7980
humanInTheLoop,
81+
showDevConsole = false,
8082
}) => {
8183
const [shouldRenderInspector, setShouldRenderInspector] = useState(false);
8284

8385
useEffect(() => {
8486
if (typeof window === "undefined") {
8587
return;
8688
}
87-
const localhostHosts = new Set(["localhost", "127.0.0.1"]);
88-
if (localhostHosts.has(window.location.hostname)) {
89+
90+
if (showDevConsole === true) {
91+
// Explicitly show the inspector
8992
setShouldRenderInspector(true);
93+
} else if (showDevConsole === "auto") {
94+
// Show on localhost or 127.0.0.1 only
95+
const localhostHosts = new Set(["localhost", "127.0.0.1"]);
96+
if (localhostHosts.has(window.location.hostname)) {
97+
setShouldRenderInspector(true);
98+
} else {
99+
setShouldRenderInspector(false);
100+
}
101+
} else {
102+
// showDevConsole is false or undefined (default false)
103+
setShouldRenderInspector(false);
90104
}
91-
}, []);
105+
}, [showDevConsole]);
92106

93107
// Normalize array props to stable references with clear dev warnings
94108
const renderToolCallsList = useStableArrayProp<ReactToolCallRenderer<any>>(

0 commit comments

Comments
 (0)