Skip to content

Commit 769d61e

Browse files
committed
fix windows shortcut for waveai focus
1 parent 440be99 commit 769d61e

File tree

5 files changed

+53
-20
lines changed

5 files changed

+53
-20
lines changed

docs/docs/waveai.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Context-aware terminal assistant with access to terminal output, widgets, and fi
1919
| Shortcut | Action |
2020
|----------|--------|
2121
| <Kbd k="Cmd:Shift:a"/> | Toggle AI panel |
22-
| <Kbd k="Ctrl:Shift:0"/> | Focus AI input |
22+
| <Kbd k="Ctrl:Shift:0" windows="Alt:0"/> | Focus AI input |
2323
| <Kbd k="Cmd:k"/> | Clear chat / start new |
2424
| <Kbd k="Enter"/> | Send message |
2525
| <Kbd k="Shift:Enter"/> | New line |

docs/src/components/kbd.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,20 @@ function convertKey(platform: Platform, key: string): [any, string, boolean] {
4444
}
4545

4646
// Custom KBD component
47-
const KbdInternal = ({ k }: { k: string }) => {
47+
const KbdInternal = ({ k, windows, mac, linux }: { k: string; windows?: string; mac?: string; linux?: string }) => {
4848
const { platform } = useContext(PlatformContext);
49-
const keys = k.split(":");
49+
50+
// Determine which key binding to use based on platform overrides
51+
let keyBinding = k;
52+
if (platform === "windows" && windows) {
53+
keyBinding = windows;
54+
} else if (platform === "mac" && mac) {
55+
keyBinding = mac;
56+
} else if (platform === "linux" && linux) {
57+
keyBinding = linux;
58+
}
59+
60+
const keys = keyBinding.split(":");
5061
const keyElems = keys.map((key, i) => {
5162
const [displayKey, title, symbol] = convertKey(platform, key);
5263
return (
@@ -58,8 +69,8 @@ const KbdInternal = ({ k }: { k: string }) => {
5869
return <div className="kbd-group">{keyElems}</div>;
5970
};
6071

61-
export const Kbd = ({ k }: { k: string }) => {
62-
return <BrowserOnly fallback={<kbd>{k}</kbd>}>{() => <KbdInternal k={k} />}</BrowserOnly>;
72+
export const Kbd = ({ k, windows, mac, linux }: { k: string; windows?: string; mac?: string; linux?: string }) => {
73+
return <BrowserOnly fallback={<kbd>{k}</kbd>}>{() => <KbdInternal k={k} windows={windows} mac={mac} linux={linux} />}</BrowserOnly>;
6374
};
6475

6576
export const KbdChord = ({ karr }: { karr: string[] }) => {

frontend/app/aipanel/aipanel.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ErrorBoundary } from "@/app/element/errorboundary";
77
import { atoms, getSettingsKeyAtom } from "@/app/store/global";
88
import { globalStore } from "@/app/store/jotaiStore";
99
import { checkKeyPressed, keydownWrapper } from "@/util/keyutil";
10-
import { isMacOS } from "@/util/platformutil";
10+
import { isMacOS, isWindows } from "@/util/platformutil";
1111
import { cn } from "@/util/util";
1212
import { useChat } from "@ai-sdk/react";
1313
import { DefaultChatTransport } from "ai";
@@ -135,10 +135,20 @@ const AIWelcomeMessage = memo(() => {
135135
<span className="ml-1.5">to toggle panel</span>
136136
</div>
137137
<div>
138-
<KeyCap>Ctrl</KeyCap>
139-
<KeyCap className="ml-1">Shift</KeyCap>
140-
<KeyCap className="ml-1">0</KeyCap>
141-
<span className="ml-1.5">to focus</span>
138+
{isWindows() ? (
139+
<>
140+
<KeyCap>Alt</KeyCap>
141+
<KeyCap className="ml-1">0</KeyCap>
142+
<span className="ml-1.5">to focus</span>
143+
</>
144+
) : (
145+
<>
146+
<KeyCap>Ctrl</KeyCap>
147+
<KeyCap className="ml-1">Shift</KeyCap>
148+
<KeyCap className="ml-1">0</KeyCap>
149+
<span className="ml-1.5">to focus</span>
150+
</>
151+
)}
142152
</div>
143153
</div>
144154
</div>

frontend/app/store/keymodel.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { TabBarModel } from "@/app/tab/tabbar-model";
2323
import { WorkspaceLayoutModel } from "@/app/workspace/workspace-layout-model";
2424
import { deleteLayoutModelForTab, getLayoutModelForStaticTab, NavigateDirection } from "@/layout/index";
2525
import * as keyutil from "@/util/keyutil";
26+
import { isWindows } from "@/util/platformutil";
2627
import { CHORD_TIMEOUT } from "@/util/sharedconst";
2728
import { fireAndForget } from "@/util/util";
2829
import * as jotai from "jotai";
@@ -606,14 +607,25 @@ function registerGlobalKeys() {
606607
return true;
607608
});
608609
}
609-
globalKeyMap.set("Ctrl:Shift:c{Digit0}", () => {
610-
WaveAIModel.getInstance().focusInput();
611-
return true;
612-
});
613-
globalKeyMap.set("Ctrl:Shift:c{Numpad0}", () => {
614-
WaveAIModel.getInstance().focusInput();
615-
return true;
616-
});
610+
if (isWindows()) {
611+
globalKeyMap.set("Alt:c{Digit0}", () => {
612+
WaveAIModel.getInstance().focusInput();
613+
return true;
614+
});
615+
globalKeyMap.set("Alt:c{Numpad0}", () => {
616+
WaveAIModel.getInstance().focusInput();
617+
return true;
618+
});
619+
} else {
620+
globalKeyMap.set("Ctrl:Shift:c{Digit0}", () => {
621+
WaveAIModel.getInstance().focusInput();
622+
return true;
623+
});
624+
globalKeyMap.set("Ctrl:Shift:c{Numpad0}", () => {
625+
WaveAIModel.getInstance().focusInput();
626+
return true;
627+
});
628+
}
617629
function activateSearch(event: WaveKeyboardEvent): boolean {
618630
const bcm = getBlockComponentModel(getFocusedBlockInStaticTab());
619631
// Ctrl+f is reserved in most shells

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)