Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

settingsSearch.ts

1,381 lines42.9 KB

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;
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;
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;
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;
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 });
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: "ghq-clone-layout",
630 title: "Clone into host folders",
631 to: "/settings/threads",
632 scope: "environment-defaults",
633 searchTerms: ["ghq clone destination host owner repository root layout"],
634 },
635 {
636 id: "unpin-confirmation",
637 title: "Unpin confirmation",
638 to: "/settings/general",
639 searchTerms: ["ask before thread pinned section"],
640 },
641 {
642 id: "archive-confirmation",
643 title: "Archive confirmation",
644 to: "/settings/general",
645 searchTerms: ["ask before thread second click inline action"],
646 },
647 {
648 id: "delete-confirmation",
649 title: "Delete confirmation",
650 to: "/settings/general",
651 searchTerms: ["ask before thread chat history"],
652 },
653 {
654 id: "quit-confirmation",
655 title: "Quit shortcut",
656 to: "/settings/general",
657 searchTerms: ["confirmation desktop app exit direct hold double click press twice"],
658 desktopOnly: true,
659 },
660 {
661 id: "text-generation-model",
662 title: "Text generation model",
663 to: "/settings/threads",
664 scope: "project-defaults",
665 searchTerms: ["generated thread titles source control content default provider"],
666 },
667 {
668 id: "thread-title-instructions",
669 title: "Thread title instructions",
670 to: "/settings/threads",
671 scope: "project-defaults",
672 searchTerms: ["generated thread titles prompt custom style naming rename regenerate"],
673 },
674 {
675 id: "app-version",
676 title: "Version",
677 to: "/settings/about",
678 searchTerms: ["about check for updates download install upgrade release"],
679 },
680 {
681 id: "update-track",
682 title: "Update track",
683 to: "/settings/about",
684 searchTerms: ["release channel stable latest nightly prerelease"],
685 releaseChannelOnly: true,
686 },
687 {
688 id: "cli-command",
689 title: "t3 command",
690 to: "/settings/about",
691 searchTerms: ["cli terminal shell path install command line"],
692 desktopOnly: true,
693 },
694 {
695 id: "mobile-app",
696 title: "Mobile app",
697 to: "/settings/about",
698 searchTerms: ["phone tablet iPhone iPad iOS Android App Store Google Play QR"],
699 },
700 {
701 id: "privacy-policy",
702 title: "Privacy policy",
703 to: "/settings/about",
704 searchTerms: ["telemetry analytics usage data tracking legal opt out"],
705 },
706 {
707 id: "telemetry-export",
708 title: "OpenTelemetry export",
709 to: "/settings/diagnostics",
710 targetId: "telemetry-export",
711 scope: "environment",
712 searchTerms: ["OTel OTLP telemetry export endpoints logs traces metrics Grafana"],
713 },
714 {
715 id: "diagnostics",
716 title: "Diagnostics",
717 to: "/settings/maintenance",
718 searchTerms: ["logs traces processes resource history failures spans cpu memory"],
719 },
720 {
721 id: "open-source-licenses",
722 title: "Open source licenses",
723 to: "/settings/about",
724 },
725 {
726 id: "legacy-plan-mode",
727 title: "Plan mode (legacy)",
728 to: "/settings/labs",
729 searchTerms: ["build plan composer old"],
730 },
731 {
732 id: "legacy-context-window-indicator",
733 title: "Context window indicator (legacy)",
734 to: "/settings/labs",
735 searchTerms: ["composer meter usage tokens circle old"],
736 },
737 {
738 id: "keybindings",
739 title: "Keybindings",
740 to: "/settings/keybindings",
741 searchTerms: ["keyboard shortcuts hotkeys commands bindings json"],
742 },
743 ...KEYBINDING_SEARCH_ITEMS,
744 {
745 id: "snap-shot-enabled",
746 title: "SnapShots",
747 searchTerms: ["window capture screenshot"],
748 to: "/settings/snap-shot",
749 },
750 {
751 id: "snap-shot-accessibility",
752 title: "Include app text",
753 to: "/settings/snap-shot",
754 targetId: "snap-shot-enabled",
755 searchTerms: [
756 "capture accessibility data text UI structure elements privacy omit agent context",
757 ],
758 },
759 {
760 id: "snap-shot-shortcut",
761 title: "Capture shortcut",
762 to: "/settings/snap-shot",
763 targetId: "snap-shot-enabled",
764 },
765 {
766 id: "snap-shot-sound",
767 title: "Capture sound",
768 to: "/settings/snap-shot",
769 targetId: "snap-shot-enabled",
770 },
771 {
772 id: "snap-shot-flash",
773 title: "Capture flash",
774 to: "/settings/snap-shot",
775 targetId: "snap-shot-enabled",
776 },
777 {
778 id: "snap-shot-animations",
779 title: "Capture animations",
780 to: "/settings/snap-shot",
781 targetId: "snap-shot-enabled",
782 },
783 {
784 id: "providers",
785 title: "Providers",
786 to: "/settings/providers",
787 searchTerms: [
788 "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",
789 ],
790 },
791 {
792 id: "usage-providers",
793 title: "Usage providers",
794 to: "/settings/providers",
795 searchTerms: [
796 "usage sources CLIProxyAPI CLI proxy hub quota subscription limits management key add remove",
797 ],
798 providerSettingsOnly: true,
799 },
800 {
801 id: "cursor-keychain-usage",
802 title: "Cursor account usage",
803 to: "/settings/providers",
804 searchTerms: ["cursor macOS keychain usage tokens cost limits permission"],
805 providerSettingsOnly: true,
806 macProviderSettingsOnly: true,
807 },
808 {
809 id: "provider-health-check-interval",
810 title: "Health check interval",
811 to: "/settings/providers",
812 searchTerms: ["refresh availability versions auth state models background probes seconds off"],
813 providerSettingsOnly: true,
814 },
815 {
816 id: "agent-browser-access",
817 title: "Agent browser access",
818 to: "/settings/browser",
819 scope: "project-defaults",
820 searchTerms: ["allow disable enable open drive preview tools sessions project override"],
821 },
822 {
823 id: "device-sources",
824 title: "Device sources",
825 to: "/settings/devices",
826 searchTerms: [
827 "device hosts ssh remote mac mini identity key connection eas expo cloud simlock pool gateway local simulators",
828 ],
829 },
830 {
831 id: "agent-device-access",
832 title: "Agents can use devices",
833 to: "/settings/devices",
834 targetId: "devices",
835 searchTerms: ["allow simulator emulator ios android drive tools sessions"],
836 },
837 {
838 id: "device-hub",
839 title: "Use devices",
840 to: "/settings/devices",
841 targetId: "devices",
842 searchTerms: ["device hub simulator emulator ios android install start version"],
843 },
844 {
845 id: "device-platform-support",
846 title: "Local simulators",
847 to: "/settings/devices",
848 targetId: "device-sources",
849 searchTerms: ["simulator support xcode android studio sdk avd runtime"],
850 },
851 {
852 id: "browser-profiles",
853 title: "Browser profiles",
854 to: "/settings/browser",
855 targetId: "browser",
856 },
857 {
858 id: "browser-default-profile",
859 title: "Default browser profile",
860 to: "/settings/browser",
861 targetId: "browser-profiles",
862 },
863 {
864 id: "browser-default-viewport",
865 title: "Default browser viewport",
866 to: "/settings/browser",
867 searchTerms: ["preview size width height device desktop mobile rotate"],
868 },
869 {
870 id: "browser-default-zoom",
871 title: "Default browser zoom",
872 to: "/settings/browser",
873 searchTerms: ["preview page scale tabs percent"],
874 },
875 {
876 id: "browser-default-appearance",
877 title: "Default browser appearance",
878 to: "/settings/browser",
879 searchTerms: ["preview color scheme light dark system os"],
880 },
881 {
882 id: "browser-recording-frame-rate",
883 title: "Browser recording frame rate",
884 to: "/settings/browser",
885 },
886 {
887 id: "browser-recording-key-presses",
888 title: "Show key presses in recordings",
889 to: "/settings/browser",
890 searchTerms: ["browser preview keyboard shortcuts keystrokes overlay capture"],
891 },
892 {
893 id: "browser-recording-mouse-presses",
894 title: "Show mouse presses in recordings",
895 to: "/settings/browser",
896 searchTerms: ["browser preview clicks buttons drag overlay capture"],
897 },
898 {
899 id: "browser-link-target",
900 title: "Open links in",
901 to: "/settings/browser",
902 searchTerms: ["links default browser in-app browser external open"],
903 },
904 {
905 id: "browser-search-engine",
906 title: "Search engine",
907 to: "/settings/browser",
908 searchTerms: ["address bar duckduckgo google bing brave kagi ecosia custom"],
909 },
910 {
911 id: "pull-request-links-open-in-app",
912 title: "Open pull requests in T3 Code",
913 to: "/settings/diffs",
914 searchTerms: [
915 `pr links ${SOURCE_CONTROL_HOST_LABELS} browser external click default pull request view panel`,
916 ],
917 },
918 {
919 id: "browser-auto-show-floating-preview",
920 title: "Auto-show floating preview",
921 to: "/settings/browser",
922 searchTerms: ["agent opens browser device simulator pop into view hide"],
923 },
924 {
925 id: "automatic-pull",
926 title: "Automatically pull",
927 to: "/settings/source-control",
928 scope: "project-defaults",
929 searchTerms: ["auto pull default branch current checkout fast forward upstream"],
930 },
931 {
932 id: "remove-agent-credits-on-merge",
933 title: "Remove agent credits when merging",
934 to: "/settings/source-control",
935 scope: "project-defaults",
936 searchTerms: [
937 `pull request ${SOURCE_CONTROL_HOST_LABELS} squash co-authored-by attribution claude codex generated`,
938 ],
939 },
940 {
941 id: "pull-request-merge-method",
942 title: "Default merge method",
943 to: "/settings/source-control",
944 scope: "project-defaults",
945 searchTerms: ["pull request merge squash rebase last selected"],
946 },
947 {
948 id: "source-control",
949 title: "Source control",
950 to: "/settings/source-control",
951 scope: "environment-defaults",
952 searchTerms: [
953 `version control git ${SOURCE_CONTROL_HOST_TERMS} hosting integrations credentials scan server environment`,
954 ],
955 },
956 {
957 id: "git-fetch-interval",
958 title: "Git fetch interval",
959 to: "/settings/maintenance",
960 targetId: "background-activity",
961 searchTerms: [
962 "automatic remote branch refresh background credentials security keys seconds off",
963 ],
964 environmentOnly: true,
965 scope: "environment-defaults",
966 },
967 {
968 id: "worktree-branch-naming",
969 title: "Worktree branch naming",
970 to: "/settings/worktrees",
971 searchTerms: ["static semantic prefix custom prompt instructions feat fix refactor chore"],
972 environmentOnly: true,
973 scope: "project-defaults",
974 },
975 ...sourceControlHostSearchItems(sourceControlClients.definitions),
976 {
977 id: "source-control-writing-style",
978 title: "Source control writing style",
979 to: "/settings/source-control",
980 searchTerms: [
981 "repository conventions conventional commits custom instructions change descriptions request titles",
982 ],
983 environmentOnly: true,
984 },
985 {
986 id: "follow-change-request-templates",
987 title: "Follow change request templates",
988 to: "/settings/source-control",
989 searchTerms: ["repository pr pull request description structure"],
990 environmentOnly: true,
991 },
992 {
993 id: "source-control-writer-model",
994 title: "Source control writer model",
995 to: "/settings/source-control",
996 searchTerms: [
997 "override generated commit change request pr titles descriptions branch bookmark",
998 ],
999 environmentOnly: true,
1000 scope: "project-defaults",
1001 },
1003 id: "review-guides",
1004 title: "Review guides (beta)",
1005 to: "/settings/source-control",
1006 searchTerms: ["pull request pr guided review guide tour beta experimental"],
1007 environmentOnly: true,
1008 },
1010 id: "review-guide-model",
1011 title: "Review guide model",
1012 to: "/settings/source-control",
1013 // Hidden until review guides are on, so a search lands on the switch that shows it.
1014 targetId: "review-guides",
1015 searchTerms: ["pull request pr guided review guide brief maintainer"],
1016 environmentOnly: true,
1017 scope: "project-defaults",
1018 },
1020 id: "review-guide-instructions",
1021 title: "Review guide instructions",
1022 to: "/settings/source-control",
1023 targetId: "review-guides",
1024 searchTerms: ["pull request pr guided review guide preferences taste prompt custom"],
1025 environmentOnly: true,
1026 scope: "project-defaults",
1027 },
1029 id: "project-actions",
1030 title: "Actions",
1031 to: "/settings/projects",
1032 searchTerms: ["commands scripts setup run dev server checkout worktree t3.json import"],
1033 },
1035 id: "environment-icon",
1036 title: "Environment icon",
1037 to: "/settings/access",
1038 targetId: "connections-environment",
1039 searchTerms: ["machine glyph sidebar mac mini studio laptop desktop server cloud vm"],
1040 },
1042 id: "local-environment",
1043 title: "Local environment",
1044 to: "/settings/connections",
1045 searchTerms: ["turn off on disable enable local server agents remote only restart"],
1046 desktopOnly: true,
1047 },
1049 id: "network-access",
1050 title: "Network access",
1051 to: "/settings/access",
1052 targetId: "connections-environment",
1053 searchTerms: ["expose backend remote pairing local machine interfaces host restart"],
1054 localBackendManagementOnly: true,
1055 },
1057 id: "tailscale-https",
1058 title: "Tailscale HTTPS",
1059 to: "/settings/access",
1060 targetId: "connections-environment",
1061 searchTerms: ["serve magicdns endpoint remote secure network"],
1062 desktopOnly: true,
1063 localBackendManagementOnly: true,
1064 },
1066 id: "wsl-backend",
1067 title: "WSL backend",
1068 to: "/settings/access",
1069 searchTerms: [
1070 "windows subsystem linux distro second server projects stop windows backend restart",
1071 ],
1072 desktopOnly: true,
1073 windowsOnly: true,
1074 localBackendManagementOnly: true,
1075 wslAvailableOnly: true,
1076 },
1078 id: "t3-connect",
1079 localEnvironmentOnly: true,
1080 title: "T3 Connect",
1081 to: "/settings/access",
1082 targetId: "connections-environment",
1083 searchTerms: ["managed tunnel cloud other devices remote tunnels limit t3 chat"],
1084 desktopOnly: true,
1085 cloudOnly: true,
1086 },
1088 id: "hold-webhooks-while-offline",
1089 localEnvironmentOnly: true,
1090 title: "Hold webhooks while offline",
1091 to: "/settings/access",
1092 targetId: "connections-environment",
1093 searchTerms: ["webhook automations offline queue mailbox t3 connect"],
1094 cloudOnly: true,
1095 managedTunnelOnly: true,
1096 },
1098 id: "publish-agent-activity",
1099 localEnvironmentOnly: true,
1100 title: "Publish agent activity",
1101 to: "/settings/access",
1102 targetId: "connections-environment",
1103 searchTerms: ["mobile push notifications live activities cloud tunnel"],
1104 cloudOnly: true,
1105 },
1107 id: "connections-environment",
1108 title: "This machine",
1109 to: "/settings/access",
1110 searchTerms: [
1111 "connections server backend local remote access administrative permissions scope pairing links qr code authorized clients sessions revoke endpoint",
1112 ],
1113 },
1115 id: "linked-environments",
1116 peerLinksOnly: true,
1117 title: "Linked environments",
1118 to: "/settings/connections",
1119 targetId: "linked-environments",
1120 searchTerms: ["link peer another machine vps agents work there handoff pairing code"],
1121 },
1123 id: "remote-environments",
1124 title: "Environments",
1125 to: "/settings/connections",
1126 searchTerms: ["add pair backend host code ssh config agent tunnel saved t3 connect"],
1127 },
1129 id: "load-balancing",
1130 title: "Load balancing",
1131 to: "/settings/connections",
1132 searchTerms: [
1133 "automatic machine environment resources cpu memory capacity preference weight shared projects",
1134 ],
1135 },
1137 id: "pull-request-routing",
1138 title: "Pull request sharing",
1139 to: "/settings/connections",
1140 searchTerms: [
1141 `pull request routing trusted environments shared credentials permissions read actions source control ${SOURCE_CONTROL_HOST_LABELS}`,
1142 ],
1143 },
1145 id: "archive",
1146 title: "Archived threads",
1147 to: "/settings/archived",
1148 searchTerms: ["restore reopen deleted history projects"],
1149 },
1150] as const satisfies ReadonlyArray<SettingsSearchItem>;
1151​
1152export type SettingsSearchItemId = (typeof SETTINGS_SEARCH_ITEMS)[number]["id"];
1153​
1154const SEARCH_ITEMS_BY_ID = new Map(SETTINGS_SEARCH_ITEMS.map((item) => [item.id, item] as const));
1155​
1156const SETTINGS_CATEGORY_SCOPES: Readonly<Record<SettingsPath, SettingsSearchScope | null>> = {
1157 "/settings/diagnostics": "environment",
1158 "/settings/projects": "project",
1159 "/settings/general": null,
1160 "/settings/appearance": null,
1161 "/settings/chat": null,
1162 "/settings/diffs": null,
1163 "/settings/snap-shot": null,
1164 "/settings/keybindings": null,
1165 "/settings/providers": null,
1166 "/settings/threads": null,
1167 "/settings/browser": null,
1168 "/settings/devices": null,
1169 "/settings/source-control": "environment-defaults",
1170 "/settings/worktrees": "project-defaults",
1171 "/settings/connections": "connections",
1172 "/settings/access": "connections",
1173 "/settings/scheduled-tasks": null,
1174 "/settings/maintenance": null,
1175 "/settings/labs": null,
1176 "/settings/about": null,
1177 "/settings/archived": "project-defaults",
1179​
1180const RENAMED_SETTINGS_PATHS: Readonly<Record<string, SettingsPath>> = {
1181 "/settings/integrations": "/settings/browser",
1182 "/settings/storage": "/settings/maintenance",
1183 "/settings/beta": "/settings/labs",
1185const SPLIT_SETTINGS_PATHS: ReadonlySet<string> = new Set([
1186 "/settings/general",
1187 "/settings/appearance",
1188 "/settings/source-control",
1189 "/settings/connections",
1190 ...Object.keys(RENAMED_SETTINGS_PATHS),
1191]);
1192// Section anchors that moved but are not search results themselves.
1193const MOVED_SECTION_ANCHORS: Readonly<Record<string, SettingsPath>> = {
1194 "authorized-clients": "/settings/access",
1195 "legacy-features": "/settings/labs",
1196 "text-generation": "/settings/threads",
1197 about: "/settings/about",
1199​
1200/** Where an old settings link now lives. Its anchor finds the page its row moved to. */
1201export function movedSettingsPath(pathname: string, hash: string): SettingsPath | null {
1202 if (!SPLIT_SETTINGS_PATHS.has(pathname)) return null;
1203 const items: readonly SettingsSearchItem[] = SETTINGS_SEARCH_ITEMS;
1204 const anchored = hash
1205 ? (items.find((item) => item.id === hash) ?? items.find((item) => item.targetId === hash))
1206 : undefined;
1207 const to =
1208 anchored?.to ?? MOVED_SECTION_ANCHORS[hash] ?? RENAMED_SETTINGS_PATHS[pathname] ?? null;
1209 return to === pathname ? null : to;
1211​
1212export function getSettingsSearchTargetScope(targetId: string) {
1213 const items: readonly SettingsSearchItem[] = SETTINGS_SEARCH_ITEMS;
1214 const item =
1215 items.find((candidate) => candidate.id === targetId) ??
1216 items.find((candidate) => candidate.targetId === targetId);
1217 return item
1218 ? {
1219 title: item.title,
1220 scope: item.scope ?? SETTINGS_CATEGORY_SCOPES[item.to],
1221 ...(item.requiresThreadAutoSettlement ? { requiresThreadAutoSettlement: true } : {}),
1223 : null;
1225​
1226interface AutoSettlementSearchEnvironment {
1227 readonly environmentId: EnvironmentId;
1228 readonly connection: { readonly phase: EnvironmentConnectionPhase };
1229 readonly serverConfig: object | null;
1231​
1232export function getThreadAutoSettlementSearchAvailability(
1233 environments: readonly AutoSettlementSearchEnvironment[],
1234 scope?: Pick<ResolvedSettingsScope, "kind" | "environmentIds">,
1235) {
1236 const connected = environments.filter(
1237 (environment) =>
1238 environment.connection.phase === "connected" && environment.serverConfig !== null,
1239 );
1240 const eligibleEnvironmentIds = connected.map((environment) => environment.environmentId);
1241 const selected = connected.filter((environment) =>
1242 scope?.environmentIds.includes(environment.environmentId),
1243 );
1244 return {
1245 eligibleEnvironmentIds,
1246 isTargetAvailable:
1247 scope !== undefined &&
1248 scope.kind !== "unavailable" &&
1249 selected.length > 0 &&
1250 selected.every((environment) => eligibleEnvironmentIds.includes(environment.environmentId)),
1251 };
1253​
1254export function isSettingsSearchScopeAvailable(
1255 requiredScope: SettingsSearchScope | null,
1256 scopeKind: ResolvedSettingsScope["kind"],
1257): boolean {
1258 switch (requiredScope) {
1259 case null:
1260 case "connections":
1261 return true;
1262 case "environment":
1263 case "checkout":
1264 return requiredScope === scopeKind;
1265 case "project":
1266 return scopeKind === "project" || scopeKind === "checkout";
1267 case "environment-defaults":
1268 return scopeKind === "environment" || scopeKind === "all";
1269 case "project-defaults":
1270 return (
1271 scopeKind === "environment" ||
1272 scopeKind === "all" ||
1273 scopeKind === "project" ||
1274 scopeKind === "checkout"
1275 );
1278​
1279export function searchableSetting(id: SettingsSearchItemId): {
1280 readonly id: string;
1281 readonly title: string;
1282} {
1283 const { id: anchorId, title } = SEARCH_ITEMS_BY_ID.get(id)!;
1284 return { id: anchorId, title };
1286​
1287export function filterAvailableSettingsSearchItems(
1288 availability: SettingsSearchAvailability,
1289): ReadonlyArray<SettingsSearchItem> {
1290 const items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS;
1291 return items.filter(
1292 (item) =>
1293 (!item.cloudOnly || availability.hasCloudPublicConfig) &&
1294 (!item.environmentOnly || availability.hasEnvironment) &&
1295 (!item.providerSettingsOnly || availability.hasProviderSettingsEnvironment) &&
1296 (!item.macProviderSettingsOnly || availability.hasMacProviderSettingsEnvironment) &&
1297 (!item.localBackendManagementOnly || availability.canManageLocalBackend) &&
1298 (!item.localEnvironmentOnly || !availability.localEnvironmentDisabled) &&
1299 (!item.wslAvailableOnly || availability.isWslSettingsRowVisible) &&
1300 (!item.requiresThreadAutoSettlement || availability.hasThreadAutoSettlement) &&
1301 (!item.managedTunnelOnly || availability.managedTunnelActive === true) &&
1302 (!item.peerLinksOnly || availability.hasPeerLinkHost === true),
1303 );
1305​
1306/** The settings that exist on this platform and app channel. */
1307export function settingsForThisPlatform(
1308 items: ReadonlyArray<SettingsSearchItem>,
1309): ReadonlyArray<SettingsSearchItem> {
1310 const platform = typeof navigator === "undefined" ? "" : navigator.platform;
1311 return items.filter(
1312 (item) =>
1313 (isElectron || item.desktopOnly !== true) &&
1314 (!item.releaseChannelOnly || isElectron || HOSTED_APP_CHANNEL !== null) &&
1315 (!item.macOnly || isMacPlatform(platform)) &&
1316 (!item.windowsOnly || isWindowsPlatform(platform)),
1317 );
1319​
1320export function searchSettings(
1321 query: string,
1322 items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS,
1323): ReadonlyArray<SettingsSearchItem> {
1324 const normalizedQuery = normalizeSearchText(query);
1325 if (normalizedQuery.length === 0) return [];
1326 const queryTokens = normalizedQuery.split(" ");
1327​
1328 return settingsForThisPlatform(items)
1329 .flatMap((item, index) => {
1330 const title = normalizeSearchText(item.title);
1331 const fields = [
1332 title,
1333 normalizeSearchText(SETTINGS_SECTION_LABELS[item.to]),
1334 ...(item.searchTerms ?? []).map(normalizeSearchText),
1335 ];
1336 if (!queryTokens.every((token) => fields.some((field) => field.includes(token)))) return [];
1337​
1338 const exactPhraseField = fields.findIndex((field) => field.includes(normalizedQuery));
1339 const rank =
1340 title === normalizedQuery
1341 ? 5
1342 : title.startsWith(normalizedQuery)
1343 ? 4
1344 : title.includes(normalizedQuery)
1345 ? 3
1346 : queryTokens.every((token) => title.includes(token))
1347 ? 2
1348 : exactPhraseField >= 0
1349 ? 1
1350 : 0;
1351 return [{ item, index, rank }];
1352 })
1353 .toSorted(
1354 (left, right) =>
1355 Number(left.item.secondary ?? false) - Number(right.item.secondary ?? false) ||
1356 right.rank - left.rank ||
1357 left.index - right.index,
1359 .map(({ item }) => item);
1361​
1362// These rows only exist with separate fonts on, so a search jump to one turns them on.
1363const ADVANCED_TYPOGRAPHY_TARGET_IDS: ReadonlySet<string> = new Set([
1364 "prompt-font",
1365 "terminal-font",
1366]);
1367​
1368export function isAdvancedTypographyTarget(targetId: string): boolean {
1369 return ADVANCED_TYPOGRAPHY_TARGET_IDS.has(targetId);
1371​
1372/**
1373 * Opens the persisted section a search result lives in before jumping to it, so
1374 * its row is mounted to scroll to. The terminal reads the same flag, so it must
1375 * stay on after the jump.
1376 */
1377export function revealSettingsSearchTarget(targetId: string): void {
1378 if (isAdvancedTypographyTarget(targetId)) {
1379 writeLocalStorageValue(TYPOGRAPHY_ADVANCED_STORAGE_KEY, true, false, Schema.Boolean);