Open History to see the last commit
1import { HOSTED_APP_CHANNEL } from "~/branding";
2import { isElectron } from "~/env";
3import { isMacPlatform, isWindowsPlatform, normalizeSearchText } from "~/lib/utils";
4import { STATIC_KEYBINDING_COMMANDS, type KeybindingCommand } from "@t3tools/contracts";
5import type { EnvironmentId } from "@t3tools/contracts";
6import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
7import {
8 sourceControlClients,
9 type SourceControlDefinition,
10} from "@t3tools/client-runtime/source-control-clients";
11import { DEFAULT_KEYBINDINGS } from "@t3tools/shared/keybindings";
12import * as Schema from "effect/Schema";
13import { TYPOGRAPHY_ADVANCED_STORAGE_KEY } from "../../appearanceFonts";
14import { writeLocalStorageValue } from "../../hooks/useLocalStorage";
15import { commandLabel } from "./KeybindingsSettings.logic";
16import type { ResolvedSettingsScope } from "./settingsScope";
17
18export type SettingsPath =
19 | "/settings/projects"
20 | "/settings/general"
21 | "/settings/diagnostics"
22 | "/settings/appearance"
23 | "/settings/chat"
24 | "/settings/diffs"
25 | "/settings/keybindings"
26 | "/settings/snap-shot"
27 | "/settings/providers"
28 | "/settings/threads"
29 | "/settings/browser"
30 | "/settings/devices"
31 | "/settings/scheduled-tasks"
32 | "/settings/source-control"
33 | "/settings/worktrees"
34 | "/settings/connections"
35 | "/settings/access"
36 | "/settings/maintenance"
37 | "/settings/labs"
38 | "/settings/about"
39 | "/settings/archived";
40
41export type SettingsSearchScope =
42 | "environment"
43 | "environment-defaults"
44 | "project-defaults"
45 | "project"
46 | "checkout"
47 | "connections";
48
49export interface SettingsSearchItem {
50 readonly id: string;
51 readonly title: string;
52 readonly to: SettingsPath;
53 readonly targetId?: string;
54 readonly searchTerms?: ReadonlyArray<string>;
55 readonly scope?: SettingsSearchScope;
56 readonly desktopOnly?: boolean;
57 readonly macOnly?: boolean;
58 readonly windowsOnly?: boolean;
59 readonly releaseChannelOnly?: boolean;
60 readonly cloudOnly?: boolean;
61 readonly environmentOnly?: boolean;
62 readonly providerSettingsOnly?: boolean;
63 readonly macProviderSettingsOnly?: boolean;
64 readonly localBackendManagementOnly?: boolean;
65 readonly localEnvironmentOnly?: boolean;
66 readonly wslAvailableOnly?: boolean;
67 readonly managedTunnelOnly?: boolean;
68 readonly peerLinksOnly?: boolean;
69 readonly secondary?: boolean;
70 readonly requiresThreadAutoSettlement?: boolean;
71}
72
73export interface SettingsSearchAvailability {
74 readonly localEnvironmentDisabled?: boolean;
75 readonly hasCloudPublicConfig: boolean;
76 readonly hasEnvironment: boolean;
77 readonly hasProviderSettingsEnvironment: boolean;
78 readonly hasMacProviderSettingsEnvironment: boolean;
79 readonly canManageLocalBackend: boolean;
80 readonly isWslSettingsRowVisible: boolean;
81 readonly hasThreadAutoSettlement: boolean;
82 readonly managedTunnelActive?: boolean;
83 readonly hasPeerLinkHost?: boolean;
84}
85
86export const SETTINGS_SECTION_LABELS: Readonly<Record<SettingsPath, string>> = {
87 "/settings/diagnostics": "Diagnostics",
88 "/settings/projects": "Projects",
89 "/settings/general": "General",
90 "/settings/appearance": "Appearance",
91 "/settings/chat": "Chat",
92 "/settings/diffs": "Diffs & pull requests",
93 "/settings/keybindings": "Keybindings",
94 "/settings/snap-shot": "SnapShots",
95 "/settings/providers": "Providers",
96 "/settings/threads": "Threads",
97 "/settings/browser": "Browser",
98 "/settings/devices": "Devices",
99 "/settings/scheduled-tasks": "Scheduled tasks",
100 "/settings/source-control": "Source control",
101 "/settings/worktrees": "Worktrees",
102 "/settings/connections": "Environments",
103 "/settings/access": "Sharing & access",
104 "/settings/maintenance": "Maintenance",
105 "/settings/labs": "Labs",
106 "/settings/about": "About",
107 "/settings/archived": "Archive",
108};
109
110/** Sidebar order. A group without a heading is set apart by space alone. */
111export const SETTINGS_NAV_GROUPS: ReadonlyArray<{
112 readonly heading: string | null;
113 readonly paths: ReadonlyArray<SettingsPath>;
114}> = [
115 {
116 heading: null,
117 paths: [
118 "/settings/general",
119 "/settings/appearance",
120 "/settings/chat",
121 "/settings/diffs",
122 "/settings/keybindings",
123 "/settings/snap-shot",
124 ],
125 },
126 {
127 heading: "Agents",
128 paths: [
129 "/settings/providers",
130 "/settings/threads",
131 "/settings/browser",
132 "/settings/devices",
133 "/settings/scheduled-tasks",
134 ],
135 },
136 {
137 heading: "Code",
138 paths: ["/settings/projects", "/settings/source-control", "/settings/worktrees"],
139 },
140 { heading: "Connections", paths: ["/settings/connections", "/settings/access"] },
141 {
142 heading: null,
143 paths: ["/settings/maintenance", "/settings/labs", "/settings/about", "/settings/archived"],
144 },
145];
146
147export function keybindingSearchAnchorId<Command extends KeybindingCommand>(command: Command) {
148 return `keybinding-${command}` as const;
149}
150
151const KEYBINDING_SEARCH_ITEMS = STATIC_KEYBINDING_COMMANDS.toSorted((left, right) =>
152 commandLabel(left).localeCompare(commandLabel(right)),
153).map((command) => {
154 const defaultKeys = DEFAULT_KEYBINDINGS.filter((binding) => binding.command === command).map(
155 (binding) => binding.key,
156 );
157 return {
158 id: keybindingSearchAnchorId(command),
159 title: commandLabel(command),
160 to: "/settings/keybindings" as const,
161 searchTerms: [command, ...defaultKeys],
162 secondary: true,
163 ...(defaultKeys.length === 0 ? { targetId: "keybindings" } : {}),
164 };
165});
166
167export function sourceControlHostSettingsSearchId(kind: string) {
168 return `source-control-host-${kind}` as const;
169}
170
171/** Each host's own settings: its accounts and token, or the fields of its settings form. */
172export function sourceControlHostSearchItems(
173 definitions: ReadonlyArray<SourceControlDefinition>,
174): ReadonlyArray<
175 SettingsSearchItem & { readonly id: ReturnType<typeof sourceControlHostSettingsSearchId> }
176> {
177 return definitions.flatMap((definition) => {
178 if (!definition.settings) return [];
179 const names = [definition.label, ...(definition.searchKeywords ?? [])].join(" ");
180 const { credentials } = definition;
181 return [
182 {
183 id: sourceControlHostSettingsSearchId(definition.kind),
184 title: credentials
185 ? `${definition.label} accounts and token`
186 : `${definition.label} credentials`,
187 to: "/settings/source-control" as const,
188 searchTerms: [
189 credentials
190 ? `${names} ${credentials.cliName} account login user host switch multiple accounts disable sign in token personal access token pat api key credential`
191 : `${names} ${Object.keys(definition.settings.fields).join(" ")} token credentials sign in`,
192 ],
193 environmentOnly: true,
194 scope: "environment-defaults" as const,
195 },
196 ];
197 });
198}
199
200/** For settings that apply to every host. */
201const SOURCE_CONTROL_HOST_LABELS = sourceControlClients.definitions
202 .map((definition) => definition.label)
203 .join(" ");
204const SOURCE_CONTROL_HOST_TERMS = sourceControlClients.definitions
205 .flatMap((definition) => [definition.label, ...(definition.searchKeywords ?? [])])
206 .join(" ");
207
208export const SETTINGS_SEARCH_ITEMS = [
209 {
210 id: "storage-worktree-keep-when",
211 targetId: "storage-worktrees",
212 title: "Keep worktrees with local changes",
213 to: "/settings/worktrees",
214 scope: "project-defaults",
215 searchTerms: [
216 "any local files uncommitted changes edited tracked files ignored env build output cleanup",
217 ],
218 },
219 {
220 id: "storage-delete-now",
221 title: "Delete now",
222 to: "/settings/maintenance",
223 scope: "environment-defaults",
224 searchTerms: ["storage cleanup run now results report removed kept failed"],
225 },
226 {
227 id: "storage-worktrees",
228 title: "Worktree cleanup",
229 to: "/settings/worktrees",
230 scope: "project-defaults",
231 searchTerms: [
232 "disk storage delete deleted archived threads old inactive merged unchanged worktrees retention days project inherit off custom",
233 ],
234 },
235 {
236 id: "storage-worktrees-location",
237 title: "Worktree location",
238 to: "/settings/worktrees",
239 scope: "environment-defaults",
240 searchTerms: ["worktree location folder directory path drive external disk"],
241 },
242 {
243 id: "storage-artifacts",
244 title: "Artifacts and logs",
245 to: "/settings/maintenance",
246 scope: "environment-defaults",
247 searchTerms: ["disk storage browser screenshots captures rotated logs cleanup retention"],
248 },
249 {
250 id: "project-defaults",
251 title: "Project defaults and overrides",
252 to: "/settings/threads",
253 scope: "project-defaults",
254 searchTerms: ["model workspace environments projects inheritance checkout"],
255 },
256 {
257 id: "project-overview",
258 title: "Project overview",
259 to: "/settings/projects",
260 searchTerms: ["name icon emoji image checkout remove delete"],
261 },
262 {
263 id: "default-model",
264 title: "Default model",
265 to: "/settings/threads",
266 scope: "project-defaults",
267 searchTerms: ["new thread project provider reasoning effort"],
268 },
269 {
270 id: "default-permissions",
271 title: "Permissions",
272 to: "/settings/threads",
273 scope: "project-defaults",
274 searchTerms: [
275 "new thread default runtime mode supervised approvals auto accept edits full access",
276 ],
277 },
278 {
279 id: "color-scheme",
280 title: "Color scheme",
281 to: "/settings/appearance",
282 searchTerms: ["appearance light dark system mode"],
283 targetId: "appearance",
284 },
285 {
286 id: "theme",
287 title: "Themes",
288 to: "/settings/appearance",
289 searchTerms: ["appearance colors palette custom import"],
290 targetId: "appearance",
291 },
292 {
293 // Prefixed because the slider control already owns the `appearance-contrast` id.
294 id: "setting-appearance-contrast",
295 title: "Contrast",
296 to: "/settings/appearance",
297 searchTerms: ["colors borders interface"],
298 },
299 {
300 // Prefixed because the slider control already owns the `glass-opacity` id.
301 id: "setting-glass-opacity",
302 title: "Glass opacity",
303 to: "/settings/appearance",
304 searchTerms: ["transparent transparency solid menus dialogs composer"],
305 },
306 {
307 id: "diff-color-scheme",
308 title: "Diff colors",
309 to: "/settings/diffs",
310 searchTerms: ["red green blue orange additions deletions changes counts palette colorblind"],
311 },
312 {
313 id: "chat-width",
314 title: "Chat width",
315 to: "/settings/appearance",
316 searchTerms: ["wide full width column layout messages composer monitor"],
317 },
318 {
319 id: "math-rendering",
320 title: "Render math",
321 to: "/settings/appearance",
322 searchTerms: ["latex tex katex equations formulas markdown"],
323 },
324 {
325 id: "panel-animations",
326 title: "Panel animations",
327 to: "/settings/appearance",
328 },
329 {
330 id: "environment-identification",
331 title: "Environment identification",
332 to: "/settings/appearance",
333 searchTerms: ["dev nightly artwork pill label hide none"],
334 targetId: "appearance-interface",
335 },
336 {
337 id: "interface-font",
338 title: "Interface font",
339 to: "/settings/appearance",
340 searchTerms: ["typography family size system sans"],
341 },
342 {
343 id: "prompt-font",
344 title: "Prompt font",
345 to: "/settings/appearance",
346 searchTerms: ["typography family size composer input"],
347 },
348 {
349 id: "code-font",
350 title: "Code font",
351 to: "/settings/appearance",
352 searchTerms: ["typography family size monospace code blocks diffs file previews"],
353 },
354 {
355 id: "terminal-font",
356 title: "Terminal font",
357 to: "/settings/appearance",
358 searchTerms: ["typography family size monospace output"],
359 },
360 {
361 id: "separate-fonts",
362 title: "Separate fonts",
363 to: "/settings/appearance",
364 searchTerms: ["typography advanced prompt code terminal font family size individually"],
365 },
366 {
367 id: "font-smoothing",
368 title: "Font smoothing",
369 to: "/settings/appearance",
370 searchTerms: ["typography text grayscale anti aliasing macos thin"],
371 macOnly: true,
372 },
373 {
374 id: "word-wrap",
375 title: "Word wrap",
376 to: "/settings/appearance",
377 searchTerms: ["long lines code blocks tables diffs file previews"],
378 },
379 {
380 id: "composer-context",
381 title: "Composer context",
382 to: "/settings/appearance",
383 },
384 {
385 id: "project-grouping",
386 title: "Project grouping",
387 to: "/settings/general",
388 searchTerms: ["combine matching repositories environments sidebar"],
389 },
390 {
391 id: "project-order",
392 title: "Project order",
393 to: "/settings/general",
394 searchTerms: ["sort projects sidebar manual created recent"],
395 },
396 {
397 id: "snooze-limited-threads",
398 title: "Snooze until limits reset",
399 to: "/settings/threads",
400 searchTerms: ["usage quota rate limit reset wake recover continue"],
401 },
402 {
403 id: "auto-resume-limited-threads",
404 title: "Resume after usage limits",
405 to: "/settings/threads",
406 searchTerms: ["usage quota rate limit reset recover continue"],
407 },
408 {
409 id: "working-shelf",
410 title: "Working section",
411 to: "/settings/general",
412 searchTerms: ["hide fold running monitoring threads inbox sidebar shelf"],
413 },
414 {
415 id: "guest-links",
416 title: "Guest links",
417 to: "/settings/labs",
418 scope: "environment",
419 searchTerms: ["beta share guest invite link teammate watch t3 connect tunnel"],
420 },
421 {
422 id: "auto-settle-inactive-threads",
423 title: "Auto-settle inactive threads",
424 to: "/settings/threads",
425 searchTerms: ["sidebar inactivity days no activity automatically"],
426 requiresThreadAutoSettlement: true,
427 scope: "project-defaults",
428 },
429 {
430 id: "compact-idle-threads",
431 title: "Compact idle threads",
432 to: "/settings/providers",
433 scope: "environment-defaults",
434 searchTerms: ["claude context compaction idle cache tokens usage summary resume"],
435 },
436 {
437 id: "auto-settle-merged-threads",
438 title: "Auto-settle merged threads",
439 to: "/settings/threads",
440 searchTerms: ["pull request merge closed automatically sidebar"],
441 requiresThreadAutoSettlement: true,
442 scope: "project-defaults",
443 },
444 {
445 id: "keep-threads-with-pull-requests",
446 title: "Keep threads with a PR",
447 to: "/settings/threads",
448 targetId: "auto-settle-inactive-threads",
449 searchTerms: ["pull request inactivity auto-settle merge close sidebar"],
450 requiresThreadAutoSettlement: true,
451 scope: "project-defaults",
452 },
453 {
454 id: "days-before-auto-settle",
455 title: "Days of inactivity before auto-settle",
456 to: "/settings/threads",
457 targetId: "auto-settle-inactive-threads",
458 searchTerms: ["thread timeout activity sidebar"],
459 requiresThreadAutoSettlement: true,
460 scope: "project-defaults",
461 },
462 {
463 id: "thread-notifications",
464 title: "Thread notifications",
465 to: "/settings/general",
466 searchTerms: ["notification sound alert completion input approval desktop"],
467 },
468 {
469 id: "in-app-notifications",
470 title: "In-app notifications",
471 to: "/settings/general",
472 searchTerms: ["notification toast popup completion input approval failure"],
473 },
474 {
475 id: "time-format",
476 title: "Time format",
477 to: "/settings/general",
478 searchTerms: ["timestamp clock locale system browser os 12 hour 24 hour"],
479 },
480 {
481 id: "response-streaming",
482 title: "Response streaming",
483 to: "/settings/threads",
484 scope: "project-defaults",
485 searchTerms: ["output token paragraph buffered wait turn legacy"],
486 },
487 {
488 id: "hide-whitespace-changes",
489 title: "Hide whitespace changes",
490 to: "/settings/diffs",
491 searchTerms: ["diff ignore spaces edits default"],
492 },
493 {
494 id: "default-diff-file-state",
495 title: "Default diff file state",
496 to: "/settings/diffs",
497 searchTerms: ["collapsed expanded collapse expand files pull request pr code tab"],
498 },
499 {
500 id: "diff-layout",
501 title: "Diff layout",
502 to: "/settings/diffs",
503 searchTerms: ["stacked split side by side unified inline view"],
504 },
505 {
506 id: "proactive-panels",
507 title: "Proactive panels",
508 to: "/settings/diffs",
509 searchTerms: ["automatically open diff pull request pr right panel agent completion"],
510 },
511 {
512 id: "skills-in-slash-menu",
513 title: "Show skills in slash menu",
514 to: "/settings/chat",
515 searchTerms: ["command menu dollar $ slash /"],
516 },
517 {
518 id: "composer-rich-text",
519 title: "Rich text composer",
520 to: "/settings/chat",
521 searchTerms: ["composer rich text tiptap bold italic markdown styled wysiwyg"],
522 },
523 {
524 id: "composer-collapse",
525 title: "Collapse composer on scroll",
526 to: "/settings/chat",
527 searchTerms: ["composer rest resting scroll wheel conversation timeline shrink minimize"],
528 },
529 {
530 id: "send-shortcut",
531 title: "Send shortcut",
532 to: "/settings/chat",
533 searchTerms: ["enter return command ctrl multiline prompt new line composer"],
534 },
535 {
536 id: "follow-up-behavior",
537 title: "Follow-up behavior",
538 to: "/settings/chat",
539 searchTerms: ["queue steer running turn send default behavior composer"],
540 },
541 {
542 id: "provider-update-checks",
543 title: "Provider update checks",
544 to: "/settings/maintenance",
545 searchTerms: ["installed cli versions newer available codex claude cursor grok fx opencode"],
546 scope: "environment-defaults",
547 },
548 {
549 id: "continue-threads-after-server-update",
550 title: "Continue threads after restarts",
551 to: "/settings/maintenance",
552 scope: "project-defaults",
553 searchTerms: [
554 "resume running active interrupted work restart reboot machine crash desktop update automatically",
555 ],
556 },
557 {
558 id: "background-activity",
559 title: "Background activity",
560 to: "/settings/maintenance",
561 scope: "environment-defaults",
562 searchTerms: [
563 "balanced performance battery saver advanced git fetch provider health refresh host power monitor idle policy",
564 ],
565 },
566 {
567 id: "new-threads",
568 title: "New threads",
569 to: "/settings/threads",
570 scope: "project-defaults",
571 searchTerms: ["default workspace mode draft local worktree"],
572 },
573 {
574 id: "worktree-submodules",
575 title: "Submodules",
576 to: "/settings/worktrees",
577 scope: "project-defaults",
578 searchTerms: ["git submodule init recursive top-level none worktree t3.json"],
579 },
580 {
581 id: "start-from-origin",
582 title: "Start from remote",
583 to: "/settings/worktrees",
584 scope: "project-defaults",
585 searchTerms: ["new worktrees start remote origin latest fetched branch local"],
586 },
587 {
588 id: "add-project-starts-in",
589 title: "Add project starts in",
590 to: "/settings/threads",
591 scope: "environment-defaults",
592 searchTerms: ["base directory folder browser path home"],
593 },
594 {
595 id: "unpin-confirmation",
596 title: "Unpin confirmation",
597 to: "/settings/general",
598 searchTerms: ["ask before thread pinned section"],
599 },
600 {
601 id: "archive-confirmation",
602 title: "Archive confirmation",
603 to: "/settings/general",
604 searchTerms: ["ask before thread second click inline action"],
605 },
606 {
607 id: "delete-confirmation",
608 title: "Delete confirmation",
609 to: "/settings/general",
610 searchTerms: ["ask before thread chat history"],
611 },
612 {
613 id: "quit-confirmation",
614 title: "Quit shortcut",
615 to: "/settings/general",
616 searchTerms: ["confirmation desktop app exit direct hold double click press twice"],
617 desktopOnly: true,
618 },
619 {
620 id: "text-generation-model",
621 title: "Text generation model",
622 to: "/settings/threads",
623 scope: "project-defaults",
624 searchTerms: ["generated thread titles source control content default provider"],
625 },
626 {
627 id: "thread-title-instructions",
628 title: "Thread title instructions",
629 to: "/settings/threads",
630 scope: "project-defaults",
631 searchTerms: ["generated thread titles prompt custom style naming rename regenerate"],
632 },
633 {
634 id: "app-version",
635 title: "Version",
636 to: "/settings/about",
637 searchTerms: ["about check for updates download install upgrade release"],
638 },
639 {
640 id: "update-track",
641 title: "Update track",
642 to: "/settings/about",
643 searchTerms: ["release channel stable latest nightly prerelease"],
644 releaseChannelOnly: true,
645 },
646 {
647 id: "cli-command",
648 title: "t3 command",
649 to: "/settings/about",
650 searchTerms: ["cli terminal shell path install command line"],
651 desktopOnly: true,
652 },
653 {
654 id: "mobile-app",
655 title: "Mobile app",
656 to: "/settings/about",
657 searchTerms: ["phone tablet iPhone iPad iOS Android App Store Google Play QR"],
658 },
659 {
660 id: "privacy-policy",
661 title: "Privacy policy",
662 to: "/settings/about",
663 searchTerms: ["telemetry analytics usage data tracking legal opt out"],
664 },
665 {
666 id: "telemetry-export",
667 title: "OpenTelemetry export",
668 to: "/settings/diagnostics",
669 targetId: "telemetry-export",
670 scope: "environment",
671 searchTerms: ["OTel OTLP telemetry export endpoints logs traces metrics Grafana"],
672 },
673 {
674 id: "diagnostics",
675 title: "Diagnostics",
676 to: "/settings/maintenance",
677 searchTerms: ["logs traces processes resource history failures spans cpu memory"],
678 },
679 {
680 id: "open-source-licenses",
681 title: "Open source licenses",
682 to: "/settings/about",
683 },
684 {
685 id: "legacy-plan-mode",
686 title: "Plan mode (legacy)",
687 to: "/settings/labs",
688 searchTerms: ["build plan composer old"],
689 },
690 {
691 id: "legacy-context-window-indicator",
692 title: "Context window indicator (legacy)",
693 to: "/settings/labs",
694 searchTerms: ["composer meter usage tokens circle old"],
695 },
696 {
697 id: "legacy-sidebar",
698 title: "Sidebar (legacy)",
699 to: "/settings/labs",
700 searchTerms: ["project thread tree old flat list"],
701 },
702 {
703 id: "keybindings",
704 title: "Keybindings",
705 to: "/settings/keybindings",
706 searchTerms: ["keyboard shortcuts hotkeys commands bindings json"],
707 },
708 ...KEYBINDING_SEARCH_ITEMS,
709 {
710 id: "snap-shot-enabled",
711 title: "SnapShots",
712 searchTerms: ["window capture screenshot"],
713 to: "/settings/snap-shot",
714 },
715 {
716 id: "snap-shot-accessibility",
717 title: "Include app text",
718 to: "/settings/snap-shot",
719 targetId: "snap-shot-enabled",
720 searchTerms: [
721 "capture accessibility data text UI structure elements privacy omit agent context",
722 ],
723 },
724 {
725 id: "snap-shot-shortcut",
726 title: "Capture shortcut",
727 to: "/settings/snap-shot",
728 targetId: "snap-shot-enabled",
729 },
730 {
731 id: "snap-shot-sound",
732 title: "Capture sound",
733 to: "/settings/snap-shot",
734 targetId: "snap-shot-enabled",
735 },
736 {
737 id: "snap-shot-flash",
738 title: "Capture flash",
739 to: "/settings/snap-shot",
740 targetId: "snap-shot-enabled",
741 },
742 {
743 id: "snap-shot-animations",
744 title: "Capture animations",
745 to: "/settings/snap-shot",
746 targetId: "snap-shot-enabled",
747 },
748 {
749 id: "providers",
750 title: "Providers",
751 to: "/settings/providers",
752 searchTerms: [
753 "agents cli codex claude cursor grok fx opencode antigravity google sign in sign out install subscription instances authentication api key models configuration binary path config directory endpoint arguments environment variables display name accent color custom favorite hidden auto compact",
754 ],
755 },
756 {
757 id: "usage-providers",
758 title: "Usage providers",
759 to: "/settings/providers",
760 searchTerms: [
761 "usage sources CLIProxyAPI CLI proxy hub quota subscription limits management key add remove",
762 ],
763 providerSettingsOnly: true,
764 },
765 {
766 id: "cursor-keychain-usage",
767 title: "Cursor account usage",
768 to: "/settings/providers",
769 searchTerms: ["cursor macOS keychain usage tokens cost limits permission"],
770 providerSettingsOnly: true,
771 macProviderSettingsOnly: true,
772 },
773 {
774 id: "provider-health-check-interval",
775 title: "Health check interval",
776 to: "/settings/providers",
777 searchTerms: ["refresh availability versions auth state models background probes seconds off"],
778 providerSettingsOnly: true,
779 },
780 {
781 id: "agent-browser-access",
782 title: "Agent browser access",
783 to: "/settings/browser",
784 scope: "project-defaults",
785 searchTerms: ["allow disable enable open drive preview tools sessions project override"],
786 },
787 {
788 id: "device-hosts",
789 title: "Device hosts",
790 to: "/settings/devices",
791 searchTerms: ["ssh remote simulator emulator ios android mac mini identity key connection"],
792 },
793 {
794 id: "agent-device-access",
795 title: "Agent device access",
796 to: "/settings/devices",
797 targetId: "devices",
798 searchTerms: ["allow simulator emulator ios android drive tools sessions"],
799 },
800 {
801 id: "device-hub",
802 title: "Device hub",
803 to: "/settings/devices",
804 targetId: "devices",
805 searchTerms: ["simulator emulator ios android install start"],
806 },
807 {
808 id: "device-platform-support",
809 title: "Simulator support",
810 to: "/settings/devices",
811 targetId: "devices",
812 searchTerms: ["xcode android studio sdk avd runtime"],
813 },
814 {
815 id: "browser-profiles",
816 title: "Browser profiles",
817 to: "/settings/browser",
818 targetId: "browser",
819 },
820 {
821 id: "browser-default-profile",
822 title: "Default browser profile",
823 to: "/settings/browser",
824 targetId: "browser-profiles",
825 },
826 {
827 id: "browser-default-viewport",
828 title: "Default browser viewport",
829 to: "/settings/browser",
830 searchTerms: ["preview size width height device desktop mobile rotate"],
831 },
832 {
833 id: "browser-default-zoom",
834 title: "Default browser zoom",
835 to: "/settings/browser",
836 searchTerms: ["preview page scale tabs percent"],
837 },
838 {
839 id: "browser-default-appearance",
840 title: "Default browser appearance",
841 to: "/settings/browser",
842 searchTerms: ["preview color scheme light dark system os"],
843 },
844 {
845 id: "browser-recording-frame-rate",
846 title: "Browser recording frame rate",
847 to: "/settings/browser",
848 },
849 {
850 id: "browser-recording-key-presses",
851 title: "Show key presses in recordings",
852 to: "/settings/browser",
853 searchTerms: ["browser preview keyboard shortcuts keystrokes overlay capture"],
854 },
855 {
856 id: "browser-recording-mouse-presses",
857 title: "Show mouse presses in recordings",
858 to: "/settings/browser",
859 searchTerms: ["browser preview clicks buttons drag overlay capture"],
860 },
861 {
862 id: "browser-link-target",
863 title: "Open links in",
864 to: "/settings/browser",
865 searchTerms: ["links default browser in-app browser external open"],
866 },
867 {
868 id: "browser-search-engine",
869 title: "Search engine",
870 to: "/settings/browser",
871 searchTerms: ["address bar duckduckgo google bing brave kagi ecosia custom"],
872 },
873 {
874 id: "pull-request-links-open-in-app",
875 title: "Open pull requests in T3 Code",
876 to: "/settings/diffs",
877 searchTerms: [
878 `pr links ${SOURCE_CONTROL_HOST_LABELS} browser external click default pull request view panel`,
879 ],
880 },
881 {
882 id: "browser-auto-show-floating-preview",
883 title: "Auto-show floating preview",
884 to: "/settings/browser",
885 searchTerms: ["agent opens browser device simulator pop into view hide"],
886 },
887 {
888 id: "automatic-pull",
889 title: "Automatically pull",
890 to: "/settings/source-control",
891 scope: "project-defaults",
892 searchTerms: ["auto pull default branch current checkout fast forward upstream"],
893 },
894 {
895 id: "remove-agent-credits-on-merge",
896 title: "Remove agent credits when merging",
897 to: "/settings/source-control",
898 scope: "project-defaults",
899 searchTerms: [
900 `pull request ${SOURCE_CONTROL_HOST_LABELS} squash co-authored-by attribution claude codex generated`,
901 ],
902 },
903 {
904 id: "pull-request-merge-method",
905 title: "Default merge method",
906 to: "/settings/source-control",
907 scope: "project-defaults",
908 searchTerms: ["pull request merge squash rebase last selected"],
909 },
910 {
911 id: "source-control",
912 title: "Source control",
913 to: "/settings/source-control",
914 scope: "environment-defaults",
915 searchTerms: [
916 `version control git ${SOURCE_CONTROL_HOST_TERMS} hosting integrations credentials scan server environment`,
917 ],
918 },
919 {
920 id: "git-fetch-interval",
921 title: "Git fetch interval",
922 to: "/settings/maintenance",
923 targetId: "background-activity",
924 searchTerms: [
925 "automatic remote branch refresh background credentials security keys seconds off",
926 ],
927 environmentOnly: true,
928 scope: "environment-defaults",
929 },
930 {
931 id: "worktree-branch-naming",
932 title: "Worktree branch naming",
933 to: "/settings/worktrees",
934 searchTerms: ["static semantic prefix custom prompt instructions feat fix refactor chore"],
935 environmentOnly: true,
936 scope: "project-defaults",
937 },
938 ...sourceControlHostSearchItems(sourceControlClients.definitions),
939 {
940 id: "source-control-writing-style",
941 title: "Source control writing style",
942 to: "/settings/source-control",
943 searchTerms: [
944 "repository conventions conventional commits custom instructions change descriptions request titles",
945 ],
946 environmentOnly: true,
947 },
948 {
949 id: "follow-change-request-templates",
950 title: "Follow change request templates",
951 to: "/settings/source-control",
952 searchTerms: ["repository pr pull request description structure"],
953 environmentOnly: true,
954 },
955 {
956 id: "source-control-writer-model",
957 title: "Source control writer model",
958 to: "/settings/source-control",
959 searchTerms: [
960 "override generated commit change request pr titles descriptions branch bookmark",
961 ],
962 environmentOnly: true,
963 scope: "project-defaults",
964 },
965 {
966 id: "review-guides",
967 title: "Review guides (beta)",
968 to: "/settings/source-control",
969 searchTerms: ["pull request pr guided review guide tour beta experimental"],
970 environmentOnly: true,
971 },
972 {
973 id: "review-guide-model",
974 title: "Review guide model",
975 to: "/settings/source-control",
976 // Hidden until review guides are on, so a search lands on the switch that shows it.
977 targetId: "review-guides",
978 searchTerms: ["pull request pr guided review guide brief maintainer"],
979 environmentOnly: true,
980 scope: "project-defaults",
981 },
982 {
983 id: "review-guide-instructions",
984 title: "Review guide instructions",
985 to: "/settings/source-control",
986 targetId: "review-guides",
987 searchTerms: ["pull request pr guided review guide preferences taste prompt custom"],
988 environmentOnly: true,
989 scope: "project-defaults",
990 },
991 {
992 id: "project-actions",
993 title: "Actions",
994 to: "/settings/projects",
995 searchTerms: ["commands scripts setup run dev server checkout worktree t3.json import"],
996 },
997 {
998 id: "environment-icon",
999 title: "Environment icon",
1000 to: "/settings/access",
1001 targetId: "connections-environment",
1002 searchTerms: ["machine glyph sidebar mac mini studio laptop desktop server cloud vm"],
1003 },
1004 {
1005 id: "local-environment",
1006 title: "Local environment",
1007 to: "/settings/connections",
1008 searchTerms: ["turn off on disable enable local server agents remote only restart"],
1009 desktopOnly: true,
1010 },
1011 {
1012 id: "network-access",
1013 title: "Network access",
1014 to: "/settings/access",
1015 targetId: "connections-environment",
1016 searchTerms: ["expose backend remote pairing local machine interfaces host restart"],
1017 localBackendManagementOnly: true,
1018 },
1019 {
1020 id: "tailscale-https",
1021 title: "Tailscale HTTPS",
1022 to: "/settings/access",
1023 targetId: "connections-environment",
1024 searchTerms: ["serve magicdns endpoint remote secure network"],
1025 desktopOnly: true,
1026 localBackendManagementOnly: true,
1027 },
1028 {
1029 id: "wsl-backend",
1030 title: "WSL backend",
1031 to: "/settings/access",
1032 searchTerms: [
1033 "windows subsystem linux distro second server projects stop windows backend restart",
1034 ],
1035 desktopOnly: true,
1036 windowsOnly: true,
1037 localBackendManagementOnly: true,
1038 wslAvailableOnly: true,
1039 },
1040 {
1041 id: "t3-connect",
1042 localEnvironmentOnly: true,
1043 title: "T3 Connect",
1044 to: "/settings/access",
1045 targetId: "connections-environment",
1046 searchTerms: ["managed tunnel cloud other devices remote"],
1047 desktopOnly: true,
1048 cloudOnly: true,
1049 },
1050 {
1051 id: "hold-webhooks-while-offline",
1052 localEnvironmentOnly: true,
1053 title: "Hold webhooks while offline",
1054 to: "/settings/access",
1055 targetId: "connections-environment",
1056 searchTerms: ["webhook automations offline queue mailbox t3 connect"],
1057 cloudOnly: true,
1058 managedTunnelOnly: true,
1059 },
1060 {
1061 id: "publish-agent-activity",
1062 localEnvironmentOnly: true,
1063 title: "Publish agent activity",
1064 to: "/settings/access",
1065 targetId: "connections-environment",
1066 searchTerms: ["mobile push notifications live activities cloud tunnel"],
1067 cloudOnly: true,
1068 },
1069 {
1070 id: "connections-environment",
1071 title: "This machine",
1072 to: "/settings/access",
1073 searchTerms: [
1074 "connections server backend local remote access administrative permissions scope pairing links qr code authorized clients sessions revoke endpoint",
1075 ],
1076 },
1077 {
1078 id: "linked-environments",
1079 peerLinksOnly: true,
1080 title: "Linked environments",
1081 to: "/settings/connections",
1082 targetId: "linked-environments",
1083 searchTerms: ["link peer another machine vps agents work there handoff pairing code"],
1084 },
1085 {
1086 id: "remote-environments",
1087 title: "Environments",
1088 to: "/settings/connections",
1089 searchTerms: ["add pair backend host code ssh config agent tunnel saved t3 connect"],
1090 },
1091 {
1092 id: "load-balancing",
1093 title: "Load balancing",
1094 to: "/settings/connections",
1095 searchTerms: [
1096 "automatic machine environment resources cpu memory capacity preference weight shared projects",
1097 ],
1098 },
1099 {
1100 id: "pull-request-routing",
1101 title: "Pull request sharing",
1102 to: "/settings/connections",
1103 searchTerms: [
1104 `pull request routing trusted environments shared credentials permissions read actions source control ${SOURCE_CONTROL_HOST_LABELS}`,
1105 ],
1106 },
1107 {
1108 id: "archive",
1109 title: "Archived threads",
1110 to: "/settings/archived",
1111 searchTerms: ["restore reopen deleted history projects"],
1112 },
1113] as const satisfies ReadonlyArray<SettingsSearchItem>;
1114
1115export type SettingsSearchItemId = (typeof SETTINGS_SEARCH_ITEMS)[number]["id"];
1116
1117const SEARCH_ITEMS_BY_ID = new Map(SETTINGS_SEARCH_ITEMS.map((item) => [item.id, item] as const));
1118
1119const SETTINGS_CATEGORY_SCOPES: Readonly<Record<SettingsPath, SettingsSearchScope | null>> = {
1120 "/settings/diagnostics": "environment",
1121 "/settings/projects": "project",
1122 "/settings/general": null,
1123 "/settings/appearance": null,
1124 "/settings/chat": null,
1125 "/settings/diffs": null,
1126 "/settings/snap-shot": null,
1127 "/settings/keybindings": null,
1128 "/settings/providers": null,
1129 "/settings/threads": null,
1130 "/settings/browser": null,
1131 "/settings/devices": null,
1132 "/settings/source-control": "environment-defaults",
1133 "/settings/worktrees": "project-defaults",
1134 "/settings/connections": "connections",
1135 "/settings/access": "connections",
1136 "/settings/scheduled-tasks": null,
1137 "/settings/maintenance": null,
1138 "/settings/labs": null,
1139 "/settings/about": null,
1140 "/settings/archived": "project-defaults",
1141};
1142
1143const RENAMED_SETTINGS_PATHS: Readonly<Record<string, SettingsPath>> = {
1144 "/settings/integrations": "/settings/browser",
1145 "/settings/storage": "/settings/maintenance",
1146 "/settings/beta": "/settings/labs",
1147};
1148const SPLIT_SETTINGS_PATHS: ReadonlySet<string> = new Set([
1149 "/settings/general",
1150 "/settings/appearance",
1151 "/settings/source-control",
1152 "/settings/connections",
1153 ...Object.keys(RENAMED_SETTINGS_PATHS),
1154]);
1155// Section anchors that moved but are not search results themselves.
1156const MOVED_SECTION_ANCHORS: Readonly<Record<string, SettingsPath>> = {
1157 "authorized-clients": "/settings/access",
1158 "legacy-features": "/settings/labs",
1159 "text-generation": "/settings/threads",
1160 about: "/settings/about",
1161};
1162
1163/** Where an old settings link now lives. Its anchor finds the page its row moved to. */
1164export function movedSettingsPath(pathname: string, hash: string): SettingsPath | null {
1165 if (!SPLIT_SETTINGS_PATHS.has(pathname)) return null;
1166 const items: readonly SettingsSearchItem[] = SETTINGS_SEARCH_ITEMS;
1167 const anchored = hash
1168 ? (items.find((item) => item.id === hash) ?? items.find((item) => item.targetId === hash))
1169 : undefined;
1170 const to =
1171 anchored?.to ?? MOVED_SECTION_ANCHORS[hash] ?? RENAMED_SETTINGS_PATHS[pathname] ?? null;
1172 return to === pathname ? null : to;
1173}
1174
1175export function getSettingsSearchTargetScope(targetId: string) {
1176 const items: readonly SettingsSearchItem[] = SETTINGS_SEARCH_ITEMS;
1177 const item =
1178 items.find((candidate) => candidate.id === targetId) ??
1179 items.find((candidate) => candidate.targetId === targetId);
1180 return item
1181 ? {
1182 title: item.title,
1183 scope: item.scope ?? SETTINGS_CATEGORY_SCOPES[item.to],
1184 ...(item.requiresThreadAutoSettlement ? { requiresThreadAutoSettlement: true } : {}),
1185 }
1186 : null;
1187}
1188
1189interface AutoSettlementSearchEnvironment {
1190 readonly environmentId: EnvironmentId;
1191 readonly connection: { readonly phase: EnvironmentConnectionPhase };
1192 readonly serverConfig: {
1193 readonly environment: {
1194 readonly capabilities: { readonly threadAutoSettlement?: boolean };
1195 };
1196 } | null;
1197}
1198
1199export function getThreadAutoSettlementSearchAvailability(
1200 environments: readonly AutoSettlementSearchEnvironment[],
1201 scope?: Pick<ResolvedSettingsScope, "kind" | "environmentIds">,
1202) {
1203 const connected = environments.filter(
1204 (environment) =>
1205 environment.connection.phase === "connected" && environment.serverConfig !== null,
1206 );
1207 const eligibleEnvironmentIds = connected
1208 .filter(
1209 (environment) =>
1210 environment.serverConfig?.environment.capabilities.threadAutoSettlement === true,
1211 )
1212 .map((environment) => environment.environmentId);
1213 const selected = connected.filter((environment) =>
1214 scope?.environmentIds.includes(environment.environmentId),
1215 );
1216 return {
1217 eligibleEnvironmentIds,
1218 isTargetAvailable:
1219 scope !== undefined &&
1220 scope.kind !== "unavailable" &&
1221 selected.length > 0 &&
1222 selected.every((environment) => eligibleEnvironmentIds.includes(environment.environmentId)),
1223 };
1224}
1225
1226export function isSettingsSearchScopeAvailable(
1227 requiredScope: SettingsSearchScope | null,
1228 scopeKind: ResolvedSettingsScope["kind"],
1229): boolean {
1230 switch (requiredScope) {
1231 case null:
1232 case "connections":
1233 return true;
1234 case "environment":
1235 case "checkout":
1236 return requiredScope === scopeKind;
1237 case "project":
1238 return scopeKind === "project" || scopeKind === "checkout";
1239 case "environment-defaults":
1240 return scopeKind === "environment" || scopeKind === "all";
1241 case "project-defaults":
1242 return (
1243 scopeKind === "environment" ||
1244 scopeKind === "all" ||
1245 scopeKind === "project" ||
1246 scopeKind === "checkout"
1247 );
1248 }
1249}
1250
1251export function searchableSetting(id: SettingsSearchItemId): {
1252 readonly id: string;
1253 readonly title: string;
1254} {
1255 const { id: anchorId, title } = SEARCH_ITEMS_BY_ID.get(id)!;
1256 return { id: anchorId, title };
1257}
1258
1259export function filterAvailableSettingsSearchItems(
1260 availability: SettingsSearchAvailability,
1261): ReadonlyArray<SettingsSearchItem> {
1262 const items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS;
1263 return items.filter(
1264 (item) =>
1265 (!item.cloudOnly || availability.hasCloudPublicConfig) &&
1266 (!item.environmentOnly || availability.hasEnvironment) &&
1267 (!item.providerSettingsOnly || availability.hasProviderSettingsEnvironment) &&
1268 (!item.macProviderSettingsOnly || availability.hasMacProviderSettingsEnvironment) &&
1269 (!item.localBackendManagementOnly || availability.canManageLocalBackend) &&
1270 (!item.localEnvironmentOnly || !availability.localEnvironmentDisabled) &&
1271 (!item.wslAvailableOnly || availability.isWslSettingsRowVisible) &&
1272 (!item.requiresThreadAutoSettlement || availability.hasThreadAutoSettlement) &&
1273 (!item.managedTunnelOnly || availability.managedTunnelActive === true) &&
1274 (!item.peerLinksOnly || availability.hasPeerLinkHost === true),
1275 );
1276}
1277
1278/** The settings that exist on this platform and app channel. */
1279export function settingsForThisPlatform(
1280 items: ReadonlyArray<SettingsSearchItem>,
1281): ReadonlyArray<SettingsSearchItem> {
1282 const platform = typeof navigator === "undefined" ? "" : navigator.platform;
1283 return items.filter(
1284 (item) =>
1285 (isElectron || item.desktopOnly !== true) &&
1286 (!item.releaseChannelOnly || isElectron || HOSTED_APP_CHANNEL !== null) &&
1287 (!item.macOnly || isMacPlatform(platform)) &&
1288 (!item.windowsOnly || isWindowsPlatform(platform)),
1289 );
1290}
1291
1292export function searchSettings(
1293 query: string,
1294 items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS,
1295): ReadonlyArray<SettingsSearchItem> {
1296 const normalizedQuery = normalizeSearchText(query);
1297 if (normalizedQuery.length === 0) return [];
1298 const queryTokens = normalizedQuery.split(" ");
1299
1300 return settingsForThisPlatform(items)
1301 .flatMap((item, index) => {
1302 const title = normalizeSearchText(item.title);
1303 const fields = [
1304 title,
1305 normalizeSearchText(SETTINGS_SECTION_LABELS[item.to]),
1306 ...(item.searchTerms ?? []).map(normalizeSearchText),
1307 ];
1308 if (!queryTokens.every((token) => fields.some((field) => field.includes(token)))) return [];
1309
1310 const exactPhraseField = fields.findIndex((field) => field.includes(normalizedQuery));
1311 const rank =
1312 title === normalizedQuery
1313 ? 5
1314 : title.startsWith(normalizedQuery)
1315 ? 4
1316 : title.includes(normalizedQuery)
1317 ? 3
1318 : queryTokens.every((token) => title.includes(token))
1319 ? 2
1320 : exactPhraseField >= 0
1321 ? 1
1322 : 0;
1323 return [{ item, index, rank }];
1324 })
1325 .toSorted(
1326 (left, right) =>
1327 Number(left.item.secondary ?? false) - Number(right.item.secondary ?? false) ||
1328 right.rank - left.rank ||
1329 left.index - right.index,
1330 )
1331 .map(({ item }) => item);
1332}
1333
1334// These rows only exist with separate fonts on, so a search jump to one turns them on.
1335const ADVANCED_TYPOGRAPHY_TARGET_IDS: ReadonlySet<string> = new Set([
1336 "prompt-font",
1337 "terminal-font",
1338]);
1339
1340export function isAdvancedTypographyTarget(targetId: string): boolean {
1341 return ADVANCED_TYPOGRAPHY_TARGET_IDS.has(targetId);
1342}
1343
1344/**
1345 * Opens the persisted section a search result lives in before jumping to it, so
1346 * its row is mounted to scroll to. The terminal reads the same flag, so it must
1347 * stay on after the jump.
1348 */
1349export function revealSettingsSearchTarget(targetId: string): void {
1350 if (isAdvancedTypographyTarget(targetId)) {
1351 writeLocalStorageValue(TYPOGRAPHY_ADVANCED_STORAGE_KEY, true, false, Schema.Boolean);
1352 }
1353}