@devries-cameron20 / composio Mirror · read-only / commits / 591750523
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 08:15 UTC

docs: add Ask AI button to navbar that opens Decimal widget

Adds a persistent "Ask AI" button next to the search bar in the docs navbar. The button opens the Decimal AI chat widget and supports a Cmd+I keyboard shortcut. Responsive: shows full button with kbd hints on desktop, compact icon on mobile. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Sushmithamallesh committed Feb 19, 2026 at 15:51 UTC 591750523b7ff9a356aa782f1d9385fd161de822
2 files changed +114
docs/components/ask-ai-button.tsx new
+107
@@ -0,0 +1,107 @@
1 +'use client';
2 +
3 +import { useEffect } from 'react';
4 +import { Search, MessageSquare } from 'lucide-react';
5 +import { useSearchContext } from '@fumadocs/ui/contexts/search';
6 +import { useI18n } from '@fumadocs/ui/contexts/i18n';
7 +
8 +function openDecimalWidget() {
9 + const win = window as typeof window & { Decimal?: Record<string, unknown> };
10 + if (win.Decimal) {
11 + for (const key of ['open', 'toggle', 'show'] as const) {
12 + if (typeof win.Decimal[key] === 'function') {
13 + (win.Decimal[key] as () => void)();
14 + return;
15 + }
16 + }
17 + }
18 + const launcher =
19 + document.querySelector<HTMLElement>('[data-decimal-widget]') ??
20 + document.querySelector<HTMLElement>('[class*="decimal" i]') ??
21 + document.querySelector<HTMLElement>('#decimal-widget button');
22 + launcher?.click();
23 +}
24 +
25 +function useAskAIShortcut() {
26 + useEffect(() => {
27 + function handleKeyDown(e: KeyboardEvent) {
28 + if ((e.metaKey || e.ctrlKey) && e.key === 'i') {
29 + e.preventDefault();
30 + openDecimalWidget();
31 + }
32 + }
33 + document.addEventListener('keydown', handleKeyDown);
34 + return () => document.removeEventListener('keydown', handleKeyDown);
35 + }, []);
36 +}
37 +
38 +/** Desktop: search bar + Ask AI button side by side */
39 +export function SearchAndAskAI() {
40 + const { enabled, hotKey, setOpenSearch } = useSearchContext();
41 + const { text } = useI18n();
42 + useAskAIShortcut();
43 +
44 + return (
45 + <>
46 + {enabled && (
47 + <button
48 + type="button"
49 + data-search-full=""
50 + className="inline-flex items-center gap-2 rounded-full border bg-fd-secondary/50 p-1.5 ps-2.5 text-sm text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground w-full max-w-[240px]"
51 + onClick={() => setOpenSearch(true)}
52 + >
53 + <Search className="size-4" />
54 + {text.search}
55 + <div className="ms-auto inline-flex gap-0.5">
56 + {hotKey.map((k, i) => (
57 + <kbd key={i} className="rounded-md border bg-fd-background px-1.5">
58 + {k.display}
59 + </kbd>
60 + ))}
61 + </div>
62 + </button>
63 + )}
64 + <button
65 + type="button"
66 + onClick={openDecimalWidget}
67 + className="inline-flex items-center gap-2 rounded-lg border bg-fd-secondary/50 p-1.5 ps-2.5 text-sm text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground shrink-0"
68 + >
69 + Ask AI
70 + <div className="hidden xl:inline-flex gap-0.5">
71 + <kbd className="rounded-md border bg-fd-background px-1.5">⌘</kbd>
72 + <kbd className="rounded-md border bg-fd-background px-1.5">I</kbd>
73 + </div>
74 + </button>
75 + </>
76 + );
77 +}
78 +
79 +/** Mobile: search icon + Ask AI icon, shown below lg breakpoint */
80 +export function SearchAndAskAIMobile() {
81 + const { enabled, setOpenSearch } = useSearchContext();
82 + useAskAIShortcut();
83 +
84 + return (
85 + <>
86 + {enabled && (
87 + <button
88 + type="button"
89 + data-search=""
90 + aria-label="Open Search"
91 + className="inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-100 hover:bg-fd-accent hover:text-fd-accent-foreground"
92 + onClick={() => setOpenSearch(true)}
93 + >
94 + <Search className="size-4.5" />
95 + </button>
96 + )}
97 + <button
98 + type="button"
99 + aria-label="Ask AI"
100 + onClick={openDecimalWidget}
101 + className="inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-100 hover:bg-fd-accent hover:text-fd-accent-foreground"
102 + >
103 + <MessageSquare className="size-4.5" />
104 + </button>
105 + </>
106 + );
107 +}
docs/lib/layout.shared.tsx
+7
@@ -1,6 +1,7 @@
1 import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
2 import Image from 'next/image';
3 import { Play } from 'lucide-react';
4 +import { SearchAndAskAI, SearchAndAskAIMobile } from '@/components/ask-ai-button';
5
6 // Composio Logo Component with light/dark mode switching
7 function ComposioLogo() {
@@ -34,6 +35,12 @@ export function baseOptions(): BaseLayoutProps {
35 title: <ComposioLogo />,
36 transparentMode: 'top',
37 },
38 + searchToggle: {
39 + components: {
40 + lg: <SearchAndAskAI />,
41 + sm: <SearchAndAskAIMobile />,
42 + },
43 + },
44 links: [
45 {
46 text: 'Docs',