All files / src/components/settings/common ContextWindowSwitcher.tsx

12.5% Statements 5/40
100% Branches 0/0
0% Functions 0/1
12.5% Lines 5/40

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 551x 1x                 1x   1x 1x                                                                                  
import { VSCodeLink } from "@vscode/webview-ui-toolkit/react"
import { useMemo } from "react"
 
interface ContextWindowSwitcherProps {
	selectedModelId: string
	base200kModelId: string
	base1mModelId: string
	onModelChange: (modelId: string) => void
}
 
/**
 * A shared component for switching between 200K and 1M context window variants of Claude models.
 */
export const ContextWindowSwitcher = ({
	selectedModelId,
	base200kModelId,
	base1mModelId,
	onModelChange,
}: ContextWindowSwitcherProps) => {
	const switcherInfo = useMemo(() => {
		if (selectedModelId === base200kModelId) {
			return {
				current: base200kModelId,
				alternate: base1mModelId,
				linkText: "Switch to 1M context window model",
			}
		} else if (selectedModelId === base1mModelId) {
			return {
				current: base1mModelId,
				alternate: base200kModelId,
				linkText: "Switch to 200K context window model",
			}
		}
		return null
	}, [selectedModelId, base200kModelId, base1mModelId])
 
	if (!switcherInfo) {
		return null
	}
 
	return (
		<div style={{ marginBottom: 2 }}>
			<VSCodeLink
				onClick={() => onModelChange(switcherInfo.alternate)}
				style={{
					display: "inline",
					fontSize: "10.5px",
					color: "var(--vscode-textLink-foreground)",
				}}>
				{switcherInfo.linkText}
			</VSCodeLink>
		</div>
	)
}