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

settingsSearch.ts

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