@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 1,726 lines 54.7 KB
Raw
1 import { HOSTED_APP_CHANNEL } from "~/branding";
2 import { isElectron, isSecretsFeatureEnabled } from "~/env";
3 import { isMacPlatform, isWindowsPlatform, normalizeSearchText } from "~/lib/utils";
4 import { STATIC_KEYBINDING_COMMANDS, type KeybindingCommand } from "@t3tools/contracts";
5 import type { EnvironmentId } from "@t3tools/contracts";
6 import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
7 import {
8 sourceControlClients,
9 type SourceControlDefinition,
10 } from "@t3tools/client-runtime/source-control-clients";
11 import { DEFAULT_KEYBINDINGS } from "@t3tools/shared/keybindings";
12 import * as Schema from "effect/Schema";
13 import { decodeMsg, msg, useMessages } from "gt-react";
14 import { TYPOGRAPHY_ADVANCED_STORAGE_KEY } from "../../appearanceFonts";
15 import { writeLocalStorageValue } from "../../hooks/useLocalStorage";
16 import type { MessageResolver } from "../../i18n/messages";
17 import { commandLabel } from "./KeybindingsSettings.logic";
18 import type { ResolvedSettingsScope } from "./settingsScope";
19
20 export type SettingsPath =
21 | "/settings/projects"
22 | "/settings/general"
23 | "/settings/diagnostics"
24 | "/settings/voice"
25 | "/settings/appearance"
26 | "/settings/chat"
27 | "/settings/diffs"
28 | "/settings/keybindings"
29 | "/settings/snap-shot"
30 | "/settings/providers"
31 | "/settings/threads"
32 | "/settings/browser"
33 | "/settings/devices"
34 | "/settings/scheduled-tasks"
35 | "/settings/source-control"
36 | "/settings/worktrees"
37 | "/settings/connections"
38 | "/settings/access"
39 | "/settings/secrets"
40 | "/settings/maintenance"
41 | "/settings/labs"
42 | "/settings/about"
43 | "/settings/archived";
44
45 export type SettingsSearchScope =
46 | "environment"
47 | "environment-defaults"
48 | "project-defaults"
49 | "project"
50 | "checkout"
51 | "connections";
52
53 export interface SettingsSearchItem {
54 readonly id: string;
55 readonly title: string;
56 readonly to: SettingsPath;
57 readonly targetId?: string;
58 readonly searchTerms?: ReadonlyArray<string>;
59 readonly scope?: SettingsSearchScope;
60 readonly desktopOnly?: boolean;
61 readonly macOnly?: boolean;
62 readonly windowsOnly?: boolean;
63 readonly releaseChannelOnly?: boolean;
64 readonly secretsFeatureOnly?: boolean;
65 readonly cloudOnly?: boolean;
66 readonly environmentOnly?: boolean;
67 readonly providerSettingsOnly?: boolean;
68 readonly localBackendManagementOnly?: boolean;
69 readonly localEnvironmentOnly?: boolean;
70 readonly primaryEnvironmentOnly?: boolean;
71 readonly wslAvailableOnly?: boolean;
72 readonly managedTunnelOnly?: boolean;
73 readonly peerLinksOnly?: boolean;
74 readonly fastWorktreeCheckoutOnly?: boolean;
75 readonly textGeneratorsOnly?: boolean;
76 readonly secondary?: boolean;
77 readonly requiresThreadAutoSettlement?: boolean;
78 }
79
80 export interface SettingsSearchAvailability {
81 readonly localEnvironmentDisabled?: boolean;
82 readonly hasCloudPublicConfig: boolean;
83 readonly hasEnvironment: boolean;
84 readonly hasProviderSettingsEnvironment: boolean;
85 readonly canManageLocalBackend: boolean;
86 readonly isWslSettingsRowVisible: boolean;
87 readonly hasThreadAutoSettlement: boolean;
88 readonly managedTunnelActive?: boolean;
89 readonly hasPeerLinkHost?: boolean;
90 readonly hasFastWorktreeCheckoutEnvironment?: boolean;
91 /** An environment without a provider allow-list, which hides text generators. */
92 readonly hasTextGeneratorsEnvironment?: boolean;
93 readonly hasPrimaryEnvironment?: boolean;
94 }
95
96 export const SETTINGS_SECTION_LABELS: Readonly<Record<SettingsPath, string>> = {
97 "/settings/diagnostics": msg("Diagnostics"),
98 "/settings/projects": msg("Projects"),
99 "/settings/general": msg("General"),
100 "/settings/appearance": msg("Appearance"),
101 "/settings/chat": msg("Chat"),
102 "/settings/diffs": msg("Diffs & pull requests"),
103 "/settings/keybindings": msg("Keybindings"),
104 "/settings/snap-shot": msg("SnapShots"),
105 "/settings/providers": msg("Providers"),
106 "/settings/threads": msg("Threads"),
107 "/settings/browser": msg("Browser"),
108 "/settings/devices": msg("Devices"),
109 "/settings/scheduled-tasks": msg("Scheduled tasks"),
110 "/settings/source-control": msg("Source control & issues"),
111 "/settings/worktrees": msg("Worktrees"),
112 "/settings/connections": msg("Environments"),
113 "/settings/access": msg("Sharing & access"),
114 "/settings/secrets": msg("Secrets"),
115 "/settings/maintenance": msg("Maintenance"),
116 "/settings/labs": msg("Labs"),
117 "/settings/about": msg("About"),
118 "/settings/voice": msg("Voice"),
119 "/settings/archived": msg("Archive"),
120 };
121
122 /** Sidebar labels; an entry of its own lets a translator shorten one below its page title. */
123 export const SETTINGS_NAV_LABELS: Readonly<Record<SettingsPath, string>> = {
124 ...SETTINGS_SECTION_LABELS,
125 "/settings/source-control": msg("Source control & issues", {
126 $context: "settings navigation item",
127 }),
128 "/settings/access": msg("Sharing & access", { $context: "settings navigation item" }),
129 };
130
131 /** Sidebar order. A group with a hidden heading is set apart on screen by space alone. */
132 export const SETTINGS_NAV_GROUPS: ReadonlyArray<{
133 readonly heading: string;
134 readonly headingHidden?: true;
135 readonly paths: ReadonlyArray<SettingsPath>;
136 }> = [
137 {
138 heading: msg("Preferences"),
139 headingHidden: true,
140 paths: [
141 "/settings/general",
142 "/settings/appearance",
143 "/settings/chat",
144 "/settings/diffs",
145 "/settings/keybindings",
146 "/settings/voice",
147 "/settings/snap-shot",
148 ],
149 },
150 {
151 heading: msg("Agents"),
152 paths: [
153 "/settings/providers",
154 "/settings/threads",
155 "/settings/browser",
156 "/settings/devices",
157 "/settings/scheduled-tasks",
158 ],
159 },
160 {
161 heading: msg("Code"),
162 paths: ["/settings/projects", "/settings/source-control", "/settings/worktrees"],
163 },
164 {
165 heading: msg("Connections"),
166 paths: [
167 "/settings/connections",
168 "/settings/access",
169 ...(isSecretsFeatureEnabled ? (["/settings/secrets"] as const) : []),
170 ],
171 },
172 {
173 heading: msg("More"),
174 headingHidden: true,
175 paths: ["/settings/maintenance", "/settings/labs", "/settings/about", "/settings/archived"],
176 },
177 ];
178
179 export function keybindingSearchAnchorId<Command extends KeybindingCommand>(command: Command) {
180 return `keybinding-${command}` as const;
181 }
182
183 const untranslated = ((message) => message) as MessageResolver;
184
185 const KEYBINDING_SEARCH_ITEMS = STATIC_KEYBINDING_COMMANDS.toSorted((left, right) =>
186 commandLabel(left).localeCompare(commandLabel(right)),
187 ).map((command) => {
188 const defaultKeys = DEFAULT_KEYBINDINGS.filter((binding) => binding.command === command).map(
189 (binding) => binding.key,
190 );
191 return {
192 id: keybindingSearchAnchorId(command),
193 title: commandLabel(command, untranslated),
194 to: "/settings/keybindings" as const,
195 searchTerms: [command, ...defaultKeys],
196 secondary: true,
197 ...(defaultKeys.length === 0 ? { targetId: "keybindings" } : {}),
198 };
199 });
200
201 export function sourceControlHostSettingsSearchId(kind: string) {
202 return `source-control-host-${kind}` as const;
203 }
204
205 /** Each host's own settings: its accounts and token, or the fields of its settings form. */
206 export function sourceControlHostSearchItems(
207 definitions: ReadonlyArray<SourceControlDefinition>,
208 ): ReadonlyArray<
209 SettingsSearchItem & { readonly id: ReturnType<typeof sourceControlHostSettingsSearchId> }
210 > {
211 return definitions.flatMap((definition) => {
212 if (!definition.settings) return [];
213 const names = [definition.label, ...(definition.searchKeywords ?? [])].join(" ");
214 const { credentials } = definition;
215 return [
216 {
217 id: sourceControlHostSettingsSearchId(definition.kind),
218 title: credentials
219 ? msg("{label} accounts and token", { label: definition.label })
220 : msg("{label} credentials", { label: definition.label }),
221 to: "/settings/source-control" as const,
222 searchTerms: [
223 credentials
224 ? `${names} ${credentials.cliName} account login user host switch multiple accounts disable sign in token personal access token pat api key credential`
225 : `${names} ${Object.keys(definition.settings.fields).join(" ")} token credentials sign in`,
226 ],
227 environmentOnly: true,
228 scope: "environment-defaults" as const,
229 },
230 ];
231 });
232 }
233
234 /** For settings that apply to every host. */
235 const SOURCE_CONTROL_HOST_LABELS = sourceControlClients.definitions
236 .map((definition) => definition.label)
237 .join(" ");
238 const SOURCE_CONTROL_HOST_TERMS = sourceControlClients.definitions
239 .flatMap((definition) => [definition.label, ...(definition.searchKeywords ?? [])])
240 .join(" ");
241
242 export const SETTINGS_SEARCH_ITEMS = [
243 {
244 id: "storage-worktree-keep-when",
245 targetId: "storage-worktrees",
246 title: msg("Keep worktrees with local changes"),
247 to: "/settings/worktrees",
248 scope: "project-defaults",
249 searchTerms: [
250 msg(
251 "any local files uncommitted changes edited tracked files ignored env build output cleanup",
252 ),
253 ],
254 },
255 {
256 id: "storage-delete-now",
257 title: msg("Delete now"),
258 to: "/settings/maintenance",
259 scope: "environment-defaults",
260 searchTerms: [msg("storage cleanup run now results report removed kept failed")],
261 },
262 {
263 id: "storage-worktrees",
264 title: msg("Worktree cleanup"),
265 to: "/settings/worktrees",
266 scope: "project-defaults",
267 searchTerms: [
268 msg(
269 "disk storage automatic delete deleted archived threads old inactive merged settled unchanged worktrees retention days project inherit off custom",
270 ),
271 ],
272 },
273 {
274 id: "storage-worktrees-location",
275 title: msg("Worktree location"),
276 to: "/settings/worktrees",
277 scope: "environment-defaults",
278 searchTerms: [msg("worktree location folder directory path drive external disk")],
279 },
280 {
281 id: "storage-artifacts",
282 title: msg("Artifacts and logs"),
283 to: "/settings/maintenance",
284 scope: "environment-defaults",
285 searchTerms: [
286 msg(
287 "disk storage delete old browser artifacts screenshots captures rotated logs cleanup retention",
288 ),
289 ],
290 },
291 {
292 id: "project-defaults",
293 title: msg("Project defaults and overrides"),
294 to: "/settings/threads",
295 scope: "project-defaults",
296 searchTerms: [msg("model workspace environments projects inheritance checkout")],
297 },
298 {
299 id: "project-overview",
300 title: msg("Project overview"),
301 to: "/settings/projects",
302 searchTerms: [msg("name icon emoji image checkout remove delete")],
303 },
304 {
305 id: "default-model",
306 title: msg("Default model"),
307 to: "/settings/threads",
308 scope: "project-defaults",
309 searchTerms: [msg("new thread project provider reasoning effort")],
310 },
311 {
312 id: "fallback-model",
313 title: msg("Fallback model"),
314 to: "/settings/threads",
315 scope: "environment-defaults",
316 searchTerms: [msg("fallback agent provider out of usage new threads")],
317 environmentOnly: true,
318 },
319 {
320 id: "default-permissions",
321 title: msg("Permissions"),
322 to: "/settings/threads",
323 scope: "project-defaults",
324 searchTerms: [
325 msg("new thread default runtime mode supervised approvals auto accept edits full access"),
326 ],
327 },
328 {
329 id: "color-scheme",
330 title: msg("Color scheme"),
331 to: "/settings/appearance",
332 searchTerms: [msg("appearance light dark system mode")],
333 targetId: "appearance",
334 },
335 {
336 id: "theme",
337 title: msg("Themes"),
338 to: "/settings/appearance",
339 searchTerms: [msg("appearance colors palette custom import")],
340 targetId: "appearance",
341 },
342 {
343 // Prefixed because the slider control already owns the `appearance-contrast` id.
344 id: "setting-appearance-contrast",
345 title: msg("Contrast"),
346 to: "/settings/appearance",
347 searchTerms: [msg("colors borders interface")],
348 },
349 {
350 // Prefixed because the slider control already owns the `glass-opacity` id.
351 id: "setting-glass-opacity",
352 title: msg("Glass opacity"),
353 to: "/settings/appearance",
354 searchTerms: [msg("transparent transparency solid menus dialogs composer")],
355 },
356 {
357 id: "diff-color-scheme",
358 title: msg("Diff colors"),
359 to: "/settings/diffs",
360 searchTerms: [
361 msg("red green blue orange additions deletions changes counts palette colorblind"),
362 ],
363 },
364 {
365 id: "chat-width",
366 title: msg("Chat width"),
367 to: "/settings/appearance",
368 searchTerms: [msg("wide full width column layout messages composer monitor")],
369 },
370 {
371 id: "thread-details-items",
372 title: msg("Thread details"),
373 to: "/settings/appearance",
374 searchTerms: [
375 msg(
376 "customize show hide panel card environment editor scripts branch pull request git changes servers automations lineage usage limits 5 hour weekly quota tokens context window",
377 ),
378 ],
379 },
380 {
381 id: "effort-display",
382 title: msg("Effort display"),
383 to: "/settings/appearance",
384 searchTerms: [msg("reasoning effort thinking bars graph word label level composer")],
385 },
386 {
387 id: "math-rendering",
388 title: msg("Render math"),
389 to: "/settings/appearance",
390 searchTerms: [msg("latex tex katex equations formulas markdown")],
391 },
392 {
393 id: "panel-animations",
394 title: msg("Panel animations"),
395 to: "/settings/appearance",
396 },
397 {
398 id: "environment-identification",
399 title: msg("Environment identification"),
400 to: "/settings/appearance",
401 searchTerms: [msg("dev nightly latest channel artwork pill label hide none")],
402 targetId: "appearance-interface",
403 },
404 {
405 id: "interface-font",
406 title: msg("Interface font"),
407 to: "/settings/appearance",
408 searchTerms: [msg("typography family size system sans")],
409 },
410 {
411 id: "prompt-font",
412 title: msg("Prompt font"),
413 to: "/settings/appearance",
414 searchTerms: [msg("typography family size composer input")],
415 },
416 {
417 id: "code-font",
418 title: msg("Code font"),
419 to: "/settings/appearance",
420 searchTerms: [msg("typography family size monospace code blocks diffs file previews")],
421 },
422 {
423 id: "terminal-font",
424 title: msg("Terminal font"),
425 to: "/settings/appearance",
426 searchTerms: [msg("typography family size monospace output")],
427 },
428 {
429 id: "separate-fonts",
430 title: msg("Separate fonts"),
431 to: "/settings/appearance",
432 searchTerms: [msg("typography advanced prompt code terminal font family size individually")],
433 },
434 {
435 id: "font-smoothing",
436 title: msg("Font smoothing"),
437 to: "/settings/appearance",
438 searchTerms: [msg("typography text grayscale anti aliasing macos thin")],
439 macOnly: true,
440 },
441 {
442 id: "word-wrap",
443 title: msg("Word wrap"),
444 to: "/settings/appearance",
445 searchTerms: [msg("long lines code blocks diffs file previews")],
446 },
447 {
448 id: "composer-context",
449 title: msg("Composer context"),
450 to: "/settings/appearance",
451 },
452 {
453 id: "project-grouping",
454 title: msg("Project grouping"),
455 to: "/settings/general",
456 searchTerms: [msg("combine matching repositories environments sidebar")],
457 },
458 {
459 id: "project-order",
460 title: msg("Project order"),
461 to: "/settings/general",
462 searchTerms: [msg("sort projects sidebar manual created recent")],
463 },
464 {
465 id: "snooze-options",
466 title: msg("Snooze options"),
467 to: "/settings/threads",
468 searchTerms: [msg("snooze presets times later tonight tomorrow next week remind")],
469 environmentOnly: true,
470 scope: "environment-defaults",
471 },
472 {
473 id: "snooze-limited-threads",
474 title: msg("Snooze until limits reset"),
475 to: "/settings/threads",
476 searchTerms: [msg("usage quota rate limit reset wake recover continue")],
477 },
478 {
479 id: "auto-resume-limited-threads",
480 title: msg("Resume after usage limits"),
481 to: "/settings/threads",
482 searchTerms: [msg("usage quota rate limit reset recover continue")],
483 },
484 {
485 id: "working-shelf",
486 title: msg("Working section"),
487 to: "/settings/general",
488 searchTerms: [msg("hide fold running monitoring threads inbox sidebar shelf")],
489 },
490 {
491 id: "boring-sidebar",
492 title: msg("Boring sidebar (group by project)"),
493 to: "/settings/labs",
494 searchTerms: [msg("beta folders project tree classic sidebar")],
495 },
496 {
497 id: "boring-sidebar-multiline",
498 title: msg("Two-line folder rows"),
499 to: "/settings/labs",
500 // Shown inside the boring sidebar row only while it is on, so search lands on the parent.
501 targetId: "boring-sidebar",
502 searchTerms: [msg("beta boring sidebar folder rows multiline branch pull request details")],
503 },
504 {
505 id: "tool-call-visibility",
506 title: msg("Tool calls in chat"),
507 to: "/settings/chat",
508 searchTerms: [
509 msg(
510 "hide tool calls commands edits searches work log activity quiet chat zen final answers only",
511 ),
512 ],
513 },
514 {
515 id: "screen-reader-announcements",
516 title: msg("Screen reader announcements"),
517 to: "/settings/chat",
518 searchTerms: [
519 msg(
520 "accessibility a11y screen reader nvda jaws voiceover orca narrator speech announce read aloud messages activity steps",
521 ),
522 ],
523 },
524 {
525 id: "screen-reader-window-title",
526 title: msg("Screen reader window title"),
527 to: "/settings/chat",
528 searchTerms: [
529 msg(
530 "accessibility a11y screen reader nvda jaws voiceover orca narrator window title tab title alt tab taskbar thread status order working approval",
531 ),
532 ],
533 },
534 {
535 id: "guest-links",
536 title: msg("Guest links"),
537 to: "/settings/labs",
538 scope: "environment",
539 searchTerms: [msg("beta share guest invite link teammate watch t3 connect tunnel")],
540 },
541 {
542 id: "linked-environments-beta",
543 title: msg("Linked environments"),
544 to: "/settings/labs",
545 scope: "environment",
546 searchTerms: [msg("beta link another machine vps peer agents work there delegate")],
547 },
548 {
549 id: "prompt-suggestions-beta",
550 title: msg("Suggest next prompt"),
551 to: "/settings/labs",
552 scope: "environment",
553 searchTerms: [msg("beta tab autocomplete predict next message claude codex ghost text")],
554 },
555 {
556 id: "simlock-hosts",
557 title: msg("Simlock device hosts (alpha)"),
558 to: "/settings/labs",
559 scope: "environment",
560 searchTerms: [
561 msg("beta alpha simlock callstack simulator emulator ios android pool lease gateway"),
562 ],
563 },
564 {
565 id: "worktree-fast-checkout",
566 title: msg("Fast worktree checkout"),
567 to: "/settings/labs",
568 scope: "environment",
569 fastWorktreeCheckoutOnly: true,
570 searchTerms: [msg("beta fast worktree checkout clone apfs copy-on-write cache macos speed")],
571 },
572 {
573 id: "voice-transcription-destination",
574 title: msg("Transcribe with"),
575 to: "/settings/voice",
576 searchTerms: [
577 msg(
578 "send microphone audio dictation destination speech voice stt transcription environment machine consent privacy cloud OpenAI Grok OpenRouter",
579 ),
580 ],
581 },
582 {
583 id: "voice-microphone",
584 title: msg("Microphone"),
585 to: "/settings/voice",
586 searchTerms: [msg("mic input audio device order priority preferred")],
587 },
588 {
589 id: "dictation-shortcut-mode",
590 title: msg("Dictation shortcut"),
591 to: "/settings/voice",
592 searchTerms: [msg("speech voice keyboard hotkey hold toggle auto")],
593 },
594 {
595 id: "speech-language",
596 title: msg("Transcription language"),
597 to: "/settings/voice",
598 searchTerms: [msg("speech voice translate english auto detect")],
599 },
600 {
601 id: "speech-dictionary",
602 title: msg("Dictionary"),
603 to: "/settings/voice",
604 searchTerms: [msg("speech voice transcription vocabulary names glossary alias")],
605 },
606 {
607 id: "speech-project-dictionary",
608 title: msg("Project dictionary"),
609 to: "/settings/voice",
610 scope: "project-defaults",
611 searchTerms: [
612 msg("speech voice transcription vocabulary shared dictionary team environment glossary"),
613 ],
614 },
615 {
616 id: "speech-post-processing-model",
617 title: msg("Cleanup model"),
618 to: "/settings/voice",
619 scope: "environment",
620 searchTerms: [msg("speech voice transcript cleanup provider model post-processing")],
621 },
622 {
623 id: "speech-correction-word",
624 title: msg("Correction cue"),
625 to: "/settings/voice",
626 searchTerms: [msg("speech voice cleanup sorry scratch that fix mistake")],
627 },
628 {
629 id: "speech-silence-filtering",
630 title: msg("Silence filtering"),
631 to: "/settings/voice",
632 searchTerms: [msg("voice speech vad silero pauses noise")],
633 },
634 {
635 id: "remove-filler-words",
636 title: msg("Remove filler words"),
637 to: "/settings/voice",
638 searchTerms: [msg("voice speech transcription hesitation um uh cleanup")],
639 },
640 {
641 id: "speech-post-processing",
642 title: msg("Clean up transcripts"),
643 to: "/settings/voice",
644 searchTerms: [msg("speech transcription polish clean provider prompt post-processing")],
645 },
646 {
647 id: "speech-models",
648 title: msg("Transcription models"),
649 to: "/settings/voice",
650 searchTerms: [
651 msg(
652 "speech voice stt download whisper parakeet canary moonshine accuracy speed benchmark languages",
653 ),
654 ],
655 },
656 {
657 id: "speech-hardware",
658 title: msg("Transcription hardware and model unloading"),
659 to: "/settings/voice",
660 searchTerms: [msg("speech voice stt advanced gpu cpu acceleration memory unload idle")],
661 },
662 {
663 id: "speech-streaming",
664 title: msg("Streaming transcription"),
665 to: "/settings/voice",
666 searchTerms: [
667 msg("speech voice stt advanced native live preview batch after stopping slow lag"),
668 ],
669 },
670 {
671 id: "microphone-test",
672 title: msg("Test microphone"),
673 to: "/settings/voice",
674 searchTerms: [msg("test mic audio playback loopback record input level")],
675 },
676 {
677 id: "transcription-test",
678 title: msg("Test model"),
679 to: "/settings/voice",
680 searchTerms: [msg("test voice speech model transcription recognition")],
681 },
682 {
683 id: "auto-settle-inactive-threads",
684 title: msg("Auto-settle inactive threads"),
685 to: "/settings/threads",
686 searchTerms: [msg("sidebar inactivity days no activity automatically")],
687 requiresThreadAutoSettlement: true,
688 scope: "project-defaults",
689 },
690 {
691 id: "compact-idle-threads",
692 title: msg("Compact idle threads"),
693 to: "/settings/providers",
694 scope: "environment-defaults",
695 searchTerms: [msg("claude context compaction idle cache tokens usage summary resume")],
696 },
697 {
698 id: "auto-settle-merged-threads",
699 title: msg("Auto-settle merged threads"),
700 to: "/settings/threads",
701 searchTerms: [msg("pull request merge closed automatically sidebar")],
702 requiresThreadAutoSettlement: true,
703 scope: "project-defaults",
704 },
705 {
706 id: "keep-threads-with-pull-requests",
707 title: msg("Keep threads with a PR"),
708 to: "/settings/threads",
709 targetId: "auto-settle-inactive-threads",
710 searchTerms: [msg("pull request inactivity auto-settle merge close sidebar")],
711 requiresThreadAutoSettlement: true,
712 scope: "project-defaults",
713 },
714 {
715 id: "days-before-auto-settle",
716 title: msg("Days of inactivity before auto-settle"),
717 to: "/settings/threads",
718 targetId: "auto-settle-inactive-threads",
719 searchTerms: [msg("thread timeout activity sidebar")],
720 requiresThreadAutoSettlement: true,
721 scope: "project-defaults",
722 },
723 {
724 id: "thread-notifications",
725 title: msg("Thread notifications"),
726 to: "/settings/general",
727 searchTerms: [msg("notification sound alert completion input approval desktop")],
728 },
729 {
730 id: "in-app-notifications",
731 title: msg("In-app notifications"),
732 to: "/settings/general",
733 searchTerms: [msg("notification toast popup completion input approval failure")],
734 },
735 {
736 id: "language",
737 title: msg("Language"),
738 to: "/settings/general",
739 searchTerms: [
740 msg(
741 "locale translation english deutsch german español spanish français french português portuguese brasil brazilian chinese 中文 japanese 日本語 korean 한국어 russian русский swedish svenska sprache idioma langue 语言 言語 언어 язык",
742 ),
743 ],
744 },
745 {
746 id: "time-format",
747 title: msg("Time format"),
748 to: "/settings/general",
749 searchTerms: [msg("timestamp clock locale system browser os 12 hour 24 hour")],
750 },
751 {
752 id: "response-streaming",
753 title: msg("Response streaming"),
754 to: "/settings/threads",
755 scope: "project-defaults",
756 searchTerms: [msg("output token paragraph buffered wait turn legacy")],
757 },
758 {
759 id: "hide-whitespace-changes",
760 title: msg("Hide whitespace changes"),
761 to: "/settings/diffs",
762 searchTerms: [msg("diff ignore spaces edits default")],
763 },
764 {
765 id: "default-diff-file-state",
766 title: msg("Default diff file state"),
767 to: "/settings/diffs",
768 searchTerms: [msg("collapsed expanded collapse expand files pull request pr code tab")],
769 },
770 {
771 id: "diff-layout",
772 title: msg("Diff layout"),
773 to: "/settings/diffs",
774 searchTerms: [msg("stacked split side by side unified inline view")],
775 },
776 {
777 id: "proactive-panels",
778 title: msg("Open pull requests and changes panels proactively"),
779 to: "/settings/diffs",
780 searchTerms: [
781 msg("proactive automatically open diff pull request pr right panel agent completion"),
782 ],
783 },
784 {
785 id: "skills-in-slash-menu",
786 title: msg("Show skills in slash menu"),
787 to: "/settings/chat",
788 searchTerms: [msg("command menu dollar $ slash /")],
789 },
790 {
791 id: "composer-rich-text",
792 title: msg("Rich text composer"),
793 to: "/settings/chat",
794 searchTerms: [msg("composer rich text tiptap bold italic markdown styled wysiwyg")],
795 },
796 {
797 id: "send-shortcut",
798 title: msg("Send shortcut"),
799 to: "/settings/chat",
800 searchTerms: [msg("enter return command ctrl multiline prompt new line composer")],
801 },
802 {
803 id: "follow-up-behavior",
804 title: msg("Follow-up behavior"),
805 to: "/settings/chat",
806 searchTerms: [msg("queue steer running turn send default behavior composer")],
807 },
808 {
809 id: "side-thread-open-target",
810 title: msg("Open subagents and side chats in"),
811 to: "/settings/chat",
812 searchTerms: [
813 msg(
814 "subagent side chat linked thread click right panel side panel main view command ctrl middle click",
815 ),
816 ],
817 },
818 {
819 id: "provider-update-checks",
820 title: msg("Provider update checks"),
821 to: "/settings/maintenance",
822 searchTerms: [
823 msg("installed cli versions newer available codex claude cursor grok fx kiro opencode"),
824 ],
825 scope: "environment-defaults",
826 },
827 {
828 id: "continue-threads-after-server-update",
829 title: msg("Continue threads after restarts"),
830 to: "/settings/maintenance",
831 scope: "project-defaults",
832 searchTerms: [
833 msg(
834 "resume running active interrupted work restart reboot machine crash desktop update automatically",
835 ),
836 ],
837 },
838 {
839 id: "keep-awake-while-agents-work",
840 title: msg("Keep awake while agents work"),
841 to: "/settings/maintenance",
842 scope: "environment-defaults",
843 searchTerms: [msg("caffeinate sleep prevent stay awake power laptop lid inhibit")],
844 },
845 {
846 id: "background-activity",
847 title: msg("Background activity"),
848 to: "/settings/maintenance",
849 scope: "environment-defaults",
850 searchTerms: [
851 msg(
852 "balanced performance battery saver advanced git fetch provider health refresh host power monitor idle policy",
853 ),
854 ],
855 },
856 {
857 id: "new-threads",
858 title: msg("New threads"),
859 to: "/settings/threads",
860 scope: "project-defaults",
861 searchTerms: [msg("default workspace mode draft local worktree")],
862 },
863 {
864 id: "worktree-submodules",
865 title: msg("Submodules"),
866 to: "/settings/worktrees",
867 scope: "project-defaults",
868 searchTerms: [msg("git submodule init recursive top-level none worktree t3.json")],
869 },
870 {
871 id: "start-from-origin",
872 title: msg("Start from remote"),
873 to: "/settings/worktrees",
874 scope: "project-defaults",
875 searchTerms: [msg("new worktrees start remote origin latest fetched branch local")],
876 },
877 {
878 id: "add-project-starts-in",
879 title: msg("Add project starts in"),
880 to: "/settings/threads",
881 scope: "environment-defaults",
882 searchTerms: [msg("base directory folder browser path home")],
883 },
884 {
885 id: "ghq-clone-layout",
886 title: msg("Clone into host folders"),
887 to: "/settings/threads",
888 scope: "environment-defaults",
889 searchTerms: [msg("ghq clone destination host owner repository root layout")],
890 },
891 {
892 id: "unpin-confirmation",
893 title: msg("Unpin confirmation"),
894 to: "/settings/general",
895 searchTerms: [msg("ask before thread pinned section")],
896 },
897 {
898 id: "archive-confirmation",
899 title: msg("Archive confirmation"),
900 to: "/settings/general",
901 searchTerms: [msg("ask before thread second click inline action")],
902 },
903 {
904 id: "delete-confirmation",
905 title: msg("Delete confirmation"),
906 to: "/settings/general",
907 searchTerms: [msg("ask before thread chat history")],
908 },
909 {
910 id: "terminal-close-confirmation",
911 title: msg("Terminal close confirmation"),
912 to: "/settings/general",
913 searchTerms: ["ask before delete stop process shell console history"],
914 },
915 {
916 id: "quit-confirmation",
917 title: msg("Quit shortcut"),
918 to: "/settings/general",
919 searchTerms: [msg("confirmation desktop app exit direct hold double click press twice")],
920 desktopOnly: true,
921 },
922 {
923 id: "text-generation-model",
924 title: msg("Text generation model"),
925 to: "/settings/threads",
926 scope: "project-defaults",
927 searchTerms: [msg("generated thread titles source control content default provider")],
928 },
929 {
930 id: "thread-title-instructions",
931 title: msg("Thread title instructions"),
932 to: "/settings/threads",
933 scope: "project-defaults",
934 searchTerms: [msg("generated thread titles prompt custom style naming rename regenerate")],
935 },
936 {
937 id: "app-version",
938 title: msg("Version"),
939 to: "/settings/about",
940 searchTerms: [msg("about check for updates download install upgrade release")],
941 },
942 {
943 id: "update-track",
944 title: msg("Update track"),
945 to: "/settings/about",
946 searchTerms: [msg("release channel stable latest nightly prerelease")],
947 releaseChannelOnly: true,
948 },
949 {
950 id: "cli-command",
951 title: msg("t3 command"),
952 to: "/settings/about",
953 searchTerms: [msg("cli terminal shell path install command line")],
954 desktopOnly: true,
955 },
956 {
957 id: "mobile-app",
958 title: msg("Mobile app"),
959 to: "/settings/about",
960 searchTerms: [msg("phone tablet iPhone iPad iOS Android App Store Google Play QR")],
961 },
962 {
963 id: "welcome-page",
964 title: msg("Welcome page"),
965 to: "/settings/about",
966 primaryEnvironmentOnly: true,
967 searchTerms: [msg("onboarding setup first run getting started agents import projects")],
968 },
969 {
970 id: "privacy-policy",
971 title: msg("Privacy policy"),
972 to: "/settings/about",
973 searchTerms: [msg("telemetry analytics usage data tracking legal opt out")],
974 },
975 {
976 id: "telemetry-export",
977 title: msg("OpenTelemetry export"),
978 to: "/settings/diagnostics",
979 targetId: "telemetry-export",
980 scope: "environment",
981 searchTerms: [msg("OTel OTLP telemetry export endpoints logs traces metrics Grafana")],
982 },
983 {
984 id: "diagnostics",
985 title: msg("Diagnostics"),
986 to: "/settings/maintenance",
987 searchTerms: [msg("logs traces processes resource history failures spans cpu memory")],
988 },
989 {
990 id: "open-source-licenses",
991 title: msg("Open source licenses"),
992 to: "/settings/about",
993 },
994 {
995 id: "keybindings",
996 title: msg("Keybindings"),
997 to: "/settings/keybindings",
998 searchTerms: [msg("keyboard shortcuts hotkeys commands bindings json")],
999 },
1000 ...KEYBINDING_SEARCH_ITEMS,
1001 {
1002 id: "snap-shot-enabled",
1003 title: msg("SnapShots"),
1004 searchTerms: [msg("window capture screenshot")],
1005 to: "/settings/snap-shot",
1006 },
1007 {
1008 id: "snap-shot-accessibility",
1009 title: msg("Include app text"),
1010 to: "/settings/snap-shot",
1011 targetId: "snap-shot-enabled",
1012 searchTerms: [
1013 msg("capture accessibility data text UI structure elements privacy omit agent context"),
1014 ],
1015 },
1016 {
1017 id: "snap-shot-shortcut",
1018 title: msg("Capture shortcut"),
1019 to: "/settings/snap-shot",
1020 targetId: "snap-shot-enabled",
1021 },
1022 {
1023 id: "snap-shot-sound",
1024 title: msg("Capture sound"),
1025 to: "/settings/snap-shot",
1026 targetId: "snap-shot-enabled",
1027 },
1028 {
1029 id: "snap-shot-flash",
1030 title: msg("Capture flash"),
1031 to: "/settings/snap-shot",
1032 targetId: "snap-shot-enabled",
1033 },
1034 {
1035 id: "snap-shot-animations",
1036 title: msg("Capture animations"),
1037 to: "/settings/snap-shot",
1038 targetId: "snap-shot-enabled",
1039 },
1040 {
1041 id: "providers",
1042 title: msg("Providers"),
1043 to: "/settings/providers",
1044 searchTerms: [
1045 msg(
1046 "agents cli codex claude cursor grok fx kiro opencode antigravity google sign in sign out install subscription instances authentication api key models configuration binary path config directory codex_home shadow home endpoint arguments environment variables display name accent color custom favorite hidden auto compact native sessions import resume",
1047 ),
1048 ],
1049 },
1050 {
1051 id: "usage-providers",
1052 title: msg("Usage providers"),
1053 to: "/settings/providers",
1054 searchTerms: [
1055 msg(
1056 "usage sources CLIProxyAPI CLI proxy hub quota subscription limits management key add remove",
1057 ),
1058 ],
1059 providerSettingsOnly: true,
1060 },
1061 {
1062 id: "text-generators",
1063 title: msg("Text generators"),
1064 to: "/settings/providers",
1065 searchTerms: [
1066 msg(
1067 "model api api key openai openrouter anthropic ollama lm studio custom endpoint base url thread titles commit messages",
1068 ),
1069 ],
1070 providerSettingsOnly: true,
1071 textGeneratorsOnly: true,
1072 },
1073 {
1074 id: "provider-health-check-interval",
1075 title: msg("Health check interval"),
1076 to: "/settings/providers",
1077 searchTerms: [
1078 msg("refresh availability versions auth state models background probes seconds off"),
1079 ],
1080 providerSettingsOnly: true,
1081 },
1082 {
1083 id: "scheduled-tasks",
1084 title: msg("Scheduled tasks"),
1085 to: "/settings/scheduled-tasks",
1086 },
1087 {
1088 id: "agent-browser-access",
1089 title: msg("Agent browser access"),
1090 to: "/settings/browser",
1091 scope: "project-defaults",
1092 searchTerms: [msg("allow disable enable open drive preview tools sessions project override")],
1093 },
1094 {
1095 id: "device-sources",
1096 title: msg("Device sources"),
1097 to: "/settings/devices",
1098 searchTerms: [
1099 msg(
1100 "device hosts ssh remote mac mini identity key connection eas expo cloud simlock pool gateway local simulators",
1101 ),
1102 ],
1103 },
1104 {
1105 id: "agent-device-access",
1106 title: msg("Agents can use devices"),
1107 to: "/settings/devices",
1108 targetId: "devices",
1109 searchTerms: [msg("allow simulator emulator ios android drive tools sessions")],
1110 },
1111 {
1112 id: "device-hub",
1113 title: msg("Use devices"),
1114 to: "/settings/devices",
1115 targetId: "devices",
1116 searchTerms: [msg("device hub simulator emulator ios android install start version")],
1117 },
1118 {
1119 id: "device-platform-support",
1120 title: msg("Local simulators"),
1121 to: "/settings/devices",
1122 targetId: "device-sources",
1123 searchTerms: [msg("simulator support xcode android studio sdk avd runtime")],
1124 },
1125 {
1126 id: "browser-profiles",
1127 title: msg("Browser profiles"),
1128 to: "/settings/browser",
1129 targetId: "browser",
1130 },
1131 {
1132 id: "browser-default-profile",
1133 title: msg("Default browser profile"),
1134 to: "/settings/browser",
1135 targetId: "browser-profiles",
1136 },
1137 {
1138 id: "browser-default-viewport",
1139 title: msg("Default browser viewport"),
1140 to: "/settings/browser",
1141 searchTerms: [msg("preview size width height device desktop mobile rotate")],
1142 },
1143 {
1144 id: "browser-default-zoom",
1145 title: msg("Default browser zoom"),
1146 to: "/settings/browser",
1147 searchTerms: [msg("preview page scale tabs percent")],
1148 },
1149 {
1150 id: "browser-default-appearance",
1151 title: msg("Default browser appearance"),
1152 to: "/settings/browser",
1153 searchTerms: [msg("preview color scheme light dark system os")],
1154 },
1155 {
1156 id: "browser-recording-frame-rate",
1157 title: msg("Browser recording frame rate"),
1158 to: "/settings/browser",
1159 },
1160 {
1161 id: "browser-recording-key-presses",
1162 title: msg("Show key presses in recordings"),
1163 to: "/settings/browser",
1164 searchTerms: [msg("browser preview keyboard shortcuts keystrokes overlay capture")],
1165 },
1166 {
1167 id: "browser-recording-mouse-presses",
1168 title: msg("Show mouse presses in recordings"),
1169 to: "/settings/browser",
1170 searchTerms: [msg("browser preview clicks buttons drag overlay capture")],
1171 },
1172 {
1173 id: "browser-link-target",
1174 title: msg("Open links in"),
1175 to: "/settings/browser",
1176 searchTerms: [msg("links default browser in-app browser external open")],
1177 },
1178 {
1179 id: "browser-search-engine",
1180 title: msg("Search engine"),
1181 to: "/settings/browser",
1182 searchTerms: [msg("address bar duckduckgo google bing brave kagi ecosia custom url")],
1183 },
1184 {
1185 id: "pull-request-links-open-in-app",
1186 title: msg("Open pull requests in T3 Code"),
1187 to: "/settings/diffs",
1188 searchTerms: [
1189 `pr commit links ${SOURCE_CONTROL_HOST_LABELS} browser external click default pull request view panel`,
1190 ],
1191 },
1192 {
1193 id: "browser-auto-show-floating-preview",
1194 title: msg("Auto-show floating preview"),
1195 to: "/settings/browser",
1196 searchTerms: [msg("agent opens browser device simulator pop into view hide")],
1197 },
1198 {
1199 id: "automatic-pull",
1200 title: msg("Automatically pull"),
1201 to: "/settings/source-control",
1202 scope: "project-defaults",
1203 searchTerms: [msg("auto pull default branch current checkout fast forward upstream")],
1204 },
1205 {
1206 id: "remove-agent-credits-on-merge",
1207 title: msg("Remove agent credits when merging"),
1208 to: "/settings/source-control",
1209 scope: "project-defaults",
1210 searchTerms: [
1211 `pull request ${SOURCE_CONTROL_HOST_LABELS} squash co-authored-by attribution claude codex generated`,
1212 ],
1213 },
1214 {
1215 id: "pull-request-merge-method",
1216 title: msg("Default merge method"),
1217 to: "/settings/source-control",
1218 scope: "project-defaults",
1219 searchTerms: [msg("pull request merge squash rebase last selected")],
1220 },
1221 {
1222 id: "issue-trackers",
1223 title: msg("Issue trackers"),
1224 to: "/settings/source-control",
1225 scope: "environment-defaults",
1226 searchTerms: [msg("linear jira issues tracker team api key connect bind project")],
1227 },
1228 {
1229 id: "source-control",
1230 title: msg("Source control"),
1231 to: "/settings/source-control",
1232 scope: "environment-defaults",
1233 searchTerms: [
1234 `version control git ${SOURCE_CONTROL_HOST_TERMS} hosting integrations credentials scan server environment`,
1235 ],
1236 },
1237 {
1238 id: "git-fetch-interval",
1239 title: msg("Git fetch interval"),
1240 to: "/settings/maintenance",
1241 targetId: "background-activity",
1242 searchTerms: [
1243 msg("automatic remote branch refresh background credentials security keys seconds off"),
1244 ],
1245 environmentOnly: true,
1246 scope: "environment-defaults",
1247 },
1248 {
1249 id: "worktree-branch-naming",
1250 title: msg("Worktree branch naming"),
1251 to: "/settings/worktrees",
1252 searchTerms: [msg("static semantic prefix custom prompt instructions feat fix refactor chore")],
1253 environmentOnly: true,
1254 scope: "project-defaults",
1255 },
1256 ...sourceControlHostSearchItems(sourceControlClients.definitions),
1257 {
1258 id: "source-control-writing-style",
1259 title: msg("Commit and pull request writing"),
1260 to: "/settings/source-control",
1261 searchTerms: [
1262 msg(
1263 "repository conventions conventional commits custom instructions commit messages change pr pull request merge request titles descriptions body style prompt write my own",
1264 ),
1265 ],
1266 environmentOnly: true,
1267 },
1268 {
1269 id: "follow-change-request-templates",
1270 title: msg("Follow pull request templates"),
1271 to: "/settings/source-control",
1272 searchTerms: [
1273 msg("repository pr pull request merge request change request description structure"),
1274 ],
1275 environmentOnly: true,
1276 },
1277 {
1278 id: "source-control-writer-model",
1279 title: msg("Source control writer model"),
1280 to: "/settings/source-control",
1281 searchTerms: [
1282 msg("override generated commit change request pr titles descriptions branch bookmark"),
1283 ],
1284 environmentOnly: true,
1285 scope: "project-defaults",
1286 },
1287 {
1288 id: "review-guides",
1289 title: msg("Review guides (beta)"),
1290 to: "/settings/source-control",
1291 searchTerms: [msg("pull request pr guided review guide tour beta experimental")],
1292 environmentOnly: true,
1293 },
1294 {
1295 id: "review-guide-model",
1296 title: msg("Review guide model"),
1297 to: "/settings/source-control",
1298 // Hidden until review guides are on, so a search lands on the switch that shows it.
1299 targetId: "review-guides",
1300 searchTerms: [msg("pull request pr guided review guide brief maintainer")],
1301 environmentOnly: true,
1302 scope: "project-defaults",
1303 },
1304 {
1305 id: "review-guide-instructions",
1306 title: msg("Review guide instructions"),
1307 to: "/settings/source-control",
1308 targetId: "review-guides",
1309 searchTerms: [msg("pull request pr guided review guide preferences taste prompt custom")],
1310 environmentOnly: true,
1311 scope: "project-defaults",
1312 },
1313 {
1314 id: "project-actions",
1315 title: msg("Actions"),
1316 to: "/settings/projects",
1317 searchTerms: [msg("commands scripts setup run dev server checkout worktree t3.json import")],
1318 },
1319 {
1320 id: "environment-icon",
1321 title: msg("Environment icon"),
1322 to: "/settings/access",
1323 targetId: "connections-environment",
1324 searchTerms: [msg("machine glyph sidebar mac mini studio laptop desktop server cloud vm")],
1325 },
1326 {
1327 id: "local-environment",
1328 title: msg("Local environment"),
1329 to: "/settings/connections",
1330 searchTerms: [msg("turn off on disable enable local server agents remote only restart")],
1331 desktopOnly: true,
1332 },
1333 {
1334 id: "network-access",
1335 title: msg("Network access"),
1336 to: "/settings/access",
1337 targetId: "connections-environment",
1338 searchTerms: [msg("expose backend remote pairing local machine interfaces host restart")],
1339 localBackendManagementOnly: true,
1340 },
1341 {
1342 id: "tailscale-https",
1343 title: msg("Tailscale HTTPS"),
1344 to: "/settings/access",
1345 targetId: "connections-environment",
1346 searchTerms: [msg("serve magicdns endpoint remote secure network")],
1347 desktopOnly: true,
1348 localBackendManagementOnly: true,
1349 },
1350 {
1351 id: "wsl-backend",
1352 title: msg("WSL backend"),
1353 to: "/settings/access",
1354 searchTerms: [
1355 msg(
1356 "windows subsystem linux distro second server projects stop windows backend restart wsl only",
1357 ),
1358 ],
1359 desktopOnly: true,
1360 windowsOnly: true,
1361 localBackendManagementOnly: true,
1362 wslAvailableOnly: true,
1363 },
1364 {
1365 id: "t3-connect",
1366 localEnvironmentOnly: true,
1367 title: msg("T3 Connect"),
1368 to: "/settings/access",
1369 targetId: "connections-environment",
1370 searchTerms: [msg("managed tunnel cloud other devices remote tunnels limit t3 chat")],
1371 desktopOnly: true,
1372 cloudOnly: true,
1373 },
1374 {
1375 id: "connect-device-approval",
1376 title: msg("Require approval for new devices"),
1377 to: "/settings/access",
1378 targetId: "connections-environment",
1379 searchTerms: [
1380 msg("t3 connect devices approve deny trust revoke pairing code security account"),
1381 ],
1382 cloudOnly: true,
1383 managedTunnelOnly: true,
1384 },
1385 {
1386 id: "hold-webhooks-while-offline",
1387 localEnvironmentOnly: true,
1388 title: msg("Hold webhooks while offline"),
1389 to: "/settings/access",
1390 targetId: "connections-environment",
1391 searchTerms: [msg("webhook automations offline queue mailbox t3 connect")],
1392 cloudOnly: true,
1393 managedTunnelOnly: true,
1394 },
1395 {
1396 id: "publish-agent-activity",
1397 localEnvironmentOnly: true,
1398 title: msg("Publish agent activity"),
1399 to: "/settings/access",
1400 targetId: "connections-environment",
1401 searchTerms: [msg("mobile push notifications live activities cloud tunnel")],
1402 cloudOnly: true,
1403 },
1404 {
1405 id: "preview-tunnel",
1406 title: msg("Preview tunnel"),
1407 to: "/settings/access",
1408 targetId: "connections-environment",
1409 searchTerms: [
1410 msg("localhost loopback port forwarding open on this device browser tabs stream security"),
1411 ],
1412 },
1413 {
1414 id: "connections-environment",
1415 title: msg("This machine"),
1416 to: "/settings/access",
1417 searchTerms: [
1418 msg(
1419 "connections server backend local remote access administrative permissions scope pairing links qr code authorized clients sessions revoke endpoint",
1420 ),
1421 ],
1422 },
1423 {
1424 id: "linked-environments",
1425 peerLinksOnly: true,
1426 title: msg("Linked environments"),
1427 to: "/settings/connections",
1428 targetId: "linked-environments",
1429 searchTerms: [msg("link peer another machine vps agents work there handoff pairing code")],
1430 },
1431 {
1432 id: "remote-environments",
1433 title: msg("Environments"),
1434 to: "/settings/connections",
1435 searchTerms: [msg("add pair backend host code ssh config agent tunnel saved t3 connect")],
1436 },
1437 {
1438 id: "load-balancing",
1439 title: msg("Load balancing"),
1440 to: "/settings/connections",
1441 searchTerms: [
1442 msg(
1443 "automatic machine environment resources cpu memory capacity preference weight shared projects",
1444 ),
1445 ],
1446 },
1447 {
1448 id: "pull-request-routing",
1449 title: msg("Pull request sharing"),
1450 to: "/settings/connections",
1451 searchTerms: [
1452 `pull request routing trusted environments shared credentials permissions read actions source control ${SOURCE_CONTROL_HOST_LABELS}`,
1453 ],
1454 },
1455 {
1456 id: "secret-providers",
1457 title: msg("Secret providers"),
1458 to: "/settings/secrets",
1459 searchTerms: [msg("1password vault credentials api key")],
1460 secretsFeatureOnly: true,
1461 },
1462 {
1463 id: "secret-providers-add",
1464 title: msg("Add secret provider"),
1465 to: "/settings/secrets",
1466 targetId: "secret-providers",
1467 searchTerms: [msg("new 1password vault op cli account")],
1468 secretsFeatureOnly: true,
1469 },
1470 {
1471 id: "archive",
1472 title: msg("Archived threads"),
1473 to: "/settings/archived",
1474 searchTerms: [msg("restore reopen deleted history projects")],
1475 },
1476 ] as const satisfies ReadonlyArray<SettingsSearchItem>;
1477
1478 export type SettingsSearchItemId = (typeof SETTINGS_SEARCH_ITEMS)[number]["id"];
1479
1480 const SEARCH_ITEMS_BY_ID = new Map(SETTINGS_SEARCH_ITEMS.map((item) => [item.id, item] as const));
1481
1482 const SETTINGS_CATEGORY_SCOPES: Readonly<Record<SettingsPath, SettingsSearchScope | null>> = {
1483 "/settings/diagnostics": "environment",
1484 "/settings/projects": "project",
1485 "/settings/general": null,
1486 "/settings/voice": null,
1487 "/settings/appearance": null,
1488 "/settings/chat": null,
1489 "/settings/diffs": null,
1490 "/settings/snap-shot": null,
1491 "/settings/keybindings": null,
1492 "/settings/providers": null,
1493 "/settings/threads": null,
1494 "/settings/browser": null,
1495 "/settings/devices": null,
1496 "/settings/source-control": "environment-defaults",
1497 "/settings/worktrees": "project-defaults",
1498 "/settings/connections": "connections",
1499 "/settings/access": "connections",
1500 "/settings/secrets": null,
1501 "/settings/scheduled-tasks": null,
1502 "/settings/maintenance": null,
1503 "/settings/labs": null,
1504 "/settings/about": null,
1505 "/settings/archived": "project-defaults",
1506 };
1507
1508 const RENAMED_SETTINGS_PATHS: Readonly<Record<string, SettingsPath>> = {
1509 "/settings/integrations": "/settings/browser",
1510 "/settings/storage": "/settings/maintenance",
1511 "/settings/beta": "/settings/labs",
1512 };
1513 const SPLIT_SETTINGS_PATHS: ReadonlySet<string> = new Set([
1514 "/settings/general",
1515 "/settings/appearance",
1516 "/settings/source-control",
1517 "/settings/connections",
1518 ...Object.keys(RENAMED_SETTINGS_PATHS),
1519 ]);
1520 // Section anchors that moved but are not search results themselves.
1521 const MOVED_SECTION_ANCHORS: Readonly<Record<string, SettingsPath>> = {
1522 "authorized-clients": "/settings/access",
1523 "text-generation": "/settings/threads",
1524 about: "/settings/about",
1525 };
1526
1527 /** Where an old settings link now lives. Its anchor finds the page its row moved to. */
1528 export function movedSettingsPath(pathname: string, hash: string): SettingsPath | null {
1529 if (!SPLIT_SETTINGS_PATHS.has(pathname)) return null;
1530 const items: readonly SettingsSearchItem[] = SETTINGS_SEARCH_ITEMS;
1531 const anchored = hash
1532 ? (items.find((item) => item.id === hash) ?? items.find((item) => item.targetId === hash))
1533 : undefined;
1534 const to =
1535 anchored?.to ?? MOVED_SECTION_ANCHORS[hash] ?? RENAMED_SETTINGS_PATHS[pathname] ?? null;
1536 return to === pathname ? null : to;
1537 }
1538
1539 export function getSettingsSearchTargetScope(targetId: string) {
1540 const items: readonly SettingsSearchItem[] = SETTINGS_SEARCH_ITEMS;
1541 const item =
1542 items.find((candidate) => candidate.id === targetId) ??
1543 items.find((candidate) => candidate.targetId === targetId);
1544 return item
1545 ? {
1546 title: item.title,
1547 scope: item.scope ?? SETTINGS_CATEGORY_SCOPES[item.to],
1548 ...(item.requiresThreadAutoSettlement ? { requiresThreadAutoSettlement: true } : {}),
1549 }
1550 : null;
1551 }
1552
1553 interface AutoSettlementSearchEnvironment {
1554 readonly environmentId: EnvironmentId;
1555 readonly connection: { readonly phase: EnvironmentConnectionPhase };
1556 readonly serverConfig: object | null;
1557 }
1558
1559 export function getThreadAutoSettlementSearchAvailability(
1560 environments: readonly AutoSettlementSearchEnvironment[],
1561 scope?: Pick<ResolvedSettingsScope, "kind" | "environmentIds">,
1562 ) {
1563 const connected = environments.filter(
1564 (environment) =>
1565 environment.connection.phase === "connected" && environment.serverConfig !== null,
1566 );
1567 const eligibleEnvironmentIds = connected.map((environment) => environment.environmentId);
1568 const selected = connected.filter((environment) =>
1569 scope?.environmentIds.includes(environment.environmentId),
1570 );
1571 return {
1572 eligibleEnvironmentIds,
1573 isTargetAvailable:
1574 scope !== undefined &&
1575 scope.kind !== "unavailable" &&
1576 selected.length > 0 &&
1577 selected.every((environment) => eligibleEnvironmentIds.includes(environment.environmentId)),
1578 };
1579 }
1580
1581 export function isSettingsSearchScopeAvailable(
1582 requiredScope: SettingsSearchScope | null,
1583 scopeKind: ResolvedSettingsScope["kind"],
1584 ): boolean {
1585 switch (requiredScope) {
1586 case null:
1587 case "connections":
1588 return true;
1589 case "environment":
1590 case "checkout":
1591 return requiredScope === scopeKind;
1592 case "project":
1593 return scopeKind === "project" || scopeKind === "checkout";
1594 case "environment-defaults":
1595 return scopeKind === "environment" || scopeKind === "all";
1596 case "project-defaults":
1597 return (
1598 scopeKind === "environment" ||
1599 scopeKind === "all" ||
1600 scopeKind === "project" ||
1601 scopeKind === "checkout"
1602 );
1603 }
1604 }
1605
1606 function searchableSetting(id: SettingsSearchItemId): {
1607 readonly id: string;
1608 readonly title: string;
1609 } {
1610 const { id: anchorId, title } = SEARCH_ITEMS_BY_ID.get(id)!;
1611 return { id: anchorId, title };
1612 }
1613
1614 /** `searchableSetting` with its title in the active language, for spreading onto a row. */
1615 export function useSearchableSetting() {
1616 const m = useMessages();
1617 return (id: SettingsSearchItemId) => {
1618 const setting = searchableSetting(id);
1619 return { ...setting, title: m(setting.title) };
1620 };
1621 }
1622
1623 export function filterAvailableSettingsSearchItems(
1624 availability: SettingsSearchAvailability,
1625 ): ReadonlyArray<SettingsSearchItem> {
1626 const items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS;
1627 return items.filter(
1628 (item) =>
1629 (!item.cloudOnly || availability.hasCloudPublicConfig) &&
1630 (!item.environmentOnly || availability.hasEnvironment) &&
1631 (!item.providerSettingsOnly || availability.hasProviderSettingsEnvironment) &&
1632 (!item.localBackendManagementOnly || availability.canManageLocalBackend) &&
1633 (!item.localEnvironmentOnly || !availability.localEnvironmentDisabled) &&
1634 (!item.primaryEnvironmentOnly || availability.hasPrimaryEnvironment === true) &&
1635 (!item.wslAvailableOnly || availability.isWslSettingsRowVisible) &&
1636 (!item.requiresThreadAutoSettlement || availability.hasThreadAutoSettlement) &&
1637 (!item.managedTunnelOnly || availability.managedTunnelActive === true) &&
1638 (!item.peerLinksOnly || availability.hasPeerLinkHost === true) &&
1639 (!item.fastWorktreeCheckoutOnly ||
1640 availability.hasFastWorktreeCheckoutEnvironment === true) &&
1641 (!item.textGeneratorsOnly || availability.hasTextGeneratorsEnvironment === true),
1642 );
1643 }
1644
1645 /** The settings that exist on this platform and app channel. */
1646 export function settingsForThisPlatform(
1647 items: ReadonlyArray<SettingsSearchItem>,
1648 ): ReadonlyArray<SettingsSearchItem> {
1649 const platform = typeof navigator === "undefined" ? "" : navigator.platform;
1650 return items.filter(
1651 (item) =>
1652 (isElectron || item.desktopOnly !== true) &&
1653 (!item.releaseChannelOnly || isElectron || HOSTED_APP_CHANNEL !== null) &&
1654 (!item.secretsFeatureOnly || isSecretsFeatureEnabled) &&
1655 (!item.macOnly || isMacPlatform(platform)) &&
1656 (!item.windowsOnly || isWindowsPlatform(platform)),
1657 );
1658 }
1659
1660 export function searchSettings(
1661 query: string,
1662 items: ReadonlyArray<SettingsSearchItem> = SETTINGS_SEARCH_ITEMS,
1663 translate: (message: string) => string = (message) => message,
1664 ): ReadonlyArray<SettingsSearchItem> {
1665 const normalizedQuery = normalizeSearchText(query);
1666 if (normalizedQuery.length === 0) return [];
1667 const queryTokens = normalizedQuery.split(" ");
1668
1669 return settingsForThisPlatform(items)
1670 .flatMap((item, index) => {
1671 const title = normalizeSearchText(decodeMsg(item.title));
1672 const fields = [
1673 title,
1674 normalizeSearchText(SETTINGS_SECTION_LABELS[item.to]),
1675 // The labels as displayed, so search also works in the active language.
1676 normalizeSearchText(translate(item.title)),
1677 normalizeSearchText(translate(SETTINGS_SECTION_LABELS[item.to])),
1678 ...(item.searchTerms ?? []).map(normalizeSearchText),
1679 ...(item.searchTerms ?? []).map((term) => normalizeSearchText(translate(term))),
1680 ];
1681 if (!queryTokens.every((token) => fields.some((field) => field.includes(token)))) return [];
1682
1683 const exactPhraseField = fields.findIndex((field) => field.includes(normalizedQuery));
1684 const rank =
1685 title === normalizedQuery
1686 ? 5
1687 : title.startsWith(normalizedQuery)
1688 ? 4
1689 : title.includes(normalizedQuery)
1690 ? 3
1691 : queryTokens.every((token) => title.includes(token))
1692 ? 2
1693 : exactPhraseField >= 0
1694 ? 1
1695 : 0;
1696 return [{ item, index, rank }];
1697 })
1698 .toSorted(
1699 (left, right) =>
1700 Number(left.item.secondary ?? false) - Number(right.item.secondary ?? false) ||
1701 right.rank - left.rank ||
1702 left.index - right.index,
1703 )
1704 .map(({ item }) => item);
1705 }
1706
1707 // These rows only exist with separate fonts on, so a search jump to one turns them on.
1708 const ADVANCED_TYPOGRAPHY_TARGET_IDS: ReadonlySet<string> = new Set([
1709 "prompt-font",
1710 "terminal-font",
1711 ]);
1712
1713 export function isAdvancedTypographyTarget(targetId: string): boolean {
1714 return ADVANCED_TYPOGRAPHY_TARGET_IDS.has(targetId);
1715 }
1716
1717 /**
1718 * Opens the persisted section a search result lives in before jumping to it, so
1719 * its row is mounted to scroll to. The terminal reads the same flag, so it must
1720 * stay on after the jump.
1721 */
1722 export function revealSettingsSearchTarget(targetId: string): void {
1723 if (isAdvancedTypographyTarget(targetId)) {
1724 writeLocalStorageValue(TYPOGRAPHY_ADVANCED_STORAGE_KEY, true, false, Schema.Boolean);
1725 }
1726 }