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

settingsSearch.ts

1,409 lines43.7 KB

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