The best way to control Claude Code, Codex and more from any computer or phone
perf(web): the settings panels compile with the React Compiler (#20528)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 19:09 UTC
1da2d60b43e7523ce0eb24768710dfa23d586f61
2 files changed
+244
-329
apps/web/reactCompiledFiles.ts
+1
@@ -95,4 +95,5 @@ export const REACT_COMPILED_FILES = [
95
"apps/web/src/components/settings/ThemeColorPicker.tsx",
96
"apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx",
97
"apps/web/src/components/ThreadTerminalDrawer.tsx",
98
+ "apps/web/src/components/settings/SettingsPanels.tsx",
99
] as const;
apps/web/src/components/settings/SettingsPanels.tsx
+243
-329
@@ -7,7 +7,7 @@ import { PRIVACY_POLICY_URL } from "../../legalLinks";
7
import { ArchiveIcon, ArchiveX, CheckIcon, ChevronRightIcon, SettingsIcon } from "lucide-react";
8
import { Link, useNavigate } from "@tanstack/react-router";
9
import type { CSSProperties, ReactNode } from "react";
10
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
10
+import { useEffect, useEffectEvent, useRef, useState } from "react";
11
import {
12
type BackgroundActivityProfile,
13
type DesktopUpdateChannel,
@@ -288,37 +288,34 @@ function AboutVersionSection() {
288
const selectedUpdateChannel = updateState?.channel ?? "latest";
289
const selectedHostedAppChannel = hasDesktopBridge ? null : HOSTED_APP_CHANNEL;
290
291
- const handleUpdateChannelChange = useCallback(
292
- (channel: DesktopUpdateChannel) => {
293
- const bridge = window.desktopBridge;
294
- if (
295
- !bridge ||
296
- typeof bridge.setUpdateChannel !== "function" ||
297
- channel === selectedUpdateChannel
298
- ) {
299
- return;
300
- }
291
+ const handleUpdateChannelChange = (channel: DesktopUpdateChannel) => {
292
+ const bridge = window.desktopBridge;
293
+ if (
294
+ !bridge ||
295
+ typeof bridge.setUpdateChannel !== "function" ||
296
+ channel === selectedUpdateChannel
297
+ ) {
298
+ return;
299
+ }
300
302
- setIsChangingUpdateChannel(true);
303
- void bridge
304
- .setUpdateChannel(channel)
305
- .catch((error: unknown) => {
306
- toastManager.add(
307
- stackedThreadToast({
308
- type: "error",
309
- title: "Could not change update track",
310
- description: error instanceof Error ? error.message : "Update track change failed.",
311
- }),
312
- );
313
- })
314
- .finally(() => {
315
- setIsChangingUpdateChannel(false);
316
- });
317
- },
318
- [selectedUpdateChannel],
319
- );
301
+ setIsChangingUpdateChannel(true);
302
+ void bridge
303
+ .setUpdateChannel(channel)
304
+ .catch((error: unknown) => {
305
+ toastManager.add(
306
+ stackedThreadToast({
307
+ type: "error",
308
+ title: "Could not change update track",
309
+ description: error instanceof Error ? error.message : "Update track change failed.",
310
+ }),
311
+ );
312
+ })
313
+ .finally(() => {
314
+ setIsChangingUpdateChannel(false);
315
+ });
316
+ };
317
321
- const handleButtonClick = useCallback(async () => {
318
+ const handleButtonClick = async () => {
319
const bridge = window.desktopBridge;
320
if (!bridge) return;
321
@@ -401,7 +398,7 @@ function AboutVersionSection() {
398
}),
399
);
400
});
404
- }, [isUpdateActionPending, updateState]);
401
+ };
402
403
const action = updateState ? resolveDesktopUpdateButtonAction(updateState) : "none";
404
const buttonTooltip = updateState ? getDesktopUpdateButtonTooltip(updateState) : null;
@@ -532,204 +529,133 @@ export function useSettingsRestore(onRestored?: () => void) {
529
);
530
const isBackgroundActivityDirty = hasChangedBackgroundActivitySettings(settings);
531
535
- const changedSettingLabels = useMemo(
536
- () => [
537
- ...(theme !== "system" ? ["Theme"] : []),
538
- ...(!followSystem ? ["Follow system"] : []),
539
- ...(themeHalves !== null ? ["Theme mix"] : []),
540
- ...(settings.appearanceContrast !== DEFAULT_UNIFIED_SETTINGS.appearanceContrast
541
- ? ["Contrast"]
542
- : []),
543
- ...(settings.glassOpacity !== DEFAULT_UNIFIED_SETTINGS.glassOpacity ? ["Glass opacity"] : []),
544
- ...(settings.diffColorScheme !== DEFAULT_UNIFIED_SETTINGS.diffColorScheme
545
- ? ["Diff colors"]
546
- : []),
547
- ...(settings.chatWidth !== DEFAULT_UNIFIED_SETTINGS.chatWidth ? ["Chat width"] : []),
548
- ...(settings.panelAnimationDurationMs !== DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs
549
- ? ["Panel animations"]
550
- : []),
551
- ...(settings.environmentIdentificationMode !==
552
- DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode
553
- ? ["Environment identification"]
554
- : []),
555
- ...(settings.timestampFormat !== DEFAULT_UNIFIED_SETTINGS.timestampFormat
556
- ? ["Time format"]
557
- : []),
558
- ...(settings.notificationMode !== DEFAULT_UNIFIED_SETTINGS.notificationMode
559
- ? ["Thread notifications"]
560
- : []),
561
- ...(settings.inAppNotificationsEnabled !== DEFAULT_UNIFIED_SETTINGS.inAppNotificationsEnabled
562
- ? ["In-app notifications"]
563
- : []),
564
- ...(settings.sidebarThreadPreviewCount !== DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount
565
- ? ["Visible threads"]
566
- : []),
567
- ...(settings.sidebarProjectGroupingMode !==
568
- DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode
569
- ? ["Project Grouping"]
570
- : []),
571
- ...(settings.sidebarProjectSortOrder !== DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder
572
- ? ["Project order"]
573
- : []),
574
- ...(settings.sidebarWorkingShelfEnabled !==
575
- DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled
576
- ? ["Working section"]
577
- : []),
578
- ...(settings.sidebarAutoSettleAfterDays !==
579
- DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays
580
- ? ["Auto-settle inactive threads"]
581
- : []),
582
- ...(settings.sidebarAutoSettleKeepPullRequests !==
583
- DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleKeepPullRequests
584
- ? ["Keep threads with a PR"]
585
- : []),
586
- ...(settings.sidebarAutoSettleOnMerge !== DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge
587
- ? ["Auto-settle merged threads"]
588
- : []),
589
- ...(settings.autoResumeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.autoResumeLimitedThreads
590
- ? ["Auto-resume limited threads"]
591
- : []),
592
- ...(settings.snoozeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads
593
- ? ["Snooze limited threads"]
594
- : []),
595
- ...(settings.wordWrap !== DEFAULT_UNIFIED_SETTINGS.wordWrap ? ["Word wrap"] : []),
596
- ...(settings.persistComposerContextStrip !==
597
- DEFAULT_UNIFIED_SETTINGS.persistComposerContextStrip
598
- ? ["Composer context"]
599
- : []),
600
- ...getChangedTypographySettingLabels(settings),
601
- ...(settings.diffFilesCollapsed !== DEFAULT_UNIFIED_SETTINGS.diffFilesCollapsed
602
- ? ["Default diff file state"]
603
- : []),
604
- ...(settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace
605
- ? ["Diff whitespace changes"]
606
- : []),
607
- ...(settings.diffLayout !== DEFAULT_UNIFIED_SETTINGS.diffLayout ? ["Diff layout"] : []),
608
- ...(settings.proactivePanelsEnabled !== DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled
609
- ? ["Proactive panels"]
610
- : []),
611
- ...(settings.showSkillsInSlashMenu !== DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu
612
- ? ["Show skills in slash menu"]
613
- : []),
614
- ...(settings.composerCollapseOnScroll !== DEFAULT_UNIFIED_SETTINGS.composerCollapseOnScroll
615
- ? ["Collapse composer on scroll"]
616
- : []),
617
- ...(settings.composerRichTextEnabled !== DEFAULT_UNIFIED_SETTINGS.composerRichTextEnabled
618
- ? ["Rich text composer"]
619
- : []),
620
- ...(settings.sendShortcut !== DEFAULT_UNIFIED_SETTINGS.sendShortcut ? ["Send shortcut"] : []),
621
- ...(settings.followUpBehavior !== DEFAULT_UNIFIED_SETTINGS.followUpBehavior
622
- ? ["Follow-up behavior"]
623
- : []),
624
- ...(settings.contextWindowMeterEnabled !== DEFAULT_UNIFIED_SETTINGS.contextWindowMeterEnabled
625
- ? ["Context window indicator"]
626
- : []),
627
- ...(settings.responseStreamingMode !== DEFAULT_UNIFIED_SETTINGS.responseStreamingMode
628
- ? ["Response streaming"]
629
- : []),
630
- ...(settings.enableProviderUpdateChecks !==
631
- DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks
632
- ? ["Provider update checks"]
633
- : []),
634
- ...(settings.continueThreadsAfterServerUpdate !==
635
- DEFAULT_UNIFIED_SETTINGS.continueThreadsAfterServerUpdate
636
- ? ["Continue threads after restarts"]
637
- : []),
638
- ...(isBackgroundActivityDirty ? ["Background activity"] : []),
639
- ...(settings.defaultThreadEnvMode !== DEFAULT_UNIFIED_SETTINGS.defaultThreadEnvMode
640
- ? ["New thread mode"]
641
- : []),
642
- ...(settings.newWorktreesStartFromOrigin !==
643
- DEFAULT_UNIFIED_SETTINGS.newWorktreesStartFromOrigin
644
- ? ["New worktrees start from origin"]
645
- : []),
646
- ...(settings.addProjectBaseDirectory !== DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory
647
- ? ["Add project base directory"]
648
- : []),
649
- ...(settings.confirmThreadUnpin !== DEFAULT_UNIFIED_SETTINGS.confirmThreadUnpin
650
- ? ["Unpin confirmation"]
651
- : []),
652
- ...(settings.confirmThreadArchive !== DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive
653
- ? ["Archive confirmation"]
654
- : []),
655
- ...(settings.confirmThreadDelete !== DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete
656
- ? ["Delete confirmation"]
657
- : []),
658
- ...(settings.confirmQuit !== DEFAULT_UNIFIED_SETTINGS.confirmQuit ? ["Quit shortcut"] : []),
659
- ...(isTextGenerationModelDirty ? ["Text generation model"] : []),
660
- ...getChangedBrowserSettingLabels(settings),
661
- ...(settings.enableAgentBrowserAccess !== DEFAULT_UNIFIED_SETTINGS.enableAgentBrowserAccess
662
- ? ["Agent browser access"]
663
- : []),
664
- ],
665
- [
666
- isTextGenerationModelDirty,
667
- isBackgroundActivityDirty,
668
- settings.browserDefaultViewport,
669
- settings.browserDefaultZoomFactor,
670
- settings.browserDefaultAppearance,
671
- settings.browserRecordingFrameRate,
672
- settings.browserRecordingShowKeyPresses,
673
- settings.browserRecordingShowMousePresses,
674
- settings.browserLinkTarget,
675
- settings.browserAutoShowFloatingPreview,
676
- settings.pullRequestLinksOpenInApp,
677
- settings.appearanceContrast,
678
- settings.diffColorScheme,
679
- settings.chatWidth,
680
- settings.enableAgentBrowserAccess,
681
- settings.confirmQuit,
682
- settings.confirmThreadArchive,
683
- settings.confirmThreadDelete,
684
- settings.confirmThreadUnpin,
685
- settings.composerCollapseOnScroll,
686
- settings.composerRichTextEnabled,
687
- settings.sendShortcut,
688
- settings.followUpBehavior,
689
- settings.addProjectBaseDirectory,
690
- settings.defaultThreadEnvMode,
691
- settings.newWorktreesStartFromOrigin,
692
- settings.diffFilesCollapsed,
693
- settings.diffIgnoreWhitespace,
694
- settings.diffLayout,
695
- settings.proactivePanelsEnabled,
696
- settings.environmentIdentificationMode,
697
- settings.contextWindowMeterEnabled,
698
- settings.fontFamilyCode,
699
- settings.fontFamilyComposer,
700
- settings.fontFamilySans,
701
- settings.fontFamilyTerminal,
702
- settings.fontSizeCode,
703
- settings.fontSizeInterface,
704
- settings.fontSizePrompt,
705
- settings.fontSizeTerminal,
706
- settings.glassOpacity,
707
- settings.panelAnimationDurationMs,
708
- settings.responseStreamingMode,
709
- settings.persistComposerContextStrip,
710
- settings.enableProviderUpdateChecks,
711
- settings.continueThreadsAfterServerUpdate,
712
- settings.sidebarAutoSettleAfterDays,
713
- settings.sidebarAutoSettleKeepPullRequests,
714
- settings.sidebarAutoSettleOnMerge,
715
- settings.autoResumeLimitedThreads,
716
- settings.snoozeLimitedThreads,
717
- settings.sidebarProjectGroupingMode,
718
- settings.sidebarProjectSortOrder,
719
- settings.sidebarWorkingShelfEnabled,
720
- settings.sidebarThreadPreviewCount,
721
- settings.showSkillsInSlashMenu,
722
- settings.timestampFormat,
723
- settings.notificationMode,
724
- settings.inAppNotificationsEnabled,
725
- settings.wordWrap,
726
- followSystem,
727
- theme,
728
- themeHalves,
729
- ],
730
- );
731
-
732
- const restoreDefaults = useCallback(async () => {
532
+ const changedSettingLabels = [
533
+ ...(theme !== "system" ? ["Theme"] : []),
534
+ ...(!followSystem ? ["Follow system"] : []),
535
+ ...(themeHalves !== null ? ["Theme mix"] : []),
536
+ ...(settings.appearanceContrast !== DEFAULT_UNIFIED_SETTINGS.appearanceContrast
537
+ ? ["Contrast"]
538
+ : []),
539
+ ...(settings.glassOpacity !== DEFAULT_UNIFIED_SETTINGS.glassOpacity ? ["Glass opacity"] : []),
540
+ ...(settings.diffColorScheme !== DEFAULT_UNIFIED_SETTINGS.diffColorScheme
541
+ ? ["Diff colors"]
542
+ : []),
543
+ ...(settings.chatWidth !== DEFAULT_UNIFIED_SETTINGS.chatWidth ? ["Chat width"] : []),
544
+ ...(settings.panelAnimationDurationMs !== DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs
545
+ ? ["Panel animations"]
546
+ : []),
547
+ ...(settings.environmentIdentificationMode !==
548
+ DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode
549
+ ? ["Environment identification"]
550
+ : []),
551
+ ...(settings.timestampFormat !== DEFAULT_UNIFIED_SETTINGS.timestampFormat
552
+ ? ["Time format"]
553
+ : []),
554
+ ...(settings.notificationMode !== DEFAULT_UNIFIED_SETTINGS.notificationMode
555
+ ? ["Thread notifications"]
556
+ : []),
557
+ ...(settings.inAppNotificationsEnabled !== DEFAULT_UNIFIED_SETTINGS.inAppNotificationsEnabled
558
+ ? ["In-app notifications"]
559
+ : []),
560
+ ...(settings.sidebarThreadPreviewCount !== DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount
561
+ ? ["Visible threads"]
562
+ : []),
563
+ ...(settings.sidebarProjectGroupingMode !== DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode
564
+ ? ["Project Grouping"]
565
+ : []),
566
+ ...(settings.sidebarProjectSortOrder !== DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder
567
+ ? ["Project order"]
568
+ : []),
569
+ ...(settings.sidebarWorkingShelfEnabled !== DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled
570
+ ? ["Working section"]
571
+ : []),
572
+ ...(settings.sidebarAutoSettleAfterDays !== DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays
573
+ ? ["Auto-settle inactive threads"]
574
+ : []),
575
+ ...(settings.sidebarAutoSettleKeepPullRequests !==
576
+ DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleKeepPullRequests
577
+ ? ["Keep threads with a PR"]
578
+ : []),
579
+ ...(settings.sidebarAutoSettleOnMerge !== DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge
580
+ ? ["Auto-settle merged threads"]
581
+ : []),
582
+ ...(settings.autoResumeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.autoResumeLimitedThreads
583
+ ? ["Auto-resume limited threads"]
584
+ : []),
585
+ ...(settings.snoozeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads
586
+ ? ["Snooze limited threads"]
587
+ : []),
588
+ ...(settings.wordWrap !== DEFAULT_UNIFIED_SETTINGS.wordWrap ? ["Word wrap"] : []),
589
+ ...(settings.persistComposerContextStrip !==
590
+ DEFAULT_UNIFIED_SETTINGS.persistComposerContextStrip
591
+ ? ["Composer context"]
592
+ : []),
593
+ ...getChangedTypographySettingLabels(settings),
594
+ ...(settings.diffFilesCollapsed !== DEFAULT_UNIFIED_SETTINGS.diffFilesCollapsed
595
+ ? ["Default diff file state"]
596
+ : []),
597
+ ...(settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace
598
+ ? ["Diff whitespace changes"]
599
+ : []),
600
+ ...(settings.diffLayout !== DEFAULT_UNIFIED_SETTINGS.diffLayout ? ["Diff layout"] : []),
601
+ ...(settings.proactivePanelsEnabled !== DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled
602
+ ? ["Proactive panels"]
603
+ : []),
604
+ ...(settings.showSkillsInSlashMenu !== DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu
605
+ ? ["Show skills in slash menu"]
606
+ : []),
607
+ ...(settings.composerCollapseOnScroll !== DEFAULT_UNIFIED_SETTINGS.composerCollapseOnScroll
608
+ ? ["Collapse composer on scroll"]
609
+ : []),
610
+ ...(settings.composerRichTextEnabled !== DEFAULT_UNIFIED_SETTINGS.composerRichTextEnabled
611
+ ? ["Rich text composer"]
612
+ : []),
613
+ ...(settings.sendShortcut !== DEFAULT_UNIFIED_SETTINGS.sendShortcut ? ["Send shortcut"] : []),
614
+ ...(settings.followUpBehavior !== DEFAULT_UNIFIED_SETTINGS.followUpBehavior
615
+ ? ["Follow-up behavior"]
616
+ : []),
617
+ ...(settings.contextWindowMeterEnabled !== DEFAULT_UNIFIED_SETTINGS.contextWindowMeterEnabled
618
+ ? ["Context window indicator"]
619
+ : []),
620
+ ...(settings.responseStreamingMode !== DEFAULT_UNIFIED_SETTINGS.responseStreamingMode
621
+ ? ["Response streaming"]
622
+ : []),
623
+ ...(settings.enableProviderUpdateChecks !== DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks
624
+ ? ["Provider update checks"]
625
+ : []),
626
+ ...(settings.continueThreadsAfterServerUpdate !==
627
+ DEFAULT_UNIFIED_SETTINGS.continueThreadsAfterServerUpdate
628
+ ? ["Continue threads after restarts"]
629
+ : []),
630
+ ...(isBackgroundActivityDirty ? ["Background activity"] : []),
631
+ ...(settings.defaultThreadEnvMode !== DEFAULT_UNIFIED_SETTINGS.defaultThreadEnvMode
632
+ ? ["New thread mode"]
633
+ : []),
634
+ ...(settings.newWorktreesStartFromOrigin !==
635
+ DEFAULT_UNIFIED_SETTINGS.newWorktreesStartFromOrigin
636
+ ? ["New worktrees start from origin"]
637
+ : []),
638
+ ...(settings.addProjectBaseDirectory !== DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory
639
+ ? ["Add project base directory"]
640
+ : []),
641
+ ...(settings.confirmThreadUnpin !== DEFAULT_UNIFIED_SETTINGS.confirmThreadUnpin
642
+ ? ["Unpin confirmation"]
643
+ : []),
644
+ ...(settings.confirmThreadArchive !== DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive
645
+ ? ["Archive confirmation"]
646
+ : []),
647
+ ...(settings.confirmThreadDelete !== DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete
648
+ ? ["Delete confirmation"]
649
+ : []),
650
+ ...(settings.confirmQuit !== DEFAULT_UNIFIED_SETTINGS.confirmQuit ? ["Quit shortcut"] : []),
651
+ ...(isTextGenerationModelDirty ? ["Text generation model"] : []),
652
+ ...getChangedBrowserSettingLabels(settings),
653
+ ...(settings.enableAgentBrowserAccess !== DEFAULT_UNIFIED_SETTINGS.enableAgentBrowserAccess
654
+ ? ["Agent browser access"]
655
+ : []),
656
+ ];
657
+
658
+ const restoreDefaults = async () => {
659
if (changedSettingLabels.length === 0) return;
660
const api = readLocalApi();
661
const confirmed = await (api ?? ensureLocalApi()).dialogs.confirm(
@@ -851,17 +777,7 @@ export function useSettingsRestore(onRestored?: () => void) {
777
enableAgentBrowserAccess: DEFAULT_UNIFIED_SETTINGS.enableAgentBrowserAccess,
778
});
779
onRestored?.();
854
- }, [
855
- changedSettingLabels,
856
- clearThemeHalves,
857
- onRestored,
858
- setFollowSystem,
859
- setTheme,
860
- setThemeHalf,
861
- theme,
862
- themeHalves,
863
- updateSettings,
864
- ]);
780
+ };
781
782
return {
783
changedSettingLabels,
@@ -1517,13 +1433,10 @@ export function AppearanceSettingsPanel() {
1433
1434
function useFontDefaultFamilies() {
1435
const settings = useScopedSettings();
1520
- const defaults = useMemo(
1521
- () => ({
1522
- sans: resolveDefaultFamilyLabel(DEFAULT_SANS_FONT_STACK) ?? "System default",
1523
- code: resolveDefaultFamilyLabel(DEFAULT_CODE_FONT_STACK) ?? "System monospace",
1524
- }),
1525
- [],
1526
- );
1436
+ const [defaults] = useState(() => ({
1437
+ sans: resolveDefaultFamilyLabel(DEFAULT_SANS_FONT_STACK) ?? "System default",
1438
+ code: resolveDefaultFamilyLabel(DEFAULT_CODE_FONT_STACK) ?? "System monospace",
1439
+ }));
1440
return {
1441
sans: defaults.sans,
1442
code: defaults.code,
@@ -1852,22 +1765,25 @@ function FontFamilySettingsRow({
1765
const trimmed = value.trim();
1766
const [draft, setDraft] = useState(value);
1767
const [draftSettled, setDraftSettled] = useState(true);
1855
- const commitTimerRef = useRef<number | null>(null);
1856
- const lastValueRef = useRef(value);
1857
- if (lastValueRef.current !== value) {
1858
- // The committed value changed externally (hydration, reset, picker
1859
- // selection); adopt it and drop any pending commit of a stale draft.
1860
- lastValueRef.current = value;
1861
- if (commitTimerRef.current !== null) {
1862
- window.clearTimeout(commitTimerRef.current);
1863
- commitTimerRef.current = null;
1864
- }
1768
+ // Each pending commit remembers the value it was typed against, so one that outlives
1769
+ // an external change (hydration, reset, picker selection) drops its stale draft.
1770
+ const commitTimerRef = useRef<{ readonly id: number; readonly value: string } | null>(null);
1771
+ const cancelPendingCommit = () => {
1772
+ if (commitTimerRef.current !== null) window.clearTimeout(commitTimerRef.current.id);
1773
+ commitTimerRef.current = null;
1774
+ };
1775
+ // Bumped on every external value change, so a pending commit typed before one never lands,
1776
+ // even if the value has since changed back to what it was typed against.
1777
+ const [adopted, setAdopted] = useState({ value, generation: 0 });
1778
+ if (adopted.value !== value) {
1779
+ setAdopted({ value, generation: adopted.generation + 1 });
1780
setDraft(value);
1781
setDraftSettled(true);
1782
}
1783
+ const readAdoptedGeneration = useEffectEvent(() => adopted.generation);
1784
useEffect(
1785
() => () => {
1870
- if (commitTimerRef.current !== null) window.clearTimeout(commitTimerRef.current);
1786
+ if (commitTimerRef.current !== null) window.clearTimeout(commitTimerRef.current.id);
1787
},
1788
[],
1789
);
@@ -1880,18 +1796,14 @@ function FontFamilySettingsRow({
1796
}
1797
};
1798
const flushDraft = () => {
1883
- if (commitTimerRef.current === null) return;
1884
- window.clearTimeout(commitTimerRef.current);
1885
- commitTimerRef.current = null;
1886
- commitDraft(draft);
1799
+ const pending = commitTimerRef.current;
1800
+ cancelPendingCommit();
1801
+ if (pending !== null && pending.value === value) commitDraft(draft);
1802
};
1803
const draftTrimmed = draft.trim();
1804
const draftPending = draftSettled && draftTrimmed.length > 0 && draftTrimmed !== trimmed;
1805
const resetToDefault = () => {
1891
- if (commitTimerRef.current !== null) {
1892
- window.clearTimeout(commitTimerRef.current);
1893
- commitTimerRef.current = null;
1894
- }
1806
+ cancelPendingCommit();
1807
setDraft(defaultValue);
1808
setDraftSettled(true);
1809
onReset();
@@ -1901,7 +1813,7 @@ function FontFamilySettingsRow({
1813
<SettingResetButton label={title.toLowerCase()} onClick={resetToDefault} />
1814
) : null;
1815
const fontEnumeration = useFontEnumeration();
1904
- const inputFocusedRef = useRef(false);
1816
+ const [inputFocused, setInputFocused] = useState(false);
1817
const familyControl =
1818
fontEnumeration.status === "granted" ? (
1819
<FontFamilyPicker
@@ -1909,7 +1821,7 @@ function FontFamilySettingsRow({
1821
defaultFamily={defaultFamily}
1822
selectedFamily={trimmed}
1823
requireMonospace={requireMonospace}
1912
- initialOpen={inputFocusedRef.current}
1824
+ initialOpen={inputFocused}
1825
onSelect={onValueChange}
1826
/>
1827
) : (
@@ -1922,24 +1834,27 @@ function FontFamilySettingsRow({
1834
className="min-w-0 flex-1"
1835
maxLength={200}
1836
onFocus={() => {
1925
- inputFocusedRef.current = true;
1837
+ setInputFocused(true);
1838
discoverInstalledFonts();
1839
}}
1840
onBlur={() => {
1929
- inputFocusedRef.current = false;
1841
+ setInputFocused(false);
1842
flushDraft();
1843
}}
1844
onChange={(event) => {
1845
const next = event.currentTarget.value;
1846
setDraft(next);
1847
setDraftSettled(false);
1936
- if (commitTimerRef.current !== null) {
1937
- window.clearTimeout(commitTimerRef.current);
1938
- }
1939
- commitTimerRef.current = window.setTimeout(() => {
1940
- commitTimerRef.current = null;
1941
- commitDraft(next);
1942
- }, 400);
1848
+ cancelPendingCommit();
1849
+ const typedAgainst = value;
1850
+ const typedInGeneration = adopted.generation;
1851
+ commitTimerRef.current = {
1852
+ id: window.setTimeout(() => {
1853
+ commitTimerRef.current = null;
1854
+ if (readAdoptedGeneration() === typedInGeneration) commitDraft(next);
1855
+ }, 400),
1856
+ value: typedAgainst,
1857
+ };
1858
}}
1859
onKeyDown={(event) => {
1860
if (event.key === "Enter") flushDraft();
@@ -1948,10 +1863,7 @@ function FontFamilySettingsRow({
1863
// which is what an unhandled Escape does.
1864
event.preventDefault();
1865
event.stopPropagation();
1951
- if (commitTimerRef.current !== null) {
1952
- window.clearTimeout(commitTimerRef.current);
1953
- commitTimerRef.current = null;
1954
- }
1866
+ cancelPendingCommit();
1867
setDraft(value);
1868
setDraftSettled(true);
1869
}
@@ -2012,9 +1924,11 @@ function AutoSettleDaysInput({
1924
onCommit: (days: number) => void;
1925
}) {
1926
const [draft, setDraft] = useState(String(value));
2015
- useEffect(() => {
1927
+ const [draftSource, setDraftSource] = useState(value);
1928
+ if (draftSource !== value) {
1929
+ setDraftSource(value);
1930
setDraft(String(value));
2017
- }, [value]);
1931
+ }
1932
1933
return (
1934
<Input
@@ -3382,7 +3296,7 @@ export function ArchivedThreadsPanel() {
3296
refresh: refreshArchivedThreads,
3297
} = useArchivedThreadSnapshots(scope.environmentIds);
3298
3385
- const { groups: archivedGroups, hasMultipleEnvironments } = useMemo(() => {
3299
+ const { groups: archivedGroups, hasMultipleEnvironments } = (() => {
3300
const selectedProjectKeys =
3301
scope.kind === "project" || scope.kind === "checkout"
3302
? new Set(scope.members.map((member) => `${member.environmentId}:${member.id}`))
@@ -3472,55 +3386,55 @@ export function ArchivedThreadsPanel() {
3386
}),
3387
}));
3388
return { groups: sortedGroups, hasMultipleEnvironments };
3475
- }, [archivedSnapshots, environments, projectGroups, scope]);
3476
-
3477
- const handleArchivedThreadContextMenu = useCallback(
3478
- async (threadRef: ScopedThreadRef, position: { x: number; y: number }) => {
3479
- const api = readLocalApi();
3480
- if (!api) return;
3481
- const clicked = await api.contextMenu.show(
3482
- [
3483
- { id: "unarchive", label: "Unarchive" },
3484
- { id: "delete", label: "Delete", destructive: true },
3485
- ],
3486
- position,
3487
- );
3389
+ })();
3390
3489
- if (clicked === "unarchive") {
3490
- const result = await unarchiveThread(threadRef);
3491
- if (result._tag === "Success") {
3492
- refreshArchivedThreads();
3493
- } else if (!isAtomCommandInterrupted(result)) {
3494
- const error = squashAtomCommandFailure(result);
3495
- toastManager.add(
3496
- stackedThreadToast({
3497
- type: "error",
3498
- title: "Failed to unarchive thread",
3499
- description: error instanceof Error ? error.message : "An error occurred.",
3500
- }),
3501
- );
3502
- }
3503
- return;
3391
+ const handleArchivedThreadContextMenu = async (
3392
+ threadRef: ScopedThreadRef,
3393
+ position: { x: number; y: number },
3394
+ ) => {
3395
+ const api = readLocalApi();
3396
+ if (!api) return;
3397
+ const clicked = await api.contextMenu.show(
3398
+ [
3399
+ { id: "unarchive", label: "Unarchive" },
3400
+ { id: "delete", label: "Delete", destructive: true },
3401
+ ],
3402
+ position,
3403
+ );
3404
+
3405
+ if (clicked === "unarchive") {
3406
+ const result = await unarchiveThread(threadRef);
3407
+ if (result._tag === "Success") {
3408
+ refreshArchivedThreads();
3409
+ } else if (!isAtomCommandInterrupted(result)) {
3410
+ const error = squashAtomCommandFailure(result);
3411
+ toastManager.add(
3412
+ stackedThreadToast({
3413
+ type: "error",
3414
+ title: "Failed to unarchive thread",
3415
+ description: error instanceof Error ? error.message : "An error occurred.",
3416
+ }),
3417
+ );
3418
}
3419
+ return;
3420
+ }
3421
3506
- if (clicked === "delete") {
3507
- const result = await confirmAndDeleteThread(threadRef);
3508
- if (result._tag === "Success") {
3509
- refreshArchivedThreads();
3510
- } else if (!isAtomCommandInterrupted(result)) {
3511
- const error = squashAtomCommandFailure(result);
3512
- toastManager.add(
3513
- stackedThreadToast({
3514
- type: "error",
3515
- title: "Failed to delete thread",
3516
- description: error instanceof Error ? error.message : "An error occurred.",
3517
- }),
3518
- );
3519
- }
3422
+ if (clicked === "delete") {
3423
+ const result = await confirmAndDeleteThread(threadRef);
3424
+ if (result._tag === "Success") {
3425
+ refreshArchivedThreads();
3426
+ } else if (!isAtomCommandInterrupted(result)) {
3427
+ const error = squashAtomCommandFailure(result);
3428
+ toastManager.add(
3429
+ stackedThreadToast({
3430
+ type: "error",
3431
+ title: "Failed to delete thread",
3432
+ description: error instanceof Error ? error.message : "An error occurred.",
3433
+ }),
3434
+ );
3435
}
3521
- },
3522
- [confirmAndDeleteThread, refreshArchivedThreads, unarchiveThread],
3523
- );
3436
+ }
3437
+ };
3438
3439
return (
3440
<SettingsPageContainer>