Skip to content

Commit f37a5eb

Browse files
committed
feat: add shortcut hint to auto-approve dropdown
1 parent f5d7ba1 commit f37a5eb

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

webview-ui/src/components/chat/AutoApproveDropdown.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Popover, PopoverContent, PopoverTrigger, StandardTooltip, ToggleSwitch
1010
import { AutoApproveSetting, autoApproveSettingsConfig } from "../settings/AutoApproveToggle"
1111
import { useAutoApprovalToggles } from "@/hooks/useAutoApprovalToggles"
1212
import { useAutoApprovalState } from "@/hooks/useAutoApprovalState"
13+
import { ShortcutHint } from "./ShortcutHint"
1314

1415
interface AutoApproveDropdownProps {
1516
disabled?: boolean
@@ -222,6 +223,7 @@ export const AutoApproveDropdown = ({ disabled = false, triggerClassName = "" }:
222223
<p className="m-0 text-xs text-vscode-descriptionForeground">
223224
{t("chat:autoApprove.description")}
224225
</p>
226+
<ShortcutHint translationKey={"chat:autoApprove.toggleShortcut"} />
225227
</div>
226228
<div className="grid grid-cols-1 min-[340px]:grid-cols-2 gap-x-2 gap-y-2 p-3">
227229
{settingsArray.map(({ key, labelKey, descriptionKey, icon }) => {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from "react"
2+
import { Trans } from "react-i18next"
3+
4+
import { useAppTranslation } from "@/i18n/TranslationContext"
5+
import { usePlatform } from "@/hooks/usePlatform"
6+
7+
interface ShortcutHintProps {
8+
translationKey: string
9+
}
10+
11+
export const ShortcutHint: React.FC<ShortcutHintProps> = ({ translationKey }) => {
12+
const { t } = useAppTranslation()
13+
const platform = usePlatform()
14+
15+
const getShortcut = () => {
16+
switch (platform) {
17+
case "mac":
18+
return "⌘⌥A"
19+
case "windows":
20+
case "linux":
21+
return "Ctrl+Alt+A"
22+
default:
23+
return ""
24+
}
25+
}
26+
27+
const shortcut = getShortcut()
28+
29+
if (!shortcut) {
30+
return null
31+
}
32+
33+
return (
34+
<p className="m-0 text-xs text-vscode-descriptionForeground">
35+
<Trans
36+
i18nKey={translationKey}
37+
components={{
38+
shortcut: <code className="p-1 rounded bg-vscode-button-background">{shortcut}</code>,
39+
}}
40+
/>
41+
</p>
42+
)
43+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { useState, useEffect } from "react"
2+
3+
type Platform = "mac" | "windows" | "linux" | "unknown"
4+
5+
export function usePlatform(): Platform {
6+
const [platform, setPlatform] = useState<Platform>("unknown")
7+
8+
useEffect(() => {
9+
const userAgent = window.navigator.userAgent.toLowerCase()
10+
if (userAgent.includes("mac")) {
11+
setPlatform("mac")
12+
} else if (userAgent.includes("win")) {
13+
setPlatform("windows")
14+
} else if (userAgent.includes("linux")) {
15+
setPlatform("linux")
16+
}
17+
}, [])
18+
19+
return platform
20+
}

webview-ui/src/i18n/locales/en/chat.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@
294294
"triggerLabel_zero": "0 auto-approve",
295295
"triggerLabel_one": "1 auto-approved",
296296
"triggerLabel_other": "{{count}} auto-approved",
297-
"triggerLabelAll": "YOLO"
297+
"triggerLabelAll": "YOLO",
298+
"toggleShortcut": "Toggle with <shortcut>"
298299
},
299300
"announcement": {
300301
"title": "🎉 Roo Code {{version}} Released",

0 commit comments

Comments
 (0)