* feat: refactor UseCustomPrompt into reusable component, add to Ollama Refactor custom prompt checkbox functionality from LMStudioProvider and OllamaProvider into a shared UseCustomPrompt component to reduce code duplication and improve maintainability. * Add changeset * replace key with providerId * clean up * Rename UseCustomPrompt to UseCustomPromptCheckbox and update imports Rename UseCustomPrompt.tsx to UseCustomPromptCheckbox.tsx for better clarity and update import paths in LMStudioProvider and OllamaProvider components.
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
|
|
import React, { useCallback, useState } from "react"
|
|
import { useExtensionState } from "@/context/ExtensionStateContext"
|
|
import { updateSetting } from "./utils/settingsHandlers"
|
|
|
|
interface CustomPromptCheckboxProps {
|
|
providerId: string
|
|
}
|
|
|
|
/**
|
|
* Checkbox to enable or disable the use of a compact prompt for local models providers.
|
|
*/
|
|
const UseCustomPromptCheckbox: React.FC<CustomPromptCheckboxProps> = ({ providerId }) => {
|
|
const { customPrompt } = useExtensionState()
|
|
const [isCompactPromptEnabled, setIsCompactPromptEnabled] = useState<boolean>(customPrompt === "compact")
|
|
|
|
const toggleCompactPrompt = useCallback((isChecked: boolean) => {
|
|
setIsCompactPromptEnabled(isChecked)
|
|
updateSetting("customPrompt", isChecked ? "compact" : "")
|
|
}, [])
|
|
|
|
return (
|
|
<div id={providerId}>
|
|
<VSCodeCheckbox checked={isCompactPromptEnabled} onChange={() => toggleCompactPrompt(!isCompactPromptEnabled)}>
|
|
Use compact prompt
|
|
</VSCodeCheckbox>
|
|
<div className="text-xs text-description">
|
|
A system prompt optimized for smaller context window (e.g. 8k or less).
|
|
<div className="text-error flex align-middle">
|
|
<i className="codicon codicon-x" />
|
|
Does not support Mcp and Focus Chain
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default UseCustomPromptCheckbox
|