Skip to content

Commit cbd8dc5

Browse files
authored
feat: open quick ai with modifier key + enter (#939)
* feat: open quick ai with modifier key + enter * docs: update changelog
1 parent d1ad1af commit cbd8dc5

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

docs/content.en/docs/release-notes/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ feat: support pageup/pagedown to navigate search results #920
2020
feat: standardize multi-level menu label structure #925
2121
feat(View Extension): page field now accepts HTTP(s) links #925
2222
feat: return sub-exts when extension type exts themselves are matched #928
23+
feat: open quick ai with modifier key + enter #939
2324

2425
### 🐛 Bug fix
2526

src/components/Search/AssistantManager.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import platformAdapter from "@/utils/platformAdapter";
77
import { Get } from "@/api/axiosRequest";
88
import type { Assistant } from "@/types/chat";
99
import { useAppStore } from "@/stores/appStore";
10-
import { navigateBack } from "@/utils";
10+
import { canNavigateBack, navigateBack } from "@/utils";
1111
import { useKeyPress } from "ahooks";
12+
import { useShortcutsStore } from "@/stores/shortcutsStore";
1213

1314
interface AssistantManagerProps {
1415
isChatMode: boolean;
@@ -49,6 +50,7 @@ export function useAssistantManager({
4950
}, [quickAiAccessAssistant, selectedAssistant]);
5051

5152
const [assistantDetail, setAssistantDetail] = useState<any>({});
53+
const { modifierKey } = useShortcutsStore();
5254

5355
useEffect(() => {
5456
if (goAskAi) return;
@@ -78,7 +80,7 @@ export function useAssistantManager({
7880
}, [askAI?.id, askAI?.querySource?.id, disabledExtensions]);
7981

8082
const handleAskAi = useCallback(() => {
81-
if (!isTauri) return;
83+
if (!isTauri || canNavigateBack()) return;
8284

8385
if (disabledExtensions.includes("QuickAIAccess")) return;
8486

@@ -206,6 +208,11 @@ export function useAssistantManager({
206208
setSourceData(selectedSearchContent);
207209
});
208210

211+
useKeyPress(`${modifierKey}.enter`, () => {
212+
assistant_get();
213+
return handleAskAi();
214+
});
215+
209216
return {
210217
askAI,
211218
askAIRef,

src/components/Search/InputBox.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
import { useTauriFocus } from "@/hooks/useTauriFocus";
2929
import { SendMessageParams } from "../Assistant/Chat";
3030
import { isEmpty } from "lodash-es";
31+
import { formatKey } from "@/utils/keyboardUtils";
3132

3233
interface ChatInputProps {
3334
onSend: (params: SendMessageParams) => void;
@@ -253,8 +254,8 @@ export default function ChatInput({
253254
replace: [akiAiTooltipPrefix, askAI.name],
254255
})}
255256
</span>
256-
<div className="flex items-center justify-center w-8 h-[20px] text-xs rounded-md border border-black/10 dark:border-[#545454]">
257-
Tab
257+
<div className="flex items-center justify-center px-1 h-[20px] text-xs rounded-md border border-black/10 dark:border-[#545454]">
258+
{formatKey(modifierKey)} + {formatKey("Enter")}
258259
</div>
259260
</div>
260261
)}

src/utils/keyboardUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const KEY_SYMBOLS: Record<string, string> = {
3737
// Special keys
3838
Space: "Space",
3939
space: "Space",
40-
Enter: "",
40+
Enter: "↩︎",
4141
Backspace: "⌫",
4242
Delete: "Del",
4343
Escape: "Esc",

0 commit comments

Comments
 (0)