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

main
tsx 645 lines 26.7 KB
Raw
1 import { msg, T, useGT, useMessages, Var } from "gt-react-native";
2 import { useNavigation } from "@react-navigation/native";
3 import { SettingsRow } from "./components/SettingsRow";
4 import { AuthSettingsWriteScope } from "@t3tools/contracts";
5 import { readEnvironmentScope, useEnvironmentsWithScope } from "../../state/session";
6 import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
7 import { AppText as Text } from "../../components/ui/AppText";
8 import {
9 type ResponseStreamingMode,
10 type ServerSettings,
11 type ServerSettingsPatch,
12 type ThreadEnvMode,
13 type WorktreeSubmodules,
14 PROJECT_SCOPED_SERVER_SETTING_KEYS,
15 type ProjectScopedServerSettingKey,
16 } from "@t3tools/contracts";
17 import { useRef, useState } from "react";
18 import { View } from "react-native";
19 import { useSafeAreaInsets } from "react-native-safe-area-context";
20
21 import {
22 RUNTIME_MODE_CHOICES,
23 withManagedRuntimeModeLimits,
24 } from "../threads/thread-settings-options";
25 import { SettingsScreen } from "./components/SettingsScreen";
26 import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
27 import { BranchNamingSettings } from "./components/BranchNamingSettings";
28 import { DatabaseStorageNotice } from "./components/DatabaseStorageNotice";
29 import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow";
30 import { SettingsSection } from "./components/SettingsSection";
31 import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
32 import { IssueTrackerSection } from "./components/IssueTrackerSection";
33 import { SourceControlProvidersSection } from "./components/SourceControlProvidersSection";
34 import { SettingsProjectOverridesSection } from "./components/SettingsProjectOverridesSection";
35 import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
36 import { useSettingsWriter } from "./useSettingsWriter";
37 import {
38 managedSettingReason,
39 planMobileScopedSettingsClear,
40 planMobileScopedSettingsPatch,
41 resolveMobileSettingsTargets,
42 uniformMobileSetting,
43 type ScopedMobileSettingsTarget,
44 } from "./settings-scoped-server";
45 import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
46 import { AutoSettleSettingsRows } from "./ThreadSettingsSections";
47 import { supportsSharedSettingsSync } from "@t3tools/client-runtime/state/shared-settings";
48
49 type SettingsPage = "threads" | "source-control" | "worktrees" | "maintenance";
50
51 const PAGE_TITLES: Record<SettingsPage, string> = {
52 threads: msg("Threads", { $context: "settings page title" }),
53 "source-control": msg("Source control & issues"),
54 worktrees: msg("Worktrees"),
55 maintenance: msg("Maintenance"),
56 };
57
58 const PAGE_PROJECT_KEYS: Record<SettingsPage, readonly ProjectScopedServerSettingKey[]> = {
59 threads: [
60 "defaultThreadEnvMode",
61 "defaultRuntimeMode",
62 "responseStreamingMode",
63 "enableAgentBrowserAccess",
64 "sidebarAutoSettleOnMerge",
65 "sidebarAutoSettleAfterDays",
66 ],
67 "source-control": ["defaultAutoPull", "removeAgentCreditsOnMerge"],
68 worktrees: [
69 "newWorktreesStartFromOrigin",
70 "worktreeSubmodules",
71 "branchNamingMode",
72 "branchNamePrefix",
73 "branchNameInstructions",
74 ],
75 maintenance: ["continueThreadsAfterServerUpdate"],
76 };
77
78 const SUBMODULE_CHOICES: ReadonlyArray<{
79 readonly mode: WorktreeSubmodules | null;
80 readonly label: string;
81 readonly description: string;
82 }> = [
83 {
84 mode: null,
85 label: msg("Inherit", { $context: "use the inherited value" }),
86 description: msg("Use the repository's t3.json, or initialize recursively."),
87 },
88 {
89 mode: "recursive",
90 label: msg("Recursive", { $context: "initialize submodules recursively" }),
91 description: msg("Initialize nested submodules too."),
92 },
93 {
94 mode: "top-level",
95 label: msg("Top level only"),
96 description: msg("Skip submodules declared inside other submodules."),
97 },
98 {
99 mode: "none",
100 label: msg("Skip", { $context: "do not initialize submodules" }),
101 description: msg("Leave submodules empty for a setup script."),
102 },
103 ];
104
105 const WORKSPACE_CHOICES: ReadonlyArray<{
106 readonly mode: ThreadEnvMode | null;
107 readonly label: string;
108 readonly description: string;
109 }> = [
110 {
111 mode: null,
112 label: msg("Inherit", { $context: "use the inherited value" }),
113 description: msg("Use the repository's t3.json, or the current checkout."),
114 },
115 {
116 mode: "local",
117 label: msg("Current checkout"),
118 description: msg("Start new threads in the existing workspace."),
119 },
120 {
121 mode: "worktree",
122 label: msg("New worktree"),
123 description: msg("Give each new thread a separate checkout."),
124 },
125 ];
126
127 const STREAMING_CHOICES: ReadonlyArray<{
128 readonly mode: ResponseStreamingMode;
129 readonly label: string;
130 readonly description: string;
131 }> = [
132 {
133 mode: "turn",
134 label: msg("After the turn"),
135 description: msg("Show the answer when the agent finishes."),
136 },
137 {
138 mode: "paragraph",
139 label: msg("Finished paragraphs"),
140 description: msg("Show each paragraph or code block as it completes."),
141 },
142 ];
143
144 // Only servers with thread auto-settlement store these, so other targets get the rest of a patch.
145 const AUTO_SETTLE_SETTING_KEYS: ReadonlySet<string> = new Set([
146 "sidebarAutoSettleOnMerge",
147 "sidebarAutoSettleAfterDays",
148 "autoResumeLimitedThreads",
149 "snoozeLimitedThreads",
150 ]);
151
152 function planServerSettingsWrites(
153 targets: readonly ScopedMobileSettingsTarget[],
154 projectSelected: boolean,
155 patch: ServerSettingsPatch,
156 ) {
157 const capable = targets.filter((target) => supportsSharedSettingsSync(target.environment));
158 const others = targets.filter((target) => !supportsSharedSettingsSync(target.environment));
159 const othersPatch = Object.fromEntries(
160 Object.entries(patch).filter(([key]) => !AUTO_SETTLE_SETTING_KEYS.has(key)),
161 ) as ServerSettingsPatch;
162 return [
163 ...planMobileScopedSettingsPatch(capable, projectSelected, patch),
164 ...(Object.keys(othersPatch).length > 0
165 ? planMobileScopedSettingsPatch(others, projectSelected, othersPatch)
166 : []),
167 ];
168 }
169
170 export function SettingsThreadsRouteScreen() {
171 return <ServerSettingsDetail page="threads" />;
172 }
173
174 export function SettingsEnvironmentSourceControlRouteScreen() {
175 return <ServerSettingsDetail page="source-control" />;
176 }
177
178 export function SettingsWorktreesRouteScreen() {
179 return <ServerSettingsDetail page="worktrees" />;
180 }
181
182 export function SettingsEnvironmentMaintenanceRouteScreen() {
183 return <ServerSettingsDetail page="maintenance" />;
184 }
185
186 function ServerSettingsDetail(props: { readonly page: SettingsPage }) {
187 const gt = useGT();
188 const m = useMessages();
189 const environmentMenu = useSettingsEnvironmentMenu();
190 const insets = useSafeAreaInsets();
191 const navigation = useNavigation();
192 const { selectedTargets, projectGroups, selectedProjectKey } = useSettingsEnvironmentFilter();
193 const selectedProject = projectGroups.find((group) => group.key === selectedProjectKey);
194 const writableEnvironments = useEnvironmentsWithScope(selectedTargets, AuthSettingsWriteScope);
195 const projectSelected = selectedProjectKey !== null;
196 const targets = resolveMobileSettingsTargets(
197 selectedTargets,
198 projectSelected ? (selectedProject?.members.map((member) => member.project) ?? []) : null,
199 );
200 const [pendingWrites, setPendingWrites] = useState(0);
201 const writeInFlight = useRef(false);
202 // Closing views can save after controls disable; queue those patches behind the pending write.
203 const queuedPatch = useRef<{ key: string; patch: ServerSettingsPatch } | null>(null);
204 const targetsKey = targets
205 .map((target) => `${target.environment.environmentId}:${target.projectId}`)
206 .join(",");
207 const [pendingTargets, setPendingTargets] = useState<
208 readonly ScopedMobileSettingsTarget[] | null
209 >(null);
210 const canWriteSettings =
211 targets.length > 0 &&
212 targets.every((target) => writableEnvironments.has(target.environment.environmentId));
213 const displayTargets = pendingWrites > 0 && pendingTargets !== null ? pendingTargets : targets;
214 const hasConnectedSelection = targets.length > 0;
215 const reference = displayTargets[0] ?? null;
216 const uniform = <K extends keyof ServerSettings>(key: K) =>
217 uniformMobileSetting(displayTargets, key);
218 // `uniform` folds a real null into "mixed"; nullable keys need the distinction.
219 const isMixed = (key: keyof ServerSettings) =>
220 reference === null ||
221 displayTargets.some((entry) => entry.settings[key] !== reference.settings[key]);
222 const writeSettings = useSettingsWriter();
223 const write = (patch: ServerSettingsPatch) => {
224 if (writeInFlight.current) {
225 const queued = queuedPatch.current;
226 queuedPatch.current = {
227 key: targetsKey,
228 patch: queued?.key === targetsKey ? { ...queued.patch, ...patch } : patch,
229 };
230 return;
231 }
232 if (
233 !hasConnectedSelection ||
234 !targets.every((target) =>
235 readEnvironmentScope(target.environment.environmentId, AuthSettingsWriteScope),
236 )
237 )
238 return;
239 const writes = planServerSettingsWrites(targets, projectSelected, patch);
240 if (writes.length === 0) return;
241 writeInFlight.current = true;
242 setPendingTargets(targets);
243 setPendingWrites((count) => count + 1);
244 void writeSettings(targets, writes).finally(() => {
245 writeInFlight.current = false;
246 setPendingTargets(null);
247 setPendingWrites((count) => count - 1);
248 const queued = queuedPatch.current;
249 queuedPatch.current = null;
250 // These targets may not show this write yet, so send it again with the
251 // queued patch; project overrides are replaced whole.
252 if (queued?.key === targetsKey) write({ ...patch, ...queued.patch });
253 });
254 };
255 const clearProjectOverrides = () => {
256 if (
257 writeInFlight.current ||
258 !targets.every((target) =>
259 readEnvironmentScope(target.environment.environmentId, AuthSettingsWriteScope),
260 )
261 )
262 return;
263 const writes = planMobileScopedSettingsClear(targets, PAGE_PROJECT_KEYS[props.page]);
264 if (writes.length === 0) return;
265 writeInFlight.current = true;
266 setPendingTargets(targets);
267 setPendingWrites((count) => count + 1);
268 void writeSettings(targets, writes).finally(() => {
269 writeInFlight.current = false;
270 // Resending a draft over these pre-clear targets would undo the clear.
271 queuedPatch.current = null;
272 setPendingTargets(null);
273 setPendingWrites((count) => count - 1);
274 });
275 };
276 const disabled = !canWriteSettings || pendingWrites > 0 || !hasConnectedSelection;
277 const managed = (...keys: string[]) => managedSettingReason(targets, keys, m);
278 // A locked row keeps its explanation and says who manages it.
279 const managedSubtitle = (key: string, subtitle: string) => {
280 const reason = managed(key);
281 return reason === undefined ? subtitle : gt("{subtitle} {reason}", { subtitle, reason });
282 };
283 const runtimeModeChoices = withManagedRuntimeModeLimits(
284 RUNTIME_MODE_CHOICES,
285 targets.map((target) => target.environment.serverConfig.managedPolicy),
286 m,
287 );
288 const disabledFor = (key: string) =>
289 disabled ||
290 managed(key) !== undefined ||
291 (projectSelected &&
292 !PROJECT_SCOPED_SERVER_SETTING_KEYS.includes(
293 key as (typeof PROJECT_SCOPED_SERVER_SETTING_KEYS)[number],
294 ));
295
296 return (
297 <SettingsScreen title={m(PAGE_TITLES[props.page])} menus={[environmentMenu]}>
298 <ScrollView
299 contentInsetAdjustmentBehavior="automatic"
300 showsVerticalScrollIndicator={false}
301 className="flex-1"
302 contentContainerClassName="gap-6 px-5 pt-4"
303 contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
304 >
305 {!hasConnectedSelection || reference === null ? (
306 <Text className="px-2 text-base text-foreground-muted">
307 {projectSelected
308 ? gt("Select a project with a checkout on a connected environment.")
309 : gt("Use the filter above to select a connected environment.")}
310 </Text>
311 ) : (
312 <>
313 <ManagedPolicyNotice targets={targets} />
314 {projectSelected ? (
315 <SettingsProjectOverridesSection
316 projectLabel={selectedProject?.label ?? gt("Unavailable project")}
317 hasOverrides={targets.some((target) =>
318 PAGE_PROJECT_KEYS[props.page].some((key) => target.sources[key] === "project"),
319 )}
320 pending={pendingWrites > 0}
321 disabled={!canWriteSettings}
322 onClear={clearProjectOverrides}
323 />
324 ) : null}
325 {props.page === "threads" ? (
326 <>
327 <SettingsSection
328 title={gt("Default workspace")}
329 footer={managed("defaultThreadEnvMode")}
330 trailing={
331 pendingWrites === 0 && isMixed("defaultThreadEnvMode") ? (
332 <MixedValuesLabel projectSelected={projectSelected} />
333 ) : null
334 }
335 >
336 {WORKSPACE_CHOICES.filter(
337 (choice) => choice.mode !== null || !projectSelected,
338 ).map((choice, index) => (
339 <SettingsChoiceRow
340 key={choice.mode ?? "inherit"}
341 label={m(choice.label)}
342 description={m(choice.description)}
343 selected={
344 !isMixed("defaultThreadEnvMode") &&
345 uniform("defaultThreadEnvMode") === choice.mode
346 }
347 separated={index > 0}
348 disabled={disabledFor("defaultThreadEnvMode")}
349 onPress={() => write({ defaultThreadEnvMode: choice.mode })}
350 />
351 ))}
352 </SettingsSection>
353 <SettingsSection
354 title={gt("Default permissions")}
355 footer={managed("defaultRuntimeMode")}
356 trailing={
357 pendingWrites === 0 && uniform("defaultRuntimeMode") === null ? (
358 <MixedValuesLabel projectSelected={projectSelected} />
359 ) : null
360 }
361 >
362 {runtimeModeChoices.map((choice, index) => (
363 <SettingsChoiceRow
364 key={choice.mode}
365 label={m(choice.label)}
366 description={choice.disabledReason ?? m(choice.description)}
367 selected={uniform("defaultRuntimeMode") === choice.mode}
368 separated={index > 0}
369 disabled={
370 disabledFor("defaultRuntimeMode") || choice.disabledReason !== undefined
371 }
372 onPress={() => write({ defaultRuntimeMode: choice.mode })}
373 />
374 ))}
375 </SettingsSection>
376 <SettingsSection
377 title={gt("Response streaming")}
378 footer={managed("responseStreamingMode")}
379 trailing={
380 pendingWrites === 0 && uniform("responseStreamingMode") === null ? (
381 <MixedValuesLabel projectSelected={projectSelected} />
382 ) : null
383 }
384 >
385 {STREAMING_CHOICES.map((choice, index) => (
386 <SettingsChoiceRow
387 key={choice.mode}
388 label={m(choice.label)}
389 description={m(choice.description)}
390 selected={uniform("responseStreamingMode") === choice.mode}
391 separated={index > 0}
392 disabled={disabledFor("responseStreamingMode")}
393 onPress={() => write({ responseStreamingMode: choice.mode })}
394 />
395 ))}
396 </SettingsSection>
397 <SettingsSection title={gt("Preview browser")}>
398 <SettingsSwitchRow
399 icon="globe"
400 label={gt("Agent browser access")}
401 subtitle={managedSubtitle(
402 "enableAgentBrowserAccess",
403 gt("Allow agents to use the in-app preview browser."),
404 )}
405 value={uniform("enableAgentBrowserAccess")}
406 disabled={disabledFor("enableAgentBrowserAccess")}
407 onValueChange={(value) => write({ enableAgentBrowserAccess: value })}
408 />
409 </SettingsSection>
410 <AutoSettleSettingsRows write={write} pending={pendingWrites > 0} />
411 </>
412 ) : null}
413
414 {props.page === "source-control" ? (
415 <>
416 {projectSelected ? null : (
417 <SourceControlProvidersSection
418 environments={selectedTargets}
419 canWrite={(environmentId) => writableEnvironments.has(environmentId)}
420 />
421 )}
422 {projectSelected ? null : <IssueTrackerSection environments={selectedTargets} />}
423 <SettingsSection title={gt("Pull requests")}>
424 <SettingsSwitchRow
425 icon={PullRequestGlyph.merged}
426 label={gt("Remove agent credits when merging")}
427 subtitle={managedSubtitle(
428 "removeAgentCreditsOnMerge",
429 gt(
430 "Remove recognized agent credits from merge and squash messages on hosts that support it, keeping human co-authors. Includes auto-merge. Excludes merge queues, stack merges, and existing commits.",
431 ),
432 )}
433 value={uniform("removeAgentCreditsOnMerge")}
434 disabled={disabledFor("removeAgentCreditsOnMerge")}
435 onValueChange={(value) => write({ removeAgentCreditsOnMerge: value })}
436 />
437 </SettingsSection>
438 <SettingsSection title={gt("Default branch")}>
439 <SettingsSwitchRow
440 icon="arrow.down.circle"
441 label={gt("Automatically pull")}
442 subtitle={managedSubtitle(
443 "defaultAutoPull",
444 gt("Keep the default branch current when there are no local changes."),
445 )}
446 value={uniform("defaultAutoPull")}
447 disabled={disabledFor("defaultAutoPull")}
448 onValueChange={(value) => write({ defaultAutoPull: value })}
449 />
450 </SettingsSection>
451 <SettingsSection title={gt("Clones")}>
452 <SettingsSwitchRow
453 icon="folder"
454 label={gt("Clone into host folders")}
455 subtitle={gt("Clones go to {path} under the Add project folder, like {tool}.", {
456 path: "github.com/owner/repo",
457 tool: "ghq",
458 })}
459 value={uniform("ghqCloneLayout")}
460 disabled={disabledFor("ghqCloneLayout")}
461 onValueChange={(value) => write({ ghqCloneLayout: value })}
462 />
463 </SettingsSection>
464 </>
465 ) : null}
466
467 {props.page === "worktrees" ? (
468 <>
469 <SettingsSection title={gt("New worktrees")}>
470 <SettingsSwitchRow
471 icon="arrow.triangle.branch"
472 label={gt("Start from remote")}
473 subtitle={managedSubtitle(
474 "newWorktreesStartFromOrigin",
475 gt(
476 "Uses the latest commit of the base branch’s tracked remote branch, even if its name differs. Otherwise uses the same-named branch on origin. Uses your local branch if that remote branch is missing.",
477 ),
478 )}
479 value={uniform("newWorktreesStartFromOrigin")}
480 disabled={disabledFor("newWorktreesStartFromOrigin")}
481 onValueChange={(value) => write({ newWorktreesStartFromOrigin: value })}
482 />
483 </SettingsSection>
484 <SettingsSection
485 title={gt("Worktree submodules")}
486 footer={managed("worktreeSubmodules")}
487 trailing={
488 pendingWrites === 0 && isMixed("worktreeSubmodules") ? (
489 <MixedValuesLabel projectSelected={projectSelected} />
490 ) : null
491 }
492 >
493 {SUBMODULE_CHOICES.filter(
494 (choice) => choice.mode !== null || !projectSelected,
495 ).map((choice, index) => (
496 <SettingsChoiceRow
497 key={choice.mode ?? "inherit"}
498 label={m(choice.label)}
499 description={m(choice.description)}
500 selected={
501 !isMixed("worktreeSubmodules") &&
502 uniform("worktreeSubmodules") === choice.mode
503 }
504 separated={index > 0}
505 disabled={disabledFor("worktreeSubmodules")}
506 onPress={() => write({ worktreeSubmodules: choice.mode })}
507 />
508 ))}
509 </SettingsSection>
510 <BranchNamingSettings
511 key={targetsKey}
512 mode={uniform("branchNamingMode")}
513 prefix={uniform("branchNamePrefix")}
514 instructions={uniform("branchNameInstructions")}
515 disabled={{
516 mode: disabledFor("branchNamingMode"),
517 prefix: disabledFor("branchNamePrefix"),
518 instructions: disabledFor("branchNameInstructions"),
519 }}
520 onChange={write}
521 />
522 </>
523 ) : null}
524
525 {props.page === "maintenance" ? (
526 <>
527 {!projectSelected ? (
528 <DatabaseStorageNotice
529 targets={selectedTargets.filter(
530 (target) =>
531 target.serverConfig.environment.capabilities.databaseStorage === true,
532 )}
533 />
534 ) : null}
535 {!projectSelected ? (
536 <SettingsSection title={gt("Manage environments")}>
537 {selectedTargets.map((target) => (
538 <SettingsRow
539 key={target.environmentId}
540 icon="server.rack"
541 label={target.label}
542 value={gt("Server and provider updates")}
543 onPress={() =>
544 navigation.navigate("SettingsEnvironmentDetail", {
545 environmentId: target.environmentId,
546 })
547 }
548 />
549 ))}
550 </SettingsSection>
551 ) : null}
552 <SettingsSection title={gt("Updates")}>
553 <SettingsSwitchRow
554 icon="arrow.clockwise"
555 label={gt("Check provider updates")}
556 subtitle={managedSubtitle(
557 "enableProviderUpdateChecks",
558 projectSelected
559 ? gt("Environment-wide setting. Select All projects to change it.")
560 : gt(
561 "Check installed provider CLIs for newer versions and fetch model catalog updates. When off, new models may not appear.",
562 ),
563 )}
564 value={uniform("enableProviderUpdateChecks")}
565 disabled={disabledFor("enableProviderUpdateChecks")}
566 onValueChange={(value) => write({ enableProviderUpdateChecks: value })}
567 />
568 <View className="border-t border-border-subtle">
569 <SettingsSwitchRow
570 icon="arrow.uturn.forward"
571 label={gt("Continue after restart")}
572 subtitle={managedSubtitle(
573 "continueThreadsAfterServerUpdate",
574 gt("Resume interrupted threads after an update or restart."),
575 )}
576 value={uniform("continueThreadsAfterServerUpdate")}
577 disabled={disabledFor("continueThreadsAfterServerUpdate")}
578 onValueChange={(value) => write({ continueThreadsAfterServerUpdate: value })}
579 />
580 </View>
581 <View className="border-t border-border-subtle">
582 <SettingsSwitchRow
583 icon="bolt.circle"
584 label={gt("Keep awake while agents work")}
585 subtitle={managedSubtitle(
586 "keepAwakeWhileAgentsWork",
587 projectSelected
588 ? gt("Environment-wide setting. Select All projects to change it.")
589 : gt(
590 "Stop the computer from sleeping while agents work. Closing a laptop lid still sleeps it.",
591 ),
592 )}
593 value={uniform("keepAwakeWhileAgentsWork")}
594 disabled={disabledFor("keepAwakeWhileAgentsWork")}
595 onValueChange={(value) => write({ keepAwakeWhileAgentsWork: value })}
596 />
597 </View>
598 </SettingsSection>
599 </>
600 ) : null}
601 </>
602 )}
603 </ScrollView>
604 </SettingsScreen>
605 );
606 }
607
608 function MixedValuesLabel(props: { readonly projectSelected: boolean }) {
609 const gt = useGT();
610 return (
611 <Text
612 accessibilityLabel={
613 props.projectSelected
614 ? gt("Selected project checkouts use different values")
615 : gt("Selected environments use different values")
616 }
617 className="px-2 text-sm text-foreground-muted android:px-4"
618 >
619 <T>Mixed</T>
620 </Text>
621 );
622 }
623
624 /** Locked settings are refused when saved; say so before the user tries. */
625 function ManagedPolicyNotice(props: { readonly targets: readonly ScopedMobileSettingsTarget[] }) {
626 const organizations = [
627 ...new Set(
628 props.targets.flatMap((target) => {
629 const policy = target.environment.serverConfig.managedPolicy;
630 return policy !== undefined && policy.lockedSettings.length > 0
631 ? [policy.organization]
632 : [];
633 }),
634 ),
635 ];
636 if (organizations.length === 0) return null;
637 return (
638 <Text className="px-2 text-sm text-foreground-muted android:px-4">
639 <T>
640 Some settings are managed by <Var>{organizations.join(", ")}</Var> and cannot be changed
641 here.
642 </T>
643 </Text>
644 );
645 }