From fcf44ffdd3a983307faf2ea6ce8443eda720b1b4 Mon Sep 17 00:00:00 2001 From: hazre Date: Wed, 15 Apr 2026 18:19:50 +0200 Subject: [PATCH] Change settings links to use explicit markers --- .changeset/change-settings-link-markers.md | 9 ++ config.json | 2 - .../components/RenderMessageContent.test.tsx | 18 ++- .../setting-tile/SettingTile.test.tsx | 4 +- src/app/features/settings/Settings.test.tsx | 24 +--- src/app/features/settings/general/General.tsx | 4 - .../SettingsLinkBaseUrlSetting.test.tsx | 77 ----------- .../general/SettingsLinkBaseUrlSetting.tsx | 108 --------------- .../features/settings/settingsLink.test.ts | 59 +++++--- src/app/features/settings/settingsLink.ts | 128 +++++++++++------- .../settings/useSettingsLinkBaseUrl.ts | 10 +- src/app/hooks/useClientConfig.ts | 1 - .../plugins/react-custom-html-parser.test.tsx | 24 +++- src/app/state/settings.ts | 2 - src/app/utils/settingsSync.test.ts | 1 - src/app/utils/settingsSync.ts | 1 - 16 files changed, 171 insertions(+), 301 deletions(-) create mode 100644 .changeset/change-settings-link-markers.md delete mode 100644 src/app/features/settings/general/SettingsLinkBaseUrlSetting.test.tsx delete mode 100644 src/app/features/settings/general/SettingsLinkBaseUrlSetting.tsx diff --git a/.changeset/change-settings-link-markers.md b/.changeset/change-settings-link-markers.md new file mode 100644 index 000000000..0a444f95f --- /dev/null +++ b/.changeset/change-settings-link-markers.md @@ -0,0 +1,9 @@ +--- +default: patch +--- + +# Change how settings links are shared + +Settings links copied from Sable now stay on the current client URL and include a small Sable marker in the link. That lets Sable recognize settings links copied from other Sable instances without treating unrelated third-party `/settings/...` links as Sable settings links. + +If you previously set `settingsLinkBaseUrl` in `config.json`, remove it. Sable now derives settings links from the runtime app URL, and the old config key is no longer used. diff --git a/config.json b/config.json index f0c3c8b61..1bdffb675 100644 --- a/config.json +++ b/config.json @@ -13,8 +13,6 @@ "webPushAppID": "moe.sable.app.sygnal" }, - "settingsLinkBaseUrl": "https://app.sable.moe", - "slidingSync": { "enabled": true }, diff --git a/src/app/components/RenderMessageContent.test.tsx b/src/app/components/RenderMessageContent.test.tsx index d795542fa..789b84469 100644 --- a/src/app/components/RenderMessageContent.test.tsx +++ b/src/app/components/RenderMessageContent.test.tsx @@ -1,5 +1,5 @@ import { render, screen } from '@testing-library/react'; -import { describe, expect, it, vi } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { MsgType } from '$types/matrix-sdk'; import { ClientConfigProvider } from '$hooks/useClientConfig'; import { RenderMessageContent } from './RenderMessageContent'; @@ -13,9 +13,9 @@ vi.mock('./url-preview', () => ({ youtubeUrl: () => false, })); -function renderMessage(body: string, settingsLinkBaseUrl = 'https://app.sable.moe') { +function renderMessage(body: string) { return render( - + { + vi.unstubAllGlobals(); +}); + describe('RenderMessageContent', () => { it('does not render url previews for settings links', () => { - renderMessage('https://app.sable.moe/settings/account?focus=status'); + renderMessage( + 'https://app.example/settings/account?focus=status&moe.sable.client.action=settings' + ); expect(screen.queryByTestId('url-preview-holder')).not.toBeInTheDocument(); expect(screen.queryByTestId('url-preview-card')).not.toBeInTheDocument(); diff --git a/src/app/components/setting-tile/SettingTile.test.tsx b/src/app/components/setting-tile/SettingTile.test.tsx index da5d25c10..b5e87e2c1 100644 --- a/src/app/components/setting-tile/SettingTile.test.tsx +++ b/src/app/components/setting-tile/SettingTile.test.tsx @@ -49,7 +49,7 @@ describe('SettingTile', () => { await waitFor(() => { expect(writeText).toHaveBeenCalledWith( - 'https://settings.example/settings/appearance?focus=message-link-preview' + 'https://settings.example/settings/appearance?focus=message-link-preview&moe.sable.client.action=settings' ); }); expect(screen.getByRole('button', { name: /copied settings link/i })).toBeInTheDocument(); @@ -64,7 +64,7 @@ describe('SettingTile', () => { await waitFor(() => { expect(writeText).toHaveBeenCalledWith( - 'https://settings.example/settings/appearance?focus=message-link-preview' + 'https://settings.example/settings/appearance?focus=message-link-preview&moe.sable.client.action=settings' ); }); expect(screen.getByRole('button', { name: /copy settings link/i })).toBeInTheDocument(); diff --git a/src/app/features/settings/Settings.test.tsx b/src/app/features/settings/Settings.test.tsx index 0ad55b17b..8a77e3c36 100644 --- a/src/app/features/settings/Settings.test.tsx +++ b/src/app/features/settings/Settings.test.tsx @@ -12,8 +12,6 @@ const { mockMatrixClient, mockProfile } = vi.hoisted(() => ({ mockProfile: { displayName: 'Alice', avatarUrl: undefined }, })); -let settingsLinkBaseUrlOverride: string | undefined; - vi.mock('$hooks/useMatrixClient', () => ({ useMatrixClient: () => mockMatrixClient, })); @@ -27,13 +25,7 @@ vi.mock('$hooks/useMediaAuthentication', () => ({ })); vi.mock('$state/hooks/settings', () => ({ - useSetting: (_atom: unknown, key: string) => { - if (key === 'settingsLinkBaseUrlOverride') { - return [settingsLinkBaseUrlOverride, vi.fn()] as const; - } - - return [true, vi.fn()] as const; - }, + useSetting: () => [true, vi.fn()] as const, })); vi.mock('$state/settings', () => ({ @@ -137,7 +129,6 @@ vi.mock('./keyboard-shortcuts', () => ({ beforeEach(() => { writeText.mockReset(); - settingsLinkBaseUrlOverride = undefined; vi.stubGlobal('location', { origin: 'https://app.example' } as Location); vi.stubGlobal('navigator', { clipboard: { writeText } } as unknown as Navigator); }); @@ -147,11 +138,11 @@ afterEach(() => { }); describe('Settings', () => { - it('uses the configured settings link base URL for copied settings links', async () => { + it('uses the current app origin for copied settings links', async () => { writeText.mockResolvedValueOnce(undefined); render( - + @@ -162,17 +153,16 @@ describe('Settings', () => { await waitFor(() => { expect(writeText).toHaveBeenCalledWith( - 'https://config.example/settings/appearance?focus=message-link-preview' + 'https://app.example/settings/appearance?focus=message-link-preview&moe.sable.client.action=settings' ); }); }); - it('prefers the client-side override over the configured settings link base URL', async () => { + it('preserves the configured hash-router basename in copied settings links', async () => { writeText.mockResolvedValueOnce(undefined); - settingsLinkBaseUrlOverride = 'https://override.example/'; render( - + @@ -183,7 +173,7 @@ describe('Settings', () => { await waitFor(() => { expect(writeText).toHaveBeenCalledWith( - 'https://override.example/settings/appearance?focus=message-link-preview' + 'https://app.example/#/app/settings/appearance?focus=message-link-preview&moe.sable.client.action=settings' ); }); }); diff --git a/src/app/features/settings/general/General.tsx b/src/app/features/settings/general/General.tsx index 291e76f2f..6a5f7d5c5 100644 --- a/src/app/features/settings/general/General.tsx +++ b/src/app/features/settings/general/General.tsx @@ -54,7 +54,6 @@ import { isKeyHotkey } from 'is-hotkey'; import { settingsSyncLastSyncedAtom, settingsSyncStatusAtom } from '$hooks/useSettingsSync'; import { exportSettingsAsJson, importSettingsFromJson } from '$utils/settingsSync'; import { SettingsSectionPage } from '../SettingsSectionPage'; -import { SettingsLinkBaseUrlSetting } from './SettingsLinkBaseUrlSetting'; type DateHintProps = { hasChanges: boolean; @@ -1072,9 +1071,6 @@ function Messages() { } /> - - - ({ - useSetting: () => [settingsLinkBaseUrlOverride, setSettingsLinkBaseUrlOverride] as const, -})); - -vi.mock('$state/settings', () => ({ - settingsAtom: {}, -})); - -function renderSetting(settingsLinkBaseUrl = 'https://app.sable.moe') { - return render( - - - - ); -} - -describe('SettingsLinkBaseUrlSetting', () => { - beforeEach(() => { - settingsLinkBaseUrlOverride = undefined; - setSettingsLinkBaseUrlOverride.mockReset(); - }); - - it('uses Url casing in the visible setting title', () => { - renderSetting('https://config.example'); - - expect(screen.getByText('Settings Link Base Url')).toBeInTheDocument(); - }); - - it('shows the configured default in the input and no separate reset button', () => { - renderSetting('https://config.example'); - - expect(screen.getByRole('textbox', { name: 'Settings link base URL' })).toHaveValue( - 'https://config.example' - ); - expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled(); - expect(screen.queryByRole('button', { name: 'Reset' })).not.toBeInTheDocument(); - }); - - it('uses an inline reset control to restore the configured default URL', () => { - renderSetting('https://config.example'); - - fireEvent.change(screen.getByRole('textbox', { name: 'Settings link base URL' }), { - target: { value: 'https://override.example' }, - }); - - expect( - screen.getByRole('button', { name: 'Reset settings link base URL' }) - ).toBeInTheDocument(); - - fireEvent.click(screen.getByRole('button', { name: 'Reset settings link base URL' })); - - expect(screen.getByRole('textbox', { name: 'Settings link base URL' })).toHaveValue( - 'https://config.example' - ); - expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled(); - }); - - it('clears the override when saving the configured default URL', () => { - settingsLinkBaseUrlOverride = 'https://override.example'; - renderSetting('https://config.example'); - - fireEvent.change(screen.getByRole('textbox', { name: 'Settings link base URL' }), { - target: { value: 'https://config.example' }, - }); - fireEvent.click(screen.getByRole('button', { name: 'Save' })); - - expect(setSettingsLinkBaseUrlOverride).toHaveBeenCalledWith(undefined); - }); -}); diff --git a/src/app/features/settings/general/SettingsLinkBaseUrlSetting.tsx b/src/app/features/settings/general/SettingsLinkBaseUrlSetting.tsx deleted file mode 100644 index deb6b760b..000000000 --- a/src/app/features/settings/general/SettingsLinkBaseUrlSetting.tsx +++ /dev/null @@ -1,108 +0,0 @@ -import { ChangeEventHandler, FormEventHandler, useEffect, useMemo, useState } from 'react'; -import { Box, Button, config, Icon, IconButton, Icons, Input, Text } from 'folds'; -import { useClientConfig } from '$hooks/useClientConfig'; -import { SettingTile } from '$components/setting-tile'; -import { useSetting } from '$state/hooks/settings'; -import { settingsAtom } from '$state/settings'; -import { getConfiguredSettingsLinkBaseUrl, normalizeSettingsLinkBaseUrl } from '../settingsLink'; - -export function SettingsLinkBaseUrlSetting() { - const clientConfig = useClientConfig(); - const [settingsLinkBaseUrlOverride, setSettingsLinkBaseUrlOverride] = useSetting( - settingsAtom, - 'settingsLinkBaseUrlOverride' - ); - const configuredBaseUrl = useMemo( - () => getConfiguredSettingsLinkBaseUrl(clientConfig), - [clientConfig] - ); - const currentValue = - normalizeSettingsLinkBaseUrl(settingsLinkBaseUrlOverride) ?? configuredBaseUrl; - const [inputValue, setInputValue] = useState(currentValue); - - useEffect(() => { - setInputValue(currentValue); - }, [currentValue]); - - const trimmedValue = inputValue.trim(); - const normalizedInputValue = normalizeSettingsLinkBaseUrl(trimmedValue); - const nextOverrideValue = - normalizedInputValue && normalizedInputValue !== configuredBaseUrl - ? normalizedInputValue - : undefined; - const hasChanges = normalizedInputValue !== currentValue; - const isValid = Boolean(normalizedInputValue); - - const handleChange: ChangeEventHandler = (evt) => { - setInputValue(evt.currentTarget.value); - }; - - const handleSubmit: FormEventHandler = (evt) => { - evt.preventDefault(); - if (!isValid) return; - - setSettingsLinkBaseUrlOverride(nextOverrideValue); - setInputValue(normalizedInputValue ?? configuredBaseUrl); - }; - - const handleReset = () => { - setInputValue(configuredBaseUrl); - }; - - return ( - - - - - - - - ) - } - /> - - - - - {!isValid && ( - - Enter a full `http://` or `https://` URL. - - )} - - ); -} diff --git a/src/app/features/settings/settingsLink.test.ts b/src/app/features/settings/settingsLink.test.ts index cb695e28f..f47c53c10 100644 --- a/src/app/features/settings/settingsLink.test.ts +++ b/src/app/features/settings/settingsLink.test.ts @@ -1,37 +1,25 @@ import { describe, expect, it } from 'vitest'; import { - DEFAULT_SETTINGS_LINK_BASE_URL, buildSettingsLink, - getEffectiveSettingsLinkBaseUrl, parseSettingsLink, + SETTINGS_LINK_ACTION_PARAM, + SETTINGS_LINK_ACTION_SETTINGS, toSettingsFocusIdPart, } from './settingsLink'; describe('settingsLink', () => { - it('builds settings links for plain and hash-router base urls', () => { + it('builds settings links with the explicit action marker for plain and hash-router base urls', () => { expect(buildSettingsLink('https://app.example', 'appearance', 'message-link-preview')).toBe( - 'https://app.example/settings/appearance?focus=message-link-preview' + `https://app.example/settings/appearance?focus=message-link-preview&${SETTINGS_LINK_ACTION_PARAM}=${SETTINGS_LINK_ACTION_SETTINGS}` ); expect( buildSettingsLink('https://app.example/#/app', 'appearance', 'message-link-preview') - ).toBe('https://app.example/#/app/settings/appearance?focus=message-link-preview'); + ).toBe( + `https://app.example/#/app/settings/appearance?focus=message-link-preview&${SETTINGS_LINK_ACTION_PARAM}=${SETTINGS_LINK_ACTION_SETTINGS}` + ); }); - it('resolves the settings link base URL from built-in default, config, and override', () => { - expect(getEffectiveSettingsLinkBaseUrl({}, undefined)).toBe(DEFAULT_SETTINGS_LINK_BASE_URL); - expect(getEffectiveSettingsLinkBaseUrl({}, true as never)).toBe(DEFAULT_SETTINGS_LINK_BASE_URL); - expect( - getEffectiveSettingsLinkBaseUrl({ settingsLinkBaseUrl: 'https://config.example/' }) - ).toBe('https://config.example'); - expect( - getEffectiveSettingsLinkBaseUrl( - { settingsLinkBaseUrl: 'https://config.example' }, - 'https://override.example/' - ) - ).toBe('https://override.example'); - }); - - it('parses settings links from the same app origin only', () => { + it('parses plain same-base settings links for compatibility', () => { expect( parseSettingsLink( 'https://app.example', @@ -45,10 +33,39 @@ describe('settingsLink', () => { ) ).toEqual({ section: 'appearance', focus: 'message-link-preview' }); + expect(parseSettingsLink('https://app.example', 'https://app.example/home/')).toBeUndefined(); + }); + + it('parses cross-base settings links only when the explicit action marker is present', () => { + expect( + parseSettingsLink( + 'https://app.example', + `https://other.example/settings/appearance?focus=message-link-preview&${SETTINGS_LINK_ACTION_PARAM}=${SETTINGS_LINK_ACTION_SETTINGS}` + ) + ).toEqual({ section: 'appearance', focus: 'message-link-preview' }); + + expect( + parseSettingsLink( + 'https://app.example/#/app', + `https://other.example/#/client/settings/account?focus=status&${SETTINGS_LINK_ACTION_PARAM}=${SETTINGS_LINK_ACTION_SETTINGS}` + ) + ).toEqual({ section: 'account', focus: 'status' }); + expect( parseSettingsLink('https://app.example', 'https://other.example/settings/appearance') ).toBeUndefined(); - expect(parseSettingsLink('https://app.example', 'https://app.example/home/')).toBeUndefined(); + expect( + parseSettingsLink( + 'https://app.example', + `https://other.example/settings/appearance?${SETTINGS_LINK_ACTION_PARAM}=not-settings` + ) + ).toBeUndefined(); + expect( + parseSettingsLink( + 'https://app.example', + `https://other.example/redirect?next=/settings/appearance?focus=status&${SETTINGS_LINK_ACTION_PARAM}=${SETTINGS_LINK_ACTION_SETTINGS}` + ) + ).toBeUndefined(); }); it('rejects a same-origin hash settings link that does not match the configured app base', () => { diff --git a/src/app/features/settings/settingsLink.ts b/src/app/features/settings/settingsLink.ts index da652d28a..fa0c1dabc 100644 --- a/src/app/features/settings/settingsLink.ts +++ b/src/app/features/settings/settingsLink.ts @@ -1,4 +1,3 @@ -import type { ClientConfig } from '$hooks/useClientConfig'; import { getAppPathFromHref, getSettingsPath, withOriginBaseUrl } from '$pages/pathUtils'; import { isSettingsSectionId, type SettingsSectionId } from './routes'; @@ -7,70 +6,101 @@ export type SettingsLink = { focus?: string; }; -export const DEFAULT_SETTINGS_LINK_BASE_URL = 'https://app.sable.moe'; +export const SETTINGS_LINK_ACTION_PARAM = 'moe.sable.client.action'; +export const SETTINGS_LINK_ACTION_SETTINGS = 'settings'; -export const normalizeSettingsLinkBaseUrl = (value?: string | null): string | undefined => { - if (typeof value !== 'string') return undefined; +const withSettingsLinkAction = (path: string): string => { + const [pathname, search = ''] = path.split('?'); + const params = new URLSearchParams(search); + params.set(SETTINGS_LINK_ACTION_PARAM, SETTINGS_LINK_ACTION_SETTINGS); - const trimmed = value.trim(); - if (!trimmed) return undefined; - - try { - const url = new URL(trimmed); - if (url.protocol !== 'http:' && url.protocol !== 'https:') { - return undefined; - } - - return url.toString().replace(/\/+$/, ''); - } catch { - return undefined; - } + return `${pathname}?${params.toString()}`; }; -export const getConfiguredSettingsLinkBaseUrl = ( - clientConfig: Pick -): string => - normalizeSettingsLinkBaseUrl(clientConfig.settingsLinkBaseUrl) ?? DEFAULT_SETTINGS_LINK_BASE_URL; +const parseSettingsAppPath = (appPath: string): SettingsLink | undefined => { + if (!appPath.startsWith('/settings/')) return undefined; -export const getEffectiveSettingsLinkBaseUrl = ( - clientConfig: Pick, - override?: string -): string => - normalizeSettingsLinkBaseUrl(override) ?? getConfiguredSettingsLinkBaseUrl(clientConfig); + const [pathname, search = ''] = appPath.split('?'); + const sectionMatch = pathname.match(/^\/settings\/([^/]+)\/?$/); + if (!sectionMatch) return undefined; + + const section = sectionMatch[1]; + if (!isSettingsSectionId(section)) return undefined; + + const focus = new URLSearchParams(search).get('focus') ?? undefined; + + return { section, focus }; +}; + +const hasSettingsLinkAction = (search: string): boolean => + new URLSearchParams(search).get(SETTINGS_LINK_ACTION_PARAM) === SETTINGS_LINK_ACTION_SETTINGS; + +const getCrossBaseSettingsPathname = (pathname: string): string | undefined => + pathname.match(/(\/settings\/[^/]+\/?)$/)?.[1]; + +const getCrossBaseSettingsAppPath = (pathname: string, search: string): string | undefined => { + if (!hasSettingsLinkAction(search)) return undefined; + + const settingsPathname = getCrossBaseSettingsPathname(pathname); + if (!settingsPathname) return undefined; + + const appPath = search ? `${settingsPathname}?${search}` : settingsPathname; + return parseSettingsAppPath(appPath) ? appPath : undefined; +}; + +const getSameBaseSettingsAppPath = (baseUrl: string, href: string): string | undefined => { + const base = new URL(baseUrl); + const target = new URL(href); + + if (base.origin !== target.origin) return undefined; + + if (base.hash) { + const baseHash = base.hash.replace(/\/+$/, ''); + if (!(target.hash === baseHash || target.hash.startsWith(`${baseHash}/`))) { + return undefined; + } + } + + return getAppPathFromHref(baseUrl, href); +}; + +const getCrossBaseSettingsAppPathFromHref = (href: string): string | undefined => { + const target = new URL(href); + + const directAppPath = getCrossBaseSettingsAppPath( + target.pathname, + target.search.replace(/^\?/, '') + ); + if (directAppPath) { + return directAppPath; + } + + const hashPath = target.hash.startsWith('#') ? target.hash.slice(1) : target.hash; + if (!hashPath) return undefined; + + const [hashPathname, hashSearch = ''] = hashPath.split('?'); + return getCrossBaseSettingsAppPath(hashPathname, hashSearch); +}; export const buildSettingsLink = ( baseUrl: string, section: SettingsSectionId, focus?: string -): string => withOriginBaseUrl(baseUrl, getSettingsPath(section, focus)); +): string => withOriginBaseUrl(baseUrl, withSettingsLinkAction(getSettingsPath(section, focus))); export const parseSettingsLink = (baseUrl: string, href: string): SettingsLink | undefined => { try { - const base = new URL(baseUrl); - const target = new URL(href); - - if (base.origin !== target.origin) return undefined; - - if (base.hash) { - const baseHash = base.hash.replace(/\/+$/, ''); - if (!(target.hash === baseHash || target.hash.startsWith(`${baseHash}/`))) { - return undefined; - } + const sameBaseAppPath = getSameBaseSettingsAppPath(baseUrl, href); + if (sameBaseAppPath) { + return parseSettingsAppPath(sameBaseAppPath); } - const appPath = getAppPathFromHref(baseUrl, href); - if (!appPath.startsWith('/settings/')) return undefined; + const crossBaseAppPath = getCrossBaseSettingsAppPathFromHref(href); + if (crossBaseAppPath) { + return parseSettingsAppPath(crossBaseAppPath); + } - const [pathname, search = ''] = appPath.split('?'); - const sectionMatch = pathname.match(/^\/settings\/([^/]+)\/?$/); - if (!sectionMatch) return undefined; - - const section = sectionMatch[1]; - if (!isSettingsSectionId(section)) return undefined; - - const focus = new URLSearchParams(search).get('focus') ?? undefined; - - return { section, focus }; + return undefined; } catch { return undefined; } diff --git a/src/app/features/settings/useSettingsLinkBaseUrl.ts b/src/app/features/settings/useSettingsLinkBaseUrl.ts index 15eb73a66..6a68301c0 100644 --- a/src/app/features/settings/useSettingsLinkBaseUrl.ts +++ b/src/app/features/settings/useSettingsLinkBaseUrl.ts @@ -1,15 +1,9 @@ import { useMemo } from 'react'; import { useClientConfig } from '$hooks/useClientConfig'; -import { useSetting } from '$state/hooks/settings'; -import { settingsAtom } from '$state/settings'; -import { getEffectiveSettingsLinkBaseUrl } from './settingsLink'; +import { getOriginBaseUrl } from '$pages/pathUtils'; export const useSettingsLinkBaseUrl = (): string => { const clientConfig = useClientConfig(); - const [settingsLinkBaseUrlOverride] = useSetting(settingsAtom, 'settingsLinkBaseUrlOverride'); - return useMemo( - () => getEffectiveSettingsLinkBaseUrl(clientConfig, settingsLinkBaseUrlOverride), - [clientConfig, settingsLinkBaseUrlOverride] - ); + return useMemo(() => getOriginBaseUrl(clientConfig.hashRouter), [clientConfig.hashRouter]); }; diff --git a/src/app/hooks/useClientConfig.ts b/src/app/hooks/useClientConfig.ts index e523f15a7..87685337d 100644 --- a/src/app/hooks/useClientConfig.ts +++ b/src/app/hooks/useClientConfig.ts @@ -42,7 +42,6 @@ export type ClientConfig = { hashRouter?: HashRouterConfig; matrixToBaseUrl?: string; - settingsLinkBaseUrl?: string; }; const ClientConfigContext = createContext(null); diff --git a/src/app/plugins/react-custom-html-parser.test.tsx b/src/app/plugins/react-custom-html-parser.test.tsx index 5d0e11e81..0513cc74d 100644 --- a/src/app/plugins/react-custom-html-parser.test.tsx +++ b/src/app/plugins/react-custom-html-parser.test.tsx @@ -148,9 +148,10 @@ describe('react custom html parser', () => { {renderLink({ tagName: 'a', attributes: { - href: 'https://app.example/settings/appearance?focus=message-link-preview', + href: 'https://app.example/settings/appearance?focus=message-link-preview&moe.sable.client.action=settings', }, - content: 'https://app.example/settings/appearance?focus=message-link-preview', + content: + 'https://app.example/settings/appearance?focus=message-link-preview&moe.sable.client.action=settings', } as never)} ); @@ -165,14 +166,14 @@ describe('react custom html parser', () => { it('renders same-origin settings links as internal app links with settings metadata', () => { renderParsedHtml( - 'Appearance', + 'Appearance', { sanitize: false } ); const link = screen.getByRole('link', { name: 'Appearance' }); expect(link).toHaveAttribute( 'href', - 'https://app.example/settings/appearance?focus=message-link-preview' + 'https://app.example/settings/appearance?focus=message-link-preview&moe.sable.client.action=settings' ); expect(link).toHaveAttribute('data-settings-link-section', 'appearance'); expect(link).toHaveAttribute('data-settings-link-focus', 'message-link-preview'); @@ -181,6 +182,21 @@ describe('react custom html parser', () => { expect(link.className).toContain(customHtmlCss.MentionWithIcon); }); + it('renders marked cross-instance settings links as internal app links with settings metadata', () => { + renderParsedHtml( + 'Account', + { sanitize: false } + ); + + const link = screen.getByRole('link', { name: 'Account' }); + expect(link).toHaveAttribute( + 'href', + 'https://other.example/#/client/settings/account?focus=status&moe.sable.client.action=settings' + ); + expect(link).toHaveAttribute('data-settings-link-section', 'account'); + expect(link).toHaveAttribute('data-settings-link-focus', 'status'); + }); + it('renders matrix message permalinks with an icon instead of the Message prefix', () => { render(
diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index 05bb8e0fb..e26fff911 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -74,7 +74,6 @@ export interface Settings { developerTools: boolean; enableMSC4268CMD: boolean; settingsSyncEnabled: boolean; - settingsLinkBaseUrlOverride?: string; // Cosmetics! jumboEmojiSize: JumboEmojiSize; @@ -177,7 +176,6 @@ const defaultSettings: Settings = { developerTools: false, settingsSyncEnabled: false, - settingsLinkBaseUrlOverride: undefined, // Cosmetics! jumboEmojiSize: 'normal', diff --git a/src/app/utils/settingsSync.test.ts b/src/app/utils/settingsSync.test.ts index e3d29aebc..270d60a11 100644 --- a/src/app/utils/settingsSync.test.ts +++ b/src/app/utils/settingsSync.test.ts @@ -30,7 +30,6 @@ describe('NON_SYNCABLE_KEYS', () => { 'isPeopleDrawer', 'isWidgetDrawer', 'memberSortFilterIndex', - 'settingsLinkBaseUrlOverride', 'developerTools', 'settingsSyncEnabled', ] as const; diff --git a/src/app/utils/settingsSync.ts b/src/app/utils/settingsSync.ts index 0f6b25888..a154ff92d 100644 --- a/src/app/utils/settingsSync.ts +++ b/src/app/utils/settingsSync.ts @@ -14,7 +14,6 @@ export const NON_SYNCABLE_KEYS = new Set([ 'isPeopleDrawer', 'isWidgetDrawer', 'memberSortFilterIndex', - 'settingsLinkBaseUrlOverride', // Developer / diagnostic 'developerTools', // Sync toggle itself must never be uploaded (it's device-local)