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

settingsSearch.ts

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