Skip to content

Commit 27eeab0

Browse files
perf(web): the provider accent color picker compiles without manual memoization
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 70d60e0 commit 27eeab0

2 files changed

Lines changed: 29 additions & 34 deletions

File tree

‎apps/web/reactCompiledFiles.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@ export const REACT_COMPILED_FILES = [
9696
"apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx",
9797
"apps/web/src/components/ThreadTerminalDrawer.tsx",
9898
"apps/web/src/components/settings/SettingsPanels.tsx",
99+
"apps/web/src/components/settings/ProviderAccentColorPicker.tsx",
99100
] as const;

‎apps/web/src/components/settings/ProviderAccentColorPicker.tsx‎

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { PlusIcon, XIcon } from "lucide-react";
4-
import { useCallback, useEffect, useRef, useState } from "react";
4+
import { useEffect, useRef, useState } from "react";
55

66
import { hexToHsv, hsvToHex, type HsvColor } from "../../lib/color";
77
import { ColorHueSlider, ColorSaturationValuePlane } from "../ui/color-picker";
@@ -21,13 +21,10 @@ function ProviderCustomColorPanel(props: {
2121
const currentColor = hsvToHex(hsv.h, hsv.s, hsv.v);
2222
const [hexDraft, setHexDraft] = useState<string | null>(null);
2323

24-
const commitHsv = useCallback(
25-
(nextHsv: HsvColor) => {
26-
setHsv(nextHsv);
27-
onCommit(hsvToHex(nextHsv.h, nextHsv.s, nextHsv.v));
28-
},
29-
[onCommit],
30-
);
24+
const commitHsv = (nextHsv: HsvColor) => {
25+
setHsv(nextHsv);
26+
onCommit(hsvToHex(nextHsv.h, nextHsv.s, nextHsv.v));
27+
};
3128

3229
return (
3330
<div className="w-56 bg-popover">
@@ -161,36 +158,33 @@ export function ProviderAccentColorPicker(props: {
161158
};
162159
}, []);
163160

164-
const commitAccentColor = useCallback(
165-
(value: string) => {
166-
const normalizedValue = normalizeProviderAccentColor(value) ?? "";
167-
setOptimisticValue(normalizedValue);
168-
169-
if (commitDelayMs <= 0) {
170-
pendingCommitRef.current = null;
171-
if (commitTimeoutRef.current !== null) {
172-
clearTimeout(commitTimeoutRef.current);
173-
commitTimeoutRef.current = null;
174-
}
175-
onCommit(normalizedValue);
176-
return;
177-
}
161+
const commitAccentColor = (value: string) => {
162+
const normalizedValue = normalizeProviderAccentColor(value) ?? "";
163+
setOptimisticValue(normalizedValue);
178164

179-
pendingCommitRef.current = normalizedValue;
165+
if (commitDelayMs <= 0) {
166+
pendingCommitRef.current = null;
180167
if (commitTimeoutRef.current !== null) {
181168
clearTimeout(commitTimeoutRef.current);
182-
}
183-
commitTimeoutRef.current = setTimeout(() => {
184169
commitTimeoutRef.current = null;
185-
const pendingCommit = pendingCommitRef.current;
186-
pendingCommitRef.current = null;
187-
if (pendingCommit !== null) {
188-
onCommitRef.current(pendingCommit);
189-
}
190-
}, commitDelayMs);
191-
},
192-
[commitDelayMs, onCommit],
193-
);
170+
}
171+
onCommit(normalizedValue);
172+
return;
173+
}
174+
175+
pendingCommitRef.current = normalizedValue;
176+
if (commitTimeoutRef.current !== null) {
177+
clearTimeout(commitTimeoutRef.current);
178+
}
179+
commitTimeoutRef.current = setTimeout(() => {
180+
commitTimeoutRef.current = null;
181+
const pendingCommit = pendingCommitRef.current;
182+
pendingCommitRef.current = null;
183+
if (pendingCommit !== null) {
184+
onCommitRef.current(pendingCommit);
185+
}
186+
}, commitDelayMs);
187+
};
194188

195189
const normalized = normalizeProviderAccentColor(optimisticValue);
196190
const picker = (

0 commit comments

Comments
 (0)