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

settingsSearch.ts

1,419 lines44.1 KB

1import { HOSTED_APP_CHANNEL } from "~/branding";
2import { isElectron, isSecretsFeatureEnabled } from "~/env";
3import { isMacPlatform, isWindowsPlatform, normalizeSearchText } from "~/lib/utils";
4import { STATIC_KEYBINDING_COMMANDS, type KeybindingCommand } from "@t3tools/contracts";
5import type { EnvironmentId } from "@t3tools/contracts";
6import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
7import {
8 sourceControlClients,
9 type SourceControlDefinition,
10} from "@t3tools/client-runtime/source-control-clients";
11import { DEFAULT_KEYBINDINGS } from "@t3tools/shared/keybindings";
12import * as Schema from "effect/Schema";
13import { TYPOGRAPHY_ADVANCED_STORAGE_KEY } from "../../appearanceFonts";
14import { writeLocalStorageValue } from "../../hooks/useLocalStorage";
15import { commandLabel } from "./KeybindingsSettings.logic";
16import type { ResolvedSettingsScope } from "./settingsScope";
17​
18export type SettingsPath =
19 | "/settings/projects"
20 | "/settings/general"
21 | "/settings/diagnostics"
22 | "/settings/appearance"
23 | "/settings/chat"
24 | "/settings/diffs"
25 | "/settings/keybindings"
26 | "/settings/snap-shot"
27 | "/settings/providers"
28 | "/settings/threads"
29 | "/settings/browser"
30 | "/settings/devices"
31 | "/settings/scheduled-tasks"
32 | "/settings/source-control"
33 | "/settings/worktrees"
34 | "/settings/connections"
35 | "/settings/access"
36 | "/settings/secrets"
37 | "/settings/maintenance"
38 | "/settings/labs"
39 | "/settings/about"
40 | "/settings/archived";
41​
42export type SettingsSearchScope =
43 | "environment"
44 | "environment-defaults"
45 | "project-defaults"
46 | "project"
47 | "checkout"
48 | "connections";
49​
50export interface SettingsSearchItem {
51 readonly id: string;
52 readonly title: string;
53 readonly to: SettingsPath;
54 readonly targetId?: string;
55 readonly searchTerms?: ReadonlyArray<string>;
56 readonly scope?: SettingsSearchScope;
57 readonly desktopOnly?: boolean;
58 readonly macOnly?: boolean;
59 readonly windowsOnly?: boolean;
60 readonly releaseChannelOnly?: boolean;
61 readonly secretsFeatureOnly?: boolean;
62 readonly cloudOnly?: boolean;
63 readonly environmentOnly?: boolean;
64 readonly providerSettingsOnly?: boolean;
65 readonly macProviderSettingsOnly?: boolean;
66 readonly localBackendManagementOnly?: boolean;
67 readonly localEnvironmentOnly?: boolean;
68 readonly wslAvailableOnly?: boolean;
69 readonly managedTunnelOnly?: boolean;
70 readonly peerLinksOnly?: boolean;
71 readonly secondary?: boolean;
72 readonly requiresThreadAutoSettlement?: boolean;
74​
75export interface SettingsSearchAvailability {
76 readonly localEnvironmentDisabled?: boolean;
77 readonly hasCloudPublicConfig: boolean;
78 readonly hasEnvironment: boolean;
79 readonly hasProviderSettingsEnvironment: boolean;
80 readonly hasMacProviderSettingsEnvironment: boolean;
81 readonly canManageLocalBackend: boolean;
82 readonly isWslSettingsRowVisible: boolean;
83 readonly hasThreadAutoSettlement: boolean;
84 readonly managedTunnelActive?: boolean;
85 readonly hasPeerLinkHost?: boolean;
87​
88export const SETTINGS_SECTION_LABELS: Readonly<Record<SettingsPath, string>> = {
89 "/settings/diagnostics": "Diagnostics",
90 "/settings/projects": "Projects",
91 "/settings/general": "General",
92 "/settings/appearance": "Appearance",
93 "/settings/chat": "Chat",
94 "/settings/diffs": "Diffs & pull requests",
95 "/settings/keybindings": "Keybindings",
96 "/settings/snap-shot": "SnapShots",
97 "/settings/providers": "Providers",
98 "/settings/threads": "Threads",
99 "/settings/browser": "Browser",
100 "/settings/devices": "Devices",
101 "/settings/scheduled-tasks": "Scheduled tasks",
102 "/settings/source-control": "Source control",
103 "/settings/worktrees": "Worktrees",
104 "/settings/connections": "Environments",
105 "/settings/access": "Sharing & access",
106 "/settings/secrets": "Secrets",
107 "/settings/maintenance": "Maintenance",
108 "/settings/labs": "Labs",
109 "/settings/about": "About",
110 "/settings/archived": "Archive",
111};
112​
113/** Sidebar order. A group without a heading is set apart by space alone. */
114export const SETTINGS_NAV_GROUPS: ReadonlyArray<{
115 readonly heading: string | null;
116 readonly paths: ReadonlyArray<SettingsPath>;
117}> = [
118 {
119 heading: null,
120 paths: [
121 "/settings/general",
122 "/settings/appearance",
123 "/settings/chat",
124 "/settings/diffs",
125 "/settings/keybindings",
126 "/settings/snap-shot",
127 ],
128 },
129 {
130 heading: "Agents",
131 paths: [
132 "/settings/providers",
133 "/settings/threads",
134 "/settings/browser",
135 "/settings/devices",
136 "/settings/scheduled-tasks",
137 ],
138 },
139 {
140 heading: "Code",
141 paths: ["/settings/projects", "/settings/source-control", "/settings/worktrees"],
142 },
143 {
144 heading: "Connections",
145 paths: [
146 "/settings/connections",
147 "/settings/access",
148 ...(isSecretsFeatureEnabled ? (["/settings/secrets"] as const) : []),
149 ],
150 },
151 {
152 heading: null,
153 paths: ["/settings/maintenance", "/settings/labs", "/settings/about", "/settings/archived"],
154 },
155];
156​
157export function keybindingSearchAnchorId<Command extends KeybindingCommand>(command: Command) {
158 return `keybinding-${command}` as const;
160​
161const KEYBINDING_SEARCH_ITEMS = STATIC_KEYBINDING_COMMANDS.toSorted((left, right) =>
162 commandLabel(left).localeCompare(commandLabel(right)),
163).map((command) => {
164 const defaultKeys = DEFAULT_KEYBINDINGS.filter((binding) => binding.command === command).map(
165 (binding) => binding.key,
166 );
167 return {
168 id: keybindingSearchAnchorId(command),
169 title: commandLabel(command),
170 to: "/settings/keybindings" as const,
171 searchTerms: [command, ...defaultKeys],
172 secondary: true,
173 ...(defaultKeys.length === 0 ? { targetId: "keybindings" } : {}),
174 };
175});
176​
177export function sourceControlHostSettingsSearchId(kind: string) {
178 return `source-control-host-${kind}` as const;
180​
181/** Each host's own settings: its accounts and token, or the fields of its settings form. */
182export function sourceControlHostSearchItems(
183 definitions: ReadonlyArray<SourceControlDefinition>,
184): ReadonlyArray<
185 SettingsSearchItem & { readonly id: ReturnType<typeof sourceControlHostSettingsSearchId> }
186> {
187 return definitions.flatMap((definition) => {
188 if (!definition.settings) return [];
189 const names = [definition.label, ...(definition.searchKeywords ?? [])].join(" ");
190 const { credentials } = definition;
191 return [
192 {
193 id: sourceControlHostSettingsSearchId(definition.kind),
194 title: credentials
195 ? `${definition.label} accounts and token`
196 : `${definition.label} credentials`,
197 to: "/settings/source-control" as const,
198 searchTerms: [
199 credentials
200 ? `${names} ${credentials.cliName} account login user host switch multiple accounts disable sign in token personal access token pat api key credential`
201 : `${names} ${Object.keys(definition.settings.fields).join(" ")} token credentials sign in`,
202 ],
203 environmentOnly: true,
204 scope: "environment-defaults" as const,
205 },
206 ];
207 });
209​
210/** For settings that apply to every host. */
211const SOURCE_CONTROL_HOST_LABELS = sourceControlClients.definitions
212 .map((definition) => definition.label)
213 .join(" ");
214const SOURCE_CONTROL_HOST_TERMS = sourceControlClients.definitions
215 .flatMap((definition) => [definition.label, ...(definition.searchKeywords ?? [])])
216 .join(" ");
217​
218export const SETTINGS_SEARCH_ITEMS = [
219 {
220 id: "storage-worktree-keep-when",
221 targetId: "storage-worktrees",
222 title: "Keep worktrees with local changes",
223 to: "/settings/worktrees",
224 scope: "project-defaults",
225 searchTerms: [
226 "any local files uncommitted changes edited tracked files ignored env build output cleanup",
227 ],
228 },
229 {
230 id: "storage-delete-now",
231 title: "Delete now",
232 to: "/settings/maintenance",
233 scope: "environment-defaults",
234 searchTerms: ["storage cleanup run now results report removed kept failed"],
235 },
236 {
237 id: "storage-worktrees",
238 title: "Worktree cleanup",
239 to: "/settings/worktrees",
240 scope: "project-defaults",
241 searchTerms: [
242 "disk storage 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: ["installed cli versions newer available codex claude cursor grok fx opencode"],
608 scope: "environment-defaults",
609 },
610 {
611 id: "continue-threads-after-server-update",
612 title: "Continue threads after restarts",
613 to: "/settings/maintenance",
614 scope: "project-defaults",
615 searchTerms: [
616 "resume running active interrupted work restart reboot machine crash desktop update automatically",
617 ],
618 },
619 {
620 id: "background-activity",
621 title: "Background activity",
622 to: "/settings/maintenance",
623 scope: "environment-defaults",
624 searchTerms: [
625 "balanced performance battery saver advanced git fetch provider health refresh host power monitor idle policy",
626 ],
627 },
628 {
629 id: "new-threads",
630 title: "New threads",
631 to: "/settings/threads",
632 scope: "project-defaults",
633 searchTerms: ["default workspace mode draft local worktree"],
634 },
635 {
636 id: "worktree-submodules",
637 title: "Submodules",
638 to: "/settings/worktrees",
639 scope: "project-defaults",
640 searchTerms: ["git submodule init recursive top-level none worktree t3.json"],
641 },
642 {
643 id: "start-from-origin",
644 title: "Start from remote",
645 to: "/settings/worktrees",
646 scope: "project-defaults",
647 searchTerms: ["new worktrees start remote origin latest fetched branch local"],
648 },
649 {
650 id: "add-project-starts-in",
651 title: "Add project starts in",
652 to: "/settings/threads",
653 scope: "environment-defaults",
654 searchTerms: ["base directory folder browser path home"],
655 },
656 {
657 id: "unpin-confirmation",
658 title: "Unpin confirmation",
659 to: "/settings/general",
660 searchTerms: ["ask before thread pinned section"],
661 },
662 {
663 id: "archive-confirmation",
664 title: "Archive confirmation",
665 to: "/settings/general",
666 searchTerms: ["ask before thread second click inline action"],
667 },
668 {
669 id: "delete-confirmation",
670 title: "Delete confirmation",
671 to: "/settings/general",
672 searchTerms: ["ask before thread chat history"],
673 },
674 {
675 id: "quit-confirmation",
676 title: "Quit shortcut",
677 to: "/settings/general",
678 searchTerms: ["confirmation desktop app exit direct hold double click press twice"],
679 desktopOnly: true,
680 },
681 {
682 id: "text-generation-model",
683 title: "Text generation model",
684 to: "/settings/threads",
685 scope: "project-defaults",
686 searchTerms: ["generated thread titles source control content default provider"],
687 },
688 {
689 id: "thread-title-instructions",
690 title: "Thread title instructions",
691 to: "/settings/threads",
692 scope: "project-defaults",
693 searchTerms: ["generated thread titles prompt custom style naming rename regenerate"],
694 },
695 {
696 id: "app-version",
697 title: "Version",
698 to: "/settings/about",
699 searchTerms: ["about check for updates download install upgrade release"],
700 },
701 {
702 id: "update-track",
703 title: "Update track",
704 to: "/settings/about",
705 searchTerms: ["release channel stable latest nightly prerelease"],
706 releaseChannelOnly: true,
707 },
708 {
709 id: "cli-command",
710 title: "t3 command",
711 to: "/settings/about",
712 searchTerms: ["cli terminal shell path install command line"],
713 desktopOnly: true,
714 },
715 {
716 id: "mobile-app",
717 title: "Mobile app",
718 to: "/settings/about",
719 searchTerms: ["phone tablet iPhone iPad iOS Android App Store Google Play QR"],
720 },
721 {
722 id: "privacy-policy",
723 title: "Privacy policy",
724 to: "/settings/about",
725 searchTerms: ["telemetry analytics usage data tracking legal opt out"],
726 },
727 {
728 id: "telemetry-export",
729 title: "OpenTelemetry export",
730 to: "/settings/diagnostics",
731 targetId: "telemetry-export",
732 scope: "environment",
733 searchTerms: ["OTel OTLP telemetry export endpoints logs traces metrics Grafana"],
734 },
735 {
736 id: "diagnostics",
737 title: "Diagnostics",
738 to: "/settings/maintenance",
739 searchTerms: ["logs traces processes resource history failures spans cpu memory"],
740 },
741 {
742 id: "open-source-licenses",
743 title: "Open source licenses",
744 to: "/settings/about",
745 },
746 {
747 id: "legacy-plan-mode",
748 title: "Plan mode (legacy)",
749 to: "/settings/labs",
750 searchTerms: ["build plan composer old"],
751 },
752 {
753 id: "legacy-context-window-indicator",
754 title: "Context window indicator (legacy)",
755 to: "/settings/labs",
756 searchTerms: ["composer meter usage tokens circle old"],
757 },
758 {
759 id: "keybindings",
760 title: "Keybindings",
761 to: "/settings/keybindings",
762 searchTerms: ["keyboard shortcuts hotkeys commands bindings json"],
763 },
764 ...KEYBINDING_SEARCH_ITEMS,
765 {
766 id: "snap-shot-enabled",
767 title: "SnapShots",
768 searchTerms: ["window capture screenshot"],
769 to: "/settings/snap-shot",
770 },
771 {
772 id: "snap-shot-accessibility",
773 title: "Include app text",
774 to: "/settings/snap-shot",
775 targetId: "snap-shot-enabled",
776 searchTerms: [
777 "capture accessibility data text UI structure elements privacy omit agent context",
778 ],
779 },
780 {
781 id: "snap-shot-shortcut",
782 title: "Capture shortcut",
783 to: "/settings/snap-shot",
784 targetId: "snap-shot-enabled",
785 },
786 {
787 id: "snap-shot-sound",
788 title: "Capture sound",
789 to: "/settings/snap-shot",
790 targetId: "snap-shot-enabled",
791 },
792 {
793 id: "snap-shot-flash",
794 title: "Capture flash",
795 to: "/settings/snap-shot",
796 targetId: "snap-shot-enabled",
797 },
798 {
799 id: "snap-shot-animations",
800 title: "Capture animations",
801 to: "/settings/snap-shot",
802 targetId: "snap-shot-enabled",
803 },
804 {
805 id: "providers",
806 title: "Providers",
807 to: "/settings/providers",
808 searchTerms: [
809 "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 codex_home shadow home endpoint arguments environment variables display name accent color custom favorite hidden auto compact native sessions import resume",
810 ],
811 },
812 {
813 id: "usage-providers",
814 title: "Usage providers",
815 to: "/settings/providers",
816 searchTerms: [
817 "usage sources CLIProxyAPI CLI proxy hub quota subscription limits management key add remove",
818 ],
819 providerSettingsOnly: true,
820 },
821 {
822 id: "cursor-keychain-usage",
823 title: "Cursor account usage",
824 to: "/settings/providers",
825 searchTerms: ["cursor macOS keychain usage tokens cost limits permission"],
826 providerSettingsOnly: true,
827 macProviderSettingsOnly: true,
828 },
829 {
830 id: "provider-health-check-interval",
831 title: "Health check interval",
832 to: "/settings/providers",
833 searchTerms: ["refresh availability versions auth state models background probes seconds off"],
834 providerSettingsOnly: true,
835 },
836 {
837 id: "agent-browser-access",
838 title: "Agent browser access",
839 to: "/settings/browser",
840 scope: "project-defaults",
841 searchTerms: ["allow disable enable open drive preview tools sessions project override"],
842 },
843 {
844 id: "device-sources",
845 title: "Device sources",
846 to: "/settings/devices",
847 searchTerms: [
848 "device hosts ssh remote mac mini identity key connection eas expo cloud simlock pool gateway local simulators",
849 ],
850 },
851 {
852 id: "agent-device-access",
853 title: "Agents can use devices",
854 to: "/settings/devices",
855 targetId: "devices",
856 searchTerms: ["allow simulator emulator ios android drive tools sessions"],
857 },
858 {
859 id: "device-hub",
860 title: "Use devices",
861 to: "/settings/devices",
862 targetId: "devices",
863 searchTerms: ["device hub simulator emulator ios android install start version"],
864 },
865 {
866 id: "device-platform-support",
867 title: "Local simulators",
868 to: "/settings/devices",
869 targetId: "device-sources",
870 searchTerms: ["simulator support xcode android studio sdk avd runtime"],
871 },
872 {
873 id: "browser-profiles",
874 title: "Browser profiles",
875 to: "/settings/browser",
876 targetId: "browser",
877 },
878 {
879 id: "browser-default-profile",
880 title: "Default browser profile",
881 to: "/settings/browser",
882 targetId: "browser-profiles",
883 },
884 {
885 id: "browser-default-viewport",
886 title: "Default browser viewport",
887 to: "/settings/browser",
888 searchTerms: ["preview size width height device desktop mobile rotate"],
889 },
890 {
891 id: "browser-default-zoom",
892 title: "Default browser zoom",
893 to: "/settings/browser",
894 searchTerms: ["preview page scale tabs percent"],
895 },
896 {
897 id: "browser-default-appearance",
898 title: "Default browser appearance",
899 to: "/settings/browser",
900 searchTerms: ["preview color scheme light dark system os"],
901 },
902 {
903 id: "browser-recording-frame-rate",
904 title: "Browser recording frame rate",
905 to: "/settings/browser",
906 },
907 {
908 id: "browser-recording-key-presses",
909 title: "Show key presses in recordings",
910 to: "/settings/browser",
911 searchTerms: ["browser preview keyboard shortcuts keystrokes overlay capture"],
912 },
913 {
914 id: "browser-recording-mouse-presses",
915 title: "Show mouse presses in recordings",
916 to: "/settings/browser",
917 searchTerms: ["browser preview clicks buttons drag overlay capture"],
918 },
919 {
920 id: "browser-link-target",
921 title: "Open links in",
922 to: "/settings/browser",
923 searchTerms: ["links default browser in-app browser external open"],
924 },
925 {
926 id: "browser-search-engine",
927 title: "Search engine",
928 to: "/settings/browser",
929 searchTerms: ["address bar duckduckgo google bing brave kagi ecosia custom url"],
930 },
931 {
932 id: "pull-request-links-open-in-app",
933 title: "Open pull requests in T3 Code",
934 to: "/settings/diffs",
935 searchTerms: [
936 `pr commit links ${SOURCE_CONTROL_HOST_LABELS} browser external click default pull request view panel`,
937 ],
938 },
939 {
940 id: "browser-auto-show-floating-preview",
941 title: "Auto-show floating preview",
942 to: "/settings/browser",
943 searchTerms: ["agent opens browser device simulator pop into view hide"],
944 },
945 {
946 id: "automatic-pull",
947 title: "Automatically pull",
948 to: "/settings/source-control",
949 scope: "project-defaults",
950 searchTerms: ["auto pull default branch current checkout fast forward upstream"],
951 },
952 {
953 id: "remove-agent-credits-on-merge",
954 title: "Remove agent credits when merging",
955 to: "/settings/source-control",
956 scope: "project-defaults",
957 searchTerms: [
958 `pull request ${SOURCE_CONTROL_HOST_LABELS} squash co-authored-by attribution claude codex generated`,
959 ],
960 },
961 {
962 id: "pull-request-merge-method",
963 title: "Default merge method",
964 to: "/settings/source-control",
965 scope: "project-defaults",
966 searchTerms: ["pull request merge squash rebase last selected"],
967 },
968 {
969 id: "source-control",
970 title: "Source control",
971 to: "/settings/source-control",
972 scope: "environment-defaults",
973 searchTerms: [
974 `version control git ${SOURCE_CONTROL_HOST_TERMS} hosting integrations credentials scan server environment`,
975 ],
976 },
977 {
978 id: "git-fetch-interval",
979 title: "Git fetch interval",
980 to: "/settings/maintenance",
981 targetId: "background-activity",
982 searchTerms: [
983 "automatic remote branch refresh background credentials security keys seconds off",
984 ],
985 environmentOnly: true,
986 scope: "environment-defaults",
987 },
988 {
989 id: "worktree-branch-naming",
990 title: "Worktree branch naming",
991 to: "/settings/worktrees",
992 searchTerms: ["static semantic prefix custom prompt instructions feat fix refactor chore"],
993 environmentOnly: true,
994 scope: "project-defaults",
995 },
996 ...sourceControlHostSearchItems(sourceControlClients.definitions),
997 {
998 id: "source-control-writing-style",
999 title: "Source control writing style",
1000 to: "/settings/source-control",
1001 searchTerms: [
1002 "repository conventions conventional commits custom instructions change descriptions request titles",
1003 ],
1004 environmentOnly: true,
1005 },
1007 id: "follow-change-request-templates",
1008 title: "Follow change request templates",
1009 to: "/settings/source-control",
1010 searchTerms: ["repository pr pull request description structure"],
1011 environmentOnly: true,
1012 },
1014 id: "source-control-writer-model",
1015 title: "Source control writer model",
1016 to: "/settings/source-control",
1017 searchTerms: [
1018 "override generated commit change request pr titles descriptions branch bookmark",
1019 ],
1020 environmentOnly: true,
1021 scope: "project-defaults",
1022 },
1024 id: "review-guides",
1025 title: "Review guides (beta)",
1026 to: "/settings/source-control",
1027 searchTerms: ["pull request pr guided review guide tour beta experimental"],
1028 environmentOnly: true,
1029 },
1031 id: "review-guide-model",
1032 title: "Review guide model",
1033 to: "/settings/source-control",
1034 // Hidden until review guides are on, so a search lands on the switch that shows it.
1035 targetId: "review-guides",
1036 searchTerms: ["pull request pr guided review guide brief maintainer"],
1037 environmentOnly: true,
1038 scope: "project-defaults",
1039 },
1041 id: "review-guide-instructions",
1042 title: "Review guide instructions",
1043 to: "/settings/source-control",
1044 targetId: "review-guides",
1045 searchTerms: ["pull request pr guided review guide preferences taste prompt custom"],
1046 environmentOnly: true,
1047 scope: "project-defaults",
1048 },
1050 id: "project-actions",
1051 title: "Actions",
1052 to: "/settings/projects",
1053 searchTerms: ["commands scripts setup run dev server checkout worktree t3.json import"],
1054 },
1056 id: "environment-icon",
1057 title: "Environment icon",
1058 to: "/settings/access",
1059 targetId: "connections-environment",
1060 searchTerms: ["machine glyph sidebar mac mini studio laptop desktop server cloud vm"],
1061 },
1063 id: "local-environment",
1064 title: "Local environment",
1065 to: "/settings/connections",
1066 searchTerms: ["turn off on disable enable local server agents remote only restart"],
1067 desktopOnly: true,
1068 },
1070 id: "network-access",
1071 title: "Network access",
1072 to: "/settings/access",
1073 targetId: "connections-environment",
1074 searchTerms: ["expose backend remote pairing local machine interfaces host restart"],
1075 localBackendManagementOnly: true,
1076 },
1078 id: "tailscale-https",
1079 title: "Tailscale HTTPS",
1080 to: "/settings/access",
1081 targetId: "connections-environment",
1082 searchTerms: ["serve magicdns endpoint remote secure network"],
1083 desktopOnly: true,
1084 localBackendManagementOnly: true,
1085 },
1087 id: "wsl-backend",
1088 title: "WSL backend",
1089 to: "/settings/access",
1090 searchTerms: [
1091 "windows subsystem linux distro second server projects stop windows backend restart wsl only",
1092 ],
1093 desktopOnly: true,
1094 windowsOnly: true,
1095 localBackendManagementOnly: true,
1096 wslAvailableOnly: true,
1097 },
1099 id: "t3-connect",
1100 localEnvironmentOnly: true,
1101 title: "T3 Connect",
1102 to: "/settings/access",
1103 targetId: "connections-environment",
1104 searchTerms: ["managed tunnel cloud other devices remote tunnels limit t3 chat"],
1105 desktopOnly: true,
1106 cloudOnly: true,
1107 },
1109 id: "hold-webhooks-while-offline",
1110 localEnvironmentOnly: true,
1111 title: "Hold webhooks while offline",
1112 to: "/settings/access",
1113 targetId: "connections-environment",
1114 searchTerms: ["webhook automations offline queue mailbox t3 connect"],
1115 cloudOnly: true,
1116 managedTunnelOnly: true,
1117 },
1119 id: "publish-agent-activity",
1120 localEnvironmentOnly: true,
1121 title: "Publish agent activity",
1122 to: "/settings/access",
1123 targetId: "connections-environment",
1124 searchTerms: ["mobile push notifications live activities cloud tunnel"],
1125 cloudOnly: true,
1126 },
1128 id: "connections-environment",
1129 title: "This machine",
1130 to: "/settings/access",
1131 searchTerms: [
1132 "connections server backend local remote access administrative permissions scope pairing links qr code authorized clients sessions revoke endpoint",
1133 ],
1134 },
1136 id: "linked-environments",
1137 peerLinksOnly: true,
1138 title: "Linked environments",
1139 to: "/settings/connections",
1140 targetId: "linked-environments",
1141 searchTerms: ["link peer another machine vps agents work there handoff pairing code"],
1142 },
1144 id: "remote-environments",
1145 title: "Environments",
1146 to: "/settings/connections",
1147 searchTerms: ["add pair backend host code ssh config agent tunnel saved t3 connect"],
1148 },
1150 id: "load-balancing",
1151 title: "Load balancing",
1152 to: "/settings/connections",
1153 searchTerms: [
1154 "automatic machine environment resources cpu memory capacity preference weight shared projects",
1155 ],
1156 },
1158 id: "pull-request-routing",
1159 title: "Pull request sharing",
1160 to: "/settings/connections",
1161 searchTerms: [
1162 `pull request routing trusted environments shared credentials permissions read actions source control ${SOURCE_CONTROL_HOST_LABELS}`,
1163 ],
1164 },
1166 id: "secret-providers",
1167 title: "Secret providers",
1168 to: "/settings/secrets",
1169 searchTerms: ["1password vault credentials api key"],
1170 secretsFeatureOnly: true,
1171 },
1173 id: "secret-providers-add",
1174 title: "Add secret provider",
1175 to: "/settings/secrets",
1176 targetId: "secret-providers",
1177 searchTerms: ["new 1password vault op cli account"],
1178 secretsFeatureOnly: true,
1179 },
1181 id: "archive",
1182 title: "Archived threads",
1183 to: "/settings/archived",
1184 searchTerms: ["restore reopen deleted history projects"],
1185 },
1186] as const satisfies ReadonlyArray<SettingsSearchItem>;
1187​
1188export type SettingsSearchItemId = (typeof SETTINGS_SEARCH_ITEMS)[number]["id"];
1189​
1190const SEARCH_ITEMS_BY_ID = new Map(SETTINGS_SEARCH_ITEMS.map((item) => [item.id, item] as const));
1191​
1192const SETTINGS_CATEGORY_SCOPES: Readonly<Record<SettingsPath, SettingsSearchScope | null>> = {
1193 "/settings/diagnostics": "environment",
1194 "/settings/projects": "project",
1195 "/settings/general": null,
1196 "/settings/appearance": null,
1197 "/settings/chat": null,
1198 "/settings/diffs": null,
1199 "/settings/snap-shot": null,
1200 "/settings/keybindings": null,
1201 "/settings/providers": null,
1202 "/settings/threads": null,
1203 "/settings/browser": null,
1204 "/settings/devices": null,
1205 "/settings/source-control": "environment-defaults",
1206 "/settings/worktrees": "project-defaults",
1207 "/settings/connections": "connections",
1208 "/settings/access": "connections",
1209 "/settings/secrets": null,
1210 "/settings/scheduled-tasks": null,
1211 "/settings/maintenance": null,
1212 "/settings/labs": null,
1213 "/settings/about": null,
1214 "/settings/archived": "project-defaults",
1216​
1217const RENAMED_SETTINGS_PATHS: Readonly<Record<string, SettingsPath>> = {
1218 "/settings/integrations": "/settings/browser",
1219 "/settings/storage": "/settings/maintenance",
1220 "/settings/beta": "/settings/labs",
1222const SPLIT_SETTINGS_PATHS: ReadonlySet<string> = new Set([
1223 "/settings/general",
1224 "/settings/appearance",
1225 "/settings/source-control",
1226 "/settings/connections",
1227 ...Object.keys(RENAMED_SETTINGS_PATHS),
1228]);
1229// Section anchors that moved but are not search results themselves.
1230const MOVED_SECTION_ANCHORS: Readonly<Record<string, SettingsPath>> = {
1231 "authorized-clients": "/settings/access",
1232 "legacy-features": "/settings/labs",
1233 "text-generation": "/settings/threads",
1234 about: "/settings/about",
1236​
1237/** Where an old settings link now lives. Its anchor finds the page its row moved to. */
1238export function movedSettingsPath(pathname: string, hash: string): SettingsPath | null {
1239 if (!SPLIT_SETTINGS_PATHS.has(pathname)) return null;
1240 const items: readonly SettingsSearchItem[] = SETTINGS_SEARCH_ITEMS;
1241 const anchored = hash
1242 ? (items.find((item) => item.id === hash) ?? items.find((item) => item.targetId === hash))
1243 : undefined;
1244 const to =
1245 anchored?.to ?? MOVED_SECTION_ANCHORS[hash] ?? RENAMED_SETTINGS_PATHS[pathname] ?? null;
1246 return to === pathname ? null : to;
1248​
1249export function getSettingsSearchTargetScope(targetId: string) {
1250 const items: readonly SettingsSearchItem[] = SETTINGS_SEARCH_ITEMS;
1251 const item =
1252 items.find((candidate) => candidate.id === targetId) ??
1253 items.find((candidate) => candidate.targetId === targetId);
1254 return item
1255 ? {
1256 title: item.title,
1257 scope: item.scope ?? SETTINGS_CATEGORY_SCOPES[item.to],
1258 ...(item.requiresThreadAutoSettlement ? { requiresThreadAutoSettlement: true } : {}),
1260 : null;
1262​
1263interface AutoSettlementSearchEnvironment {
1264 readonly environmentId: EnvironmentId;
1265 readonly connection: { readonly phase: EnvironmentConnectionPhase };
1266 readonly serverConfig: object | null;
1268​
1269export function getThreadAutoSettlementSearchAvailability(
1270 environments: readonly AutoSettlementSearchEnvironment[],
1271 scope?: Pick<ResolvedSettingsScope, "kind" | "environmentIds">,
1272) {
1273 const connected = environments.filter(
1274 (environment) =>
1275 environment.connection.phase === "connected" && environment.serverConfig !== null,
1276 );
1277 const eligibleEnvironmentIds = connected.map((environment) => environment.environmentId);
1278 const selected = connected.filter((environment) =>
1279 scope?.environmentIds.includes(environment.environmentId),
1280 );
1281 return {
1282 eligibleEnvironmentIds,
1283 isTargetAvailable:
1284 scope !== undefined &&
1285 scope.kind !== "unavailable" &&
1286 selected.length > 0 &&
1287 selected.every((environment) => eligibleEnvironmentIds.includes(environment.environmentId)),
1288 };
1290​
1291export function isSettingsSearchScopeAvailable(
1292 requiredScope: SettingsSearchScope | null,
1293 scopeKind: ResolvedSettingsScope["kind"],
1294): boolean {
1295 switch (requiredScope) {
1296 case null:
1297 case "connections":
1298 return true;
1299 case "environment":
1300 case "checkout":
1301 return requiredScope === scopeKind;
1302 case "project":
1303 return scopeKind === "project" || scopeKind === "checkout";
1304 case "environment-defaults":
1305 return scopeKind === "environment" || scopeKind === "all";
1306 case "project-defaults":
1307 return (
1308 scopeKind === "environment" ||
1309 scopeKind === "all" ||
1310 scopeKind === "project" ||
1311 scopeKind === "checkout"
1312 );
1315​
1316export function searchableSetting(id: SettingsSearchItemId): {
1317 readonly id: string;
1318 readonly title: string;
1319} {
1320 const { id: anchorId, title } = SEARCH_ITEMS_BY_ID.get(id)!;
1321 return { id: anchorId, title };
1323​
1324export function filterAvailableSettingsSearchItems(
1325 availability: SettingsSearchAvailability,
1326): ReadonlyArray<SettingsSearchItem> {
1327 const items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS;
1328 return items.filter(
1329 (item) =>
1330 (!item.cloudOnly || availability.hasCloudPublicConfig) &&
1331 (!item.environmentOnly || availability.hasEnvironment) &&
1332 (!item.providerSettingsOnly || availability.hasProviderSettingsEnvironment) &&
1333 (!item.macProviderSettingsOnly || availability.hasMacProviderSettingsEnvironment) &&
1334 (!item.localBackendManagementOnly || availability.canManageLocalBackend) &&
1335 (!item.localEnvironmentOnly || !availability.localEnvironmentDisabled) &&
1336 (!item.wslAvailableOnly || availability.isWslSettingsRowVisible) &&
1337 (!item.requiresThreadAutoSettlement || availability.hasThreadAutoSettlement) &&
1338 (!item.managedTunnelOnly || availability.managedTunnelActive === true) &&
1339 (!item.peerLinksOnly || availability.hasPeerLinkHost === true),
1340 );
1342​
1343/** The settings that exist on this platform and app channel. */
1344export function settingsForThisPlatform(
1345 items: ReadonlyArray<SettingsSearchItem>,
1346): ReadonlyArray<SettingsSearchItem> {
1347 const platform = typeof navigator === "undefined" ? "" : navigator.platform;
1348 return items.filter(
1349 (item) =>
1350 (isElectron || item.desktopOnly !== true) &&
1351 (!item.releaseChannelOnly || isElectron || HOSTED_APP_CHANNEL !== null) &&
1352 (!item.secretsFeatureOnly || isSecretsFeatureEnabled) &&
1353 (!item.macOnly || isMacPlatform(platform)) &&
1354 (!item.windowsOnly || isWindowsPlatform(platform)),
1355 );
1357​
1358export function searchSettings(
1359 query: string,
1360 items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS,
1361): ReadonlyArray<SettingsSearchItem> {
1362 const normalizedQuery = normalizeSearchText(query);
1363 if (normalizedQuery.length === 0) return [];
1364 const queryTokens = normalizedQuery.split(" ");
1365​
1366 return settingsForThisPlatform(items)
1367 .flatMap((item, index) => {
1368 const title = normalizeSearchText(item.title);
1369 const fields = [
1370 title,
1371 normalizeSearchText(SETTINGS_SECTION_LABELS[item.to]),
1372 ...(item.searchTerms ?? []).map(normalizeSearchText),
1373 ];
1374 if (!queryTokens.every((token) => fields.some((field) => field.includes(token)))) return [];
1375​
1376 const exactPhraseField = fields.findIndex((field) => field.includes(normalizedQuery));
1377 const rank =
1378 title === normalizedQuery
1379 ? 5
1380 : title.startsWith(normalizedQuery)
1381 ? 4
1382 : title.includes(normalizedQuery)
1383 ? 3
1384 : queryTokens.every((token) => title.includes(token))
1385 ? 2
1386 : exactPhraseField >= 0
1387 ? 1
1388 : 0;
1389 return [{ item, index, rank }];
1390 })
1391 .toSorted(
1392 (left, right) =>
1393 Number(left.item.secondary ?? false) - Number(right.item.secondary ?? false) ||
1394 right.rank - left.rank ||
1395 left.index - right.index,
1397 .map(({ item }) => item);
1399​
1400// These rows only exist with separate fonts on, so a search jump to one turns them on.
1401const ADVANCED_TYPOGRAPHY_TARGET_IDS: ReadonlySet<string> = new Set([
1402 "prompt-font",
1403 "terminal-font",
1404]);
1405​
1406export function isAdvancedTypographyTarget(targetId: string): boolean {
1407 return ADVANCED_TYPOGRAPHY_TARGET_IDS.has(targetId);
1409​
1410/**
1411 * Opens the persisted section a search result lives in before jumping to it, so
1412 * its row is mounted to scroll to. The terminal reads the same flag, so it must
1413 * stay on after the jump.
1414 */
1415export function revealSettingsSearchTarget(targetId: string): void {
1416 if (isAdvancedTypographyTarget(targetId)) {
1417 writeLocalStorageValue(TYPOGRAPHY_ADVANCED_STORAGE_KEY, true, false, Schema.Boolean);