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

settingsSearch.ts

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