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