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

SettingsServerControlsRouteScreen.tsx

660 lines27.4 KB

1import { msg, T, useGT, useMessages, Var } from "gt-react-native";
2import { useNavigation } from "@react-navigation/native";
3import { SettingsRow } from "./components/SettingsRow";
4import { AuthSettingsWriteScope } from "@t3tools/contracts";
5import { readEnvironmentScope, useEnvironmentsWithScope } from "../../state/session";
6import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
7import { AppText as Text } from "../../components/ui/AppText";
8import {
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";
17import { useRef, useState } from "react";
18import { View } from "react-native";
19import { useSafeAreaInsets } from "react-native-safe-area-context";
20​
21import {
22 RUNTIME_MODE_CHOICES,
23 withManagedRuntimeModeLimits,
24} from "../threads/thread-settings-options";
25import { SettingsScreen } from "./components/SettingsScreen";
26import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
27import { BranchNamingSettings } from "./components/BranchNamingSettings";
28import { DatabaseStorageNotice } from "./components/DatabaseStorageNotice";
29import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow";
30import { SettingsSection } from "./components/SettingsSection";
31import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
32import { IssueTrackerSection } from "./components/IssueTrackerSection";
33import { SourceControlProvidersSection } from "./components/SourceControlProvidersSection";
34import { SettingsProjectOverridesSection } from "./components/SettingsProjectOverridesSection";
35import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
36import { useSettingsWriter } from "./useSettingsWriter";
37import {
38 managedSettingReason,
39 planMobileScopedSettingsClear,
40 planMobileScopedSettingsPatch,
41 resolveMobileSettingsTargets,
42 uniformMobileSetting,
43 type ScopedMobileSettingsTarget,
44} from "./settings-scoped-server";
45import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
46import { AutoSettleSettingsRows } from "./ThreadSettingsSections";
47import { supportsSharedSettingsSync } from "@t3tools/client-runtime/state/shared-settings";
48​
49type SettingsPage = "threads" | "source-control" | "worktrees" | "maintenance";
50​
51const 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​
58const 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​
78const 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​
105const 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​
127const 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.
145const AUTO_SETTLE_SETTING_KEYS: ReadonlySet<string> = new Set([
146 "sidebarAutoSettleOnMerge",
147 "sidebarAutoSettleAfterDays",
148 "autoResumeLimitedThreads",
149 "snoozeLimitedThreads",
150]);
151​
152function 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 ];
169​
170export function SettingsThreadsRouteScreen() {
171 return <ServerSettingsDetail page="threads" />;
173​
174export function SettingsEnvironmentSourceControlRouteScreen() {
175 return <ServerSettingsDetail page="source-control" />;
177​
178export function SettingsWorktreesRouteScreen() {
179 return <ServerSettingsDetail page="worktrees" />;
181​
182export function SettingsEnvironmentMaintenanceRouteScreen() {
183 return <ServerSettingsDetail page="maintenance" />;
185​
186function 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 <SettingsSection title={gt("Computer")}>
411 <SettingsSwitchRow
412 icon="desktopcomputer"
413 label={gt("Computer use")}
414 subtitle={managedSubtitle(
415 "enableCua",
416 gt(
417 "Allow agents to use apps on the selected environments' computers through Cua Driver. On macOS, grant Accessibility and Screen Recording on each host.",
418 ),
419 )}
420 value={uniform("enableCua")}
421 disabled={disabledFor("enableCua")}
422 onValueChange={(value) => write({ enableCua: value })}
423 />
424 </SettingsSection>
425 <AutoSettleSettingsRows write={write} pending={pendingWrites > 0} />
426 </>
427 ) : null}
428​
429 {props.page === "source-control" ? (
430 <>
431 {projectSelected ? null : (
432 <SourceControlProvidersSection
433 environments={selectedTargets}
434 canWrite={(environmentId) => writableEnvironments.has(environmentId)}
435 />
436 )}
437 {projectSelected ? null : <IssueTrackerSection environments={selectedTargets} />}
438 <SettingsSection title={gt("Pull requests")}>
439 <SettingsSwitchRow
440 icon={PullRequestGlyph.merged}
441 label={gt("Remove agent credits when merging")}
442 subtitle={managedSubtitle(
443 "removeAgentCreditsOnMerge",
444 gt(
445 "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.",
446 ),
447 )}
448 value={uniform("removeAgentCreditsOnMerge")}
449 disabled={disabledFor("removeAgentCreditsOnMerge")}
450 onValueChange={(value) => write({ removeAgentCreditsOnMerge: value })}
451 />
452 </SettingsSection>
453 <SettingsSection title={gt("Default branch")}>
454 <SettingsSwitchRow
455 icon="arrow.down.circle"
456 label={gt("Automatically pull")}
457 subtitle={managedSubtitle(
458 "defaultAutoPull",
459 gt("Keep the default branch current when there are no local changes."),
460 )}
461 value={uniform("defaultAutoPull")}
462 disabled={disabledFor("defaultAutoPull")}
463 onValueChange={(value) => write({ defaultAutoPull: value })}
464 />
465 </SettingsSection>
466 <SettingsSection title={gt("Clones")}>
467 <SettingsSwitchRow
468 icon="folder"
469 label={gt("Clone into host folders")}
470 subtitle={gt("Clones go to {path} under the Add project folder, like {tool}.", {
471 path: "github.com/owner/repo",
472 tool: "ghq",
473 })}
474 value={uniform("ghqCloneLayout")}
475 disabled={disabledFor("ghqCloneLayout")}
476 onValueChange={(value) => write({ ghqCloneLayout: value })}
477 />
478 </SettingsSection>
479 </>
480 ) : null}
481​
482 {props.page === "worktrees" ? (
483 <>
484 <SettingsSection title={gt("New worktrees")}>
485 <SettingsSwitchRow
486 icon="arrow.triangle.branch"
487 label={gt("Start from remote")}
488 subtitle={managedSubtitle(
489 "newWorktreesStartFromOrigin",
490 gt(
491 "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.",
492 ),
493 )}
494 value={uniform("newWorktreesStartFromOrigin")}
495 disabled={disabledFor("newWorktreesStartFromOrigin")}
496 onValueChange={(value) => write({ newWorktreesStartFromOrigin: value })}
497 />
498 </SettingsSection>
499 <SettingsSection
500 title={gt("Worktree submodules")}
501 footer={managed("worktreeSubmodules")}
502 trailing={
503 pendingWrites === 0 && isMixed("worktreeSubmodules") ? (
504 <MixedValuesLabel projectSelected={projectSelected} />
505 ) : null
506 }
507 >
508 {SUBMODULE_CHOICES.filter(
509 (choice) => choice.mode !== null || !projectSelected,
510 ).map((choice, index) => (
511 <SettingsChoiceRow
512 key={choice.mode ?? "inherit"}
513 label={m(choice.label)}
514 description={m(choice.description)}
515 selected={
516 !isMixed("worktreeSubmodules") &&
517 uniform("worktreeSubmodules") === choice.mode
518 }
519 separated={index > 0}
520 disabled={disabledFor("worktreeSubmodules")}
521 onPress={() => write({ worktreeSubmodules: choice.mode })}
522 />
523 ))}
524 </SettingsSection>
525 <BranchNamingSettings
526 key={targetsKey}
527 mode={uniform("branchNamingMode")}
528 prefix={uniform("branchNamePrefix")}
529 instructions={uniform("branchNameInstructions")}
530 disabled={{
531 mode: disabledFor("branchNamingMode"),
532 prefix: disabledFor("branchNamePrefix"),
533 instructions: disabledFor("branchNameInstructions"),
534 }}
535 onChange={write}
536 />
537 </>
538 ) : null}
539​
540 {props.page === "maintenance" ? (
541 <>
542 {!projectSelected ? (
543 <DatabaseStorageNotice
544 targets={selectedTargets.filter(
545 (target) =>
546 target.serverConfig.environment.capabilities.databaseStorage === true,
547 )}
548 />
549 ) : null}
550 {!projectSelected ? (
551 <SettingsSection title={gt("Manage environments")}>
552 {selectedTargets.map((target) => (
553 <SettingsRow
554 key={target.environmentId}
555 icon="server.rack"
556 label={target.label}
557 value={gt("Server and provider updates")}
558 onPress={() =>
559 navigation.navigate("SettingsEnvironmentDetail", {
560 environmentId: target.environmentId,
561 })
562 }
563 />
564 ))}
565 </SettingsSection>
566 ) : null}
567 <SettingsSection title={gt("Updates")}>
568 <SettingsSwitchRow
569 icon="arrow.clockwise"
570 label={gt("Check provider updates")}
571 subtitle={managedSubtitle(
572 "enableProviderUpdateChecks",
573 projectSelected
574 ? gt("Environment-wide setting. Select All projects to change it.")
575 : gt(
576 "Check installed provider CLIs for newer versions and fetch model catalog updates. When off, new models may not appear.",
577 ),
578 )}
579 value={uniform("enableProviderUpdateChecks")}
580 disabled={disabledFor("enableProviderUpdateChecks")}
581 onValueChange={(value) => write({ enableProviderUpdateChecks: value })}
582 />
583 <View className="border-t border-border-subtle">
584 <SettingsSwitchRow
585 icon="arrow.uturn.forward"
586 label={gt("Continue after restart")}
587 subtitle={managedSubtitle(
588 "continueThreadsAfterServerUpdate",
589 gt("Resume interrupted threads after an update or restart."),
590 )}
591 value={uniform("continueThreadsAfterServerUpdate")}
592 disabled={disabledFor("continueThreadsAfterServerUpdate")}
593 onValueChange={(value) => write({ continueThreadsAfterServerUpdate: value })}
594 />
595 </View>
596 <View className="border-t border-border-subtle">
597 <SettingsSwitchRow
598 icon="bolt.circle"
599 label={gt("Keep awake while agents work")}
600 subtitle={managedSubtitle(
601 "keepAwakeWhileAgentsWork",
602 projectSelected
603 ? gt("Environment-wide setting. Select All projects to change it.")
604 : gt(
605 "Stop the computer from sleeping while agents work. Closing a laptop lid still sleeps it.",
606 ),
607 )}
608 value={uniform("keepAwakeWhileAgentsWork")}
609 disabled={disabledFor("keepAwakeWhileAgentsWork")}
610 onValueChange={(value) => write({ keepAwakeWhileAgentsWork: value })}
611 />
612 </View>
613 </SettingsSection>
614 </>
615 ) : null}
616 </>
617 )}
618 </ScrollView>
619 </SettingsScreen>
620 );
622​
623function MixedValuesLabel(props: { readonly projectSelected: boolean }) {
624 const gt = useGT();
625 return (
626 <Text
627 accessibilityLabel={
628 props.projectSelected
629 ? gt("Selected project checkouts use different values")
630 : gt("Selected environments use different values")
631 }
632 className="px-2 text-sm text-foreground-muted android:px-4"
633 >
634 <T>Mixed</T>
635 </Text>
636 );
638​
639/** Locked settings are refused when saved; say so before the user tries. */
640function ManagedPolicyNotice(props: { readonly targets: readonly ScopedMobileSettingsTarget[] }) {
641 const organizations = [
642 ...new Set(
643 props.targets.flatMap((target) => {
644 const policy = target.environment.serverConfig.managedPolicy;
645 return policy !== undefined && policy.lockedSettings.length > 0
646 ? [policy.organization]
647 : [];
648 }),
649 ),
650 ];
651 if (organizations.length === 0) return null;
652 return (
653 <Text className="px-2 text-sm text-foreground-muted android:px-4">
654 <T>
655 Some settings are managed by <Var>{organizations.join(", ")}</Var> and cannot be changed
656 here.
657 </T>
658 </Text>
659 );