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