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 latest channel 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: "linked-environments-beta",
423 title: "Linked environments",
424 to: "/settings/labs",
425 scope: "environment",
426 searchTerms: ["beta link another machine vps peer agents work there delegate"],
427 },
428 {
429 id: "auto-settle-inactive-threads",
430 title: "Auto-settle inactive threads",
431 to: "/settings/threads",
432 searchTerms: ["sidebar inactivity days no activity automatically"],
433 requiresThreadAutoSettlement: true,
434 scope: "project-defaults",
435 },
436 {
437 id: "compact-idle-threads",
438 title: "Compact idle threads",
439 to: "/settings/providers",
440 scope: "environment-defaults",
441 searchTerms: ["claude context compaction idle cache tokens usage summary resume"],
442 },
443 {
444 id: "auto-settle-merged-threads",
445 title: "Auto-settle merged threads",
446 to: "/settings/threads",
447 searchTerms: ["pull request merge closed automatically sidebar"],
448 requiresThreadAutoSettlement: true,
449 scope: "project-defaults",
450 },
451 {
452 id: "keep-threads-with-pull-requests",
453 title: "Keep threads with a PR",
454 to: "/settings/threads",
455 targetId: "auto-settle-inactive-threads",
456 searchTerms: ["pull request inactivity auto-settle merge close sidebar"],
457 requiresThreadAutoSettlement: true,
458 scope: "project-defaults",
459 },
460 {
461 id: "days-before-auto-settle",
462 title: "Days of inactivity before auto-settle",
463 to: "/settings/threads",
464 targetId: "auto-settle-inactive-threads",
465 searchTerms: ["thread timeout activity sidebar"],
466 requiresThreadAutoSettlement: true,
467 scope: "project-defaults",
468 },
469 {
470 id: "thread-notifications",
471 title: "Thread notifications",
472 to: "/settings/general",
473 searchTerms: ["notification sound alert completion input approval desktop"],
474 },
475 {
476 id: "in-app-notifications",
477 title: "In-app notifications",
478 to: "/settings/general",
479 searchTerms: ["notification toast popup completion input approval failure"],
480 },
481 {
482 id: "time-format",
483 title: "Time format",
484 to: "/settings/general",
485 searchTerms: ["timestamp clock locale system browser os 12 hour 24 hour"],
486 },
487 {
488 id: "response-streaming",
489 title: "Response streaming",
490 to: "/settings/threads",
491 scope: "project-defaults",
492 searchTerms: ["output token paragraph buffered wait turn legacy"],
493 },
494 {
495 id: "hide-whitespace-changes",
496 title: "Hide whitespace changes",
497 to: "/settings/diffs",
498 searchTerms: ["diff ignore spaces edits default"],
499 },
500 {
501 id: "default-diff-file-state",
502 title: "Default diff file state",
503 to: "/settings/diffs",
504 searchTerms: ["collapsed expanded collapse expand files pull request pr code tab"],
505 },
506 {
507 id: "diff-layout",
508 title: "Diff layout",
509 to: "/settings/diffs",
510 searchTerms: ["stacked split side by side unified inline view"],
511 },
512 {
513 id: "proactive-panels",
514 title: "Proactive panels",
515 to: "/settings/diffs",
516 searchTerms: ["automatically open diff pull request pr right panel agent completion"],
517 },
518 {
519 id: "skills-in-slash-menu",
520 title: "Show skills in slash menu",
521 to: "/settings/chat",
522 searchTerms: ["command menu dollar $ slash /"],
523 },
524 {
525 id: "composer-rich-text",
526 title: "Rich text composer",
527 to: "/settings/chat",
528 searchTerms: ["composer rich text tiptap bold italic markdown styled wysiwyg"],
529 },
530 {
531 id: "composer-collapse",
532 title: "Collapse composer on scroll",
533 to: "/settings/chat",
534 searchTerms: ["composer rest resting scroll wheel conversation timeline shrink minimize"],
535 },
536 {
537 id: "send-shortcut",
538 title: "Send shortcut",
539 to: "/settings/chat",
540 searchTerms: ["enter return command ctrl multiline prompt new line composer"],
541 },
542 {
543 id: "follow-up-behavior",
544 title: "Follow-up behavior",
545 to: "/settings/chat",
546 searchTerms: ["queue steer running turn send default behavior composer"],
547 },
548 {
549 id: "provider-update-checks",
550 title: "Provider update checks",
551 to: "/settings/maintenance",
552 searchTerms: ["installed cli versions newer available codex claude cursor grok fx opencode"],
553 scope: "environment-defaults",
554 },
555 {
556 id: "continue-threads-after-server-update",
557 title: "Continue threads after restarts",
558 to: "/settings/maintenance",
559 scope: "project-defaults",
560 searchTerms: [
561 "resume running active interrupted work restart reboot machine crash desktop update automatically",
562 ],
563 },
564 {
565 id: "background-activity",
566 title: "Background activity",
567 to: "/settings/maintenance",
568 scope: "environment-defaults",
569 searchTerms: [
570 "balanced performance battery saver advanced git fetch provider health refresh host power monitor idle policy",
571 ],
572 },
573 {
574 id: "new-threads",
575 title: "New threads",
576 to: "/settings/threads",
577 scope: "project-defaults",
578 searchTerms: ["default workspace mode draft local worktree"],
579 },
580 {
581 id: "worktree-submodules",
582 title: "Submodules",
583 to: "/settings/worktrees",
584 scope: "project-defaults",
585 searchTerms: ["git submodule init recursive top-level none worktree t3.json"],
586 },
587 {
588 id: "start-from-origin",
589 title: "Start from remote",
590 to: "/settings/worktrees",
591 scope: "project-defaults",
592 searchTerms: ["new worktrees start remote origin latest fetched branch local"],
593 },
594 {
595 id: "add-project-starts-in",
596 title: "Add project starts in",
597 to: "/settings/threads",
598 scope: "environment-defaults",
599 searchTerms: ["base directory folder browser path home"],
600 },
601 {
602 id: "unpin-confirmation",
603 title: "Unpin confirmation",
604 to: "/settings/general",
605 searchTerms: ["ask before thread pinned section"],
606 },
607 {
608 id: "archive-confirmation",
609 title: "Archive confirmation",
610 to: "/settings/general",
611 searchTerms: ["ask before thread second click inline action"],
612 },
613 {
614 id: "delete-confirmation",
615 title: "Delete confirmation",
616 to: "/settings/general",
617 searchTerms: ["ask before thread chat history"],
618 },
619 {
620 id: "quit-confirmation",
621 title: "Quit shortcut",
622 to: "/settings/general",
623 searchTerms: ["confirmation desktop app exit direct hold double click press twice"],
624 desktopOnly: true,
625 },
626 {
627 id: "text-generation-model",
628 title: "Text generation model",
629 to: "/settings/threads",
630 scope: "project-defaults",
631 searchTerms: ["generated thread titles source control content default provider"],
632 },
633 {
634 id: "thread-title-instructions",
635 title: "Thread title instructions",
636 to: "/settings/threads",
637 scope: "project-defaults",
638 searchTerms: ["generated thread titles prompt custom style naming rename regenerate"],
639 },
640 {
641 id: "app-version",
642 title: "Version",
643 to: "/settings/about",
644 searchTerms: ["about check for updates download install upgrade release"],
645 },
646 {
647 id: "update-track",
648 title: "Update track",
649 to: "/settings/about",
650 searchTerms: ["release channel stable latest nightly prerelease"],
651 releaseChannelOnly: true,
652 },
653 {
654 id: "cli-command",
655 title: "t3 command",
656 to: "/settings/about",
657 searchTerms: ["cli terminal shell path install command line"],
658 desktopOnly: true,
659 },
660 {
661 id: "mobile-app",
662 title: "Mobile app",
663 to: "/settings/about",
664 searchTerms: ["phone tablet iPhone iPad iOS Android App Store Google Play QR"],
665 },
666 {
667 id: "privacy-policy",
668 title: "Privacy policy",
669 to: "/settings/about",
670 searchTerms: ["telemetry analytics usage data tracking legal opt out"],
671 },
672 {
673 id: "telemetry-export",
674 title: "OpenTelemetry export",
675 to: "/settings/diagnostics",
676 targetId: "telemetry-export",
677 scope: "environment",
678 searchTerms: ["OTel OTLP telemetry export endpoints logs traces metrics Grafana"],
679 },
680 {
681 id: "diagnostics",
682 title: "Diagnostics",
683 to: "/settings/maintenance",
684 searchTerms: ["logs traces processes resource history failures spans cpu memory"],
685 },
686 {
687 id: "open-source-licenses",
688 title: "Open source licenses",
689 to: "/settings/about",
690 },
691 {
692 id: "legacy-plan-mode",
693 title: "Plan mode (legacy)",
694 to: "/settings/labs",
695 searchTerms: ["build plan composer old"],
696 },
697 {
698 id: "legacy-context-window-indicator",
699 title: "Context window indicator (legacy)",
700 to: "/settings/labs",
701 searchTerms: ["composer meter usage tokens circle old"],
702 },
703 {
704 id: "legacy-sidebar",
705 title: "Sidebar (legacy)",
706 to: "/settings/labs",
707 searchTerms: ["project thread tree old flat list"],
708 },
709 {
710 id: "keybindings",
711 title: "Keybindings",
712 to: "/settings/keybindings",
713 searchTerms: ["keyboard shortcuts hotkeys commands bindings json"],
714 },
715 ...KEYBINDING_SEARCH_ITEMS,
716 {
717 id: "snap-shot-enabled",
718 title: "SnapShots",
719 searchTerms: ["window capture screenshot"],
720 to: "/settings/snap-shot",
721 },
722 {
723 id: "snap-shot-accessibility",
724 title: "Include app text",
725 to: "/settings/snap-shot",
726 targetId: "snap-shot-enabled",
727 searchTerms: [
728 "capture accessibility data text UI structure elements privacy omit agent context",
729 ],
730 },
731 {
732 id: "snap-shot-shortcut",
733 title: "Capture shortcut",
734 to: "/settings/snap-shot",
735 targetId: "snap-shot-enabled",
736 },
737 {
738 id: "snap-shot-sound",
739 title: "Capture sound",
740 to: "/settings/snap-shot",
741 targetId: "snap-shot-enabled",
742 },
743 {
744 id: "snap-shot-flash",
745 title: "Capture flash",
746 to: "/settings/snap-shot",
747 targetId: "snap-shot-enabled",
748 },
749 {
750 id: "snap-shot-animations",
751 title: "Capture animations",
752 to: "/settings/snap-shot",
753 targetId: "snap-shot-enabled",
754 },
755 {
756 id: "providers",
757 title: "Providers",
758 to: "/settings/providers",
759 searchTerms: [
760 "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",
761 ],
762 },
763 {
764 id: "usage-providers",
765 title: "Usage providers",
766 to: "/settings/providers",
767 searchTerms: [
768 "usage sources CLIProxyAPI CLI proxy hub quota subscription limits management key add remove",
769 ],
770 providerSettingsOnly: true,
771 },
772 {
773 id: "cursor-keychain-usage",
774 title: "Cursor account usage",
775 to: "/settings/providers",
776 searchTerms: ["cursor macOS keychain usage tokens cost limits permission"],
777 providerSettingsOnly: true,
778 macProviderSettingsOnly: true,
779 },
780 {
781 id: "provider-health-check-interval",
782 title: "Health check interval",
783 to: "/settings/providers",
784 searchTerms: ["refresh availability versions auth state models background probes seconds off"],
785 providerSettingsOnly: true,
786 },
787 {
788 id: "agent-browser-access",
789 title: "Agent browser access",
790 to: "/settings/browser",
791 scope: "project-defaults",
792 searchTerms: ["allow disable enable open drive preview tools sessions project override"],
793 },
794 {
795 id: "device-hosts",
796 title: "Device hosts",
797 to: "/settings/devices",
798 searchTerms: ["ssh remote simulator emulator ios android mac mini identity key connection"],
799 },
800 {
801 id: "agent-device-access",
802 title: "Agent device access",
803 to: "/settings/devices",
804 targetId: "devices",
805 searchTerms: ["allow simulator emulator ios android drive tools sessions"],
806 },
807 {
808 id: "device-hub",
809 title: "Device hub",
810 to: "/settings/devices",
811 targetId: "devices",
812 searchTerms: ["simulator emulator ios android install start"],
813 },
814 {
815 id: "device-platform-support",
816 title: "Simulator support",
817 to: "/settings/devices",
818 targetId: "devices",
819 searchTerms: ["xcode android studio sdk avd runtime"],
820 },
821 {
822 id: "browser-profiles",
823 title: "Browser profiles",
824 to: "/settings/browser",
825 targetId: "browser",
826 },
827 {
828 id: "browser-default-profile",
829 title: "Default browser profile",
830 to: "/settings/browser",
831 targetId: "browser-profiles",
832 },
833 {
834 id: "browser-default-viewport",
835 title: "Default browser viewport",
836 to: "/settings/browser",
837 searchTerms: ["preview size width height device desktop mobile rotate"],
838 },
839 {
840 id: "browser-default-zoom",
841 title: "Default browser zoom",
842 to: "/settings/browser",
843 searchTerms: ["preview page scale tabs percent"],
844 },
845 {
846 id: "browser-default-appearance",
847 title: "Default browser appearance",
848 to: "/settings/browser",
849 searchTerms: ["preview color scheme light dark system os"],
850 },
851 {
852 id: "browser-recording-frame-rate",
853 title: "Browser recording frame rate",
854 to: "/settings/browser",
855 },
856 {
857 id: "browser-recording-key-presses",
858 title: "Show key presses in recordings",
859 to: "/settings/browser",
860 searchTerms: ["browser preview keyboard shortcuts keystrokes overlay capture"],
861 },
862 {
863 id: "browser-recording-mouse-presses",
864 title: "Show mouse presses in recordings",
865 to: "/settings/browser",
866 searchTerms: ["browser preview clicks buttons drag overlay capture"],
867 },
868 {
869 id: "browser-link-target",
870 title: "Open links in",
871 to: "/settings/browser",
872 searchTerms: ["links default browser in-app browser external open"],
873 },
874 {
875 id: "browser-search-engine",
876 title: "Search engine",
877 to: "/settings/browser",
878 searchTerms: ["address bar duckduckgo google bing brave kagi ecosia custom"],
879 },
880 {
881 id: "pull-request-links-open-in-app",
882 title: "Open pull requests in T3 Code",
883 to: "/settings/diffs",
884 searchTerms: [
885 `pr links ${SOURCE_CONTROL_HOST_LABELS} browser external click default pull request view panel`,
886 ],
887 },
888 {
889 id: "browser-auto-show-floating-preview",
890 title: "Auto-show floating preview",
891 to: "/settings/browser",
892 searchTerms: ["agent opens browser device simulator pop into view hide"],
893 },
894 {
895 id: "automatic-pull",
896 title: "Automatically pull",
897 to: "/settings/source-control",
898 scope: "project-defaults",
899 searchTerms: ["auto pull default branch current checkout fast forward upstream"],
900 },
901 {
902 id: "remove-agent-credits-on-merge",
903 title: "Remove agent credits when merging",
904 to: "/settings/source-control",
905 scope: "project-defaults",
906 searchTerms: [
907 `pull request ${SOURCE_CONTROL_HOST_LABELS} squash co-authored-by attribution claude codex generated`,
908 ],
909 },
910 {
911 id: "pull-request-merge-method",
912 title: "Default merge method",
913 to: "/settings/source-control",
914 scope: "project-defaults",
915 searchTerms: ["pull request merge squash rebase last selected"],
916 },
917 {
918 id: "source-control",
919 title: "Source control",
920 to: "/settings/source-control",
921 scope: "environment-defaults",
922 searchTerms: [
923 `version control git ${SOURCE_CONTROL_HOST_TERMS} hosting integrations credentials scan server environment`,
924 ],
925 },
926 {
927 id: "git-fetch-interval",
928 title: "Git fetch interval",
929 to: "/settings/maintenance",
930 targetId: "background-activity",
931 searchTerms: [
932 "automatic remote branch refresh background credentials security keys seconds off",
933 ],
934 environmentOnly: true,
935 scope: "environment-defaults",
936 },
937 {
938 id: "worktree-branch-naming",
939 title: "Worktree branch naming",
940 to: "/settings/worktrees",
941 searchTerms: ["static semantic prefix custom prompt instructions feat fix refactor chore"],
942 environmentOnly: true,
943 scope: "project-defaults",
944 },
945 ...sourceControlHostSearchItems(sourceControlClients.definitions),
946 {
947 id: "source-control-writing-style",
948 title: "Source control writing style",
949 to: "/settings/source-control",
950 searchTerms: [
951 "repository conventions conventional commits custom instructions change descriptions request titles",
952 ],
953 environmentOnly: true,
954 },
955 {
956 id: "follow-change-request-templates",
957 title: "Follow change request templates",
958 to: "/settings/source-control",
959 searchTerms: ["repository pr pull request description structure"],
960 environmentOnly: true,
961 },
962 {
963 id: "source-control-writer-model",
964 title: "Source control writer model",
965 to: "/settings/source-control",
966 searchTerms: [
967 "override generated commit change request pr titles descriptions branch bookmark",
968 ],
969 environmentOnly: true,
970 scope: "project-defaults",
971 },
972 {
973 id: "review-guides",
974 title: "Review guides (beta)",
975 to: "/settings/source-control",
976 searchTerms: ["pull request pr guided review guide tour beta experimental"],
977 environmentOnly: true,
978 },
979 {
980 id: "review-guide-model",
981 title: "Review guide model",
982 to: "/settings/source-control",
983 // Hidden until review guides are on, so a search lands on the switch that shows it.
984 targetId: "review-guides",
985 searchTerms: ["pull request pr guided review guide brief maintainer"],
986 environmentOnly: true,
987 scope: "project-defaults",
988 },
989 {
990 id: "review-guide-instructions",
991 title: "Review guide instructions",
992 to: "/settings/source-control",
993 targetId: "review-guides",
994 searchTerms: ["pull request pr guided review guide preferences taste prompt custom"],
995 environmentOnly: true,
996 scope: "project-defaults",
997 },
998 {
999 id: "project-actions",
1000 title: "Actions",
1001 to: "/settings/projects",
1002 searchTerms: ["commands scripts setup run dev server checkout worktree t3.json import"],
1003 },
1004 {
1005 id: "environment-icon",
1006 title: "Environment icon",
1007 to: "/settings/access",
1008 targetId: "connections-environment",
1009 searchTerms: ["machine glyph sidebar mac mini studio laptop desktop server cloud vm"],
1010 },
1011 {
1012 id: "local-environment",
1013 title: "Local environment",
1014 to: "/settings/connections",
1015 searchTerms: ["turn off on disable enable local server agents remote only restart"],
1016 desktopOnly: true,
1017 },
1018 {
1019 id: "network-access",
1020 title: "Network access",
1021 to: "/settings/access",
1022 targetId: "connections-environment",
1023 searchTerms: ["expose backend remote pairing local machine interfaces host restart"],
1024 localBackendManagementOnly: true,
1025 },
1026 {
1027 id: "tailscale-https",
1028 title: "Tailscale HTTPS",
1029 to: "/settings/access",
1030 targetId: "connections-environment",
1031 searchTerms: ["serve magicdns endpoint remote secure network"],
1032 desktopOnly: true,
1033 localBackendManagementOnly: true,
1034 },
1035 {
1036 id: "wsl-backend",
1037 title: "WSL backend",
1038 to: "/settings/access",
1039 searchTerms: [
1040 "windows subsystem linux distro second server projects stop windows backend restart",
1041 ],
1042 desktopOnly: true,
1043 windowsOnly: true,
1044 localBackendManagementOnly: true,
1045 wslAvailableOnly: true,
1046 },
1047 {
1048 id: "t3-connect",
1049 localEnvironmentOnly: true,
1050 title: "T3 Connect",
1051 to: "/settings/access",
1052 targetId: "connections-environment",
1053 searchTerms: ["managed tunnel cloud other devices remote"],
1054 desktopOnly: true,
1055 cloudOnly: true,
1056 },
1057 {
1058 id: "hold-webhooks-while-offline",
1059 localEnvironmentOnly: true,
1060 title: "Hold webhooks while offline",
1061 to: "/settings/access",
1062 targetId: "connections-environment",
1063 searchTerms: ["webhook automations offline queue mailbox t3 connect"],
1064 cloudOnly: true,
1065 managedTunnelOnly: true,
1066 },
1067 {
1068 id: "publish-agent-activity",
1069 localEnvironmentOnly: true,
1070 title: "Publish agent activity",
1071 to: "/settings/access",
1072 targetId: "connections-environment",
1073 searchTerms: ["mobile push notifications live activities cloud tunnel"],
1074 cloudOnly: true,
1075 },
1076 {
1077 id: "connections-environment",
1078 title: "This machine",
1079 to: "/settings/access",
1080 searchTerms: [
1081 "connections server backend local remote access administrative permissions scope pairing links qr code authorized clients sessions revoke endpoint",
1082 ],
1083 },
1084 {
1085 id: "linked-environments",
1086 peerLinksOnly: true,
1087 title: "Linked environments",
1088 to: "/settings/connections",
1089 targetId: "linked-environments",
1090 searchTerms: ["link peer another machine vps agents work there handoff pairing code"],
1091 },
1092 {
1093 id: "remote-environments",
1094 title: "Environments",
1095 to: "/settings/connections",
1096 searchTerms: ["add pair backend host code ssh config agent tunnel saved t3 connect"],
1097 },
1098 {
1099 id: "load-balancing",
1100 title: "Load balancing",
1101 to: "/settings/connections",
1102 searchTerms: [
1103 "automatic machine environment resources cpu memory capacity preference weight shared projects",
1104 ],
1105 },
1106 {
1107 id: "pull-request-routing",
1108 title: "Pull request sharing",
1109 to: "/settings/connections",
1110 searchTerms: [
1111 `pull request routing trusted environments shared credentials permissions read actions source control ${SOURCE_CONTROL_HOST_LABELS}`,
1112 ],
1113 },
1114 {
1115 id: "archive",
1116 title: "Archived threads",
1117 to: "/settings/archived",
1118 searchTerms: ["restore reopen deleted history projects"],
1119 },
1120] as const satisfies ReadonlyArray<SettingsSearchItem>;
1121
1122export type SettingsSearchItemId = (typeof SETTINGS_SEARCH_ITEMS)[number]["id"];
1123
1124const SEARCH_ITEMS_BY_ID = new Map(SETTINGS_SEARCH_ITEMS.map((item) => [item.id, item] as const));
1125
1126const SETTINGS_CATEGORY_SCOPES: Readonly<Record<SettingsPath, SettingsSearchScope | null>> = {
1127 "/settings/diagnostics": "environment",
1128 "/settings/projects": "project",
1129 "/settings/general": null,
1130 "/settings/appearance": null,
1131 "/settings/chat": null,
1132 "/settings/diffs": null,
1133 "/settings/snap-shot": null,
1134 "/settings/keybindings": null,
1135 "/settings/providers": null,
1136 "/settings/threads": null,
1137 "/settings/browser": null,
1138 "/settings/devices": null,
1139 "/settings/source-control": "environment-defaults",
1140 "/settings/worktrees": "project-defaults",
1141 "/settings/connections": "connections",
1142 "/settings/access": "connections",
1143 "/settings/scheduled-tasks": null,
1144 "/settings/maintenance": null,
1145 "/settings/labs": null,
1146 "/settings/about": null,
1147 "/settings/archived": "project-defaults",
1148};
1149
1150const RENAMED_SETTINGS_PATHS: Readonly<Record<string, SettingsPath>> = {
1151 "/settings/integrations": "/settings/browser",
1152 "/settings/storage": "/settings/maintenance",
1153 "/settings/beta": "/settings/labs",
1154};
1155const SPLIT_SETTINGS_PATHS: ReadonlySet<string> = new Set([
1156 "/settings/general",
1157 "/settings/appearance",
1158 "/settings/source-control",
1159 "/settings/connections",
1160 ...Object.keys(RENAMED_SETTINGS_PATHS),
1161]);
1162// Section anchors that moved but are not search results themselves.
1163const MOVED_SECTION_ANCHORS: Readonly<Record<string, SettingsPath>> = {
1164 "authorized-clients": "/settings/access",
1165 "legacy-features": "/settings/labs",
1166 "text-generation": "/settings/threads",
1167 about: "/settings/about",
1168};
1169
1170/** Where an old settings link now lives. Its anchor finds the page its row moved to. */
1171export function movedSettingsPath(pathname: string, hash: string): SettingsPath | null {
1172 if (!SPLIT_SETTINGS_PATHS.has(pathname)) return null;
1173 const items: readonly SettingsSearchItem[] = SETTINGS_SEARCH_ITEMS;
1174 const anchored = hash
1175 ? (items.find((item) => item.id === hash) ?? items.find((item) => item.targetId === hash))
1176 : undefined;
1177 const to =
1178 anchored?.to ?? MOVED_SECTION_ANCHORS[hash] ?? RENAMED_SETTINGS_PATHS[pathname] ?? null;
1179 return to === pathname ? null : to;
1180}
1181
1182export function getSettingsSearchTargetScope(targetId: string) {
1183 const items: readonly SettingsSearchItem[] = SETTINGS_SEARCH_ITEMS;
1184 const item =
1185 items.find((candidate) => candidate.id === targetId) ??
1186 items.find((candidate) => candidate.targetId === targetId);
1187 return item
1188 ? {
1189 title: item.title,
1190 scope: item.scope ?? SETTINGS_CATEGORY_SCOPES[item.to],
1191 ...(item.requiresThreadAutoSettlement ? { requiresThreadAutoSettlement: true } : {}),
1192 }
1193 : null;
1194}
1195
1196interface AutoSettlementSearchEnvironment {
1197 readonly environmentId: EnvironmentId;
1198 readonly connection: { readonly phase: EnvironmentConnectionPhase };
1199 readonly serverConfig: {
1200 readonly environment: {
1201 readonly capabilities: { readonly threadAutoSettlement?: boolean };
1202 };
1203 } | null;
1204}
1205
1206export function getThreadAutoSettlementSearchAvailability(
1207 environments: readonly AutoSettlementSearchEnvironment[],
1208 scope?: Pick<ResolvedSettingsScope, "kind" | "environmentIds">,
1209) {
1210 const connected = environments.filter(
1211 (environment) =>
1212 environment.connection.phase === "connected" && environment.serverConfig !== null,
1213 );
1214 const eligibleEnvironmentIds = connected
1215 .filter(
1216 (environment) =>
1217 environment.serverConfig?.environment.capabilities.threadAutoSettlement === true,
1218 )
1219 .map((environment) => environment.environmentId);
1220 const selected = connected.filter((environment) =>
1221 scope?.environmentIds.includes(environment.environmentId),
1222 );
1223 return {
1224 eligibleEnvironmentIds,
1225 isTargetAvailable:
1226 scope !== undefined &&
1227 scope.kind !== "unavailable" &&
1228 selected.length > 0 &&
1229 selected.every((environment) => eligibleEnvironmentIds.includes(environment.environmentId)),
1230 };
1231}
1232
1233export function isSettingsSearchScopeAvailable(
1234 requiredScope: SettingsSearchScope | null,
1235 scopeKind: ResolvedSettingsScope["kind"],
1236): boolean {
1237 switch (requiredScope) {
1238 case null:
1239 case "connections":
1240 return true;
1241 case "environment":
1242 case "checkout":
1243 return requiredScope === scopeKind;
1244 case "project":
1245 return scopeKind === "project" || scopeKind === "checkout";
1246 case "environment-defaults":
1247 return scopeKind === "environment" || scopeKind === "all";
1248 case "project-defaults":
1249 return (
1250 scopeKind === "environment" ||
1251 scopeKind === "all" ||
1252 scopeKind === "project" ||
1253 scopeKind === "checkout"
1254 );
1255 }
1256}
1257
1258export function searchableSetting(id: SettingsSearchItemId): {
1259 readonly id: string;
1260 readonly title: string;
1261} {
1262 const { id: anchorId, title } = SEARCH_ITEMS_BY_ID.get(id)!;
1263 return { id: anchorId, title };
1264}
1265
1266export function filterAvailableSettingsSearchItems(
1267 availability: SettingsSearchAvailability,
1268): ReadonlyArray<SettingsSearchItem> {
1269 const items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS;
1270 return items.filter(
1271 (item) =>
1272 (!item.cloudOnly || availability.hasCloudPublicConfig) &&
1273 (!item.environmentOnly || availability.hasEnvironment) &&
1274 (!item.providerSettingsOnly || availability.hasProviderSettingsEnvironment) &&
1275 (!item.macProviderSettingsOnly || availability.hasMacProviderSettingsEnvironment) &&
1276 (!item.localBackendManagementOnly || availability.canManageLocalBackend) &&
1277 (!item.localEnvironmentOnly || !availability.localEnvironmentDisabled) &&
1278 (!item.wslAvailableOnly || availability.isWslSettingsRowVisible) &&
1279 (!item.requiresThreadAutoSettlement || availability.hasThreadAutoSettlement) &&
1280 (!item.managedTunnelOnly || availability.managedTunnelActive === true) &&
1281 (!item.peerLinksOnly || availability.hasPeerLinkHost === true),
1282 );
1283}
1284
1285/** The settings that exist on this platform and app channel. */
1286export function settingsForThisPlatform(
1287 items: ReadonlyArray<SettingsSearchItem>,
1288): ReadonlyArray<SettingsSearchItem> {
1289 const platform = typeof navigator === "undefined" ? "" : navigator.platform;
1290 return items.filter(
1291 (item) =>
1292 (isElectron || item.desktopOnly !== true) &&
1293 (!item.releaseChannelOnly || isElectron || HOSTED_APP_CHANNEL !== null) &&
1294 (!item.macOnly || isMacPlatform(platform)) &&
1295 (!item.windowsOnly || isWindowsPlatform(platform)),
1296 );
1297}
1298
1299export function searchSettings(
1300 query: string,
1301 items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS,
1302): ReadonlyArray<SettingsSearchItem> {
1303 const normalizedQuery = normalizeSearchText(query);
1304 if (normalizedQuery.length === 0) return [];
1305 const queryTokens = normalizedQuery.split(" ");
1306
1307 return settingsForThisPlatform(items)
1308 .flatMap((item, index) => {
1309 const title = normalizeSearchText(item.title);
1310 const fields = [
1311 title,
1312 normalizeSearchText(SETTINGS_SECTION_LABELS[item.to]),
1313 ...(item.searchTerms ?? []).map(normalizeSearchText),
1314 ];
1315 if (!queryTokens.every((token) => fields.some((field) => field.includes(token)))) return [];
1316
1317 const exactPhraseField = fields.findIndex((field) => field.includes(normalizedQuery));
1318 const rank =
1319 title === normalizedQuery
1320 ? 5
1321 : title.startsWith(normalizedQuery)
1322 ? 4
1323 : title.includes(normalizedQuery)
1324 ? 3
1325 : queryTokens.every((token) => title.includes(token))
1326 ? 2
1327 : exactPhraseField >= 0
1328 ? 1
1329 : 0;
1330 return [{ item, index, rank }];
1331 })
1332 .toSorted(
1333 (left, right) =>
1334 Number(left.item.secondary ?? false) - Number(right.item.secondary ?? false) ||
1335 right.rank - left.rank ||
1336 left.index - right.index,
1337 )
1338 .map(({ item }) => item);
1339}
1340
1341// These rows only exist with separate fonts on, so a search jump to one turns them on.
1342const ADVANCED_TYPOGRAPHY_TARGET_IDS: ReadonlySet<string> = new Set([
1343 "prompt-font",
1344 "terminal-font",
1345]);
1346
1347export function isAdvancedTypographyTarget(targetId: string): boolean {
1348 return ADVANCED_TYPOGRAPHY_TARGET_IDS.has(targetId);
1349}
1350
1351/**
1352 * Opens the persisted section a search result lives in before jumping to it, so
1353 * its row is mounted to scroll to. The terminal reads the same flag, so it must
1354 * stay on after the jump.
1355 */
1356export function revealSettingsSearchTarget(targetId: string): void {
1357 if (isAdvancedTypographyTarget(targetId)) {
1358 writeLocalStorageValue(TYPOGRAPHY_ADVANCED_STORAGE_KEY, true, false, Schema.Boolean);
1359 }
1360}