TypeScript
perf(web): the settings panels compile with the React Compiler (#20528)
Julius Marminge1da2d60b43e7
diff --git a/apps/web/reactCompiledFiles.ts b/apps/web/reactCompiledFiles.tsindex 710bf1325c0..ae08700d891 100644--- a/apps/web/reactCompiledFiles.ts+++ b/apps/web/reactCompiledFiles.ts@@ -95,4 +95,5 @@ export const REACT_COMPILED_FILES = ["apps/web/src/components/settings/ThemeColorPicker.tsx","apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx","apps/web/src/components/ThreadTerminalDrawer.tsx",+ "apps/web/src/components/settings/SettingsPanels.tsx",] as const;diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsxindex fcb561b27b8..cd14f5233d1 100644--- a/apps/web/src/components/settings/SettingsPanels.tsx+++ b/apps/web/src/components/settings/SettingsPanels.tsx@@ -7,7 +7,7 @@ import { PRIVACY_POLICY_URL } from "../../legalLinks";import { ArchiveIcon, ArchiveX, CheckIcon, ChevronRightIcon, SettingsIcon } from "lucide-react";import { Link, useNavigate } from "@tanstack/react-router";import type { CSSProperties, ReactNode } from "react";-import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import { useEffect, useEffectEvent, useRef, useState } from "react";import {type BackgroundActivityProfile,type DesktopUpdateChannel,@@ -288,37 +288,34 @@ function AboutVersionSection() {const selectedUpdateChannel = updateState?.channel ?? "latest";const selectedHostedAppChannel = hasDesktopBridge ? null : HOSTED_APP_CHANNEL;- const handleUpdateChannelChange = useCallback(- (channel: DesktopUpdateChannel) => {- const bridge = window.desktopBridge;- if (- !bridge ||- typeof bridge.setUpdateChannel !== "function" ||- channel === selectedUpdateChannel- ) {- return;- }+ const handleUpdateChannelChange = (channel: DesktopUpdateChannel) => {+ const bridge = window.desktopBridge;+ if (+ !bridge ||+ typeof bridge.setUpdateChannel !== "function" ||+ channel === selectedUpdateChannel+ ) {+ return;+ }- setIsChangingUpdateChannel(true);- void bridge- .setUpdateChannel(channel)- .catch((error: unknown) => {- toastManager.add(- stackedThreadToast({- type: "error",- title: "Could not change update track",- description: error instanceof Error ? error.message : "Update track change failed.",- }),- );- })- .finally(() => {- setIsChangingUpdateChannel(false);- });- },- [selectedUpdateChannel],- );+ setIsChangingUpdateChannel(true);+ void bridge+ .setUpdateChannel(channel)+ .catch((error: unknown) => {+ toastManager.add(+ stackedThreadToast({+ type: "error",+ title: "Could not change update track",+ description: error instanceof Error ? error.message : "Update track change failed.",+ }),+ );+ })+ .finally(() => {+ setIsChangingUpdateChannel(false);+ });+ };- const handleButtonClick = useCallback(async () => {+ const handleButtonClick = async () => {const bridge = window.desktopBridge;if (!bridge) return;@@ -401,7 +398,7 @@ function AboutVersionSection() {}),);});- }, [isUpdateActionPending, updateState]);+ };const action = updateState ? resolveDesktopUpdateButtonAction(updateState) : "none";const buttonTooltip = updateState ? getDesktopUpdateButtonTooltip(updateState) : null;@@ -532,204 +529,133 @@ export function useSettingsRestore(onRestored?: () => void) {);const isBackgroundActivityDirty = hasChangedBackgroundActivitySettings(settings);- const changedSettingLabels = useMemo(- () => [- ...(theme !== "system" ? ["Theme"] : []),- ...(!followSystem ? ["Follow system"] : []),- ...(themeHalves !== null ? ["Theme mix"] : []),- ...(settings.appearanceContrast !== DEFAULT_UNIFIED_SETTINGS.appearanceContrast- ? ["Contrast"]- : []),- ...(settings.glassOpacity !== DEFAULT_UNIFIED_SETTINGS.glassOpacity ? ["Glass opacity"] : []),- ...(settings.diffColorScheme !== DEFAULT_UNIFIED_SETTINGS.diffColorScheme- ? ["Diff colors"]- : []),- ...(settings.chatWidth !== DEFAULT_UNIFIED_SETTINGS.chatWidth ? ["Chat width"] : []),- ...(settings.panelAnimationDurationMs !== DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs- ? ["Panel animations"]- : []),- ...(settings.environmentIdentificationMode !==- DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode- ? ["Environment identification"]- : []),- ...(settings.timestampFormat !== DEFAULT_UNIFIED_SETTINGS.timestampFormat- ? ["Time format"]- : []),- ...(settings.notificationMode !== DEFAULT_UNIFIED_SETTINGS.notificationMode- ? ["Thread notifications"]- : []),- ...(settings.inAppNotificationsEnabled !== DEFAULT_UNIFIED_SETTINGS.inAppNotificationsEnabled- ? ["In-app notifications"]- : []),- ...(settings.sidebarThreadPreviewCount !== DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount- ? ["Visible threads"]- : []),- ...(settings.sidebarProjectGroupingMode !==- DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode- ? ["Project Grouping"]- : []),- ...(settings.sidebarProjectSortOrder !== DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder- ? ["Project order"]- : []),- ...(settings.sidebarWorkingShelfEnabled !==- DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled- ? ["Working section"]- : []),- ...(settings.sidebarAutoSettleAfterDays !==- DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays- ? ["Auto-settle inactive threads"]- : []),- ...(settings.sidebarAutoSettleKeepPullRequests !==- DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleKeepPullRequests- ? ["Keep threads with a PR"]- : []),- ...(settings.sidebarAutoSettleOnMerge !== DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge- ? ["Auto-settle merged threads"]- : []),- ...(settings.autoResumeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.autoResumeLimitedThreads- ? ["Auto-resume limited threads"]- : []),- ...(settings.snoozeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads- ? ["Snooze limited threads"]- : []),- ...(settings.wordWrap !== DEFAULT_UNIFIED_SETTINGS.wordWrap ? ["Word wrap"] : []),- ...(settings.persistComposerContextStrip !==- DEFAULT_UNIFIED_SETTINGS.persistComposerContextStrip- ? ["Composer context"]- : []),- ...getChangedTypographySettingLabels(settings),- ...(settings.diffFilesCollapsed !== DEFAULT_UNIFIED_SETTINGS.diffFilesCollapsed- ? ["Default diff file state"]- : []),- ...(settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace- ? ["Diff whitespace changes"]- : []),- ...(settings.diffLayout !== DEFAULT_UNIFIED_SETTINGS.diffLayout ? ["Diff layout"] : []),- ...(settings.proactivePanelsEnabled !== DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled- ? ["Proactive panels"]- : []),- ...(settings.showSkillsInSlashMenu !== DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu- ? ["Show skills in slash menu"]- : []),- ...(settings.composerCollapseOnScroll !== DEFAULT_UNIFIED_SETTINGS.composerCollapseOnScroll- ? ["Collapse composer on scroll"]- : []),- ...(settings.composerRichTextEnabled !== DEFAULT_UNIFIED_SETTINGS.composerRichTextEnabled- ? ["Rich text composer"]- : []),- ...(settings.sendShortcut !== DEFAULT_UNIFIED_SETTINGS.sendShortcut ? ["Send shortcut"] : []),- ...(settings.followUpBehavior !== DEFAULT_UNIFIED_SETTINGS.followUpBehavior- ? ["Follow-up behavior"]- : []),- ...(settings.contextWindowMeterEnabled !== DEFAULT_UNIFIED_SETTINGS.contextWindowMeterEnabled- ? ["Context window indicator"]- : []),- ...(settings.responseStreamingMode !== DEFAULT_UNIFIED_SETTINGS.responseStreamingMode- ? ["Response streaming"]- : []),- ...(settings.enableProviderUpdateChecks !==- DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks- ? ["Provider update checks"]- : []),- ...(settings.continueThreadsAfterServerUpdate !==- DEFAULT_UNIFIED_SETTINGS.continueThreadsAfterServerUpdate- ? ["Continue threads after restarts"]- : []),- ...(isBackgroundActivityDirty ? ["Background activity"] : []),- ...(settings.defaultThreadEnvMode !== DEFAULT_UNIFIED_SETTINGS.defaultThreadEnvMode- ? ["New thread mode"]- : []),- ...(settings.newWorktreesStartFromOrigin !==- DEFAULT_UNIFIED_SETTINGS.newWorktreesStartFromOrigin- ? ["New worktrees start from origin"]- : []),- ...(settings.addProjectBaseDirectory !== DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory- ? ["Add project base directory"]- : []),- ...(settings.confirmThreadUnpin !== DEFAULT_UNIFIED_SETTINGS.confirmThreadUnpin- ? ["Unpin confirmation"]- : []),- ...(settings.confirmThreadArchive !== DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive- ? ["Archive confirmation"]- : []),- ...(settings.confirmThreadDelete !== DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete- ? ["Delete confirmation"]- : []),- ...(settings.confirmQuit !== DEFAULT_UNIFIED_SETTINGS.confirmQuit ? ["Quit shortcut"] : []),- ...(isTextGenerationModelDirty ? ["Text generation model"] : []),- ...getChangedBrowserSettingLabels(settings),- ...(settings.enableAgentBrowserAccess !== DEFAULT_UNIFIED_SETTINGS.enableAgentBrowserAccess- ? ["Agent browser access"]- : []),- ],- [- isTextGenerationModelDirty,- isBackgroundActivityDirty,- settings.browserDefaultViewport,- settings.browserDefaultZoomFactor,- settings.browserDefaultAppearance,- settings.browserRecordingFrameRate,- settings.browserRecordingShowKeyPresses,- settings.browserRecordingShowMousePresses,- settings.browserLinkTarget,- settings.browserAutoShowFloatingPreview,- settings.pullRequestLinksOpenInApp,- settings.appearanceContrast,- settings.diffColorScheme,- settings.chatWidth,- settings.enableAgentBrowserAccess,- settings.confirmQuit,- settings.confirmThreadArchive,- settings.confirmThreadDelete,- settings.confirmThreadUnpin,- settings.composerCollapseOnScroll,- settings.composerRichTextEnabled,- settings.sendShortcut,- settings.followUpBehavior,- settings.addProjectBaseDirectory,- settings.defaultThreadEnvMode,- settings.newWorktreesStartFromOrigin,- settings.diffFilesCollapsed,- settings.diffIgnoreWhitespace,- settings.diffLayout,- settings.proactivePanelsEnabled,- settings.environmentIdentificationMode,- settings.contextWindowMeterEnabled,- settings.fontFamilyCode,- settings.fontFamilyComposer,- settings.fontFamilySans,- settings.fontFamilyTerminal,- settings.fontSizeCode,- settings.fontSizeInterface,- settings.fontSizePrompt,- settings.fontSizeTerminal,- settings.glassOpacity,- settings.panelAnimationDurationMs,- settings.responseStreamingMode,- settings.persistComposerContextStrip,- settings.enableProviderUpdateChecks,- settings.continueThreadsAfterServerUpdate,- settings.sidebarAutoSettleAfterDays,- settings.sidebarAutoSettleKeepPullRequests,- settings.sidebarAutoSettleOnMerge,- settings.autoResumeLimitedThreads,- settings.snoozeLimitedThreads,- settings.sidebarProjectGroupingMode,- settings.sidebarProjectSortOrder,- settings.sidebarWorkingShelfEnabled,- settings.sidebarThreadPreviewCount,- settings.showSkillsInSlashMenu,- settings.timestampFormat,- settings.notificationMode,- settings.inAppNotificationsEnabled,- settings.wordWrap,- followSystem,- theme,- themeHalves,- ],- );-- const restoreDefaults = useCallback(async () => {+ const changedSettingLabels = [+ ...(theme !== "system" ? ["Theme"] : []),+ ...(!followSystem ? ["Follow system"] : []),+ ...(themeHalves !== null ? ["Theme mix"] : []),+ ...(settings.appearanceContrast !== DEFAULT_UNIFIED_SETTINGS.appearanceContrast+ ? ["Contrast"]+ : []),+ ...(settings.glassOpacity !== DEFAULT_UNIFIED_SETTINGS.glassOpacity ? ["Glass opacity"] : []),+ ...(settings.diffColorScheme !== DEFAULT_UNIFIED_SETTINGS.diffColorScheme+ ? ["Diff colors"]+ : []),+ ...(settings.chatWidth !== DEFAULT_UNIFIED_SETTINGS.chatWidth ? ["Chat width"] : []),+ ...(settings.panelAnimationDurationMs !== DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs+ ? ["Panel animations"]+ : []),+ ...(settings.environmentIdentificationMode !==+ DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode+ ? ["Environment identification"]+ : []),+ ...(settings.timestampFormat !== DEFAULT_UNIFIED_SETTINGS.timestampFormat+ ? ["Time format"]+ : []),+ ...(settings.notificationMode !== DEFAULT_UNIFIED_SETTINGS.notificationMode+ ? ["Thread notifications"]+ : []),+ ...(settings.inAppNotificationsEnabled !== DEFAULT_UNIFIED_SETTINGS.inAppNotificationsEnabled+ ? ["In-app notifications"]+ : []),+ ...(settings.sidebarThreadPreviewCount !== DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount+ ? ["Visible threads"]+ : []),+ ...(settings.sidebarProjectGroupingMode !== DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode+ ? ["Project Grouping"]+ : []),+ ...(settings.sidebarProjectSortOrder !== DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder+ ? ["Project order"]+ : []),+ ...(settings.sidebarWorkingShelfEnabled !== DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled+ ? ["Working section"]+ : []),+ ...(settings.sidebarAutoSettleAfterDays !== DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays+ ? ["Auto-settle inactive threads"]+ : []),+ ...(settings.sidebarAutoSettleKeepPullRequests !==+ DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleKeepPullRequests+ ? ["Keep threads with a PR"]+ : []),+ ...(settings.sidebarAutoSettleOnMerge !== DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge+ ? ["Auto-settle merged threads"]+ : []),+ ...(settings.autoResumeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.autoResumeLimitedThreads+ ? ["Auto-resume limited threads"]+ : []),+ ...(settings.snoozeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads+ ? ["Snooze limited threads"]+ : []),+ ...(settings.wordWrap !== DEFAULT_UNIFIED_SETTINGS.wordWrap ? ["Word wrap"] : []),+ ...(settings.persistComposerContextStrip !==+ DEFAULT_UNIFIED_SETTINGS.persistComposerContextStrip+ ? ["Composer context"]+ : []),+ ...getChangedTypographySettingLabels(settings),+ ...(settings.diffFilesCollapsed !== DEFAULT_UNIFIED_SETTINGS.diffFilesCollapsed+ ? ["Default diff file state"]+ : []),+ ...(settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace+ ? ["Diff whitespace changes"]+ : []),+ ...(settings.diffLayout !== DEFAULT_UNIFIED_SETTINGS.diffLayout ? ["Diff layout"] : []),+ ...(settings.proactivePanelsEnabled !== DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled+ ? ["Proactive panels"]+ : []),+ ...(settings.showSkillsInSlashMenu !== DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu+ ? ["Show skills in slash menu"]+ : []),+ ...(settings.composerCollapseOnScroll !== DEFAULT_UNIFIED_SETTINGS.composerCollapseOnScroll+ ? ["Collapse composer on scroll"]+ : []),+ ...(settings.composerRichTextEnabled !== DEFAULT_UNIFIED_SETTINGS.composerRichTextEnabled+ ? ["Rich text composer"]+ : []),+ ...(settings.sendShortcut !== DEFAULT_UNIFIED_SETTINGS.sendShortcut ? ["Send shortcut"] : []),+ ...(settings.followUpBehavior !== DEFAULT_UNIFIED_SETTINGS.followUpBehavior+ ? ["Follow-up behavior"]+ : []),+ ...(settings.contextWindowMeterEnabled !== DEFAULT_UNIFIED_SETTINGS.contextWindowMeterEnabled+ ? ["Context window indicator"]+ : []),+ ...(settings.responseStreamingMode !== DEFAULT_UNIFIED_SETTINGS.responseStreamingMode+ ? ["Response streaming"]+ : []),+ ...(settings.enableProviderUpdateChecks !== DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks+ ? ["Provider update checks"]+ : []),+ ...(settings.continueThreadsAfterServerUpdate !==+ DEFAULT_UNIFIED_SETTINGS.continueThreadsAfterServerUpdate+ ? ["Continue threads after restarts"]+ : []),+ ...(isBackgroundActivityDirty ? ["Background activity"] : []),+ ...(settings.defaultThreadEnvMode !== DEFAULT_UNIFIED_SETTINGS.defaultThreadEnvMode+ ? ["New thread mode"]+ : []),+ ...(settings.newWorktreesStartFromOrigin !==+ DEFAULT_UNIFIED_SETTINGS.newWorktreesStartFromOrigin+ ? ["New worktrees start from origin"]+ : []),+ ...(settings.addProjectBaseDirectory !== DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory+ ? ["Add project base directory"]+ : []),+ ...(settings.confirmThreadUnpin !== DEFAULT_UNIFIED_SETTINGS.confirmThreadUnpin+ ? ["Unpin confirmation"]+ : []),+ ...(settings.confirmThreadArchive !== DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive+ ? ["Archive confirmation"]+ : []),+ ...(settings.confirmThreadDelete !== DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete+ ? ["Delete confirmation"]+ : []),+ ...(settings.confirmQuit !== DEFAULT_UNIFIED_SETTINGS.confirmQuit ? ["Quit shortcut"] : []),+ ...(isTextGenerationModelDirty ? ["Text generation model"] : []),+ ...getChangedBrowserSettingLabels(settings),+ ...(settings.enableAgentBrowserAccess !== DEFAULT_UNIFIED_SETTINGS.enableAgentBrowserAccess+ ? ["Agent browser access"]+ : []),+ ];++ const restoreDefaults = async () => {if (changedSettingLabels.length === 0) return;const api = readLocalApi();const confirmed = await (api ?? ensureLocalApi()).dialogs.confirm(@@ -851,17 +777,7 @@ export function useSettingsRestore(onRestored?: () => void) {enableAgentBrowserAccess: DEFAULT_UNIFIED_SETTINGS.enableAgentBrowserAccess,});onRestored?.();- }, [- changedSettingLabels,- clearThemeHalves,- onRestored,- setFollowSystem,- setTheme,- setThemeHalf,- theme,- themeHalves,- updateSettings,- ]);+ };return {changedSettingLabels,@@ -1517,13 +1433,10 @@ export function AppearanceSettingsPanel() {function useFontDefaultFamilies() {const settings = useScopedSettings();- const defaults = useMemo(- () => ({- sans: resolveDefaultFamilyLabel(DEFAULT_SANS_FONT_STACK) ?? "System default",- code: resolveDefaultFamilyLabel(DEFAULT_CODE_FONT_STACK) ?? "System monospace",- }),- [],- );+ const [defaults] = useState(() => ({+ sans: resolveDefaultFamilyLabel(DEFAULT_SANS_FONT_STACK) ?? "System default",+ code: resolveDefaultFamilyLabel(DEFAULT_CODE_FONT_STACK) ?? "System monospace",+ }));return {sans: defaults.sans,code: defaults.code,@@ -1852,22 +1765,25 @@ function FontFamilySettingsRow({const trimmed = value.trim();const [draft, setDraft] = useState(value);const [draftSettled, setDraftSettled] = useState(true);- const commitTimerRef = useRef<number | null>(null);- const lastValueRef = useRef(value);- if (lastValueRef.current !== value) {- // The committed value changed externally (hydration, reset, picker- // selection); adopt it and drop any pending commit of a stale draft.- lastValueRef.current = value;- if (commitTimerRef.current !== null) {- window.clearTimeout(commitTimerRef.current);- commitTimerRef.current = null;- }+ // Each pending commit remembers the value it was typed against, so one that outlives+ // an external change (hydration, reset, picker selection) drops its stale draft.+ const commitTimerRef = useRef<{ readonly id: number; readonly value: string } | null>(null);+ const cancelPendingCommit = () => {+ if (commitTimerRef.current !== null) window.clearTimeout(commitTimerRef.current.id);+ commitTimerRef.current = null;+ };+ // Bumped on every external value change, so a pending commit typed before one never lands,+ // even if the value has since changed back to what it was typed against.+ const [adopted, setAdopted] = useState({ value, generation: 0 });+ if (adopted.value !== value) {+ setAdopted({ value, generation: adopted.generation + 1 });setDraft(value);setDraftSettled(true);}+ const readAdoptedGeneration = useEffectEvent(() => adopted.generation);useEffect(() => () => {- if (commitTimerRef.current !== null) window.clearTimeout(commitTimerRef.current);+ if (commitTimerRef.current !== null) window.clearTimeout(commitTimerRef.current.id);},[],);@@ -1880,18 +1796,14 @@ function FontFamilySettingsRow({}};const flushDraft = () => {- if (commitTimerRef.current === null) return;- window.clearTimeout(commitTimerRef.current);- commitTimerRef.current = null;- commitDraft(draft);+ const pending = commitTimerRef.current;+ cancelPendingCommit();+ if (pending !== null && pending.value === value) commitDraft(draft);};const draftTrimmed = draft.trim();const draftPending = draftSettled && draftTrimmed.length > 0 && draftTrimmed !== trimmed;const resetToDefault = () => {- if (commitTimerRef.current !== null) {- window.clearTimeout(commitTimerRef.current);- commitTimerRef.current = null;- }+ cancelPendingCommit();setDraft(defaultValue);setDraftSettled(true);onReset();@@ -1901,7 +1813,7 @@ function FontFamilySettingsRow({<SettingResetButton label={title.toLowerCase()} onClick={resetToDefault} />) : null;const fontEnumeration = useFontEnumeration();- const inputFocusedRef = useRef(false);+ const [inputFocused, setInputFocused] = useState(false);const familyControl =fontEnumeration.status === "granted" ? (<FontFamilyPicker@@ -1909,7 +1821,7 @@ function FontFamilySettingsRow({defaultFamily={defaultFamily}selectedFamily={trimmed}requireMonospace={requireMonospace}- initialOpen={inputFocusedRef.current}+ initialOpen={inputFocused}onSelect={onValueChange}/>) : (@@ -1922,24 +1834,27 @@ function FontFamilySettingsRow({className="min-w-0 flex-1"maxLength={200}onFocus={() => {- inputFocusedRef.current = true;+ setInputFocused(true);discoverInstalledFonts();}}onBlur={() => {- inputFocusedRef.current = false;+ setInputFocused(false);flushDraft();}}onChange={(event) => {const next = event.currentTarget.value;setDraft(next);setDraftSettled(false);- if (commitTimerRef.current !== null) {- window.clearTimeout(commitTimerRef.current);- }- commitTimerRef.current = window.setTimeout(() => {- commitTimerRef.current = null;- commitDraft(next);- }, 400);+ cancelPendingCommit();+ const typedAgainst = value;+ const typedInGeneration = adopted.generation;+ commitTimerRef.current = {+ id: window.setTimeout(() => {+ commitTimerRef.current = null;+ if (readAdoptedGeneration() === typedInGeneration) commitDraft(next);+ }, 400),+ value: typedAgainst,+ };}}onKeyDown={(event) => {if (event.key === "Enter") flushDraft();@@ -1948,10 +1863,7 @@ function FontFamilySettingsRow({// which is what an unhandled Escape does.event.preventDefault();event.stopPropagation();- if (commitTimerRef.current !== null) {- window.clearTimeout(commitTimerRef.current);- commitTimerRef.current = null;- }+ cancelPendingCommit();setDraft(value);setDraftSettled(true);}@@ -2012,9 +1924,11 @@ function AutoSettleDaysInput({onCommit: (days: number) => void;}) {const [draft, setDraft] = useState(String(value));- useEffect(() => {+ const [draftSource, setDraftSource] = useState(value);+ if (draftSource !== value) {+ setDraftSource(value);setDraft(String(value));- }, [value]);+ }return (<Input@@ -3382,7 +3296,7 @@ export function ArchivedThreadsPanel() {refresh: refreshArchivedThreads,} = useArchivedThreadSnapshots(scope.environmentIds);- const { groups: archivedGroups, hasMultipleEnvironments } = useMemo(() => {+ const { groups: archivedGroups, hasMultipleEnvironments } = (() => {const selectedProjectKeys =scope.kind === "project" || scope.kind === "checkout"? new Set(scope.members.map((member) => `${member.environmentId}:${member.id}`))@@ -3472,55 +3386,55 @@ export function ArchivedThreadsPanel() {}),}));return { groups: sortedGroups, hasMultipleEnvironments };- }, [archivedSnapshots, environments, projectGroups, scope]);-- const handleArchivedThreadContextMenu = useCallback(- async (threadRef: ScopedThreadRef, position: { x: number; y: number }) => {- const api = readLocalApi();- if (!api) return;- const clicked = await api.contextMenu.show(- [- { id: "unarchive", label: "Unarchive" },- { id: "delete", label: "Delete", destructive: true },- ],- position,- );+ })();- if (clicked === "unarchive") {- const result = await unarchiveThread(threadRef);- if (result._tag === "Success") {- refreshArchivedThreads();- } else if (!isAtomCommandInterrupted(result)) {- const error = squashAtomCommandFailure(result);- toastManager.add(- stackedThreadToast({- type: "error",- title: "Failed to unarchive thread",- description: error instanceof Error ? error.message : "An error occurred.",- }),- );- }- return;+ const handleArchivedThreadContextMenu = async (+ threadRef: ScopedThreadRef,+ position: { x: number; y: number },+ ) => {+ const api = readLocalApi();+ if (!api) return;+ const clicked = await api.contextMenu.show(+ [+ { id: "unarchive", label: "Unarchive" },+ { id: "delete", label: "Delete", destructive: true },+ ],+ position,+ );++ if (clicked === "unarchive") {+ const result = await unarchiveThread(threadRef);+ if (result._tag === "Success") {+ refreshArchivedThreads();+ } else if (!isAtomCommandInterrupted(result)) {+ const error = squashAtomCommandFailure(result);+ toastManager.add(+ stackedThreadToast({+ type: "error",+ title: "Failed to unarchive thread",+ description: error instanceof Error ? error.message : "An error occurred.",+ }),+ );}+ return;+ }- if (clicked === "delete") {- const result = await confirmAndDeleteThread(threadRef);- if (result._tag === "Success") {- refreshArchivedThreads();- } else if (!isAtomCommandInterrupted(result)) {- const error = squashAtomCommandFailure(result);- toastManager.add(- stackedThreadToast({- type: "error",- title: "Failed to delete thread",- description: error instanceof Error ? error.message : "An error occurred.",- }),- );- }+ if (clicked === "delete") {+ const result = await confirmAndDeleteThread(threadRef);+ if (result._tag === "Success") {+ refreshArchivedThreads();+ } else if (!isAtomCommandInterrupted(result)) {+ const error = squashAtomCommandFailure(result);+ toastManager.add(+ stackedThreadToast({+ type: "error",+ title: "Failed to delete thread",+ description: error instanceof Error ? error.message : "An error occurred.",+ }),+ );}- },- [confirmAndDeleteThread, refreshArchivedThreads, unarchiveThread],- );+ }+ };return (<SettingsPageContainer>