The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { thrownErrorMessage } from "@t3tools/client-runtime/errors"; |
| 2 | import { m as resolveMessage } from "~/i18n/messages"; |
| 3 | import { useAtomValue } from "@effect/atom-react"; |
| 4 | import { NotificationSettings } from "./NotificationSettings"; |
| 5 | import { PRIVACY_POLICY_URL } from "../../legalLinks"; |
| 6 | import { CheckIcon } from "lucide-react"; |
| 7 | import { msg, T, useGT, useMessages } from "gt-react"; |
| 8 | import { Link, useNavigate } from "@tanstack/react-router"; |
| 9 | import { useRef, useState } from "react"; |
| 10 | import { |
| 11 | type DesktopUpdateChannel, |
| 12 | IDLE_COMPACTION_MODES, |
| 13 | type IdleCompactionMode, |
| 14 | globalIdleCompaction, |
| 15 | ProviderDriverKind, |
| 16 | type ProviderInstanceId, |
| 17 | type SidebarProjectGroupingMode, |
| 18 | } from "@t3tools/contracts"; |
| 19 | import { |
| 20 | DEFAULT_UNIFIED_SETTINGS, |
| 21 | type DiffLayout, |
| 22 | MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS, |
| 23 | MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS, |
| 24 | type ResponseStreamingMode, |
| 25 | type QuitConfirmationMode, |
| 26 | SidebarProjectSortOrder, |
| 27 | ScreenReaderAnnouncements, |
| 28 | ToolCallVisibility, |
| 29 | } from "@t3tools/contracts/settings"; |
| 30 | import { |
| 31 | managedUpdatesDenial, |
| 32 | managedUpdatesMessage, |
| 33 | } from "@t3tools/client-runtime/contract-labels"; |
| 34 | import { desktopUpdateChannelOf } from "@t3tools/shared/cliRelease"; |
| 35 | import { createModelSelection, pickModelSelection } from "@t3tools/shared/model"; |
| 36 | import { resolvePastedPath } from "@t3tools/shared/path"; |
| 37 | import * as Equal from "effect/Equal"; |
| 38 | import * as Schema from "effect/Schema"; |
| 39 | import { APP_VERSION, HOSTED_APP_CHANNEL, HOSTED_APP_CHANNEL_LABEL } from "../../branding"; |
| 40 | import { AboutVersionTitle } from "./AboutVersionTitle"; |
| 41 | import { CliCommandSettingsRow } from "./CliCommandSettingsRow"; |
| 42 | import { MobileAppSettingsRow } from "./MobileAppSettingsRow"; |
| 43 | import { |
| 44 | canCheckForUpdate, |
| 45 | getDesktopUpdateButtonTooltip, |
| 46 | getDesktopUpdateDisabledReason, |
| 47 | getDesktopUpdateInstallConfirmationMessage, |
| 48 | isDesktopUpdateButtonDisabled, |
| 49 | resolveDesktopUpdateButtonAction, |
| 50 | } from "../../components/desktopUpdate.logic"; |
| 51 | import { ProviderModelPicker } from "../chat/ProviderModelPicker"; |
| 52 | import { TraitsPicker } from "../chat/TraitsPicker"; |
| 53 | import { isElectron } from "../../env"; |
| 54 | import { buildHostedChannelSelectionUrl, type HostedAppChannel } from "../../hostedPairing"; |
| 55 | import { |
| 56 | readAppearanceModePreference, |
| 57 | readThemeHalves, |
| 58 | readThemePreference, |
| 59 | useTheme, |
| 60 | } from "../../hooks/useTheme"; |
| 61 | import { |
| 62 | useScopedSettings, |
| 63 | useScopedSettingsMixed, |
| 64 | useUpdateScopedSettings, |
| 65 | } from "./useScopedSettings"; |
| 66 | import { useScopedModelDisabledReason } from "./useScopedModelAvailability"; |
| 67 | import { useOptionalSettingsScope, useSettingsScope } from "./SettingsScopeContext"; |
| 68 | import { scopedIdleCompaction } from "./scopedSettings"; |
| 69 | import { ProjectDefaultsSettings } from "./ProjectDefaultsSettings"; |
| 70 | import { ThreadTitleInstructionsSettings } from "./ThreadTitleInstructionsSettings"; |
| 71 | import { SnoozePresetsRow } from "./SnoozePresetsSettings"; |
| 72 | import { useDesktopUpdateState } from "../../state/desktopUpdate"; |
| 73 | import { managedTelemetryOffMessage, usePrimaryManagedPolicy } from "../../state/managedPolicy"; |
| 74 | import { |
| 75 | getTextGenerationModelOptionsByInstance, |
| 76 | resolveAppModelSelectionState, |
| 77 | selectsPlanAgent, |
| 78 | } from "../../modelSelection"; |
| 79 | import { useTextGenerationTargets } from "../../textGenerators"; |
| 80 | import { ensureLocalApi, readLocalApi } from "../../localApi"; |
| 81 | import { isMacPlatform } from "../../lib/utils"; |
| 82 | import { |
| 83 | useEnvironmentProviders, |
| 84 | useEnvironments, |
| 85 | usePrimaryEnvironmentId, |
| 86 | } from "../../state/environments"; |
| 87 | import { EMPTY_SERVER_PROVIDERS } from "../../state/server"; |
| 88 | import { Button } from "../ui/button"; |
| 89 | import { DraftInput } from "../ui/draft-input"; |
| 90 | import { Input } from "../ui/input"; |
| 91 | import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select"; |
| 92 | import { Switch } from "../ui/switch"; |
| 93 | import { ScopedSwitch } from "./ScopedSwitch"; |
| 94 | import { stackedThreadToast, toastManager } from "../ui/toast"; |
| 95 | import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; |
| 96 | import { |
| 97 | autoSettleDaysField, |
| 98 | cancelAutoSettleDaysField, |
| 99 | commitAutoSettleDaysField, |
| 100 | editAutoSettleDaysField, |
| 101 | failAutoSettleDaysField, |
| 102 | getChangedBrowserSettingLabels, |
| 103 | getChangedTypographySettingLabels, |
| 104 | hasChangedBackgroundActivitySettings, |
| 105 | isProjectGroupingEnabled, |
| 106 | projectGroupingModeFromToggle, |
| 107 | readLastEnabledProjectGroupingMode, |
| 108 | rememberEnabledProjectGroupingMode, |
| 109 | syncAutoSettleDaysField, |
| 110 | } from "./SettingsPanels.logic"; |
| 111 | import { |
| 112 | SETTINGS_PICKER_TRIGGER_CLASSNAME, |
| 113 | SettingResetButton, |
| 114 | SettingsPageContainer, |
| 115 | SettingsRow, |
| 116 | SettingsSection, |
| 117 | } from "./settingsLayout"; |
| 118 | import { useSearchableSetting } from "./settingsSearch"; |
| 119 | import { nativeLanguageName, SYSTEM_LANGUAGE } from "@t3tools/client-runtime/locales"; |
| 120 | import { SUPPORTED_LOCALES } from "../../i18n/locales"; |
| 121 | import { BackgroundActivitySettingsRow } from "./BackgroundActivitySettings"; |
| 122 | import { AdvancedSettings } from "./AdvancedSettings"; |
| 123 | import { PullRequestLinksOpenInAppSetting } from "./IntegrationsSettings"; |
| 124 | import { StorageCleanupSections } from "./StorageSettings"; |
| 125 | import { UpdateTrackSwitchDialog } from "./UpdateTrackSwitchDialog"; |
| 126 | import { environmentIdsKey } from "~/state/environmentAtomList"; |
| 127 | import { environmentSessionStatesAtom } from "~/state/session"; |
| 128 | import { useCheckProviderUpdates } from "../ProviderUpdatesAction"; |
| 129 | import { canUpdateServer } from "../ServerUpdateAction"; |
| 130 | import { downloadLocalUpdate } from "../sidebar/SidebarUpdatePill"; |
| 131 | import { useUpdateEverythingRun } from "../sidebar/updateEverythingRun"; |
| 132 | import { awaitsTrackSwitch, channelSwitchLabel } from "../sidebar/updateEverything.logic"; |
| 133 | import { isHostedByThisApp } from "../sidebar/useUpdateEverything"; |
| 134 | |
| 135 | const RESPONSE_STREAMING_MODE_LABELS: Record<ResponseStreamingMode, string> = { |
| 136 | turn: msg("Wait for the full response"), |
| 137 | paragraph: msg("Show finished paragraphs"), |
| 138 | }; |
| 139 | |
| 140 | const RESPONSE_STREAMING_MODE_DESCRIPTIONS: Record<ResponseStreamingMode, string> = { |
| 141 | turn: msg("Text appears once the agent finishes its turn."), |
| 142 | paragraph: msg("Each paragraph or code block appears as soon as it is complete."), |
| 143 | }; |
| 144 | |
| 145 | const SIDEBAR_PROJECT_SORT_ORDER_LABELS: Record<SidebarProjectSortOrder, string> = { |
| 146 | updated_at: msg("Last user message"), |
| 147 | created_at: msg("Created at"), |
| 148 | manual: msg("Manual"), |
| 149 | }; |
| 150 | const isSidebarProjectSortOrder = Schema.is(SidebarProjectSortOrder); |
| 151 | |
| 152 | const TIMESTAMP_FORMAT_LABELS = { |
| 153 | locale: msg("System default"), |
| 154 | "12-hour": msg("12-hour"), |
| 155 | "24-hour": msg("24-hour"), |
| 156 | }; |
| 157 | |
| 158 | const DIFF_LAYOUT_LABELS: Record<DiffLayout, string> = { |
| 159 | stacked: msg("Stacked", { $context: "diff layout" }), |
| 160 | split: msg("Split", { $context: "diff layout" }), |
| 161 | }; |
| 162 | |
| 163 | const QUIT_CONFIRMATION_MODE_LABELS: Record<QuitConfirmationMode, string> = { |
| 164 | direct: msg("Direct"), |
| 165 | hold: msg("Hold"), |
| 166 | "double-click": msg("Double press"), |
| 167 | }; |
| 168 | |
| 169 | const DEFAULT_DRIVER_KIND = ProviderDriverKind.make("codex"); |
| 170 | function AboutVersionSection() { |
| 171 | const setting = useSearchableSetting(); |
| 172 | const gt = useGT(); |
| 173 | const messages = useMessages(); |
| 174 | const updateState = useDesktopUpdateState(); |
| 175 | const [switchChannel, setSwitchChannel] = useState<DesktopUpdateChannel | null>(null); |
| 176 | const [isUpdateActionPending, setIsUpdateActionPending] = useState(false); |
| 177 | const { environments } = useEnvironments(); |
| 178 | const sessionStates = useAtomValue( |
| 179 | environmentSessionStatesAtom( |
| 180 | environmentIdsKey(environments.map(({ environmentId }) => environmentId)), |
| 181 | ), |
| 182 | ); |
| 183 | // A second run would replace the first run's progress and local download. |
| 184 | const updateRun = useUpdateEverythingRun(); |
| 185 | const checkProviderUpdates = useCheckProviderUpdates(); |
| 186 | |
| 187 | const hasDesktopBridge = typeof window !== "undefined" && Boolean(window.desktopBridge); |
| 188 | const selectedUpdateChannel = updateState?.channel ?? "latest"; |
| 189 | // The desktop updates this machine, whose policy the primary environment reports. |
| 190 | const primaryPolicy = usePrimaryManagedPolicy(); |
| 191 | const updatesDenial = hasDesktopBridge |
| 192 | ? managedUpdatesDenial(primaryPolicy, messages) |
| 193 | : undefined; |
| 194 | const nightlyDeniedBy = |
| 195 | hasDesktopBridge && primaryPolicy?.limits?.updates?.allowNightly === false |
| 196 | ? primaryPolicy.organization |
| 197 | : undefined; |
| 198 | const selectedHostedAppChannel = hasDesktopBridge ? null : HOSTED_APP_CHANNEL; |
| 199 | // A switch that failed part way leaves this app or a server on the other track. |
| 200 | // With its updater off, a switch cannot move this app, so it is not counted. |
| 201 | const appOffTrack = |
| 202 | updateState?.enabled !== false && desktopUpdateChannelOf(APP_VERSION) !== selectedUpdateChannel; |
| 203 | const unswitchedMachines = |
| 204 | (appOffTrack ? 1 : 0) + |
| 205 | environments.filter( |
| 206 | (environment, index) => |
| 207 | environment.connection.phase === "connected" && |
| 208 | canUpdateServer(sessionStates[index]!) && |
| 209 | awaitsTrackSwitch( |
| 210 | { |
| 211 | serverConfig: environment.serverConfig, |
| 212 | hostedByThisApp: isHostedByThisApp(environment), |
| 213 | }, |
| 214 | selectedUpdateChannel, |
| 215 | ), |
| 216 | ).length; |
| 217 | |
| 218 | const handleButtonClick = async () => { |
| 219 | const bridge = window.desktopBridge; |
| 220 | if (!bridge) return; |
| 221 | |
| 222 | const action = updateState ? resolveDesktopUpdateButtonAction(updateState) : "none"; |
| 223 | |
| 224 | if (action === "download") { |
| 225 | void downloadLocalUpdate(bridge, { notifyDownloaded: false }); |
| 226 | return; |
| 227 | } |
| 228 | |
| 229 | if (action === "install") { |
| 230 | if (isUpdateActionPending) return; |
| 231 | setIsUpdateActionPending(true); |
| 232 | let confirmed = false; |
| 233 | try { |
| 234 | confirmed = await ensureLocalApi().dialogs.confirm( |
| 235 | getDesktopUpdateInstallConfirmationMessage( |
| 236 | updateState ?? { availableVersion: null, downloadedVersion: null }, |
| 237 | ), |
| 238 | { initialFocus: "confirm" }, |
| 239 | ); |
| 240 | } catch (error) { |
| 241 | setIsUpdateActionPending(false); |
| 242 | toastManager.add( |
| 243 | stackedThreadToast({ |
| 244 | type: "error", |
| 245 | title: gt("Could not confirm update"), |
| 246 | description: |
| 247 | error instanceof Error |
| 248 | ? (thrownErrorMessage(error, resolveMessage) ?? error.message) |
| 249 | : gt("Update confirmation failed."), |
| 250 | }), |
| 251 | ); |
| 252 | return; |
| 253 | } |
| 254 | if (!confirmed) { |
| 255 | setIsUpdateActionPending(false); |
| 256 | return; |
| 257 | } |
| 258 | void bridge |
| 259 | .installUpdate() |
| 260 | .catch((error: unknown) => { |
| 261 | toastManager.add( |
| 262 | stackedThreadToast({ |
| 263 | type: "error", |
| 264 | title: gt("Could not install update"), |
| 265 | description: |
| 266 | error instanceof Error |
| 267 | ? (thrownErrorMessage(error, resolveMessage) ?? error.message) |
| 268 | : gt("Install failed."), |
| 269 | }), |
| 270 | ); |
| 271 | }) |
| 272 | .finally(() => setIsUpdateActionPending(false)); |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | if (typeof bridge.checkForUpdate !== "function") return; |
| 277 | void checkProviderUpdates(); |
| 278 | void bridge |
| 279 | .checkForUpdate() |
| 280 | .then((result) => { |
| 281 | if (!result.checked) { |
| 282 | toastManager.add( |
| 283 | stackedThreadToast({ |
| 284 | type: "error", |
| 285 | title: gt("Could not check for updates"), |
| 286 | description: |
| 287 | updatesDenial ?? |
| 288 | result.state.message ?? |
| 289 | gt("Automatic updates are not available in this build."), |
| 290 | }), |
| 291 | ); |
| 292 | } |
| 293 | }) |
| 294 | .catch((error: unknown) => { |
| 295 | toastManager.add( |
| 296 | stackedThreadToast({ |
| 297 | type: "error", |
| 298 | title: gt("Could not check for updates"), |
| 299 | description: |
| 300 | error instanceof Error |
| 301 | ? (thrownErrorMessage(error, resolveMessage) ?? error.message) |
| 302 | : gt("Update check failed."), |
| 303 | }), |
| 304 | ); |
| 305 | }); |
| 306 | }; |
| 307 | |
| 308 | const action = updateState ? resolveDesktopUpdateButtonAction(updateState) : "none"; |
| 309 | const buttonTooltip = updateState ? getDesktopUpdateButtonTooltip(updateState, messages) : null; |
| 310 | const buttonDisabled = |
| 311 | action === "none" |
| 312 | ? !canCheckForUpdate(updateState) |
| 313 | : isDesktopUpdateButtonDisabled(updateState); |
| 314 | |
| 315 | const actionLabel: Record<string, string> = { download: gt("Download"), install: gt("Install") }; |
| 316 | const statusLabel: Record<string, string> = { |
| 317 | checking: gt("Checking…"), |
| 318 | downloading: gt("Downloading…"), |
| 319 | // Off its track, "up to date" only means no switch is pending; Review moves it. |
| 320 | ...(appOffTrack ? {} : { "up-to-date": gt("Up to Date") }), |
| 321 | }; |
| 322 | const buttonLabel = |
| 323 | actionLabel[action] ?? statusLabel[updateState?.status ?? ""] ?? gt("Check for Updates"); |
| 324 | const description = |
| 325 | action === "download" || action === "install" |
| 326 | ? gt("Update available.") |
| 327 | : (getDesktopUpdateDisabledReason(updateState, updatesDenial, messages) ?? |
| 328 | gt("Current version of the application.")); |
| 329 | |
| 330 | return ( |
| 331 | <> |
| 332 | <SettingsRow |
| 333 | id={setting("app-version").id} |
| 334 | title={<AboutVersionTitle />} |
| 335 | description={description} |
| 336 | managed={updatesDenial} |
| 337 | control={ |
| 338 | <Tooltip> |
| 339 | <TooltipTrigger |
| 340 | render={ |
| 341 | <Button |
| 342 | size="sm" |
| 343 | variant="outline" |
| 344 | disabled={buttonDisabled || isUpdateActionPending} |
| 345 | onClick={handleButtonClick} |
| 346 | > |
| 347 | {buttonLabel} |
| 348 | </Button> |
| 349 | } |
| 350 | /> |
| 351 | {buttonTooltip ? <TooltipPopup>{buttonTooltip}</TooltipPopup> : null} |
| 352 | </Tooltip> |
| 353 | } |
| 354 | /> |
| 355 | {hasDesktopBridge ? ( |
| 356 | <SettingsRow |
| 357 | {...setting("update-track")} |
| 358 | description={ |
| 359 | nightlyDeniedBy !== undefined ? ( |
| 360 | selectedUpdateChannel === "nightly" ? ( |
| 361 | gt( |
| 362 | "{policy} Nightly builds are not available; switch to Stable to keep getting updates.", |
| 363 | { policy: managedUpdatesMessage(nightlyDeniedBy, messages) }, |
| 364 | ) |
| 365 | ) : ( |
| 366 | gt("{policy} Nightly builds are not available.", { |
| 367 | policy: managedUpdatesMessage(nightlyDeniedBy, messages), |
| 368 | }) |
| 369 | ) |
| 370 | ) : unswitchedMachines > 0 ? ( |
| 371 | <> |
| 372 | {gt( |
| 373 | "{count, plural, one {{count} machine still runs {track}.} other {{count} machines still run {track}.}}", |
| 374 | { |
| 375 | count: unswitchedMachines, |
| 376 | track: channelSwitchLabel( |
| 377 | selectedUpdateChannel === "nightly" ? "latest" : "nightly", |
| 378 | messages, |
| 379 | ), |
| 380 | }, |
| 381 | )}{" "} |
| 382 | {/* The dialog moves what it can and says why it skips the rest. */} |
| 383 | <Button |
| 384 | size="xs" |
| 385 | variant="link" |
| 386 | disabled={updateRun !== null} |
| 387 | onClick={() => setSwitchChannel(selectedUpdateChannel)} |
| 388 | > |
| 389 | <T>Review</T> |
| 390 | </Button> |
| 391 | </> |
| 392 | ) : ( |
| 393 | gt( |
| 394 | "Switches this app and every connected machine whose database the target release supports.", |
| 395 | ) |
| 396 | ) |
| 397 | } |
| 398 | managed={updatesDenial} |
| 399 | control={ |
| 400 | <Select |
| 401 | value={selectedUpdateChannel} |
| 402 | onValueChange={(value) => { |
| 403 | if (value !== selectedUpdateChannel) { |
| 404 | setSwitchChannel(value as DesktopUpdateChannel); |
| 405 | } |
| 406 | }} |
| 407 | > |
| 408 | <SelectTrigger |
| 409 | size="sm" |
| 410 | className="w-full sm:w-40" |
| 411 | aria-label={gt("Update track")} |
| 412 | disabled={switchChannel !== null || updateRun !== null} |
| 413 | > |
| 414 | <SelectValue>{channelSwitchLabel(selectedUpdateChannel, messages)}</SelectValue> |
| 415 | </SelectTrigger> |
| 416 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 417 | <SelectItem hideIndicator value="latest"> |
| 418 | <T>Stable</T> |
| 419 | </SelectItem> |
| 420 | <SelectItem |
| 421 | hideIndicator |
| 422 | value="nightly" |
| 423 | disabled={nightlyDeniedBy !== undefined && selectedUpdateChannel !== "nightly"} |
| 424 | > |
| 425 | <T>Nightly</T> |
| 426 | </SelectItem> |
| 427 | </SelectPopup> |
| 428 | </Select> |
| 429 | } |
| 430 | /> |
| 431 | ) : selectedHostedAppChannel ? ( |
| 432 | <SettingsRow |
| 433 | {...setting("update-track")} |
| 434 | description={gt("Switches the hosted app release channel.")} |
| 435 | control={ |
| 436 | <Select |
| 437 | value={selectedHostedAppChannel} |
| 438 | onValueChange={(value) => { |
| 439 | if (value === selectedHostedAppChannel) return; |
| 440 | window.location.assign( |
| 441 | buildHostedChannelSelectionUrl({ channel: value as HostedAppChannel }), |
| 442 | ); |
| 443 | }} |
| 444 | > |
| 445 | <SelectTrigger size="sm" className="w-full sm:w-40" aria-label={gt("Update track")}> |
| 446 | <SelectValue>{HOSTED_APP_CHANNEL_LABEL}</SelectValue> |
| 447 | </SelectTrigger> |
| 448 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 449 | <SelectItem hideIndicator value="latest"> |
| 450 | <T>Latest</T> |
| 451 | </SelectItem> |
| 452 | <SelectItem hideIndicator value="nightly"> |
| 453 | <T>Nightly</T> |
| 454 | </SelectItem> |
| 455 | </SelectPopup> |
| 456 | </Select> |
| 457 | } |
| 458 | /> |
| 459 | ) : null} |
| 460 | {hasDesktopBridge ? <CliCommandSettingsRow /> : null} |
| 461 | {switchChannel === null ? null : ( |
| 462 | <UpdateTrackSwitchDialog channel={switchChannel} onClose={() => setSwitchChannel(null)} /> |
| 463 | )} |
| 464 | </> |
| 465 | ); |
| 466 | } |
| 467 | |
| 468 | export function useSettingsRestore(onRestored?: () => void) { |
| 469 | const messages = useMessages(); |
| 470 | const gt = useGT(); |
| 471 | const { |
| 472 | theme, |
| 473 | setTheme, |
| 474 | followSystem, |
| 475 | setFollowSystem, |
| 476 | setThemeHalf, |
| 477 | clearThemeHalves, |
| 478 | themeHalves, |
| 479 | } = useTheme(); |
| 480 | const settings = useScopedSettings(); |
| 481 | const updateSettings = useUpdateScopedSettings(); |
| 482 | |
| 483 | const isTextGenerationModelDirty = !Equal.equals( |
| 484 | settings.textGenerationModelSelection ?? null, |
| 485 | DEFAULT_UNIFIED_SETTINGS.textGenerationModelSelection ?? null, |
| 486 | ); |
| 487 | const isBackgroundActivityDirty = hasChangedBackgroundActivitySettings(settings); |
| 488 | |
| 489 | const changedSettingLabels = [ |
| 490 | ...(theme !== "system" ? [gt("Theme")] : []), |
| 491 | ...(!followSystem ? [gt("Follow system")] : []), |
| 492 | ...(themeHalves !== null ? [gt("Theme mix")] : []), |
| 493 | ...(settings.appearanceContrast !== DEFAULT_UNIFIED_SETTINGS.appearanceContrast |
| 494 | ? [gt("Contrast")] |
| 495 | : []), |
| 496 | ...(settings.glassOpacity !== DEFAULT_UNIFIED_SETTINGS.glassOpacity |
| 497 | ? [gt("Glass opacity")] |
| 498 | : []), |
| 499 | ...(settings.diffColorScheme !== DEFAULT_UNIFIED_SETTINGS.diffColorScheme |
| 500 | ? [gt("Diff colors")] |
| 501 | : []), |
| 502 | ...(settings.chatWidth !== DEFAULT_UNIFIED_SETTINGS.chatWidth ? [gt("Chat width")] : []), |
| 503 | ...(settings.effortDisplay !== DEFAULT_UNIFIED_SETTINGS.effortDisplay |
| 504 | ? [gt("Effort display")] |
| 505 | : []), |
| 506 | ...(settings.mathRenderingEnabled !== DEFAULT_UNIFIED_SETTINGS.mathRenderingEnabled |
| 507 | ? [gt("Render math")] |
| 508 | : []), |
| 509 | ...(settings.panelAnimationDurationMs !== DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs |
| 510 | ? [gt("Panel animations")] |
| 511 | : []), |
| 512 | ...(settings.environmentIdentificationMode !== |
| 513 | DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode |
| 514 | ? [gt("Environment identification")] |
| 515 | : []), |
| 516 | ...(settings.language !== DEFAULT_UNIFIED_SETTINGS.language ? [gt("Language")] : []), |
| 517 | ...(settings.timestampFormat !== DEFAULT_UNIFIED_SETTINGS.timestampFormat |
| 518 | ? [gt("Time format")] |
| 519 | : []), |
| 520 | ...(settings.notificationMode !== DEFAULT_UNIFIED_SETTINGS.notificationMode |
| 521 | ? [gt("Thread notifications")] |
| 522 | : []), |
| 523 | ...(settings.inAppNotificationsEnabled !== DEFAULT_UNIFIED_SETTINGS.inAppNotificationsEnabled |
| 524 | ? [gt("In-app notifications")] |
| 525 | : []), |
| 526 | ...(settings.sidebarProjectGroupingMode !== DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode |
| 527 | ? [gt("Project Grouping")] |
| 528 | : []), |
| 529 | ...(settings.sidebarProjectSortOrder !== DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder |
| 530 | ? [gt("Project order")] |
| 531 | : []), |
| 532 | ...(settings.sidebarWorkingShelfEnabled !== DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled |
| 533 | ? [gt("Working section")] |
| 534 | : []), |
| 535 | ...(settings.sidebarAutoSettleAfterDays !== DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays |
| 536 | ? [gt("Auto-settle inactive threads")] |
| 537 | : []), |
| 538 | ...(settings.sidebarAutoSettleKeepPullRequests !== |
| 539 | DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleKeepPullRequests |
| 540 | ? [gt("Keep threads with a PR")] |
| 541 | : []), |
| 542 | ...(settings.sidebarAutoSettleOnMerge !== DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge |
| 543 | ? [gt("Auto-settle merged threads")] |
| 544 | : []), |
| 545 | ...(settings.autoResumeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.autoResumeLimitedThreads |
| 546 | ? [gt("Resume after usage limits")] |
| 547 | : []), |
| 548 | ...(settings.snoozeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads |
| 549 | ? [gt("Snooze until limits reset")] |
| 550 | : []), |
| 551 | ...(!Equal.equals(settings.snoozePresets, DEFAULT_UNIFIED_SETTINGS.snoozePresets) |
| 552 | ? [gt("Snooze options")] |
| 553 | : []), |
| 554 | ...(settings.wordWrap !== DEFAULT_UNIFIED_SETTINGS.wordWrap ? [gt("Word wrap")] : []), |
| 555 | ...(settings.persistComposerContextStrip !== |
| 556 | DEFAULT_UNIFIED_SETTINGS.persistComposerContextStrip |
| 557 | ? [gt("Composer context")] |
| 558 | : []), |
| 559 | ...getChangedTypographySettingLabels(settings, messages), |
| 560 | ...(settings.diffFilesCollapsed !== DEFAULT_UNIFIED_SETTINGS.diffFilesCollapsed |
| 561 | ? [gt("Default diff file state")] |
| 562 | : []), |
| 563 | ...(settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace |
| 564 | ? [gt("Diff whitespace changes")] |
| 565 | : []), |
| 566 | ...(settings.diffLayout !== DEFAULT_UNIFIED_SETTINGS.diffLayout ? [gt("Diff layout")] : []), |
| 567 | ...(settings.proactivePanelsEnabled !== DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled |
| 568 | ? [gt("Open pull requests and changes panels proactively")] |
| 569 | : []), |
| 570 | ...(settings.showSkillsInSlashMenu !== DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu |
| 571 | ? [gt("Show skills in slash menu")] |
| 572 | : []), |
| 573 | ...(settings.composerRichTextEnabled !== DEFAULT_UNIFIED_SETTINGS.composerRichTextEnabled |
| 574 | ? [gt("Rich text composer")] |
| 575 | : []), |
| 576 | ...(settings.sendShortcut !== DEFAULT_UNIFIED_SETTINGS.sendShortcut |
| 577 | ? [gt("Send shortcut")] |
| 578 | : []), |
| 579 | ...(settings.followUpBehavior !== DEFAULT_UNIFIED_SETTINGS.followUpBehavior |
| 580 | ? [gt("Follow-up behavior")] |
| 581 | : []), |
| 582 | ...(settings.sideThreadOpenTarget !== DEFAULT_UNIFIED_SETTINGS.sideThreadOpenTarget |
| 583 | ? [gt("Open subagents and side chats in")] |
| 584 | : []), |
| 585 | ...(settings.toolCallVisibility !== DEFAULT_UNIFIED_SETTINGS.toolCallVisibility |
| 586 | ? [gt("Tool calls in chat")] |
| 587 | : []), |
| 588 | ...(settings.screenReaderAnnouncements !== DEFAULT_UNIFIED_SETTINGS.screenReaderAnnouncements |
| 589 | ? [gt("Screen reader announcements")] |
| 590 | : []), |
| 591 | ...(settings.screenReaderWindowTitle !== DEFAULT_UNIFIED_SETTINGS.screenReaderWindowTitle |
| 592 | ? [gt("Screen reader window title")] |
| 593 | : []), |
| 594 | ...(settings.responseStreamingMode !== DEFAULT_UNIFIED_SETTINGS.responseStreamingMode |
| 595 | ? [gt("Response streaming")] |
| 596 | : []), |
| 597 | ...(settings.enableProviderUpdateChecks !== DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks |
| 598 | ? [gt("Provider update checks")] |
| 599 | : []), |
| 600 | ...(settings.continueThreadsAfterServerUpdate !== |
| 601 | DEFAULT_UNIFIED_SETTINGS.continueThreadsAfterServerUpdate |
| 602 | ? [gt("Continue threads after restarts")] |
| 603 | : []), |
| 604 | ...(isBackgroundActivityDirty ? [gt("Background activity")] : []), |
| 605 | ...(settings.keepAwakeWhileAgentsWork !== DEFAULT_UNIFIED_SETTINGS.keepAwakeWhileAgentsWork |
| 606 | ? [gt("Keep awake while agents work")] |
| 607 | : []), |
| 608 | ...(settings.defaultThreadEnvMode !== DEFAULT_UNIFIED_SETTINGS.defaultThreadEnvMode |
| 609 | ? [gt("New thread mode")] |
| 610 | : []), |
| 611 | ...(settings.newWorktreesStartFromOrigin !== |
| 612 | DEFAULT_UNIFIED_SETTINGS.newWorktreesStartFromOrigin |
| 613 | ? [gt("New worktrees start from remote")] |
| 614 | : []), |
| 615 | ...(settings.addProjectBaseDirectory !== DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory |
| 616 | ? [gt("Add project base directory")] |
| 617 | : []), |
| 618 | ...(settings.ghqCloneLayout !== DEFAULT_UNIFIED_SETTINGS.ghqCloneLayout |
| 619 | ? [gt("Clone into host folders")] |
| 620 | : []), |
| 621 | ...(settings.confirmThreadUnpin !== DEFAULT_UNIFIED_SETTINGS.confirmThreadUnpin |
| 622 | ? [gt("Unpin confirmation")] |
| 623 | : []), |
| 624 | ...(settings.confirmThreadArchive !== DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive |
| 625 | ? [gt("Archive confirmation")] |
| 626 | : []), |
| 627 | ...(settings.confirmTerminalClose !== DEFAULT_UNIFIED_SETTINGS.confirmTerminalClose |
| 628 | ? [gt("Terminal close confirmation")] |
| 629 | : []), |
| 630 | ...(settings.confirmThreadDelete !== DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete |
| 631 | ? [gt("Delete confirmation")] |
| 632 | : []), |
| 633 | ...(settings.confirmQuit !== DEFAULT_UNIFIED_SETTINGS.confirmQuit ? [gt("Quit shortcut")] : []), |
| 634 | ...(isTextGenerationModelDirty ? [gt("Text generation model")] : []), |
| 635 | ...(settings.threadTitleInstructions !== DEFAULT_UNIFIED_SETTINGS.threadTitleInstructions |
| 636 | ? [gt("Thread title instructions")] |
| 637 | : []), |
| 638 | ...getChangedBrowserSettingLabels(settings, messages), |
| 639 | ...(settings.enableAgentBrowserAccess !== DEFAULT_UNIFIED_SETTINGS.enableAgentBrowserAccess |
| 640 | ? [gt("Agent browser access")] |
| 641 | : []), |
| 642 | ]; |
| 643 | |
| 644 | const restoreDefaults = async () => { |
| 645 | if (changedSettingLabels.length === 0) return; |
| 646 | const api = readLocalApi(); |
| 647 | const confirmed = await (api ?? ensureLocalApi()).dialogs.confirm( |
| 648 | [ |
| 649 | gt("Restore default settings?"), |
| 650 | gt("This will reset: {settings}.", { settings: changedSettingLabels.join(", ") }), |
| 651 | ].join("\n"), |
| 652 | { variant: "destructive" }, |
| 653 | ); |
| 654 | if (!confirmed) return; |
| 655 | |
| 656 | // Reset only dirty theme keys so storage failures cannot block other settings; re-read after confirmation |
| 657 | // for safe rollback. |
| 658 | let previousTheme = theme; |
| 659 | try { |
| 660 | previousTheme = readThemePreference(); |
| 661 | } catch {} |
| 662 | const liveHalves = readThemeHalves(); |
| 663 | const needsThemeReset = previousTheme !== "system"; |
| 664 | const needsMixReset = liveHalves !== null; |
| 665 | const needsFollowSystemReset = readAppearanceModePreference(previousTheme) !== "system"; |
| 666 | const notifyThemeRestoreFailure = () => { |
| 667 | toastManager.add( |
| 668 | stackedThreadToast({ |
| 669 | type: "error", |
| 670 | title: gt("Couldn’t restore theme settings"), |
| 671 | description: gt("Try again."), |
| 672 | }), |
| 673 | ); |
| 674 | }; |
| 675 | // Restore the base preference before the mix because restoring the base clears the mix. |
| 676 | const previousHalves = liveHalves; |
| 677 | const rollbackThemeState = () => { |
| 678 | if (needsThemeReset) setTheme(previousTheme); |
| 679 | if (previousHalves?.light) setThemeHalf("light", previousHalves.light); |
| 680 | if (previousHalves?.dark) setThemeHalf("dark", previousHalves.dark); |
| 681 | }; |
| 682 | if (needsThemeReset && !setTheme("system")) { |
| 683 | notifyThemeRestoreFailure(); |
| 684 | return; |
| 685 | } |
| 686 | if (needsMixReset && !clearThemeHalves()) { |
| 687 | rollbackThemeState(); |
| 688 | notifyThemeRestoreFailure(); |
| 689 | return; |
| 690 | } |
| 691 | if (needsFollowSystemReset && !setFollowSystem(true)) { |
| 692 | rollbackThemeState(); |
| 693 | notifyThemeRestoreFailure(); |
| 694 | return; |
| 695 | } |
| 696 | updateSettings({ |
| 697 | appearanceContrast: DEFAULT_UNIFIED_SETTINGS.appearanceContrast, |
| 698 | diffColorScheme: DEFAULT_UNIFIED_SETTINGS.diffColorScheme, |
| 699 | chatWidth: DEFAULT_UNIFIED_SETTINGS.chatWidth, |
| 700 | effortDisplay: DEFAULT_UNIFIED_SETTINGS.effortDisplay, |
| 701 | mathRenderingEnabled: DEFAULT_UNIFIED_SETTINGS.mathRenderingEnabled, |
| 702 | language: DEFAULT_UNIFIED_SETTINGS.language, |
| 703 | timestampFormat: DEFAULT_UNIFIED_SETTINGS.timestampFormat, |
| 704 | notificationMode: DEFAULT_UNIFIED_SETTINGS.notificationMode, |
| 705 | inAppNotificationsEnabled: DEFAULT_UNIFIED_SETTINGS.inAppNotificationsEnabled, |
| 706 | wordWrap: DEFAULT_UNIFIED_SETTINGS.wordWrap, |
| 707 | persistComposerContextStrip: DEFAULT_UNIFIED_SETTINGS.persistComposerContextStrip, |
| 708 | diffFilesCollapsed: DEFAULT_UNIFIED_SETTINGS.diffFilesCollapsed, |
| 709 | diffIgnoreWhitespace: DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace, |
| 710 | diffLayout: DEFAULT_UNIFIED_SETTINGS.diffLayout, |
| 711 | proactivePanelsEnabled: DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled, |
| 712 | showSkillsInSlashMenu: DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu, |
| 713 | composerRichTextEnabled: DEFAULT_UNIFIED_SETTINGS.composerRichTextEnabled, |
| 714 | sendShortcut: DEFAULT_UNIFIED_SETTINGS.sendShortcut, |
| 715 | followUpBehavior: DEFAULT_UNIFIED_SETTINGS.followUpBehavior, |
| 716 | sideThreadOpenTarget: DEFAULT_UNIFIED_SETTINGS.sideThreadOpenTarget, |
| 717 | toolCallVisibility: DEFAULT_UNIFIED_SETTINGS.toolCallVisibility, |
| 718 | screenReaderAnnouncements: DEFAULT_UNIFIED_SETTINGS.screenReaderAnnouncements, |
| 719 | screenReaderWindowTitle: DEFAULT_UNIFIED_SETTINGS.screenReaderWindowTitle, |
| 720 | environmentIdentificationMode: DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode, |
| 721 | glassOpacity: DEFAULT_UNIFIED_SETTINGS.glassOpacity, |
| 722 | panelAnimationDurationMs: DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs, |
| 723 | sidebarProjectGroupingMode: DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode, |
| 724 | sidebarProjectSortOrder: DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder, |
| 725 | sidebarWorkingShelfEnabled: DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled, |
| 726 | sidebarAutoSettleAfterDays: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays, |
| 727 | sidebarAutoSettleKeepPullRequests: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleKeepPullRequests, |
| 728 | sidebarAutoSettleOnMerge: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge, |
| 729 | autoResumeLimitedThreads: DEFAULT_UNIFIED_SETTINGS.autoResumeLimitedThreads, |
| 730 | snoozeLimitedThreads: DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads, |
| 731 | snoozePresets: DEFAULT_UNIFIED_SETTINGS.snoozePresets, |
| 732 | responseStreamingMode: DEFAULT_UNIFIED_SETTINGS.responseStreamingMode, |
| 733 | enableProviderUpdateChecks: DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks, |
| 734 | continueThreadsAfterServerUpdate: DEFAULT_UNIFIED_SETTINGS.continueThreadsAfterServerUpdate, |
| 735 | backgroundActivity: DEFAULT_UNIFIED_SETTINGS.backgroundActivity, |
| 736 | keepAwakeWhileAgentsWork: DEFAULT_UNIFIED_SETTINGS.keepAwakeWhileAgentsWork, |
| 737 | backgroundActivityProfile: DEFAULT_UNIFIED_SETTINGS.backgroundActivityProfile, |
| 738 | automaticGitFetchInterval: DEFAULT_UNIFIED_SETTINGS.automaticGitFetchInterval, |
| 739 | providerHealthRefreshInterval: DEFAULT_UNIFIED_SETTINGS.providerHealthRefreshInterval, |
| 740 | defaultThreadEnvMode: DEFAULT_UNIFIED_SETTINGS.defaultThreadEnvMode, |
| 741 | newWorktreesStartFromOrigin: DEFAULT_UNIFIED_SETTINGS.newWorktreesStartFromOrigin, |
| 742 | addProjectBaseDirectory: DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory, |
| 743 | ghqCloneLayout: DEFAULT_UNIFIED_SETTINGS.ghqCloneLayout, |
| 744 | confirmThreadArchive: DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive, |
| 745 | confirmTerminalClose: DEFAULT_UNIFIED_SETTINGS.confirmTerminalClose, |
| 746 | confirmThreadDelete: DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete, |
| 747 | confirmThreadUnpin: DEFAULT_UNIFIED_SETTINGS.confirmThreadUnpin, |
| 748 | confirmQuit: DEFAULT_UNIFIED_SETTINGS.confirmQuit, |
| 749 | textGenerationModelSelection: DEFAULT_UNIFIED_SETTINGS.textGenerationModelSelection, |
| 750 | threadTitleInstructions: DEFAULT_UNIFIED_SETTINGS.threadTitleInstructions, |
| 751 | fontFamilySans: DEFAULT_UNIFIED_SETTINGS.fontFamilySans, |
| 752 | fontFamilyComposer: DEFAULT_UNIFIED_SETTINGS.fontFamilyComposer, |
| 753 | fontFamilyCode: DEFAULT_UNIFIED_SETTINGS.fontFamilyCode, |
| 754 | fontFamilyTerminal: DEFAULT_UNIFIED_SETTINGS.fontFamilyTerminal, |
| 755 | fontSizeInterface: DEFAULT_UNIFIED_SETTINGS.fontSizeInterface, |
| 756 | fontSizePrompt: DEFAULT_UNIFIED_SETTINGS.fontSizePrompt, |
| 757 | fontSizeCode: DEFAULT_UNIFIED_SETTINGS.fontSizeCode, |
| 758 | fontSizeTerminal: DEFAULT_UNIFIED_SETTINGS.fontSizeTerminal, |
| 759 | browserDefaultViewport: DEFAULT_UNIFIED_SETTINGS.browserDefaultViewport, |
| 760 | browserDefaultZoomFactor: DEFAULT_UNIFIED_SETTINGS.browserDefaultZoomFactor, |
| 761 | browserDefaultAppearance: DEFAULT_UNIFIED_SETTINGS.browserDefaultAppearance, |
| 762 | browserRecordingFrameRate: DEFAULT_UNIFIED_SETTINGS.browserRecordingFrameRate, |
| 763 | browserRecordingShowKeyPresses: DEFAULT_UNIFIED_SETTINGS.browserRecordingShowKeyPresses, |
| 764 | browserRecordingShowMousePresses: DEFAULT_UNIFIED_SETTINGS.browserRecordingShowMousePresses, |
| 765 | browserLinkTarget: DEFAULT_UNIFIED_SETTINGS.browserLinkTarget, |
| 766 | browserSearchEngine: DEFAULT_UNIFIED_SETTINGS.browserSearchEngine, |
| 767 | browserCustomSearchUrl: DEFAULT_UNIFIED_SETTINGS.browserCustomSearchUrl, |
| 768 | browserAutoShowFloatingPreview: DEFAULT_UNIFIED_SETTINGS.browserAutoShowFloatingPreview, |
| 769 | pullRequestLinksOpenInApp: DEFAULT_UNIFIED_SETTINGS.pullRequestLinksOpenInApp, |
| 770 | enableAgentBrowserAccess: DEFAULT_UNIFIED_SETTINGS.enableAgentBrowserAccess, |
| 771 | }); |
| 772 | onRestored?.(); |
| 773 | }; |
| 774 | |
| 775 | return { |
| 776 | changedSettingLabels, |
| 777 | restoreDefaults, |
| 778 | }; |
| 779 | } |
| 780 | |
| 781 | const AUTO_SETTLE_DEFAULT_DAYS = DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays ?? 7; |
| 782 | |
| 783 | function AutoSettleDaysInput({ |
| 784 | value, |
| 785 | onCommit, |
| 786 | }: { |
| 787 | value: number; |
| 788 | onCommit: (days: number, options: { onFailed: () => void }) => void; |
| 789 | }) { |
| 790 | const gt = useGT(); |
| 791 | const [stored, setField] = useState(() => autoSettleDaysField(value)); |
| 792 | const field = syncAutoSettleDaysField(stored, value); |
| 793 | if (field !== stored) setField(field); |
| 794 | |
| 795 | const commit = () => { |
| 796 | const next = commitAutoSettleDaysField(field); |
| 797 | setField(next.field); |
| 798 | if (next.submit === null) return; |
| 799 | const { revision } = next.field; |
| 800 | onCommit(next.submit, { |
| 801 | onFailed: () => setField((current) => failAutoSettleDaysField(current, revision)), |
| 802 | }); |
| 803 | }; |
| 804 | |
| 805 | return ( |
| 806 | <Input |
| 807 | size="sm" |
| 808 | type="number" |
| 809 | min={MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS} |
| 810 | max={MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS} |
| 811 | className="w-full sm:w-24" |
| 812 | value={field.draft} |
| 813 | onChange={(event) => setField(editAutoSettleDaysField(field, event.target.value))} |
| 814 | onBlur={commit} |
| 815 | onKeyDown={(event) => { |
| 816 | if (event.nativeEvent.isComposing) return; |
| 817 | if (event.key === "Enter") commit(); |
| 818 | if (event.key === "Escape" && field.dirty) { |
| 819 | // An unhandled Escape closes the settings page, and the blur that follows would save. |
| 820 | event.preventDefault(); |
| 821 | event.stopPropagation(); |
| 822 | setField(cancelAutoSettleDaysField(field)); |
| 823 | } |
| 824 | }} |
| 825 | aria-label={gt("Days of inactivity before auto-settle")} |
| 826 | /> |
| 827 | ); |
| 828 | } |
| 829 | |
| 830 | export function GeneralSettingsPanel() { |
| 831 | const gt = useGT(); |
| 832 | const m = useMessages(); |
| 833 | const setting = useSearchableSetting(); |
| 834 | const settings = useScopedSettings(); |
| 835 | const updateSettings = useUpdateScopedSettings(); |
| 836 | const lastEnabledProjectGroupingMode = useRef<SidebarProjectGroupingMode>( |
| 837 | readLastEnabledProjectGroupingMode(), |
| 838 | ); |
| 839 | const languageValue = SUPPORTED_LOCALES.includes(settings.language) |
| 840 | ? settings.language |
| 841 | : SYSTEM_LANGUAGE; |
| 842 | |
| 843 | return ( |
| 844 | <SettingsPageContainer> |
| 845 | <SettingsSection id="notifications" title={gt("Notifications")}> |
| 846 | <NotificationSettings /> |
| 847 | <SettingsRow |
| 848 | {...setting("in-app-notifications")} |
| 849 | description={ |
| 850 | <T> |
| 851 | Show a toast when another thread finishes, fails, or needs input or approval while |
| 852 | this app has focus. |
| 853 | </T> |
| 854 | } |
| 855 | control={ |
| 856 | <Switch |
| 857 | checked={settings.inAppNotificationsEnabled} |
| 858 | onCheckedChange={(checked) => updateSettings({ inAppNotificationsEnabled: checked })} |
| 859 | aria-label={gt("In-app notifications")} |
| 860 | /> |
| 861 | } |
| 862 | /> |
| 863 | </SettingsSection> |
| 864 | |
| 865 | <SettingsSection id="sidebar" title={gt("Sidebar")}> |
| 866 | <SettingsRow |
| 867 | {...setting("project-grouping")} |
| 868 | description={<T>Combine matching repositories across environments.</T>} |
| 869 | resetAction={ |
| 870 | settings.sidebarProjectGroupingMode !== |
| 871 | DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode ? ( |
| 872 | <SettingResetButton |
| 873 | ariaLabel={gt("Reset project grouping to default")} |
| 874 | onClick={() => |
| 875 | updateSettings({ |
| 876 | sidebarProjectGroupingMode: DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode, |
| 877 | }) |
| 878 | } |
| 879 | /> |
| 880 | ) : null |
| 881 | } |
| 882 | control={ |
| 883 | <Switch |
| 884 | checked={isProjectGroupingEnabled(settings.sidebarProjectGroupingMode)} |
| 885 | onCheckedChange={(checked) => { |
| 886 | if (!checked && settings.sidebarProjectGroupingMode !== "separate") { |
| 887 | lastEnabledProjectGroupingMode.current = settings.sidebarProjectGroupingMode; |
| 888 | rememberEnabledProjectGroupingMode(settings.sidebarProjectGroupingMode); |
| 889 | } |
| 890 | updateSettings({ |
| 891 | sidebarProjectGroupingMode: projectGroupingModeFromToggle( |
| 892 | checked, |
| 893 | lastEnabledProjectGroupingMode.current, |
| 894 | ), |
| 895 | }); |
| 896 | }} |
| 897 | aria-label={gt("Project grouping")} |
| 898 | /> |
| 899 | } |
| 900 | /> |
| 901 | <SettingsRow |
| 902 | {...setting("project-order")} |
| 903 | description={<T>Order of projects in the sidebar project picker and command palette.</T>} |
| 904 | resetAction={ |
| 905 | settings.sidebarProjectSortOrder !== |
| 906 | DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder ? ( |
| 907 | <SettingResetButton |
| 908 | ariaLabel={gt("Reset project order to default")} |
| 909 | onClick={() => |
| 910 | updateSettings({ |
| 911 | sidebarProjectSortOrder: DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder, |
| 912 | }) |
| 913 | } |
| 914 | /> |
| 915 | ) : null |
| 916 | } |
| 917 | control={ |
| 918 | <Select |
| 919 | value={settings.sidebarProjectSortOrder} |
| 920 | onValueChange={(value) => { |
| 921 | if (isSidebarProjectSortOrder(value)) { |
| 922 | updateSettings({ sidebarProjectSortOrder: value }); |
| 923 | } |
| 924 | }} |
| 925 | > |
| 926 | <SelectTrigger size="sm" className="w-full sm:w-44" aria-label={gt("Project order")}> |
| 927 | <SelectValue> |
| 928 | {m(SIDEBAR_PROJECT_SORT_ORDER_LABELS[settings.sidebarProjectSortOrder])} |
| 929 | </SelectValue> |
| 930 | </SelectTrigger> |
| 931 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 932 | {SidebarProjectSortOrder.literals.map((sortOrder) => ( |
| 933 | <SelectItem hideIndicator key={sortOrder} value={sortOrder}> |
| 934 | {m(SIDEBAR_PROJECT_SORT_ORDER_LABELS[sortOrder])} |
| 935 | </SelectItem> |
| 936 | ))} |
| 937 | </SelectPopup> |
| 938 | </Select> |
| 939 | } |
| 940 | /> |
| 941 | <SettingsRow |
| 942 | {...setting("working-shelf")} |
| 943 | description={ |
| 944 | <T> |
| 945 | Fold working and monitoring threads into a Working section. They return to the top of |
| 946 | the inbox when they need you. The boring sidebar in Labs has no Working section. |
| 947 | </T> |
| 948 | } |
| 949 | resetAction={ |
| 950 | settings.sidebarWorkingShelfEnabled !== |
| 951 | DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled ? ( |
| 952 | <SettingResetButton |
| 953 | ariaLabel={gt("Reset working section to default")} |
| 954 | onClick={() => |
| 955 | updateSettings({ |
| 956 | sidebarWorkingShelfEnabled: DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled, |
| 957 | }) |
| 958 | } |
| 959 | /> |
| 960 | ) : null |
| 961 | } |
| 962 | control={ |
| 963 | <Switch |
| 964 | checked={settings.sidebarWorkingShelfEnabled} |
| 965 | onCheckedChange={(checked) => |
| 966 | updateSettings({ sidebarWorkingShelfEnabled: Boolean(checked) }) |
| 967 | } |
| 968 | aria-label={gt("Working section")} |
| 969 | /> |
| 970 | } |
| 971 | /> |
| 972 | </SettingsSection> |
| 973 | |
| 974 | <SettingsSection id="confirmations" title={gt("Confirmations")}> |
| 975 | <SettingsRow |
| 976 | {...setting("unpin-confirmation")} |
| 977 | description={<T>Ask before unpinning a thread from the pinned section.</T>} |
| 978 | resetAction={ |
| 979 | settings.confirmThreadUnpin !== DEFAULT_UNIFIED_SETTINGS.confirmThreadUnpin ? ( |
| 980 | <SettingResetButton |
| 981 | ariaLabel={gt("Reset unpin confirmation to default")} |
| 982 | onClick={() => |
| 983 | updateSettings({ |
| 984 | confirmThreadUnpin: DEFAULT_UNIFIED_SETTINGS.confirmThreadUnpin, |
| 985 | }) |
| 986 | } |
| 987 | /> |
| 988 | ) : null |
| 989 | } |
| 990 | control={ |
| 991 | <Switch |
| 992 | checked={settings.confirmThreadUnpin} |
| 993 | onCheckedChange={(checked) => |
| 994 | updateSettings({ confirmThreadUnpin: Boolean(checked) }) |
| 995 | } |
| 996 | aria-label={gt("Confirm thread unpinning")} |
| 997 | /> |
| 998 | } |
| 999 | /> |
| 1000 | <SettingsRow |
| 1001 | {...setting("archive-confirmation")} |
| 1002 | description={ |
| 1003 | <T>Require a second click on the inline archive action before a thread is archived.</T> |
| 1004 | } |
| 1005 | resetAction={ |
| 1006 | settings.confirmThreadArchive !== DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive ? ( |
| 1007 | <SettingResetButton |
| 1008 | ariaLabel={gt("Reset archive confirmation to default")} |
| 1009 | onClick={() => |
| 1010 | updateSettings({ |
| 1011 | confirmThreadArchive: DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive, |
| 1012 | }) |
| 1013 | } |
| 1014 | /> |
| 1015 | ) : null |
| 1016 | } |
| 1017 | control={ |
| 1018 | <Switch |
| 1019 | checked={settings.confirmThreadArchive} |
| 1020 | onCheckedChange={(checked) => |
| 1021 | updateSettings({ confirmThreadArchive: Boolean(checked) }) |
| 1022 | } |
| 1023 | aria-label={gt("Confirm thread archiving")} |
| 1024 | /> |
| 1025 | } |
| 1026 | /> |
| 1027 | <SettingsRow |
| 1028 | {...setting("delete-confirmation")} |
| 1029 | description={<T>Ask before deleting a thread and its chat history.</T>} |
| 1030 | resetAction={ |
| 1031 | settings.confirmThreadDelete !== DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete ? ( |
| 1032 | <SettingResetButton |
| 1033 | ariaLabel={gt("Reset delete confirmation to default")} |
| 1034 | onClick={() => |
| 1035 | updateSettings({ |
| 1036 | confirmThreadDelete: DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete, |
| 1037 | }) |
| 1038 | } |
| 1039 | /> |
| 1040 | ) : null |
| 1041 | } |
| 1042 | control={ |
| 1043 | <Switch |
| 1044 | checked={settings.confirmThreadDelete} |
| 1045 | onCheckedChange={(checked) => |
| 1046 | updateSettings({ confirmThreadDelete: Boolean(checked) }) |
| 1047 | } |
| 1048 | aria-label={gt("Confirm thread deletion")} |
| 1049 | /> |
| 1050 | } |
| 1051 | /> |
| 1052 | <SettingsRow |
| 1053 | {...setting("terminal-close-confirmation")} |
| 1054 | description={<T>Ask before closing terminals and stopping their running processes.</T>} |
| 1055 | resetAction={ |
| 1056 | settings.confirmTerminalClose !== DEFAULT_UNIFIED_SETTINGS.confirmTerminalClose ? ( |
| 1057 | <SettingResetButton |
| 1058 | ariaLabel={gt("Reset terminal close confirmation to default")} |
| 1059 | onClick={() => |
| 1060 | updateSettings({ |
| 1061 | confirmTerminalClose: DEFAULT_UNIFIED_SETTINGS.confirmTerminalClose, |
| 1062 | }) |
| 1063 | } |
| 1064 | /> |
| 1065 | ) : null |
| 1066 | } |
| 1067 | control={ |
| 1068 | <Switch |
| 1069 | checked={settings.confirmTerminalClose} |
| 1070 | onCheckedChange={(checked) => |
| 1071 | updateSettings({ confirmTerminalClose: Boolean(checked) }) |
| 1072 | } |
| 1073 | aria-label={gt("Confirm terminal closing")} |
| 1074 | /> |
| 1075 | } |
| 1076 | /> |
| 1077 | {isElectron ? ( |
| 1078 | <SettingsRow |
| 1079 | {...setting("quit-confirmation")} |
| 1080 | description={<T>Hold mode also quits on two quick presses.</T>} |
| 1081 | resetAction={ |
| 1082 | settings.confirmQuit !== DEFAULT_UNIFIED_SETTINGS.confirmQuit ? ( |
| 1083 | <SettingResetButton |
| 1084 | ariaLabel={gt("Reset quit shortcut behavior to default")} |
| 1085 | onClick={() => |
| 1086 | updateSettings({ confirmQuit: DEFAULT_UNIFIED_SETTINGS.confirmQuit }) |
| 1087 | } |
| 1088 | /> |
| 1089 | ) : null |
| 1090 | } |
| 1091 | control={ |
| 1092 | <Select |
| 1093 | value={settings.confirmQuit} |
| 1094 | onValueChange={(value) => { |
| 1095 | if (value === "direct" || value === "hold" || value === "double-click") { |
| 1096 | updateSettings({ confirmQuit: value }); |
| 1097 | } |
| 1098 | }} |
| 1099 | > |
| 1100 | <SelectTrigger |
| 1101 | size="sm" |
| 1102 | className="w-full sm:w-40" |
| 1103 | aria-label={gt("Quit shortcut behavior")} |
| 1104 | > |
| 1105 | <SelectValue> |
| 1106 | {m(QUIT_CONFIRMATION_MODE_LABELS[settings.confirmQuit])} |
| 1107 | </SelectValue> |
| 1108 | </SelectTrigger> |
| 1109 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1110 | {Object.entries(QUIT_CONFIRMATION_MODE_LABELS).map(([value, label]) => ( |
| 1111 | <SelectItem hideIndicator key={value} value={value}> |
| 1112 | {m(label)} |
| 1113 | </SelectItem> |
| 1114 | ))} |
| 1115 | </SelectPopup> |
| 1116 | </Select> |
| 1117 | } |
| 1118 | /> |
| 1119 | ) : null} |
| 1120 | </SettingsSection> |
| 1121 | |
| 1122 | <SettingsSection id="display" title={gt("Display")}> |
| 1123 | <SettingsRow |
| 1124 | {...setting("language")} |
| 1125 | description={<T>System default follows your browser or OS language.</T>} |
| 1126 | resetAction={ |
| 1127 | settings.language !== DEFAULT_UNIFIED_SETTINGS.language ? ( |
| 1128 | <SettingResetButton |
| 1129 | ariaLabel={gt("Reset language to default")} |
| 1130 | onClick={() => |
| 1131 | updateSettings({ |
| 1132 | language: DEFAULT_UNIFIED_SETTINGS.language, |
| 1133 | }) |
| 1134 | } |
| 1135 | /> |
| 1136 | ) : null |
| 1137 | } |
| 1138 | control={ |
| 1139 | <Select |
| 1140 | value={languageValue} |
| 1141 | onValueChange={(value) => { |
| 1142 | if (value) { |
| 1143 | updateSettings({ language: value }); |
| 1144 | } |
| 1145 | }} |
| 1146 | > |
| 1147 | <SelectTrigger size="sm" className="w-full sm:w-40" aria-label={gt("Language")}> |
| 1148 | <SelectValue> |
| 1149 | {languageValue === SYSTEM_LANGUAGE |
| 1150 | ? m(TIMESTAMP_FORMAT_LABELS.locale) |
| 1151 | : nativeLanguageName(languageValue)} |
| 1152 | </SelectValue> |
| 1153 | </SelectTrigger> |
| 1154 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1155 | <SelectItem hideIndicator value={SYSTEM_LANGUAGE}> |
| 1156 | {m(TIMESTAMP_FORMAT_LABELS.locale)} |
| 1157 | </SelectItem> |
| 1158 | {SUPPORTED_LOCALES.map((locale) => ( |
| 1159 | <SelectItem hideIndicator key={locale} value={locale}> |
| 1160 | {nativeLanguageName(locale)} |
| 1161 | </SelectItem> |
| 1162 | ))} |
| 1163 | </SelectPopup> |
| 1164 | </Select> |
| 1165 | } |
| 1166 | /> |
| 1167 | <SettingsRow |
| 1168 | {...setting("time-format")} |
| 1169 | description={<T>System default follows your browser or OS clock preference.</T>} |
| 1170 | resetAction={ |
| 1171 | settings.timestampFormat !== DEFAULT_UNIFIED_SETTINGS.timestampFormat ? ( |
| 1172 | <SettingResetButton |
| 1173 | ariaLabel={gt("Reset time format to default")} |
| 1174 | onClick={() => |
| 1175 | updateSettings({ |
| 1176 | timestampFormat: DEFAULT_UNIFIED_SETTINGS.timestampFormat, |
| 1177 | }) |
| 1178 | } |
| 1179 | /> |
| 1180 | ) : null |
| 1181 | } |
| 1182 | control={ |
| 1183 | <Select |
| 1184 | value={settings.timestampFormat} |
| 1185 | onValueChange={(value) => { |
| 1186 | if (value === "locale" || value === "12-hour" || value === "24-hour") { |
| 1187 | updateSettings({ timestampFormat: value }); |
| 1188 | } |
| 1189 | }} |
| 1190 | > |
| 1191 | <SelectTrigger |
| 1192 | size="sm" |
| 1193 | className="w-full sm:w-40" |
| 1194 | aria-label={gt("Timestamp format")} |
| 1195 | > |
| 1196 | <SelectValue>{m(TIMESTAMP_FORMAT_LABELS[settings.timestampFormat])}</SelectValue> |
| 1197 | </SelectTrigger> |
| 1198 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1199 | <SelectItem hideIndicator value="locale"> |
| 1200 | {m(TIMESTAMP_FORMAT_LABELS.locale)} |
| 1201 | </SelectItem> |
| 1202 | <SelectItem hideIndicator value="12-hour"> |
| 1203 | {m(TIMESTAMP_FORMAT_LABELS["12-hour"])} |
| 1204 | </SelectItem> |
| 1205 | <SelectItem hideIndicator value="24-hour"> |
| 1206 | {m(TIMESTAMP_FORMAT_LABELS["24-hour"])} |
| 1207 | </SelectItem> |
| 1208 | </SelectPopup> |
| 1209 | </Select> |
| 1210 | } |
| 1211 | /> |
| 1212 | </SettingsSection> |
| 1213 | </SettingsPageContainer> |
| 1214 | ); |
| 1215 | } |
| 1216 | |
| 1217 | export function ChatSettingsPanel() { |
| 1218 | const setting = useSearchableSetting(); |
| 1219 | const gt = useGT(); |
| 1220 | const modifierLabel = isMacPlatform(navigator.platform) ? "⌘" : "Ctrl"; |
| 1221 | const sendShortcutOptions = [ |
| 1222 | { value: "enter", label: "Enter" }, |
| 1223 | { |
| 1224 | value: "mod-enter-multiline", |
| 1225 | label: gt("{modifierLabel} + Enter for multiline prompts", { modifierLabel }), |
| 1226 | }, |
| 1227 | { value: "mod-enter", label: gt("{modifierLabel} + Enter always", { modifierLabel }) }, |
| 1228 | ] as const; |
| 1229 | const settings = useScopedSettings(); |
| 1230 | const updateSettings = useUpdateScopedSettings(); |
| 1231 | |
| 1232 | return ( |
| 1233 | <SettingsPageContainer> |
| 1234 | <SettingsSection id="composer" title={gt("Composer")}> |
| 1235 | <SettingsRow |
| 1236 | {...setting("composer-rich-text")} |
| 1237 | description={gt("Show formatted Markdown as you type.")} |
| 1238 | resetAction={ |
| 1239 | settings.composerRichTextEnabled !== |
| 1240 | DEFAULT_UNIFIED_SETTINGS.composerRichTextEnabled ? ( |
| 1241 | <SettingResetButton |
| 1242 | ariaLabel={gt("Reset rich text composer to default")} |
| 1243 | onClick={() => |
| 1244 | updateSettings({ |
| 1245 | composerRichTextEnabled: DEFAULT_UNIFIED_SETTINGS.composerRichTextEnabled, |
| 1246 | }) |
| 1247 | } |
| 1248 | /> |
| 1249 | ) : null |
| 1250 | } |
| 1251 | control={ |
| 1252 | <Switch |
| 1253 | checked={settings.composerRichTextEnabled} |
| 1254 | onCheckedChange={(checked) => |
| 1255 | updateSettings({ composerRichTextEnabled: Boolean(checked) }) |
| 1256 | } |
| 1257 | aria-label={gt("Rich text composer")} |
| 1258 | /> |
| 1259 | } |
| 1260 | /> |
| 1261 | <SettingsRow |
| 1262 | {...setting("send-shortcut")} |
| 1263 | description={gt("Choose when Enter sends a prompt or inserts a new line")} |
| 1264 | resetAction={ |
| 1265 | settings.sendShortcut !== DEFAULT_UNIFIED_SETTINGS.sendShortcut ? ( |
| 1266 | <SettingResetButton |
| 1267 | ariaLabel={gt("Reset send shortcut to default")} |
| 1268 | onClick={() => |
| 1269 | updateSettings({ sendShortcut: DEFAULT_UNIFIED_SETTINGS.sendShortcut }) |
| 1270 | } |
| 1271 | /> |
| 1272 | ) : null |
| 1273 | } |
| 1274 | control={ |
| 1275 | <Select |
| 1276 | value={settings.sendShortcut} |
| 1277 | onValueChange={(value) => { |
| 1278 | const option = sendShortcutOptions.find((option) => option.value === value); |
| 1279 | if (option) updateSettings({ sendShortcut: option.value }); |
| 1280 | }} |
| 1281 | > |
| 1282 | <SelectTrigger |
| 1283 | size="sm" |
| 1284 | className="w-auto min-w-0 max-w-full" |
| 1285 | aria-label={gt("Send shortcut")} |
| 1286 | > |
| 1287 | <SelectValue> |
| 1288 | { |
| 1289 | sendShortcutOptions.find((option) => option.value === settings.sendShortcut) |
| 1290 | ?.label |
| 1291 | } |
| 1292 | </SelectValue> |
| 1293 | </SelectTrigger> |
| 1294 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1295 | {sendShortcutOptions.map((option) => ( |
| 1296 | <SelectItem key={option.value} value={option.value}> |
| 1297 | <span className="flex items-center justify-between gap-4"> |
| 1298 | {option.label} |
| 1299 | {settings.sendShortcut === option.value && <CheckIcon aria-hidden="true" />} |
| 1300 | </span> |
| 1301 | </SelectItem> |
| 1302 | ))} |
| 1303 | </SelectPopup> |
| 1304 | </Select> |
| 1305 | } |
| 1306 | /> |
| 1307 | <AdvancedSettings targetIds={[setting("skills-in-slash-menu").id]}> |
| 1308 | <SettingsRow |
| 1309 | {...setting("skills-in-slash-menu")} |
| 1310 | description={gt( |
| 1311 | "Also include skills in the / command menu. Skills always appear when you type $.", |
| 1312 | )} |
| 1313 | resetAction={ |
| 1314 | settings.showSkillsInSlashMenu !== DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu ? ( |
| 1315 | <SettingResetButton |
| 1316 | ariaLabel={gt("Reset skills in slash menu to default")} |
| 1317 | onClick={() => |
| 1318 | updateSettings({ |
| 1319 | showSkillsInSlashMenu: DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu, |
| 1320 | }) |
| 1321 | } |
| 1322 | /> |
| 1323 | ) : null |
| 1324 | } |
| 1325 | control={ |
| 1326 | <Switch |
| 1327 | checked={settings.showSkillsInSlashMenu} |
| 1328 | onCheckedChange={(checked) => |
| 1329 | updateSettings({ showSkillsInSlashMenu: Boolean(checked) }) |
| 1330 | } |
| 1331 | aria-label={gt("Show skills in slash menu")} |
| 1332 | /> |
| 1333 | } |
| 1334 | /> |
| 1335 | </AdvancedSettings> |
| 1336 | </SettingsSection> |
| 1337 | |
| 1338 | <SettingsSection id="follow-ups" title={gt("Follow-ups")}> |
| 1339 | <SettingsRow |
| 1340 | {...setting("follow-up-behavior")} |
| 1341 | description={ |
| 1342 | settings.sendShortcut === "mod-enter-multiline" |
| 1343 | ? gt( |
| 1344 | "Queue follow-ups while the agent runs or steer the current run. Press {modifier} + Enter for single-line prompts or {modifier} + Shift + Enter for multiline prompts to do the opposite for one message.", |
| 1345 | { modifier: modifierLabel }, |
| 1346 | ) |
| 1347 | : settings.sendShortcut === "mod-enter" |
| 1348 | ? gt( |
| 1349 | "Queue follow-ups while the agent runs or steer the current run. Press {modifier} + Shift + Enter to do the opposite for one message.", |
| 1350 | { modifier: modifierLabel }, |
| 1351 | ) |
| 1352 | : gt( |
| 1353 | "Queue follow-ups while the agent runs or steer the current run. Press {modifier} + Enter to do the opposite for one message.", |
| 1354 | { modifier: modifierLabel }, |
| 1355 | ) |
| 1356 | } |
| 1357 | resetAction={ |
| 1358 | settings.followUpBehavior !== DEFAULT_UNIFIED_SETTINGS.followUpBehavior ? ( |
| 1359 | <SettingResetButton |
| 1360 | ariaLabel={gt("Reset follow-up behavior to default")} |
| 1361 | onClick={() => |
| 1362 | updateSettings({ |
| 1363 | followUpBehavior: DEFAULT_UNIFIED_SETTINGS.followUpBehavior, |
| 1364 | }) |
| 1365 | } |
| 1366 | /> |
| 1367 | ) : null |
| 1368 | } |
| 1369 | control={ |
| 1370 | <Select |
| 1371 | value={settings.followUpBehavior} |
| 1372 | onValueChange={(value) => { |
| 1373 | if (value === "queue" || value === "steer") { |
| 1374 | updateSettings({ followUpBehavior: value }); |
| 1375 | } |
| 1376 | }} |
| 1377 | > |
| 1378 | <SelectTrigger |
| 1379 | size="sm" |
| 1380 | className="w-auto min-w-0" |
| 1381 | aria-label={gt("Follow-up behavior")} |
| 1382 | > |
| 1383 | <SelectValue> |
| 1384 | {settings.followUpBehavior === "queue" ? gt("Queue") : gt("Steer")} |
| 1385 | </SelectValue> |
| 1386 | </SelectTrigger> |
| 1387 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1388 | <SelectItem value="queue"> |
| 1389 | <T>Queue</T> |
| 1390 | </SelectItem> |
| 1391 | <SelectItem value="steer"> |
| 1392 | <T>Steer</T> |
| 1393 | </SelectItem> |
| 1394 | </SelectPopup> |
| 1395 | </Select> |
| 1396 | } |
| 1397 | /> |
| 1398 | </SettingsSection> |
| 1399 | |
| 1400 | <SettingsSection id="side-threads" title={gt("Subagents and side chats")}> |
| 1401 | <SettingsRow |
| 1402 | {...setting("side-thread-open-target")} |
| 1403 | description={ |
| 1404 | settings.sideThreadOpenTarget === "panel" |
| 1405 | ? gt( |
| 1406 | "Where a click opens a subagent, a side chat, or a thread on a linked environment. {modifier}-click or middle-click opens it in the main view instead.", |
| 1407 | { modifier: modifierLabel }, |
| 1408 | ) |
| 1409 | : gt( |
| 1410 | "Where a click opens a subagent, a side chat, or a thread on a linked environment. {modifier}-click or middle-click opens it in the side panel instead.", |
| 1411 | { modifier: modifierLabel }, |
| 1412 | ) |
| 1413 | } |
| 1414 | resetAction={ |
| 1415 | settings.sideThreadOpenTarget !== DEFAULT_UNIFIED_SETTINGS.sideThreadOpenTarget ? ( |
| 1416 | <SettingResetButton |
| 1417 | ariaLabel={gt("Reset where subagents and side chats open to default")} |
| 1418 | onClick={() => |
| 1419 | updateSettings({ |
| 1420 | sideThreadOpenTarget: DEFAULT_UNIFIED_SETTINGS.sideThreadOpenTarget, |
| 1421 | }) |
| 1422 | } |
| 1423 | /> |
| 1424 | ) : null |
| 1425 | } |
| 1426 | control={ |
| 1427 | <Select |
| 1428 | value={settings.sideThreadOpenTarget} |
| 1429 | onValueChange={(value) => { |
| 1430 | if (value === "panel" || value === "main") { |
| 1431 | updateSettings({ sideThreadOpenTarget: value }); |
| 1432 | } |
| 1433 | }} |
| 1434 | > |
| 1435 | <SelectTrigger |
| 1436 | size="sm" |
| 1437 | className="w-auto min-w-0" |
| 1438 | aria-label={gt("Open subagents and side chats in")} |
| 1439 | > |
| 1440 | <SelectValue> |
| 1441 | {settings.sideThreadOpenTarget === "panel" ? gt("Side panel") : gt("Main view")} |
| 1442 | </SelectValue> |
| 1443 | </SelectTrigger> |
| 1444 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1445 | <SelectItem value="panel"> |
| 1446 | <T>Side panel</T> |
| 1447 | </SelectItem> |
| 1448 | <SelectItem value="main"> |
| 1449 | <T>Main view</T> |
| 1450 | </SelectItem> |
| 1451 | </SelectPopup> |
| 1452 | </Select> |
| 1453 | } |
| 1454 | /> |
| 1455 | </SettingsSection> |
| 1456 | |
| 1457 | <SettingsSection id="activity" title={gt("Activity")}> |
| 1458 | <ToolCallVisibilityRow /> |
| 1459 | </SettingsSection> |
| 1460 | |
| 1461 | <SettingsSection id="screen-reader" title={gt("Screen reader")}> |
| 1462 | <ScreenReaderAnnouncementsRow /> |
| 1463 | <ScreenReaderWindowTitleRow /> |
| 1464 | </SettingsSection> |
| 1465 | </SettingsPageContainer> |
| 1466 | ); |
| 1467 | } |
| 1468 | |
| 1469 | const TOOL_CALL_VISIBILITY_LABELS: Record<ToolCallVisibility, string> = { |
| 1470 | showAll: msg("Show all"), |
| 1471 | hideSuccessful: msg("Hide successful"), |
| 1472 | hideAll: msg("Hide all"), |
| 1473 | zen: msg("Zen", { $context: "tool call visibility" }), |
| 1474 | }; |
| 1475 | |
| 1476 | const isToolCallVisibility = Schema.is(ToolCallVisibility); |
| 1477 | |
| 1478 | function ToolCallVisibilityRow() { |
| 1479 | const messages = useMessages(); |
| 1480 | const setting = useSearchableSetting(); |
| 1481 | const gt = useGT(); |
| 1482 | const settings = useScopedSettings(); |
| 1483 | const updateSettings = useUpdateScopedSettings(); |
| 1484 | return ( |
| 1485 | <SettingsRow |
| 1486 | {...setting("tool-call-visibility")} |
| 1487 | description={gt( |
| 1488 | "Hide the commands, edits, and searches agents run. Hide successful keeps failures. Zen shows only final answers. Approvals, questions, and errors always show.", |
| 1489 | )} |
| 1490 | resetAction={ |
| 1491 | settings.toolCallVisibility !== DEFAULT_UNIFIED_SETTINGS.toolCallVisibility ? ( |
| 1492 | <SettingResetButton |
| 1493 | ariaLabel={gt("Reset tool calls in chat to default")} |
| 1494 | onClick={() => |
| 1495 | updateSettings({ toolCallVisibility: DEFAULT_UNIFIED_SETTINGS.toolCallVisibility }) |
| 1496 | } |
| 1497 | /> |
| 1498 | ) : null |
| 1499 | } |
| 1500 | control={ |
| 1501 | <Select |
| 1502 | value={settings.toolCallVisibility} |
| 1503 | onValueChange={(value) => { |
| 1504 | if (isToolCallVisibility(value)) updateSettings({ toolCallVisibility: value }); |
| 1505 | }} |
| 1506 | > |
| 1507 | <SelectTrigger size="sm" className="w-full sm:w-40" aria-label={gt("Tool calls in chat")}> |
| 1508 | <SelectValue> |
| 1509 | {messages(TOOL_CALL_VISIBILITY_LABELS[settings.toolCallVisibility])} |
| 1510 | </SelectValue> |
| 1511 | </SelectTrigger> |
| 1512 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1513 | {ToolCallVisibility.literals.map((value) => ( |
| 1514 | <SelectItem key={value} value={value}> |
| 1515 | {messages(TOOL_CALL_VISIBILITY_LABELS[value])} |
| 1516 | </SelectItem> |
| 1517 | ))} |
| 1518 | </SelectPopup> |
| 1519 | </Select> |
| 1520 | } |
| 1521 | /> |
| 1522 | ); |
| 1523 | } |
| 1524 | |
| 1525 | const SCREEN_READER_ANNOUNCEMENTS_LABELS: Record<ScreenReaderAnnouncements, string> = { |
| 1526 | status: msg("Status only"), |
| 1527 | messages: msg("Status and messages"), |
| 1528 | everything: msg("Everything"), |
| 1529 | }; |
| 1530 | |
| 1531 | const isScreenReaderAnnouncements = Schema.is(ScreenReaderAnnouncements); |
| 1532 | |
| 1533 | function ScreenReaderAnnouncementsRow() { |
| 1534 | const messages = useMessages(); |
| 1535 | const setting = useSearchableSetting(); |
| 1536 | const gt = useGT(); |
| 1537 | const settings = useScopedSettings(); |
| 1538 | const updateSettings = useUpdateScopedSettings(); |
| 1539 | return ( |
| 1540 | <SettingsRow |
| 1541 | {...setting("screen-reader-announcements")} |
| 1542 | description={gt( |
| 1543 | "What a screen reader hears from the open thread: a turn starting, needing you, and ending. Status and messages adds what the agent writes before its last message. Everything adds each step.", |
| 1544 | )} |
| 1545 | resetAction={ |
| 1546 | settings.screenReaderAnnouncements !== |
| 1547 | DEFAULT_UNIFIED_SETTINGS.screenReaderAnnouncements ? ( |
| 1548 | <SettingResetButton |
| 1549 | ariaLabel={gt("Reset screen reader announcements to default")} |
| 1550 | onClick={() => |
| 1551 | updateSettings({ |
| 1552 | screenReaderAnnouncements: DEFAULT_UNIFIED_SETTINGS.screenReaderAnnouncements, |
| 1553 | }) |
| 1554 | } |
| 1555 | /> |
| 1556 | ) : null |
| 1557 | } |
| 1558 | control={ |
| 1559 | <Select |
| 1560 | value={settings.screenReaderAnnouncements} |
| 1561 | onValueChange={(value) => { |
| 1562 | if (isScreenReaderAnnouncements(value)) { |
| 1563 | updateSettings({ screenReaderAnnouncements: value }); |
| 1564 | } |
| 1565 | }} |
| 1566 | > |
| 1567 | <SelectTrigger |
| 1568 | size="sm" |
| 1569 | className="w-full sm:w-48" |
| 1570 | aria-label={gt("Screen reader announcements")} |
| 1571 | > |
| 1572 | <SelectValue> |
| 1573 | {messages(SCREEN_READER_ANNOUNCEMENTS_LABELS[settings.screenReaderAnnouncements])} |
| 1574 | </SelectValue> |
| 1575 | </SelectTrigger> |
| 1576 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1577 | {ScreenReaderAnnouncements.literals.map((value) => ( |
| 1578 | <SelectItem key={value} value={value}> |
| 1579 | {messages(SCREEN_READER_ANNOUNCEMENTS_LABELS[value])} |
| 1580 | </SelectItem> |
| 1581 | ))} |
| 1582 | </SelectPopup> |
| 1583 | </Select> |
| 1584 | } |
| 1585 | /> |
| 1586 | ); |
| 1587 | } |
| 1588 | |
| 1589 | function ScreenReaderWindowTitleRow() { |
| 1590 | const setting = useSearchableSetting(); |
| 1591 | const gt = useGT(); |
| 1592 | const settings = useScopedSettings(); |
| 1593 | const updateSettings = useUpdateScopedSettings(); |
| 1594 | return ( |
| 1595 | <SettingsRow |
| 1596 | {...setting("screen-reader-window-title")} |
| 1597 | description={gt( |
| 1598 | "Start the window title with the thread's status, like Needs approval, and its name, so screen readers read them first when you switch apps. Taskbars, shared screens, and time trackers see it too.", |
| 1599 | )} |
| 1600 | resetAction={ |
| 1601 | settings.screenReaderWindowTitle !== DEFAULT_UNIFIED_SETTINGS.screenReaderWindowTitle ? ( |
| 1602 | <SettingResetButton |
| 1603 | ariaLabel={gt("Reset screen reader window title to default")} |
| 1604 | onClick={() => |
| 1605 | updateSettings({ |
| 1606 | screenReaderWindowTitle: DEFAULT_UNIFIED_SETTINGS.screenReaderWindowTitle, |
| 1607 | }) |
| 1608 | } |
| 1609 | /> |
| 1610 | ) : null |
| 1611 | } |
| 1612 | control={ |
| 1613 | <Switch |
| 1614 | checked={settings.screenReaderWindowTitle} |
| 1615 | onCheckedChange={(checked) => updateSettings({ screenReaderWindowTitle: checked })} |
| 1616 | aria-label={gt("Screen reader window title")} |
| 1617 | /> |
| 1618 | } |
| 1619 | /> |
| 1620 | ); |
| 1621 | } |
| 1622 | |
| 1623 | function DiffColorsSettingsRow() { |
| 1624 | const setting = useSearchableSetting(); |
| 1625 | const gt = useGT(); |
| 1626 | const settings = useScopedSettings(); |
| 1627 | const updateSettings = useUpdateScopedSettings(); |
| 1628 | return ( |
| 1629 | <SettingsRow |
| 1630 | {...setting("diff-color-scheme")} |
| 1631 | description={gt("Choose colors for additions and deletions, including change counts.")} |
| 1632 | resetAction={ |
| 1633 | settings.diffColorScheme !== DEFAULT_UNIFIED_SETTINGS.diffColorScheme ? ( |
| 1634 | <SettingResetButton |
| 1635 | ariaLabel={gt("Reset diff colors to default")} |
| 1636 | onClick={() => |
| 1637 | updateSettings({ diffColorScheme: DEFAULT_UNIFIED_SETTINGS.diffColorScheme }) |
| 1638 | } |
| 1639 | /> |
| 1640 | ) : null |
| 1641 | } |
| 1642 | control={ |
| 1643 | <div className="w-full sm:w-40"> |
| 1644 | <Select |
| 1645 | value={settings.diffColorScheme} |
| 1646 | onValueChange={(value) => { |
| 1647 | if (value === "red-green" || value === "blue-orange") |
| 1648 | updateSettings({ diffColorScheme: value }); |
| 1649 | }} |
| 1650 | > |
| 1651 | <SelectTrigger size="sm" className="w-full min-w-0" aria-label={gt("Diff colors")}> |
| 1652 | <span |
| 1653 | aria-hidden="true" |
| 1654 | className={ |
| 1655 | settings.diffColorScheme === "blue-orange" |
| 1656 | ? "flex shrink-0 flex-row-reverse gap-1" |
| 1657 | : "flex shrink-0 gap-1" |
| 1658 | } |
| 1659 | > |
| 1660 | <span className="size-2 rounded-full bg-diff-deletion" /> |
| 1661 | <span className="size-2 rounded-full bg-diff-addition" /> |
| 1662 | </span> |
| 1663 | <SelectValue> |
| 1664 | {settings.diffColorScheme === "blue-orange" |
| 1665 | ? gt("Blue & orange") |
| 1666 | : gt("Red & green")} |
| 1667 | </SelectValue> |
| 1668 | </SelectTrigger> |
| 1669 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1670 | <SelectItem value="red-green"> |
| 1671 | <T>Red & green (default)</T> |
| 1672 | </SelectItem> |
| 1673 | <SelectItem value="blue-orange"> |
| 1674 | <T>Blue & orange</T> |
| 1675 | </SelectItem> |
| 1676 | </SelectPopup> |
| 1677 | </Select> |
| 1678 | </div> |
| 1679 | } |
| 1680 | /> |
| 1681 | ); |
| 1682 | } |
| 1683 | |
| 1684 | export function DiffsSettingsPanel() { |
| 1685 | const messages = useMessages(); |
| 1686 | const setting = useSearchableSetting(); |
| 1687 | const gt = useGT(); |
| 1688 | const settings = useScopedSettings(); |
| 1689 | const updateSettings = useUpdateScopedSettings(); |
| 1690 | |
| 1691 | return ( |
| 1692 | <SettingsPageContainer> |
| 1693 | <SettingsSection id="diffs" title={gt("Diffs")}> |
| 1694 | <SettingsRow |
| 1695 | {...setting("diff-layout")} |
| 1696 | description={gt( |
| 1697 | "Show diffs stacked or side by side. The toggle in the diff toolbar changes this too.", |
| 1698 | )} |
| 1699 | resetAction={ |
| 1700 | settings.diffLayout !== DEFAULT_UNIFIED_SETTINGS.diffLayout ? ( |
| 1701 | <SettingResetButton |
| 1702 | ariaLabel={gt("Reset diff layout to default")} |
| 1703 | onClick={() => updateSettings({ diffLayout: DEFAULT_UNIFIED_SETTINGS.diffLayout })} |
| 1704 | /> |
| 1705 | ) : null |
| 1706 | } |
| 1707 | control={ |
| 1708 | <Select |
| 1709 | value={settings.diffLayout} |
| 1710 | onValueChange={(value) => { |
| 1711 | if (value === "stacked" || value === "split") { |
| 1712 | updateSettings({ diffLayout: value }); |
| 1713 | } |
| 1714 | }} |
| 1715 | > |
| 1716 | <SelectTrigger size="sm" className="w-full sm:w-40" aria-label={gt("Diff layout")}> |
| 1717 | <SelectValue>{messages(DIFF_LAYOUT_LABELS[settings.diffLayout])}</SelectValue> |
| 1718 | </SelectTrigger> |
| 1719 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1720 | <SelectItem hideIndicator value="stacked"> |
| 1721 | {messages(DIFF_LAYOUT_LABELS.stacked)} |
| 1722 | </SelectItem> |
| 1723 | <SelectItem hideIndicator value="split"> |
| 1724 | {messages(DIFF_LAYOUT_LABELS.split)} |
| 1725 | </SelectItem> |
| 1726 | </SelectPopup> |
| 1727 | </Select> |
| 1728 | } |
| 1729 | /> |
| 1730 | <SettingsRow |
| 1731 | {...setting("hide-whitespace-changes")} |
| 1732 | description={gt("Set whether the diff panel ignores whitespace-only edits by default.")} |
| 1733 | resetAction={ |
| 1734 | settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace ? ( |
| 1735 | <SettingResetButton |
| 1736 | ariaLabel={gt("Reset diff whitespace changes to default")} |
| 1737 | onClick={() => |
| 1738 | updateSettings({ |
| 1739 | diffIgnoreWhitespace: DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace, |
| 1740 | }) |
| 1741 | } |
| 1742 | /> |
| 1743 | ) : null |
| 1744 | } |
| 1745 | control={ |
| 1746 | <Switch |
| 1747 | checked={settings.diffIgnoreWhitespace} |
| 1748 | onCheckedChange={(checked) => |
| 1749 | updateSettings({ diffIgnoreWhitespace: Boolean(checked) }) |
| 1750 | } |
| 1751 | aria-label={gt("Hide whitespace changes by default")} |
| 1752 | /> |
| 1753 | } |
| 1754 | /> |
| 1755 | <SettingsRow |
| 1756 | {...setting("default-diff-file-state")} |
| 1757 | description={gt( |
| 1758 | "Start with files expanded or collapsed when opening diffs or a pull request's Code tab.", |
| 1759 | )} |
| 1760 | resetAction={ |
| 1761 | settings.diffFilesCollapsed !== DEFAULT_UNIFIED_SETTINGS.diffFilesCollapsed ? ( |
| 1762 | <SettingResetButton |
| 1763 | ariaLabel={gt("Reset default diff file state to default")} |
| 1764 | onClick={() => |
| 1765 | updateSettings({ |
| 1766 | diffFilesCollapsed: DEFAULT_UNIFIED_SETTINGS.diffFilesCollapsed, |
| 1767 | }) |
| 1768 | } |
| 1769 | /> |
| 1770 | ) : null |
| 1771 | } |
| 1772 | control={ |
| 1773 | <Select |
| 1774 | value={settings.diffFilesCollapsed ? "collapsed" : "expanded"} |
| 1775 | onValueChange={(value) => { |
| 1776 | if (value === "expanded" || value === "collapsed") { |
| 1777 | updateSettings({ diffFilesCollapsed: value === "collapsed" }); |
| 1778 | } |
| 1779 | }} |
| 1780 | > |
| 1781 | <SelectTrigger |
| 1782 | size="sm" |
| 1783 | className="w-full sm:w-40" |
| 1784 | aria-label={gt("Default diff file state")} |
| 1785 | > |
| 1786 | <SelectValue> |
| 1787 | {settings.diffFilesCollapsed ? gt("Collapsed") : gt("Expanded")} |
| 1788 | </SelectValue> |
| 1789 | </SelectTrigger> |
| 1790 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1791 | <SelectItem hideIndicator value="expanded"> |
| 1792 | <T>Expanded</T> |
| 1793 | </SelectItem> |
| 1794 | <SelectItem hideIndicator value="collapsed"> |
| 1795 | <T>Collapsed</T> |
| 1796 | </SelectItem> |
| 1797 | </SelectPopup> |
| 1798 | </Select> |
| 1799 | } |
| 1800 | /> |
| 1801 | <DiffColorsSettingsRow /> |
| 1802 | </SettingsSection> |
| 1803 | |
| 1804 | <SettingsSection id="pull-requests" title={gt("Pull requests")}> |
| 1805 | <SettingsRow |
| 1806 | {...setting("proactive-panels")} |
| 1807 | description={gt( |
| 1808 | "Open linked pull requests first. Otherwise, open Changes for edits to at least 3 files or 50 lines.", |
| 1809 | )} |
| 1810 | resetAction={ |
| 1811 | settings.proactivePanelsEnabled !== DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled ? ( |
| 1812 | <SettingResetButton |
| 1813 | ariaLabel={gt("Reset proactive panels to default")} |
| 1814 | onClick={() => |
| 1815 | updateSettings({ |
| 1816 | proactivePanelsEnabled: DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled, |
| 1817 | }) |
| 1818 | } |
| 1819 | /> |
| 1820 | ) : null |
| 1821 | } |
| 1822 | control={ |
| 1823 | <Switch |
| 1824 | checked={settings.proactivePanelsEnabled} |
| 1825 | onCheckedChange={(checked) => |
| 1826 | updateSettings({ proactivePanelsEnabled: Boolean(checked) }) |
| 1827 | } |
| 1828 | aria-label={gt("Open pull requests and changes panels proactively")} |
| 1829 | /> |
| 1830 | } |
| 1831 | /> |
| 1832 | <PullRequestLinksOpenInAppSetting /> |
| 1833 | </SettingsSection> |
| 1834 | </SettingsPageContainer> |
| 1835 | ); |
| 1836 | } |
| 1837 | |
| 1838 | /** The Providers panel can render without a settings scope, as its tests do; this row needs one. */ |
| 1839 | export function CompactIdleThreadsRow() { |
| 1840 | return useOptionalSettingsScope() === null ? null : <ScopedCompactIdleThreadsRow />; |
| 1841 | } |
| 1842 | |
| 1843 | const IDLE_COMPACTION_MODE_LABELS: Record<IdleCompactionMode, string> = { |
| 1844 | onReturn: msg("When you return"), |
| 1845 | beforeCacheExpires: msg("Before the cache expires (beta)"), |
| 1846 | off: msg("Never", { $context: "idle thread compaction mode" }), |
| 1847 | }; |
| 1848 | |
| 1849 | function ScopedCompactIdleThreadsRow() { |
| 1850 | const setting = useSearchableSetting(); |
| 1851 | const gt = useGT(); |
| 1852 | const messages = useMessages(); |
| 1853 | const settings = useScopedSettings(); |
| 1854 | const updateSettings = useUpdateScopedSettings(); |
| 1855 | const { targets } = useSettingsScope(); |
| 1856 | const idleCompaction = scopedIdleCompaction(targets.length > 0 ? targets : [{ settings }]); |
| 1857 | |
| 1858 | return ( |
| 1859 | <SettingsRow |
| 1860 | serverScoped |
| 1861 | settingKeys={["idleCompaction", "compactIdleThreads"]} |
| 1862 | mixed={idleCompaction.mixed} |
| 1863 | {...setting("compact-idle-threads")} |
| 1864 | description={gt( |
| 1865 | "When to compact an idle Claude thread over 200,000 tokens: after you return, just before its prompt cache expires, or never. Each Claude provider can override this.", |
| 1866 | )} |
| 1867 | resetAction={ |
| 1868 | globalIdleCompaction(settings) !== globalIdleCompaction(DEFAULT_UNIFIED_SETTINGS) ? ( |
| 1869 | <SettingResetButton |
| 1870 | ariaLabel={gt("Reset compact idle threads to default")} |
| 1871 | onClick={() => |
| 1872 | updateSettings({ idleCompaction: globalIdleCompaction(DEFAULT_UNIFIED_SETTINGS) }) |
| 1873 | } |
| 1874 | /> |
| 1875 | ) : null |
| 1876 | } |
| 1877 | control={ |
| 1878 | <Select |
| 1879 | value={idleCompaction.mixed ? null : globalIdleCompaction(settings)} |
| 1880 | onValueChange={(value) => { |
| 1881 | const mode = IDLE_COMPACTION_MODES.find((candidate) => candidate.value === value); |
| 1882 | if (mode) updateSettings({ idleCompaction: mode.value }); |
| 1883 | }} |
| 1884 | > |
| 1885 | <SelectTrigger |
| 1886 | size="sm" |
| 1887 | className="w-full sm:w-56" |
| 1888 | aria-label={gt("Compact idle threads")} |
| 1889 | > |
| 1890 | <SelectValue> |
| 1891 | {(value: string | null) => |
| 1892 | value === null |
| 1893 | ? gt("Mixed") |
| 1894 | : IDLE_COMPACTION_MODES.some((mode) => mode.value === value) |
| 1895 | ? messages(IDLE_COMPACTION_MODE_LABELS[value as IdleCompactionMode]) |
| 1896 | : undefined |
| 1897 | } |
| 1898 | </SelectValue> |
| 1899 | </SelectTrigger> |
| 1900 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 1901 | {IDLE_COMPACTION_MODES.map((mode) => ( |
| 1902 | <SelectItem |
| 1903 | hideIndicator |
| 1904 | key={mode.value} |
| 1905 | value={mode.value} |
| 1906 | // A server from before modes has only the on/off switch, so it cannot store "Never". |
| 1907 | disabled={mode.value === "off" && !idleCompaction.neverAvailable} |
| 1908 | > |
| 1909 | {messages(IDLE_COMPACTION_MODE_LABELS[mode.value])} |
| 1910 | </SelectItem> |
| 1911 | ))} |
| 1912 | </SelectPopup> |
| 1913 | </Select> |
| 1914 | } |
| 1915 | /> |
| 1916 | ); |
| 1917 | } |
| 1918 | |
| 1919 | export function ThreadsSettingsPanel() { |
| 1920 | const setting = useSearchableSetting(); |
| 1921 | const messages = useMessages(); |
| 1922 | const gt = useGT(); |
| 1923 | const settings = useScopedSettings(); |
| 1924 | const updateSettings = useUpdateScopedSettings(); |
| 1925 | const navigate = useNavigate(); |
| 1926 | const { environment, connectedEnvironments, target, scope } = useSettingsScope(); |
| 1927 | const isProjectScope = scope.kind === "project" || scope.kind === "checkout"; |
| 1928 | const environmentId = environment?.environmentId ?? null; |
| 1929 | const hasServerTargets = connectedEnvironments.length > 0; |
| 1930 | const mixedResponseStreamingMode = useScopedSettingsMixed(["responseStreamingMode"]); |
| 1931 | const providersByEnvironment = useEnvironmentProviders(); |
| 1932 | const serverProviders = |
| 1933 | (environment?.serverConfig |
| 1934 | ? providersByEnvironment.get(environment.environmentId) |
| 1935 | : undefined) ?? EMPTY_SERVER_PROVIDERS; |
| 1936 | const supportsAutoSettlementScope = connectedEnvironments.every( |
| 1937 | (target) => target.serverConfig?.environment.capabilities.threadAutoSettlementScope === true, |
| 1938 | ); |
| 1939 | |
| 1940 | const textGenerationTargets = useTextGenerationTargets({ |
| 1941 | environmentId, |
| 1942 | settings, |
| 1943 | providers: serverProviders.filter((provider) => provider.supportsTextGeneration !== false), |
| 1944 | projectId: target?.projectId ?? null, |
| 1945 | selections: [settings.textGenerationModelSelection], |
| 1946 | }); |
| 1947 | const textGenerationProviders = textGenerationTargets.providers; |
| 1948 | const textGenerationModelSelection = resolveAppModelSelectionState( |
| 1949 | settings, |
| 1950 | textGenerationProviders, |
| 1951 | ); |
| 1952 | const textGenInstanceId = textGenerationModelSelection.instanceId; |
| 1953 | const textGenModel = textGenerationModelSelection.model; |
| 1954 | const textGenModelOptions = textGenerationModelSelection.options; |
| 1955 | const textGenerationModelInstanceEntries = textGenerationTargets.entries; |
| 1956 | const hasTextGenerationProvider = textGenerationModelInstanceEntries.some( |
| 1957 | (entry) => entry.enabled && entry.isAvailable, |
| 1958 | ); |
| 1959 | const textGenInstanceEntry = textGenerationModelInstanceEntries.find( |
| 1960 | (entry) => entry.instanceId === textGenInstanceId, |
| 1961 | ); |
| 1962 | const textGenProvider: ProviderDriverKind = |
| 1963 | textGenInstanceEntry?.driverKind ?? DEFAULT_DRIVER_KIND; |
| 1964 | const textGenerationModelOptionsByInstance = getTextGenerationModelOptionsByInstance( |
| 1965 | settings, |
| 1966 | textGenerationProviders, |
| 1967 | textGenInstanceId, |
| 1968 | textGenModel, |
| 1969 | ); |
| 1970 | const isTextGenerationModelDirty = !Equal.equals( |
| 1971 | settings.textGenerationModelSelection ?? null, |
| 1972 | DEFAULT_UNIFIED_SETTINGS.textGenerationModelSelection ?? null, |
| 1973 | ); |
| 1974 | const textGenerationModelDisabledReason = useScopedModelDisabledReason( |
| 1975 | settings, |
| 1976 | textGenerationModelInstanceEntries, |
| 1977 | true, |
| 1978 | ); |
| 1979 | const mixedAddProjectBaseDirectory = useScopedSettingsMixed(["addProjectBaseDirectory"]); |
| 1980 | const mixedTextGenerationModel = useScopedSettingsMixed(["textGenerationModelSelection"]); |
| 1981 | |
| 1982 | return ( |
| 1983 | <SettingsPageContainer> |
| 1984 | <SettingsSection id="new-projects" title={gt("New projects")}> |
| 1985 | <SettingsRow |
| 1986 | serverScoped |
| 1987 | settingKeys={["addProjectBaseDirectory"]} |
| 1988 | {...setting("add-project-starts-in")} |
| 1989 | description={gt('Leave empty to use "~/" when the Add Project browser opens.')} |
| 1990 | resetAction={ |
| 1991 | settings.addProjectBaseDirectory !== |
| 1992 | DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory ? ( |
| 1993 | <SettingResetButton |
| 1994 | ariaLabel={gt("Reset add project base directory to default")} |
| 1995 | onClick={() => |
| 1996 | updateSettings({ |
| 1997 | addProjectBaseDirectory: DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory, |
| 1998 | }) |
| 1999 | } |
| 2000 | /> |
| 2001 | ) : null |
| 2002 | } |
| 2003 | control={ |
| 2004 | <DraftInput |
| 2005 | size="sm" |
| 2006 | className="w-full sm:w-72" |
| 2007 | value={mixedAddProjectBaseDirectory ? "" : settings.addProjectBaseDirectory} |
| 2008 | onCommit={(next) => updateSettings({ addProjectBaseDirectory: next })} |
| 2009 | normalizeDraft={resolvePastedPath} |
| 2010 | placeholder={mixedAddProjectBaseDirectory ? gt("Mixed") : "~/"} |
| 2011 | spellCheck={false} |
| 2012 | aria-label={gt("Add project base directory")} |
| 2013 | /> |
| 2014 | } |
| 2015 | /> |
| 2016 | <SettingsRow |
| 2017 | serverScoped |
| 2018 | settingKeys={["ghqCloneLayout"]} |
| 2019 | {...setting("ghq-clone-layout")} |
| 2020 | description={gt("Clones go to github.com/owner/repo under the folder above, like ghq.")} |
| 2021 | resetAction={ |
| 2022 | settings.ghqCloneLayout !== DEFAULT_UNIFIED_SETTINGS.ghqCloneLayout ? ( |
| 2023 | <SettingResetButton |
| 2024 | ariaLabel={gt("Reset clone into host folders to default")} |
| 2025 | onClick={() => |
| 2026 | updateSettings({ ghqCloneLayout: DEFAULT_UNIFIED_SETTINGS.ghqCloneLayout }) |
| 2027 | } |
| 2028 | /> |
| 2029 | ) : null |
| 2030 | } |
| 2031 | control={ |
| 2032 | <ScopedSwitch |
| 2033 | settingKeys={["ghqCloneLayout"]} |
| 2034 | checked={settings.ghqCloneLayout} |
| 2035 | onCheckedChange={(checked) => updateSettings({ ghqCloneLayout: Boolean(checked) })} |
| 2036 | aria-label={gt("Clone into host folders")} |
| 2037 | /> |
| 2038 | } |
| 2039 | /> |
| 2040 | </SettingsSection> |
| 2041 | |
| 2042 | <ProjectDefaultsSettings category="general" /> |
| 2043 | |
| 2044 | {!isProjectScope ? ( |
| 2045 | <SettingsSection id="snooze" title={gt("Snooze")}> |
| 2046 | <SnoozePresetsRow /> |
| 2047 | </SettingsSection> |
| 2048 | ) : null} |
| 2049 | |
| 2050 | <SettingsSection id="usage-limits" title={gt("Usage limits")}> |
| 2051 | <SettingsRow |
| 2052 | serverScoped |
| 2053 | {...setting("auto-resume-limited-threads")} |
| 2054 | description={gt( |
| 2055 | "Automatically resume threads when their usage limits reset. You can cancel auto-resume in each thread.", |
| 2056 | )} |
| 2057 | settingKeys={["autoResumeLimitedThreads"]} |
| 2058 | control={ |
| 2059 | <ScopedSwitch |
| 2060 | settingKeys={["autoResumeLimitedThreads"]} |
| 2061 | checked={settings.autoResumeLimitedThreads} |
| 2062 | onCheckedChange={(checked) => |
| 2063 | updateSettings({ autoResumeLimitedThreads: Boolean(checked) }) |
| 2064 | } |
| 2065 | aria-label={gt("Resume after usage limits")} |
| 2066 | /> |
| 2067 | } |
| 2068 | /> |
| 2069 | <SettingsRow |
| 2070 | serverScoped |
| 2071 | {...setting("snooze-limited-threads")} |
| 2072 | description={gt( |
| 2073 | "Snooze threads until their usage limits reset. Enable auto-resume to continue the agent after the reset.", |
| 2074 | )} |
| 2075 | settingKeys={["snoozeLimitedThreads"]} |
| 2076 | control={ |
| 2077 | <ScopedSwitch |
| 2078 | settingKeys={["snoozeLimitedThreads"]} |
| 2079 | checked={settings.snoozeLimitedThreads} |
| 2080 | onCheckedChange={(checked) => |
| 2081 | updateSettings({ snoozeLimitedThreads: Boolean(checked) }) |
| 2082 | } |
| 2083 | aria-label={gt("Snooze until limits reset")} |
| 2084 | /> |
| 2085 | } |
| 2086 | /> |
| 2087 | </SettingsSection> |
| 2088 | |
| 2089 | {hasServerTargets ? ( |
| 2090 | <SettingsSection id="auto-settle" title={gt("Auto-settle")}> |
| 2091 | <SettingsRow |
| 2092 | serverScoped |
| 2093 | settingKeys={["sidebarAutoSettleOnMerge"]} |
| 2094 | {...setting("auto-settle-merged-threads")} |
| 2095 | description={gt( |
| 2096 | "Settle a thread when its pull request merges. Closed pull requests still settle automatically.", |
| 2097 | )} |
| 2098 | resetAction={ |
| 2099 | settings.sidebarAutoSettleOnMerge !== |
| 2100 | DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge ? ( |
| 2101 | <SettingResetButton |
| 2102 | ariaLabel={gt("Reset auto-settle on merge to default")} |
| 2103 | onClick={() => |
| 2104 | updateSettings({ |
| 2105 | sidebarAutoSettleOnMerge: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge, |
| 2106 | }) |
| 2107 | } |
| 2108 | /> |
| 2109 | ) : null |
| 2110 | } |
| 2111 | control={ |
| 2112 | <ScopedSwitch |
| 2113 | settingKeys={["sidebarAutoSettleOnMerge"]} |
| 2114 | checked={settings.sidebarAutoSettleOnMerge} |
| 2115 | onCheckedChange={(checked) => |
| 2116 | updateSettings({ sidebarAutoSettleOnMerge: Boolean(checked) }) |
| 2117 | } |
| 2118 | aria-label={gt("Auto-settle merged threads")} |
| 2119 | /> |
| 2120 | } |
| 2121 | /> |
| 2122 | |
| 2123 | <SettingsRow |
| 2124 | serverScoped |
| 2125 | settingKeys={["sidebarAutoSettleAfterDays"]} |
| 2126 | {...setting("auto-settle-inactive-threads")} |
| 2127 | description={gt("Sidebar threads with no activity for this long settle automatically.")} |
| 2128 | resetAction={ |
| 2129 | settings.sidebarAutoSettleAfterDays !== |
| 2130 | DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays ? ( |
| 2131 | <SettingResetButton |
| 2132 | ariaLabel={gt("Reset auto-settle to default")} |
| 2133 | onClick={() => |
| 2134 | updateSettings({ |
| 2135 | sidebarAutoSettleAfterDays: |
| 2136 | DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays, |
| 2137 | }) |
| 2138 | } |
| 2139 | /> |
| 2140 | ) : null |
| 2141 | } |
| 2142 | control={ |
| 2143 | <ScopedSwitch |
| 2144 | settingKeys={["sidebarAutoSettleAfterDays"]} |
| 2145 | checked={settings.sidebarAutoSettleAfterDays !== null} |
| 2146 | onCheckedChange={(checked) => |
| 2147 | updateSettings({ |
| 2148 | sidebarAutoSettleAfterDays: checked ? AUTO_SETTLE_DEFAULT_DAYS : null, |
| 2149 | }) |
| 2150 | } |
| 2151 | aria-label={gt("Auto-settle inactive threads")} |
| 2152 | /> |
| 2153 | } |
| 2154 | /> |
| 2155 | {settings.sidebarAutoSettleAfterDays !== null ? ( |
| 2156 | <SettingsRow |
| 2157 | serverScoped |
| 2158 | settingKeys={["sidebarAutoSettleAfterDays"]} |
| 2159 | title={setting("days-before-auto-settle").title} |
| 2160 | description={gt("Any new activity un-settles a thread automatically.")} |
| 2161 | control={ |
| 2162 | <AutoSettleDaysInput |
| 2163 | value={settings.sidebarAutoSettleAfterDays} |
| 2164 | onCommit={(days, options) => |
| 2165 | updateSettings({ sidebarAutoSettleAfterDays: days }, options) |
| 2166 | } |
| 2167 | /> |
| 2168 | } |
| 2169 | /> |
| 2170 | ) : null} |
| 2171 | {settings.sidebarAutoSettleAfterDays !== null && supportsAutoSettlementScope ? ( |
| 2172 | <SettingsRow |
| 2173 | serverScoped |
| 2174 | settingKeys={["sidebarAutoSettleKeepPullRequests"]} |
| 2175 | title={gt("Keep threads with a PR")} |
| 2176 | description={gt( |
| 2177 | "Inactivity does not settle threads with a pull request. Merge and close still do.", |
| 2178 | )} |
| 2179 | control={ |
| 2180 | <ScopedSwitch |
| 2181 | settingKeys={["sidebarAutoSettleKeepPullRequests"]} |
| 2182 | checked={settings.sidebarAutoSettleKeepPullRequests} |
| 2183 | onCheckedChange={(checked) => |
| 2184 | updateSettings({ sidebarAutoSettleKeepPullRequests: checked }) |
| 2185 | } |
| 2186 | aria-label={gt("Keep threads with a PR")} |
| 2187 | /> |
| 2188 | } |
| 2189 | /> |
| 2190 | ) : null} |
| 2191 | </SettingsSection> |
| 2192 | ) : null} |
| 2193 | |
| 2194 | <SettingsSection id="text-generation" title={gt("Text generation")}> |
| 2195 | <SettingsRow |
| 2196 | serverScoped |
| 2197 | settingKeys={["textGenerationModelSelection"]} |
| 2198 | {...setting("text-generation-model")} |
| 2199 | description={gt( |
| 2200 | "For thread titles and other generated text. Source control has its own setting. Text generators from Providers also appear here.", |
| 2201 | )} |
| 2202 | resetAction={ |
| 2203 | hasServerTargets && isTextGenerationModelDirty ? ( |
| 2204 | <SettingResetButton |
| 2205 | ariaLabel={gt("Reset text generation model to default")} |
| 2206 | onClick={() => |
| 2207 | updateSettings({ |
| 2208 | textGenerationModelSelection: |
| 2209 | DEFAULT_UNIFIED_SETTINGS.textGenerationModelSelection, |
| 2210 | }) |
| 2211 | } |
| 2212 | /> |
| 2213 | ) : null |
| 2214 | } |
| 2215 | control={ |
| 2216 | !hasServerTargets ? ( |
| 2217 | <span className="text-sm text-muted-foreground"> |
| 2218 | <T>Connect an environment to choose its text generation model.</T> |
| 2219 | </span> |
| 2220 | ) : !hasTextGenerationProvider ? ( |
| 2221 | <span className="text-sm text-muted-foreground"> |
| 2222 | <T>No text generation providers available.</T> |
| 2223 | </span> |
| 2224 | ) : ( |
| 2225 | <div className="flex flex-wrap items-center justify-end gap-1.5"> |
| 2226 | <ProviderModelPicker |
| 2227 | environmentId={environmentId} |
| 2228 | activeInstanceId={textGenInstanceId} |
| 2229 | model={textGenModel} |
| 2230 | lockedProvider={null} |
| 2231 | instanceEntries={textGenerationModelInstanceEntries} |
| 2232 | modelOptionsByInstance={textGenerationModelOptionsByInstance} |
| 2233 | triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME} |
| 2234 | {...(mixedTextGenerationModel ? { triggerLabel: gt("Mixed") } : {})} |
| 2235 | getModelDisabledReason={textGenerationModelDisabledReason} |
| 2236 | {...(environmentId |
| 2237 | ? { |
| 2238 | onOpenProviderSetup: (instanceId: ProviderInstanceId) => { |
| 2239 | void navigate({ |
| 2240 | to: "/settings/providers", |
| 2241 | search: { environmentId, instanceId }, |
| 2242 | }); |
| 2243 | }, |
| 2244 | } |
| 2245 | : {})} |
| 2246 | onInstanceModelChange={(instanceId, model) => { |
| 2247 | const reason = textGenerationModelDisabledReason(instanceId, model); |
| 2248 | if (reason) { |
| 2249 | toastManager.add({ |
| 2250 | type: "error", |
| 2251 | title: gt("Text generation model not saved"), |
| 2252 | description: reason, |
| 2253 | }); |
| 2254 | return; |
| 2255 | } |
| 2256 | updateSettings({ |
| 2257 | textGenerationModelSelection: resolveAppModelSelectionState( |
| 2258 | { |
| 2259 | ...settings, |
| 2260 | textGenerationModelSelection: pickModelSelection( |
| 2261 | textGenerationModelSelection, |
| 2262 | instanceId, |
| 2263 | model, |
| 2264 | ), |
| 2265 | }, |
| 2266 | textGenerationProviders, |
| 2267 | ), |
| 2268 | }); |
| 2269 | }} |
| 2270 | /> |
| 2271 | {textGenInstanceEntry ? ( |
| 2272 | <TraitsPicker |
| 2273 | provider={textGenProvider} |
| 2274 | models={textGenInstanceEntry?.models ?? []} |
| 2275 | model={textGenModel} |
| 2276 | modelOptions={textGenModelOptions} |
| 2277 | allowPromptInjectedEffort={false} |
| 2278 | includePlanAgent={selectsPlanAgent(textGenModelOptions)} |
| 2279 | triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME} |
| 2280 | onModelOptionsChange={(nextOptions) => { |
| 2281 | updateSettings({ |
| 2282 | textGenerationModelSelection: resolveAppModelSelectionState( |
| 2283 | { |
| 2284 | ...settings, |
| 2285 | textGenerationModelSelection: createModelSelection( |
| 2286 | textGenInstanceId, |
| 2287 | textGenModel, |
| 2288 | nextOptions, |
| 2289 | ), |
| 2290 | }, |
| 2291 | textGenerationProviders, |
| 2292 | ), |
| 2293 | }); |
| 2294 | }} |
| 2295 | /> |
| 2296 | ) : null} |
| 2297 | </div> |
| 2298 | ) |
| 2299 | } |
| 2300 | /> |
| 2301 | <AdvancedSettings |
| 2302 | targetIds={[setting("thread-title-instructions").id, setting("response-streaming").id]} |
| 2303 | > |
| 2304 | <ThreadTitleInstructionsSettings /> |
| 2305 | <SettingsRow |
| 2306 | serverScoped |
| 2307 | settingKeys={["responseStreamingMode"]} |
| 2308 | {...setting("response-streaming")} |
| 2309 | description={ |
| 2310 | mixedResponseStreamingMode |
| 2311 | ? gt("The selected targets use different streaming modes.") |
| 2312 | : messages(RESPONSE_STREAMING_MODE_DESCRIPTIONS[settings.responseStreamingMode]) |
| 2313 | } |
| 2314 | resetAction={ |
| 2315 | settings.responseStreamingMode !== DEFAULT_UNIFIED_SETTINGS.responseStreamingMode ? ( |
| 2316 | <SettingResetButton |
| 2317 | ariaLabel={gt("Reset response streaming to default")} |
| 2318 | onClick={() => |
| 2319 | updateSettings({ |
| 2320 | responseStreamingMode: DEFAULT_UNIFIED_SETTINGS.responseStreamingMode, |
| 2321 | }) |
| 2322 | } |
| 2323 | /> |
| 2324 | ) : null |
| 2325 | } |
| 2326 | control={ |
| 2327 | <Select |
| 2328 | value={mixedResponseStreamingMode ? null : settings.responseStreamingMode} |
| 2329 | onValueChange={(value) => { |
| 2330 | if (value === "turn" || value === "paragraph") { |
| 2331 | updateSettings({ responseStreamingMode: value }); |
| 2332 | } |
| 2333 | }} |
| 2334 | > |
| 2335 | <SelectTrigger |
| 2336 | size="sm" |
| 2337 | className="w-full sm:w-56" |
| 2338 | aria-label={gt("Response streaming")} |
| 2339 | > |
| 2340 | <SelectValue> |
| 2341 | {(value: ResponseStreamingMode | null) => |
| 2342 | value === null ? gt("Mixed") : messages(RESPONSE_STREAMING_MODE_LABELS[value]) |
| 2343 | } |
| 2344 | </SelectValue> |
| 2345 | </SelectTrigger> |
| 2346 | <SelectPopup align="end" alignItemWithTrigger={false}> |
| 2347 | <SelectItem hideIndicator value="turn"> |
| 2348 | {messages(RESPONSE_STREAMING_MODE_LABELS.turn)} |
| 2349 | </SelectItem> |
| 2350 | <SelectItem hideIndicator value="paragraph"> |
| 2351 | {messages(RESPONSE_STREAMING_MODE_LABELS.paragraph)} |
| 2352 | </SelectItem> |
| 2353 | </SelectPopup> |
| 2354 | </Select> |
| 2355 | } |
| 2356 | /> |
| 2357 | </AdvancedSettings> |
| 2358 | </SettingsSection> |
| 2359 | </SettingsPageContainer> |
| 2360 | ); |
| 2361 | } |
| 2362 | |
| 2363 | export function MaintenanceSettingsPanel() { |
| 2364 | const setting = useSearchableSetting(); |
| 2365 | const gt = useGT(); |
| 2366 | const settings = useScopedSettings(); |
| 2367 | const updateSettings = useUpdateScopedSettings(); |
| 2368 | const { scope, environment, connectedEnvironments } = useSettingsScope(); |
| 2369 | const environmentId = environment?.environmentId ?? null; |
| 2370 | const isEnvironmentScope = scope.environmentIds.length === 1 && environmentId !== null; |
| 2371 | const hasServerTargets = connectedEnvironments.length > 0; |
| 2372 | |
| 2373 | return ( |
| 2374 | <SettingsPageContainer> |
| 2375 | <SettingsSection id="updates" title={gt("Updates")}> |
| 2376 | <SettingsRow |
| 2377 | serverScoped |
| 2378 | settingKeys={["enableProviderUpdateChecks"]} |
| 2379 | {...setting("provider-update-checks")} |
| 2380 | description={gt( |
| 2381 | "Check installed provider CLIs for newer available versions and fetch model catalog updates. When off, new models may not appear.", |
| 2382 | )} |
| 2383 | resetAction={ |
| 2384 | settings.enableProviderUpdateChecks !== |
| 2385 | DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks ? ( |
| 2386 | <SettingResetButton |
| 2387 | ariaLabel={gt("Reset provider update checks to default")} |
| 2388 | onClick={() => |
| 2389 | updateSettings({ |
| 2390 | enableProviderUpdateChecks: DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks, |
| 2391 | }) |
| 2392 | } |
| 2393 | /> |
| 2394 | ) : null |
| 2395 | } |
| 2396 | control={ |
| 2397 | <ScopedSwitch |
| 2398 | settingKeys={["enableProviderUpdateChecks"]} |
| 2399 | checked={settings.enableProviderUpdateChecks} |
| 2400 | onCheckedChange={(checked) => |
| 2401 | updateSettings({ enableProviderUpdateChecks: Boolean(checked) }) |
| 2402 | } |
| 2403 | aria-label={gt("Check provider versions")} |
| 2404 | /> |
| 2405 | } |
| 2406 | /> |
| 2407 | <SettingsRow |
| 2408 | {...setting("continue-threads-after-server-update")} |
| 2409 | serverScoped |
| 2410 | settingKeys={["continueThreadsAfterServerUpdate"]} |
| 2411 | description={gt( |
| 2412 | "Automatically resume interrupted threads after an update, crash, or machine restart on the selected environments.", |
| 2413 | )} |
| 2414 | status={ |
| 2415 | !hasServerTargets |
| 2416 | ? gt("All selected connected environments must support restart continuation.") |
| 2417 | : undefined |
| 2418 | } |
| 2419 | resetAction={ |
| 2420 | hasServerTargets && |
| 2421 | settings.continueThreadsAfterServerUpdate !== |
| 2422 | DEFAULT_UNIFIED_SETTINGS.continueThreadsAfterServerUpdate ? ( |
| 2423 | <SettingResetButton |
| 2424 | ariaLabel={gt("Reset continue threads after restarts to default")} |
| 2425 | onClick={() => |
| 2426 | updateSettings({ |
| 2427 | continueThreadsAfterServerUpdate: |
| 2428 | DEFAULT_UNIFIED_SETTINGS.continueThreadsAfterServerUpdate, |
| 2429 | }) |
| 2430 | } |
| 2431 | /> |
| 2432 | ) : null |
| 2433 | } |
| 2434 | control={ |
| 2435 | <ScopedSwitch |
| 2436 | settingKeys={["continueThreadsAfterServerUpdate"]} |
| 2437 | checked={settings.continueThreadsAfterServerUpdate} |
| 2438 | disabled={!hasServerTargets} |
| 2439 | onCheckedChange={(checked) => |
| 2440 | updateSettings({ continueThreadsAfterServerUpdate: Boolean(checked) }) |
| 2441 | } |
| 2442 | aria-label={gt("Continue threads after restarts")} |
| 2443 | /> |
| 2444 | } |
| 2445 | /> |
| 2446 | </SettingsSection> |
| 2447 | |
| 2448 | <SettingsSection id="background" title={gt("Background activity")}> |
| 2449 | <BackgroundActivitySettingsRow /> |
| 2450 | <SettingsRow |
| 2451 | serverScoped |
| 2452 | settingKeys={["keepAwakeWhileAgentsWork"]} |
| 2453 | {...setting("keep-awake-while-agents-work")} |
| 2454 | description={gt( |
| 2455 | "Stop the computer from going to sleep while agents are working, and let it sleep once they finish. Closing a laptop lid still puts it to sleep.", |
| 2456 | )} |
| 2457 | resetAction={ |
| 2458 | settings.keepAwakeWhileAgentsWork !== |
| 2459 | DEFAULT_UNIFIED_SETTINGS.keepAwakeWhileAgentsWork ? ( |
| 2460 | <SettingResetButton |
| 2461 | ariaLabel={gt("Reset keep awake while agents work to default")} |
| 2462 | onClick={() => |
| 2463 | updateSettings({ |
| 2464 | keepAwakeWhileAgentsWork: DEFAULT_UNIFIED_SETTINGS.keepAwakeWhileAgentsWork, |
| 2465 | }) |
| 2466 | } |
| 2467 | /> |
| 2468 | ) : null |
| 2469 | } |
| 2470 | control={ |
| 2471 | <ScopedSwitch |
| 2472 | settingKeys={["keepAwakeWhileAgentsWork"]} |
| 2473 | checked={settings.keepAwakeWhileAgentsWork} |
| 2474 | onCheckedChange={(checked) => |
| 2475 | updateSettings({ keepAwakeWhileAgentsWork: Boolean(checked) }) |
| 2476 | } |
| 2477 | aria-label={gt("Keep awake while agents work")} |
| 2478 | /> |
| 2479 | } |
| 2480 | /> |
| 2481 | </SettingsSection> |
| 2482 | |
| 2483 | <StorageCleanupSections /> |
| 2484 | |
| 2485 | <SettingsSection id="diagnostics-section" title={gt("Diagnostics")}> |
| 2486 | <SettingsRow |
| 2487 | {...setting("diagnostics")} |
| 2488 | description={ |
| 2489 | isEnvironmentScope |
| 2490 | ? gt("Inspect processes, resource use, and logs on this environment.") |
| 2491 | : gt("Inspect processes, resource use, and logs on one environment at a time.") |
| 2492 | } |
| 2493 | control={ |
| 2494 | <Button |
| 2495 | render={ |
| 2496 | <Link to="/settings/diagnostics" search={{ machine: environmentId ?? undefined }} /> |
| 2497 | } |
| 2498 | size="sm" |
| 2499 | variant="outline" |
| 2500 | > |
| 2501 | <T>View diagnostics</T> |
| 2502 | </Button> |
| 2503 | } |
| 2504 | /> |
| 2505 | </SettingsSection> |
| 2506 | </SettingsPageContainer> |
| 2507 | ); |
| 2508 | } |
| 2509 | |
| 2510 | export function AboutSettingsPanel() { |
| 2511 | const setting = useSearchableSetting(); |
| 2512 | const gt = useGT(); |
| 2513 | const messages = useMessages(); |
| 2514 | const primaryPolicy = usePrimaryManagedPolicy(); |
| 2515 | // The Welcome page sets up this computer, so it needs one. |
| 2516 | const primaryEnvironmentId = usePrimaryEnvironmentId(); |
| 2517 | const telemetryOff = managedTelemetryOffMessage(primaryPolicy, messages); |
| 2518 | return ( |
| 2519 | <SettingsPageContainer> |
| 2520 | <SettingsSection id="about" title={gt("App")}> |
| 2521 | {primaryPolicy ? ( |
| 2522 | <SettingsRow |
| 2523 | title={gt("Organization")} |
| 2524 | description={gt( |
| 2525 | "This environment is managed by {organization}. Some settings and features follow its policy.", |
| 2526 | { organization: primaryPolicy.organization }, |
| 2527 | )} |
| 2528 | control={ |
| 2529 | primaryPolicy.supportUrl ? ( |
| 2530 | <Button |
| 2531 | render={ |
| 2532 | <a href={primaryPolicy.supportUrl} target="_blank" rel="noreferrer noopener" /> |
| 2533 | } |
| 2534 | size="sm" |
| 2535 | variant="outline" |
| 2536 | > |
| 2537 | <T>Get help</T> |
| 2538 | </Button> |
| 2539 | ) : null |
| 2540 | } |
| 2541 | /> |
| 2542 | ) : null} |
| 2543 | {isElectron || HOSTED_APP_CHANNEL ? ( |
| 2544 | <AboutVersionSection /> |
| 2545 | ) : ( |
| 2546 | <> |
| 2547 | <SettingsRow |
| 2548 | id={setting("app-version").id} |
| 2549 | title={<AboutVersionTitle />} |
| 2550 | description={gt("Current version of the application.")} |
| 2551 | /> |
| 2552 | </> |
| 2553 | )} |
| 2554 | <MobileAppSettingsRow /> |
| 2555 | {primaryEnvironmentId === null ? null : ( |
| 2556 | <SettingsRow |
| 2557 | {...setting("welcome-page")} |
| 2558 | description={gt("See your agents, import projects, and set up your phone.")} |
| 2559 | control={ |
| 2560 | <Button size="sm" variant="outline" render={<Link to="/welcome" />}> |
| 2561 | <T context="verb, opens a page">Open</T> |
| 2562 | </Button> |
| 2563 | } |
| 2564 | /> |
| 2565 | )} |
| 2566 | </SettingsSection> |
| 2567 | |
| 2568 | <SettingsSection id="legal" title={gt("Legal")}> |
| 2569 | <SettingsRow |
| 2570 | {...setting("privacy-policy")} |
| 2571 | description={ |
| 2572 | telemetryOff === undefined |
| 2573 | ? gt("How we handle your data, including the anonymous usage data T3 Code collects.") |
| 2574 | : gt("How we handle your data. {telemetryOff}", { telemetryOff }) |
| 2575 | } |
| 2576 | control={ |
| 2577 | <Button |
| 2578 | render={<a href={PRIVACY_POLICY_URL} target="_blank" rel="noreferrer noopener" />} |
| 2579 | size="sm" |
| 2580 | variant="outline" |
| 2581 | > |
| 2582 | <T>View policy</T> |
| 2583 | </Button> |
| 2584 | } |
| 2585 | /> |
| 2586 | <SettingsRow |
| 2587 | {...setting("open-source-licenses")} |
| 2588 | description={gt("Notices for dependencies, assets, and optional tools used by T3 Code.")} |
| 2589 | control={ |
| 2590 | <Button |
| 2591 | render={<Link to="/settings/open-source-licenses" />} |
| 2592 | size="sm" |
| 2593 | variant="outline" |
| 2594 | > |
| 2595 | <T>View licenses</T> |
| 2596 | </Button> |
| 2597 | } |
| 2598 | /> |
| 2599 | </SettingsSection> |
| 2600 | </SettingsPageContainer> |
| 2601 | ); |
| 2602 | } |