From 4da7b796848d1aba4f86ee150ff39ff474bbeb21 Mon Sep 17 00:00:00 2001 From: Daniel Riccio Date: Fri, 30 May 2025 18:55:41 -0500 Subject: [PATCH] fix: ensure slider always displays valid value (min 2) for concurrent file reads - Fix issue where slider could display values below minimum when enabled with maxConcurrentFileReads <= 1 - Add test cases for edge cases (value 0 and 1) - Ensure UI always shows at least the minimum value of 2 --- .../ConcurrentFileReadsExperiment.tsx | 4 +-- .../ConcurrentFileReadsExperiment.test.tsx | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/webview-ui/src/components/settings/ConcurrentFileReadsExperiment.tsx b/webview-ui/src/components/settings/ConcurrentFileReadsExperiment.tsx index e203e4cf75..fb1f0dc718 100644 --- a/webview-ui/src/components/settings/ConcurrentFileReadsExperiment.tsx +++ b/webview-ui/src/components/settings/ConcurrentFileReadsExperiment.tsx @@ -55,11 +55,11 @@ export const ConcurrentFileReadsExperiment = ({ min={2} max={100} step={1} - value={[maxConcurrentFileReads]} + value={[Math.max(2, maxConcurrentFileReads)]} onValueChange={([value]) => onMaxConcurrentFileReadsChange(value)} data-testid="max-concurrent-file-reads-slider" /> - {maxConcurrentFileReads} + {Math.max(2, maxConcurrentFileReads)} diff --git a/webview-ui/src/components/settings/__tests__/ConcurrentFileReadsExperiment.test.tsx b/webview-ui/src/components/settings/__tests__/ConcurrentFileReadsExperiment.test.tsx index 0c302d006e..590a072ee9 100644 --- a/webview-ui/src/components/settings/__tests__/ConcurrentFileReadsExperiment.test.tsx +++ b/webview-ui/src/components/settings/__tests__/ConcurrentFileReadsExperiment.test.tsx @@ -138,4 +138,35 @@ describe("ConcurrentFileReadsExperiment", () => { // Verify new value is displayed expect(screen.getByText("50")).toBeInTheDocument() }) + + it("should display minimum value of 2 when maxConcurrentFileReads is less than 2", () => { + render( + , + ) + + // Should display 2 (minimum value) instead of 1 + expect(screen.getByText("2")).toBeInTheDocument() + }) + + it("should set maxConcurrentFileReads to 15 when enabling with value of 0", () => { + render( + , + ) + + const checkbox = screen.getByTestId("concurrent-file-reads-checkbox") + fireEvent.click(checkbox) + + expect(mockOnEnabledChange).toHaveBeenCalledWith(true) + expect(mockOnMaxConcurrentFileReadsChange).toHaveBeenCalledWith(15) + }) })