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