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

settingsSearch.ts

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