|
1
|
"use client" |
|
2
|
|
|
3
|
import React from "react" |
|
4
|
import { Button } from "../../Button" |
|
5
|
import { Tooltip } from "../../Tooltip" |
|
6
|
import { Kbd } from "../../Kbd" |
|
7
|
import { getOsShortcut } from "../../../utils/os-browser-utils" |
|
8
|
import { useAiAssistant } from "../../../providers/AiAssistant" |
|
9
|
import { useKeyboardShortcut } from "../../../hooks" |
|
10
|
import { useSearch } from "../../../providers/Search" |
|
11
|
import { BloomIcon } from "../../Icons" |
|
12
|
|
|
13
|
export const AiAssistantTriggerButton = () => { |
|
14
|
const { setChatOpened } = useAiAssistant() |
|
15
|
const { setIsOpen } = useSearch() |
|
16
|
const osShortcut = getOsShortcut() |
|
17
|
|
|
18
|
useKeyboardShortcut({ |
|
19
|
metakey: true, |
|
20
|
shortcutKeys: ["i"], |
|
21
|
action: () => { |
|
22
|
setChatOpened((prev) => !prev) |
|
23
|
setIsOpen(false) |
|
24
|
}, |
|
25
|
checkEditing: false, |
|
26
|
}) |
|
27
|
|
|
28
|
return ( |
|
29
|
<Tooltip |
|
30
|
render={() => ( |
|
31
|
<span className="flex gap-[5px] items-center"> |
|
32
|
<Kbd className="bg-medusa-bg-field-component border-medusa-border-strong w-[18px] h-[18px] inline-block"> |
|
33
|
{osShortcut} |
|
34
|
</Kbd> |
|
35
|
<Kbd className="bg-medusa-bg-field-component border-medusa-border-strong w-[18px] h-[18px] inline-block"> |
|
36
|
i |
|
37
|
</Kbd> |
|
38
|
</span> |
|
39
|
)} |
|
40
|
> |
|
41
|
<Button |
|
42
|
variant="transparent-clear" |
|
43
|
onClick={() => setChatOpened((prev) => !prev)} |
|
44
|
> |
|
45
|
<BloomIcon className="text-medusa-fg-subtle" /> |
|
46
|
<span className="hidden md:inline-block text-medusa-fg-subtle"> |
|
47
|
Ask Bloom |
|
48
|
</span> |
|
49
|
</Button> |
|
50
|
</Tooltip> |
|
51
|
) |
|
52
|
} |