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

settingsSearch.ts

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