From 2c0cd0d26c3a901a75524e681c54fc26eed3282d Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Fri, 24 Jul 2026 17:00:36 -0400 Subject: [PATCH] fix(settings): resync push-rule toggle from account-data; MSC1929 support host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PushRuleEditor: the enable Switch initialized its state from pushRule.enabled once (useState initializer), so a rule toggled on another device left the Switch stale until remount. A useEffect now resyncs on pushRule.enabled change. pushRule flows from useAccountData(m.push_rules), which re-renders on sync, so the resync is genuinely reached; no optimistic-update conflict (the toggle sets state only after the PUT resolves). - About: the "Homeserver Support" panel fetched /.well-known/matrix/support from the client-API URL (mx.getHomeserverUrl()). Per MSC1929 that file lives at the MXID server-name host (like /.well-known/matrix/client), which differs on delegated/split-domain servers. Now fetched from https://{mx.getDomain()}; identical target for non-delegated servers (incl. Lotus), spec-correct for delegated ones, and degrades gracefully (catch → panel hidden) otherwise. Bug-hunt findings from LOTUS_TODO. Two review agents; both confirmed effective and non-regressing (full account-data re-render chain traced; CORS/host edge weighed). Gate-green (tsc, eslint, prettier, 914 tests, build). Co-Authored-By: Claude Opus 4.8 --- src/app/features/settings/about/About.tsx | 11 +++++++++-- .../settings/notifications/PushRuleEditor.tsx | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/app/features/settings/about/About.tsx b/src/app/features/settings/about/About.tsx index 54d81ec93..0ecf98452 100644 --- a/src/app/features/settings/about/About.tsx +++ b/src/app/features/settings/about/About.tsx @@ -42,9 +42,16 @@ function useServerSupport(): { support: MSC1929Support | null; loading: boolean useEffect(() => { const controller = new AbortController(); - const baseUrl = mx.getHomeserverUrl(); + // MSC1929 support info is served from the MXID server-name host (like + // /.well-known/matrix/client), which on delegated/split-domain servers is + // NOT the client-API URL. Derive it from the user's domain. + const serverName = mx.getDomain(); + if (!serverName) { + setLoading(false); + return undefined; + } setLoading(true); - fetch(`${baseUrl}/.well-known/matrix/support`, { signal: controller.signal }) + fetch(`https://${serverName}/.well-known/matrix/support`, { signal: controller.signal }) .then((res) => { if (!res.ok) return null; return res.json(); diff --git a/src/app/features/settings/notifications/PushRuleEditor.tsx b/src/app/features/settings/notifications/PushRuleEditor.tsx index df57676db..68291526c 100644 --- a/src/app/features/settings/notifications/PushRuleEditor.tsx +++ b/src/app/features/settings/notifications/PushRuleEditor.tsx @@ -1,4 +1,11 @@ -import React, { ChangeEventHandler, FormEventHandler, useCallback, useMemo, useState } from 'react'; +import React, { + ChangeEventHandler, + FormEventHandler, + useCallback, + useEffect, + useMemo, + useState, +} from 'react'; import { IPushRule, IPushRules, PushRuleKind } from 'matrix-js-sdk'; import { Box, Text, Button, Input, config, IconButton, Icons, Icon, Spinner, Switch } from 'folds'; import { SettingsSelect } from '../../../components/settings-select/SettingsSelect'; @@ -56,6 +63,13 @@ function RuleEnableToggle({ kind, pushRule }: RuleEnableToggleProps) { const mx = useMatrixClient(); const [enabled, setEnabled] = useState(pushRule.enabled !== false); + // Re-sync when the rule changes externally (e.g. toggled on another device → + // account-data sync). The useState initializer only runs once, so without + // this the Switch would show a stale value. + useEffect(() => { + setEnabled(pushRule.enabled !== false); + }, [pushRule.enabled]); + const [toggleState, toggle] = useAsyncCallback( useCallback( async (value: boolean) => {