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