-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(ui): add chat font size multiplier setting #10489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
aecec67
007629a
3c5e393
e6e1c5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||||||||||||||||||||||
| import { HTMLAttributes, useMemo } from "react" | ||||||||||||||||||||||||||||||||||
| import { HTMLAttributes, useMemo, useState, useCallback, useEffect } from "react" | ||||||||||||||||||||||||||||||||||
| import { useAppTranslation } from "@/i18n/TranslationContext" | ||||||||||||||||||||||||||||||||||
| import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" | ||||||||||||||||||||||||||||||||||
| import { RotateCcw } from "lucide-react" | ||||||||||||||||||||||||||||||||||
| import { telemetryClient } from "@/utils/TelemetryClient" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import { SetCachedStateField } from "./types" | ||||||||||||||||||||||||||||||||||
|
|
@@ -12,17 +13,27 @@ import { ExtensionStateContextType } from "@/context/ExtensionStateContext" | |||||||||||||||||||||||||||||||||
| interface UISettingsProps extends HTMLAttributes<HTMLDivElement> { | ||||||||||||||||||||||||||||||||||
| reasoningBlockCollapsed: boolean | ||||||||||||||||||||||||||||||||||
| enterBehavior: "send" | "newline" | ||||||||||||||||||||||||||||||||||
| chatFontSizeMultiplier: number | ||||||||||||||||||||||||||||||||||
| setCachedStateField: SetCachedStateField<keyof ExtensionStateContextType> | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| export const UISettings = ({ | ||||||||||||||||||||||||||||||||||
| reasoningBlockCollapsed, | ||||||||||||||||||||||||||||||||||
| enterBehavior, | ||||||||||||||||||||||||||||||||||
| chatFontSizeMultiplier, | ||||||||||||||||||||||||||||||||||
| setCachedStateField, | ||||||||||||||||||||||||||||||||||
| ...props | ||||||||||||||||||||||||||||||||||
| }: UISettingsProps) => { | ||||||||||||||||||||||||||||||||||
| const { t } = useAppTranslation() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Local state for the input value to allow typing freely | ||||||||||||||||||||||||||||||||||
| const [localMultiplier, setLocalMultiplier] = useState(chatFontSizeMultiplier.toString()) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Sync local state when prop changes (e.g., from commands) | ||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||
| setLocalMultiplier(chatFontSizeMultiplier.toString()) | ||||||||||||||||||||||||||||||||||
| }, [chatFontSizeMultiplier]) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Detect platform for dynamic modifier key display | ||||||||||||||||||||||||||||||||||
| const primaryMod = useMemo(() => { | ||||||||||||||||||||||||||||||||||
| const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0 | ||||||||||||||||||||||||||||||||||
|
|
@@ -48,6 +59,45 @@ export const UISettings = ({ | |||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const handleFontSizeMultiplierChange = useCallback( | ||||||||||||||||||||||||||||||||||
| (value: string) => { | ||||||||||||||||||||||||||||||||||
| setLocalMultiplier(value) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Parse and validate the value | ||||||||||||||||||||||||||||||||||
| const numValue = parseFloat(value) | ||||||||||||||||||||||||||||||||||
| if (!isNaN(numValue)) { | ||||||||||||||||||||||||||||||||||
| // Clamp the value between 0.5 and 2 | ||||||||||||||||||||||||||||||||||
| const clampedValue = Math.max(0.5, Math.min(2, numValue)) | ||||||||||||||||||||||||||||||||||
| setCachedStateField("chatFontSizeMultiplier", clampedValue) | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| [setCachedStateField], | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const handleFontSizeMultiplierBlur = useCallback(() => { | ||||||||||||||||||||||||||||||||||
| // On blur, ensure the display value matches the clamped value | ||||||||||||||||||||||||||||||||||
| const numValue = parseFloat(localMultiplier) | ||||||||||||||||||||||||||||||||||
| if (isNaN(numValue)) { | ||||||||||||||||||||||||||||||||||
| setLocalMultiplier(chatFontSizeMultiplier.toString()) | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| const clampedValue = Math.max(0.5, Math.min(2, numValue)) | ||||||||||||||||||||||||||||||||||
| setLocalMultiplier(clampedValue.toString()) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Track telemetry event on blur to capture only the user's final value | ||||||||||||||||||||||||||||||||||
| telemetryClient.capture("ui_settings_chat_font_size_changed", { | ||||||||||||||||||||||||||||||||||
| multiplier: clampedValue, | ||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+83
to
+89
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Fix it with Roo Code or mention @roomote and request a fix. |
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| }, [localMultiplier, chatFontSizeMultiplier]) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const handleResetFontSize = useCallback(() => { | ||||||||||||||||||||||||||||||||||
| setCachedStateField("chatFontSizeMultiplier", 1) | ||||||||||||||||||||||||||||||||||
| setLocalMultiplier("1") | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Track telemetry event | ||||||||||||||||||||||||||||||||||
| telemetryClient.capture("ui_settings_chat_font_size_reset", {}) | ||||||||||||||||||||||||||||||||||
| }, [setCachedStateField]) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||
| <div {...props}> | ||||||||||||||||||||||||||||||||||
| <SectionHeader>{t("settings:sections.ui")}</SectionHeader> | ||||||||||||||||||||||||||||||||||
|
|
@@ -91,6 +141,43 @@ export const UISettings = ({ | |||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| </SearchableSetting> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| {/* Chat Font Size Multiplier Setting */} | ||||||||||||||||||||||||||||||||||
| <SearchableSetting | ||||||||||||||||||||||||||||||||||
| settingId="ui-chat-font-size" | ||||||||||||||||||||||||||||||||||
| section="ui" | ||||||||||||||||||||||||||||||||||
| label={t("settings:ui.chatFontSizeMultiplier.label")}> | ||||||||||||||||||||||||||||||||||
| <div className="flex flex-col gap-1"> | ||||||||||||||||||||||||||||||||||
| <label className="font-medium" htmlFor="chat-font-size-input"> | ||||||||||||||||||||||||||||||||||
| {t("settings:ui.chatFontSizeMultiplier.label")} | ||||||||||||||||||||||||||||||||||
| </label> | ||||||||||||||||||||||||||||||||||
| <div className="flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||
| <input | ||||||||||||||||||||||||||||||||||
| id="chat-font-size-input" | ||||||||||||||||||||||||||||||||||
| type="number" | ||||||||||||||||||||||||||||||||||
| min="0.5" | ||||||||||||||||||||||||||||||||||
| max="2" | ||||||||||||||||||||||||||||||||||
| step="0.1" | ||||||||||||||||||||||||||||||||||
| value={localMultiplier} | ||||||||||||||||||||||||||||||||||
| onChange={(e) => handleFontSizeMultiplierChange(e.target.value)} | ||||||||||||||||||||||||||||||||||
| onBlur={handleFontSizeMultiplierBlur} | ||||||||||||||||||||||||||||||||||
| className="w-20 px-2 py-1 bg-vscode-input-background text-vscode-input-foreground border border-vscode-input-border rounded" | ||||||||||||||||||||||||||||||||||
| data-testid="chat-font-size-input" | ||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||
| onClick={handleResetFontSize} | ||||||||||||||||||||||||||||||||||
| className="flex items-center gap-1 px-2 py-1 text-sm bg-vscode-button-secondaryBackground text-vscode-button-secondaryForeground hover:bg-vscode-button-secondaryHoverBackground rounded" | ||||||||||||||||||||||||||||||||||
| title={t("settings:ui.chatFontSizeMultiplier.reset")} | ||||||||||||||||||||||||||||||||||
| data-testid="chat-font-size-reset-button"> | ||||||||||||||||||||||||||||||||||
| <RotateCcw className="w-3 h-3" /> | ||||||||||||||||||||||||||||||||||
| {t("settings:ui.chatFontSizeMultiplier.reset")} | ||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| <div className="text-vscode-descriptionForeground text-sm mt-1"> | ||||||||||||||||||||||||||||||||||
| {t("settings:ui.chatFontSizeMultiplier.description")} | ||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| </SearchableSetting> | ||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| </Section> | ||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chatFontSizeMultiplieris destructured fromcachedStatehere but is never included in theupdatedSettingspayload insidehandleSubmit(around line 416, next toenterBehavior). The commands persist correctly viacontextProxy.setValue(), but changes made through the Settings UI will be lost on reload becausehandleSubmitnever sends this field to the extension host. AddchatFontSizeMultiplier: chatFontSizeMultiplier ?? 1,to theupdatedSettingsobject inhandleSubmit.Fix it with Roo Code or mention @roomote and request a fix.