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

settingsSearch.ts

1,245 lines38.6 KB

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