@devries-cameron20 / composio-1 / commits / b1ef51326
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix: use robust platform detection for Ask AI shortcut hint

navigator.platform is deprecated and unreliable in embedded browsers like ChatGPT Atlas. Use navigator.userAgentData.platform (modern API) with fallback to navigator.platform, defaulting to Mac on failure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Sushmitha Mallesh committed Feb 22, 2026 at 12:47 UTC b1ef513267803ae3f33f3fec2fa796c0cba7f8fc
2 files changed +24 -2
docs/components/ask-ai-button.tsx
+12 -1
@@ -26,10 +26,21 @@ export function toggleDecimalWidget() {
26 widgetOpen = !widgetOpen;
27 }
28
29 +function detectMac(): boolean {
30 + try {
31 + if ('userAgentData' in navigator) {
32 + return (navigator as Navigator & { userAgentData?: { platform?: string } }).userAgentData?.platform === 'macOS';
33 + }
34 + return /mac/i.test(navigator.platform);
35 + } catch {
36 + return true; // default to Mac
37 + }
38 +}
39 +
40 function useIsMac() {
41 const [isMac, setIsMac] = useState(true);
42 useEffect(() => {
32 - setIsMac(navigator.platform.toUpperCase().includes('MAC'));
43 + setIsMac(detectMac());
44 }, []);
45 return isMac;
46 }
docs/components/custom-search-dialog.tsx
+12 -1
@@ -18,10 +18,21 @@ import { useDocsSearch } from 'fumadocs-core/search/client';
18 import { BotMessageSquare } from 'lucide-react';
19 import { toggleDecimalWidget } from './ask-ai-button';
20
21 +function detectMac(): boolean {
22 + try {
23 + if ('userAgentData' in navigator) {
24 + return (navigator as Navigator & { userAgentData?: { platform?: string } }).userAgentData?.platform === 'macOS';
25 + }
26 + return /mac/i.test(navigator.platform);
27 + } catch {
28 + return true; // default to Mac
29 + }
30 +}
31 +
32 function MetaKey() {
33 const [key, setKey] = useState('⌘');
34 useEffect(() => {
24 - if (!navigator.platform.toUpperCase().includes('MAC')) setKey('Ctrl');
35 + if (!detectMac()) setKey('Ctrl');
36 }, []);
37 return key;
38 }