|
|
@@ -1,4 +1,4 @@
|
|
|
-import { HTMLAttributes } from "react"
|
|
|
+import { HTMLAttributes, useMemo } from "react"
|
|
|
import { useAppTranslation } from "@/i18n/TranslationContext"
|
|
|
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
|
|
|
import { Glasses } from "lucide-react"
|
|
|
@@ -11,12 +11,24 @@ import { ExtensionStateContextType } from "@/context/ExtensionStateContext"
|
|
|
|
|
|
interface UISettingsProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
reasoningBlockCollapsed: boolean
|
|
|
+ enterBehavior: "send" | "newline"
|
|
|
setCachedStateField: SetCachedStateField<keyof ExtensionStateContextType>
|
|
|
}
|
|
|
|
|
|
-export const UISettings = ({ reasoningBlockCollapsed, setCachedStateField, ...props }: UISettingsProps) => {
|
|
|
+export const UISettings = ({
|
|
|
+ reasoningBlockCollapsed,
|
|
|
+ enterBehavior,
|
|
|
+ setCachedStateField,
|
|
|
+ ...props
|
|
|
+}: UISettingsProps) => {
|
|
|
const { t } = useAppTranslation()
|
|
|
|
|
|
+ // Detect platform for dynamic modifier key display
|
|
|
+ const primaryMod = useMemo(() => {
|
|
|
+ const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0
|
|
|
+ return isMac ? "⌘" : "Ctrl"
|
|
|
+ }, [])
|
|
|
+
|
|
|
const handleReasoningBlockCollapsedChange = (value: boolean) => {
|
|
|
setCachedStateField("reasoningBlockCollapsed", value)
|
|
|
|
|
|
@@ -26,6 +38,16 @@ export const UISettings = ({ reasoningBlockCollapsed, setCachedStateField, ...pr
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ const handleEnterBehaviorChange = (requireCtrlEnter: boolean) => {
|
|
|
+ const newBehavior = requireCtrlEnter ? "newline" : "send"
|
|
|
+ setCachedStateField("enterBehavior", newBehavior)
|
|
|
+
|
|
|
+ // Track telemetry event
|
|
|
+ telemetryClient.capture("ui_settings_enter_behavior_changed", {
|
|
|
+ behavior: newBehavior,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
return (
|
|
|
<div {...props}>
|
|
|
<SectionHeader>
|
|
|
@@ -49,6 +71,21 @@ export const UISettings = ({ reasoningBlockCollapsed, setCachedStateField, ...pr
|
|
|
{t("settings:ui.collapseThinking.description")}
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ {/* Enter Key Behavior Setting */}
|
|
|
+ <div className="flex flex-col gap-1">
|
|
|
+ <VSCodeCheckbox
|
|
|
+ checked={enterBehavior === "newline"}
|
|
|
+ onChange={(e: any) => handleEnterBehaviorChange(e.target.checked)}
|
|
|
+ data-testid="enter-behavior-checkbox">
|
|
|
+ <span className="font-medium">
|
|
|
+ {t("settings:ui.requireCtrlEnterToSend.label", { primaryMod })}
|
|
|
+ </span>
|
|
|
+ </VSCodeCheckbox>
|
|
|
+ <div className="text-vscode-descriptionForeground text-sm ml-5 mt-1">
|
|
|
+ {t("settings:ui.requireCtrlEnterToSend.description", { primaryMod })}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</Section>
|
|
|
</div>
|