Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/waveai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Context-aware terminal assistant with access to terminal output, widgets, and fi
| Shortcut | Action |
|----------|--------|
| <Kbd k="Cmd:Shift:a"/> | Toggle AI panel |
| <Kbd k="Ctrl:Shift:0"/> | Focus AI input |
| <Kbd k="Ctrl:Shift:0" windows="Alt:0"/> | Focus AI input |
| <Kbd k="Cmd:k"/> | Clear chat / start new |
| <Kbd k="Enter"/> | Send message |
| <Kbd k="Shift:Enter"/> | New line |
Expand Down
19 changes: 15 additions & 4 deletions docs/src/components/kbd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,20 @@ function convertKey(platform: Platform, key: string): [any, string, boolean] {
}

// Custom KBD component
const KbdInternal = ({ k }: { k: string }) => {
const KbdInternal = ({ k, windows, mac, linux }: { k: string; windows?: string; mac?: string; linux?: string }) => {
const { platform } = useContext(PlatformContext);
const keys = k.split(":");

// Determine which key binding to use based on platform overrides
let keyBinding = k;
if (platform === "windows" && windows) {
keyBinding = windows;
} else if (platform === "mac" && mac) {
keyBinding = mac;
} else if (platform === "linux" && linux) {
keyBinding = linux;
}

const keys = keyBinding.split(":");
const keyElems = keys.map((key, i) => {
const [displayKey, title, symbol] = convertKey(platform, key);
return (
Expand All @@ -58,8 +69,8 @@ const KbdInternal = ({ k }: { k: string }) => {
return <div className="kbd-group">{keyElems}</div>;
};

export const Kbd = ({ k }: { k: string }) => {
return <BrowserOnly fallback={<kbd>{k}</kbd>}>{() => <KbdInternal k={k} />}</BrowserOnly>;
export const Kbd = ({ k, windows, mac, linux }: { k: string; windows?: string; mac?: string; linux?: string }) => {
return <BrowserOnly fallback={<kbd>{k}</kbd>}>{() => <KbdInternal k={k} windows={windows} mac={mac} linux={linux} />}</BrowserOnly>;
};

export const KbdChord = ({ karr }: { karr: string[] }) => {
Expand Down
20 changes: 15 additions & 5 deletions frontend/app/aipanel/aipanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ErrorBoundary } from "@/app/element/errorboundary";
import { atoms, getSettingsKeyAtom } from "@/app/store/global";
import { globalStore } from "@/app/store/jotaiStore";
import { checkKeyPressed, keydownWrapper } from "@/util/keyutil";
import { isMacOS } from "@/util/platformutil";
import { isMacOS, isWindows } from "@/util/platformutil";
import { cn } from "@/util/util";
import { useChat } from "@ai-sdk/react";
import { DefaultChatTransport } from "ai";
Expand Down Expand Up @@ -135,10 +135,20 @@ const AIWelcomeMessage = memo(() => {
<span className="ml-1.5">to toggle panel</span>
</div>
<div>
<KeyCap>Ctrl</KeyCap>
<KeyCap className="ml-1">Shift</KeyCap>
<KeyCap className="ml-1">0</KeyCap>
<span className="ml-1.5">to focus</span>
{isWindows() ? (
<>
<KeyCap>Alt</KeyCap>
<KeyCap className="ml-1">0</KeyCap>
<span className="ml-1.5">to focus</span>
</>
) : (
<>
<KeyCap>Ctrl</KeyCap>
<KeyCap className="ml-1">Shift</KeyCap>
<KeyCap className="ml-1">0</KeyCap>
<span className="ml-1.5">to focus</span>
</>
)}
</div>
</div>
</div>
Expand Down
28 changes: 20 additions & 8 deletions frontend/app/store/keymodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { TabBarModel } from "@/app/tab/tabbar-model";
import { WorkspaceLayoutModel } from "@/app/workspace/workspace-layout-model";
import { deleteLayoutModelForTab, getLayoutModelForStaticTab, NavigateDirection } from "@/layout/index";
import * as keyutil from "@/util/keyutil";
import { isWindows } from "@/util/platformutil";
import { CHORD_TIMEOUT } from "@/util/sharedconst";
import { fireAndForget } from "@/util/util";
import * as jotai from "jotai";
Expand Down Expand Up @@ -606,14 +607,25 @@ function registerGlobalKeys() {
return true;
});
}
globalKeyMap.set("Ctrl:Shift:c{Digit0}", () => {
WaveAIModel.getInstance().focusInput();
return true;
});
globalKeyMap.set("Ctrl:Shift:c{Numpad0}", () => {
WaveAIModel.getInstance().focusInput();
return true;
});
if (isWindows()) {
globalKeyMap.set("Alt:c{Digit0}", () => {
WaveAIModel.getInstance().focusInput();
return true;
});
globalKeyMap.set("Alt:c{Numpad0}", () => {
WaveAIModel.getInstance().focusInput();
return true;
});
} else {
globalKeyMap.set("Ctrl:Shift:c{Digit0}", () => {
WaveAIModel.getInstance().focusInput();
return true;
});
globalKeyMap.set("Ctrl:Shift:c{Numpad0}", () => {
WaveAIModel.getInstance().focusInput();
return true;
});
}
function activateSearch(event: WaveKeyboardEvent): boolean {
const bcm = getBlockComponentModel(getFocusedBlockInStaticTab());
// Ctrl+f is reserved in most shells
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading