@@ -41,14 +41,8 @@ import {
4141 DEFAULT_SERVER_SETTINGS ,
4242 MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS ,
4343 MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS ,
44- type ServerSettingsPatch ,
4544} from "@t3tools/contracts" ;
46- import {
47- filterSharedServerPatch ,
48- findSharedSettingsMismatches ,
49- pickSharedServerSettings ,
50- supportsSharedSettingsSync ,
51- } from "@t3tools/client-runtime/state/shared-settings" ;
45+ import { supportsSharedSettingsSync } from "@t3tools/client-runtime/state/shared-settings" ;
5246import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled" ;
5347import {
5448 type AppUpdateCheckState ,
@@ -61,6 +55,7 @@ import { SettingsRow } from "./components/SettingsRow";
6155import { SettingsSection } from "./components/SettingsSection" ;
6256import { SettingsSwitchRow } from "./components/SettingsSwitchRow" ;
6357import { resolveAgentAwarenessPlatformPresentation } from "./SettingsRouteScreen.logic" ;
58+ import { planAutoSettleSettingsSync , type AutoSettleSettings } from "./autoSettleSettingsSync" ;
6459
6560type NotificationStatus = "checking" | "enabled" | "disabled" | "unsupported" ;
6661type LiveActivityStatus = "checking" | "enabled" | "disabled" | "signed-out" | "linking" ;
@@ -588,10 +583,9 @@ function GeneralSettingsSection() {
588583const AUTO_SETTLE_DEFAULT_DAYS = DEFAULT_SERVER_SETTINGS . sidebarAutoSettleAfterDays ?? 3 ;
589584
590585/**
591- * Auto-settlement is a user preference that every server has to hold. Mobile
592- * has no primary environment, so the first eligible sync target provides the
593- * reference value. Edits fan out to every eligible target, and a mismatch row
594- * lets the user push the reference out.
586+ * Mobile edits auto-settle defaults across connected, capable environments.
587+ * The first target supplies the displayed values. Applying them leaves each
588+ * environment's other defaults and overrides intact.
595589 */
596590function AutoSettleSettingsRows ( ) {
597591 const { environments } = useEnvironments ( ) ;
@@ -610,24 +604,20 @@ function AutoSettleSettingsRows() {
610604 return null ;
611605 }
612606
613- const writeToAll = ( patch : ServerSettingsPatch ) => {
607+ const writeToAll = ( patch : Partial < AutoSettleSettings > ) => {
614608 for ( const environment of syncTargets ) {
615609 void updateSettings ( { environmentId : environment . environmentId , input : { patch } } ) ;
616610 }
617611 } ;
618612
619- const mismatches = findSharedSettingsMismatches ( {
620- primaryEnvironmentId : reference . environmentId ,
621- primarySettings : referenceSettings ,
622- primaryCapabilities : reference . serverConfig ?. environment . capabilities ,
623- environments : environments . map ( ( environment ) => ( {
613+ const { patch : autoSettlePatch , mismatches } = planAutoSettleSettingsSync (
614+ { environmentId : reference . environmentId , settings : referenceSettings } ,
615+ syncTargets . map ( ( environment ) => ( {
624616 environmentId : environment . environmentId ,
625617 label : environment . label ,
626- syncEligible : supportsSharedSettingsSync ( environment ) ,
627618 settings : environment . serverConfig ?. settings ?? null ,
628- capabilities : environment . serverConfig ?. environment . capabilities ,
629619 } ) ) ,
630- } ) ;
620+ ) ;
631621
632622 const afterDays = referenceSettings . sidebarAutoSettleAfterDays ;
633623 const commitDays = ( ) => {
@@ -681,38 +671,26 @@ function AutoSettleSettingsRows() {
681671 { mismatches . length > 0 ? (
682672 < View className = "flex-row items-center gap-4 border-t border-border-subtle p-4" >
683673 < View className = "min-w-0 flex-1" >
684- < Text className = "text-lg text-foreground" > Settings differ</ Text >
674+ < Text className = "text-lg text-foreground" > Auto-settle defaults differ</ Text >
685675 < Text className = "text-sm text-foreground-muted" >
686676 { mismatches . map ( ( mismatch ) => mismatch . label ) . join ( ", " ) }
687677 </ Text >
688678 </ View >
689679 < Pressable
690680 accessibilityRole = "button"
691681 onPress = { ( ) => {
692- const patch = pickSharedServerSettings (
693- referenceSettings ,
694- reference . serverConfig ?. environment . capabilities ,
695- ) ;
696682 for ( const mismatch of mismatches ) {
697- const target = environments . find (
698- ( candidate ) => candidate . environmentId === mismatch . environmentId ,
699- ) ;
700683 void updateSettings ( {
701684 environmentId : mismatch . environmentId ,
702- input : {
703- patch : filterSharedServerPatch (
704- patch ,
705- target ?. serverConfig ?. environment . capabilities ,
706- target ?. serverConfig ?. settings ,
707- referenceSettings ,
708- ) ,
709- } ,
685+ input : { patch : autoSettlePatch } ,
710686 } ) ;
711687 }
712688 } }
713689 className = "rounded-full bg-subtle px-4 py-2 active:opacity-70"
714690 >
715- < Text className = "text-base font-t3-medium text-foreground" > Apply to all</ Text >
691+ < Text className = "text-base font-t3-medium text-foreground" >
692+ Apply auto-settle defaults
693+ </ Text >
716694 </ Pressable >
717695 </ View >
718696 ) : null }
0 commit comments