From 79cd9bd2bf2844dab23ef0bba7d9cf1c977f77b8 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Sun, 24 May 2026 22:29:03 -0500 Subject: [PATCH 1/9] feat: pronoun pill hover details --- .changeset/add-hover-pronouns-list.md | 5 ++ src/app/features/room/message/Message.tsx | 75 ++++++++++++++++++++++- 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 .changeset/add-hover-pronouns-list.md diff --git a/.changeset/add-hover-pronouns-list.md b/.changeset/add-hover-pronouns-list.md new file mode 100644 index 000000000..a302a53be --- /dev/null +++ b/.changeset/add-hover-pronouns-list.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Adds the ability to hover/tap over `...` to see the rest of someone's pronouns. diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index ca1517de8..94b51f1dc 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -11,10 +11,13 @@ import { MenuItem, PopOut, Text, + Tooltip, + TooltipProvider, as, config, + toRem, } from 'folds'; -import type { MouseEventHandler, MouseEvent, ReactNode } from 'react'; +import type { KeyboardEventHandler, MouseEventHandler, MouseEvent, ReactNode } from 'react'; import { memo, useCallback, useRef, useState, useEffect, useMemo } from 'react'; import FocusTrap from 'focus-trap-react'; import { useHover, useFocusWithin } from 'react-aria'; @@ -274,6 +277,72 @@ function useMobileDoubleTap(callback: () => void, delay = 300) { const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str); +type MorePronounsPillProps = { + pronouns: PronounSet[]; + tagColor: string; +}; + +function MorePronounsPill({ pronouns, tagColor }: MorePronounsPillProps) { + const [anchor, setAnchor] = useState(); + + const toggleAnchor = (target: HTMLElement) => { + setAnchor((prev) => (prev ? undefined : target.getBoundingClientRect())); + }; + + const handleClick: MouseEventHandler = (e) => { + e.stopPropagation(); + toggleAnchor(e.currentTarget); + }; + + const handleKeyDown: KeyboardEventHandler = (e) => { + if (e.key !== 'Enter' && e.key !== ' ') return; + e.preventDefault(); + e.stopPropagation(); + toggleAnchor(e.currentTarget); + }; + + // On mobile, tapping the pill pins the tooltip open. + // Tapping anywhere else dismisses it. + useEffect(() => { + if (!anchor) return undefined; + const dismiss = () => setAnchor(undefined); + document.addEventListener('click', dismiss, { once: true }); + return () => document.removeEventListener('click', dismiss); + }, [anchor]); + + const tooltipText = pronouns.map((p) => clamp(p.summary, 16)).join(', '); + + const tooltipContent = ( + + {tooltipText} + + ); + + return ( + <> + + {(triggerRef) => ( + } + style={{ color: tagColor, cursor: 'help' }} + onClick={handleClick} + onKeyDown={handleKeyDown} + role="button" + tabIndex={0} + > + ... + + )} + + {anchor && ( + + {null} + + )} + + ); +} + /** * Component to render pronouns in the chat timeline. * It also filters them. @@ -320,7 +389,9 @@ const Pronouns = as< {clamp(p.summary, 16)} ))} - {visiblePronouns.length > limit && ...} + {visiblePronouns.length > limit && ( + + )} ); }); From a2f2707a3722a7dd70af9f2529c5dfcbe5446584 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Sun, 24 May 2026 22:54:54 -0500 Subject: [PATCH 2/9] feat: customizable pronoun pill limits --- ...add-ability-to-customize-pronoun-limits.md | 5 + .changeset/add-hover-pronouns-list.md | 2 +- src/app/features/room/message/Message.tsx | 16 ++- .../features/settings/cosmetics/Cosmetics.tsx | 119 +++++++++++++++++- src/app/features/settings/settingsLink.ts | 2 + src/app/state/settings.ts | 12 ++ 6 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 .changeset/add-ability-to-customize-pronoun-limits.md diff --git a/.changeset/add-ability-to-customize-pronoun-limits.md b/.changeset/add-ability-to-customize-pronoun-limits.md new file mode 100644 index 000000000..7b5c04bdf --- /dev/null +++ b/.changeset/add-ability-to-customize-pronoun-limits.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +Added configurable max pronoun pill count and max pill length rendering settings. diff --git a/.changeset/add-hover-pronouns-list.md b/.changeset/add-hover-pronouns-list.md index a302a53be..4d71893f6 100644 --- a/.changeset/add-hover-pronouns-list.md +++ b/.changeset/add-hover-pronouns-list.md @@ -1,5 +1,5 @@ --- -default: patch +default: minor --- Adds the ability to hover/tap over `...` to see the rest of someone's pronouns. diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index 94b51f1dc..a0bc3e1d1 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -280,9 +280,10 @@ const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, type MorePronounsPillProps = { pronouns: PronounSet[]; tagColor: string; + maxPillLength: number; }; -function MorePronounsPill({ pronouns, tagColor }: MorePronounsPillProps) { +function MorePronounsPill({ pronouns, tagColor, maxPillLength }: MorePronounsPillProps) { const [anchor, setAnchor] = useState(); const toggleAnchor = (target: HTMLElement) => { @@ -310,7 +311,7 @@ function MorePronounsPill({ pronouns, tagColor }: MorePronounsPillProps) { return () => document.removeEventListener('click', dismiss); }, [anchor]); - const tooltipText = pronouns.map((p) => clamp(p.summary, 16)).join(', '); + const tooltipText = pronouns.map((p) => clamp(p.summary, maxPillLength)).join(', '); const tooltipContent = ( @@ -375,7 +376,8 @@ const Pronouns = as< selectedLanguages ); - const limit = mobileOrTablet() ? 1 : 3; + const limit = getSettings().pronounPillMaxCount ?? 3; + const maxPillLength = getSettings().pronounPillMaxLength ?? 16; // if language specific pronouns can't be found matching the filter return unfiltered if (visiblePronouns.length === 0) { @@ -386,11 +388,15 @@ const Pronouns = as< {visiblePronouns.slice(0, limit).map((p) => ( - {clamp(p.summary, 16)} + {clamp(p.summary, maxPillLength)} ))} {visiblePronouns.length > limit && ( - + )} ); diff --git a/src/app/features/settings/cosmetics/Cosmetics.tsx b/src/app/features/settings/cosmetics/Cosmetics.tsx index 49ab59374..bb938a855 100644 --- a/src/app/features/settings/cosmetics/Cosmetics.tsx +++ b/src/app/features/settings/cosmetics/Cosmetics.tsx @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from 'react'; -import type { MouseEventHandler } from 'react'; +import type { ChangeEventHandler, KeyboardEventHandler, MouseEventHandler } from 'react'; import type { RectCords } from 'folds'; import { Box, @@ -7,13 +7,16 @@ import { config, Icon, Icons, + Input, Menu, MenuItem, PopOut, Scroll, Switch, Text, + toRem, } from 'folds'; +import { isKeyHotkey } from 'is-hotkey'; import FocusTrap from 'focus-trap-react'; import { PageContent } from '$components/page'; import { SequenceCard } from '$components/sequence-card'; @@ -27,6 +30,94 @@ import { SettingsSectionPage } from '../SettingsSectionPage'; import { Appearance } from './Themes'; import { LanguageSpecificPronouns } from './LanguageSpecificPronouns'; +function PronounPillMaxCountInput({ disabled }: { disabled: boolean }) { + const [maxCount, setMaxCount] = useSetting(settingsAtom, 'pronounPillMaxCount'); + const [inputValue, setInputValue] = useState(maxCount.toString()); + + const handleChange: ChangeEventHandler = (evt) => { + const val = evt.target.value; + setInputValue(val); + + const parsed = Number.parseInt(val, 10); + if (!Number.isNaN(parsed) && parsed >= 1 && parsed <= 10) { + setMaxCount(parsed); + } + }; + + const handleKeyDown: KeyboardEventHandler = (evt) => { + if (isKeyHotkey('escape', evt)) { + evt.stopPropagation(); + setInputValue(maxCount.toString()); + (evt.target as HTMLInputElement).blur(); + } + + if (isKeyHotkey('enter', evt)) { + (evt.target as HTMLInputElement).blur(); + } + }; + + return ( + + ); +} + +function PronounPillMaxLengthInput({ disabled }: { disabled: boolean }) { + const [maxLength, setMaxLength] = useSetting(settingsAtom, 'pronounPillMaxLength'); + const [inputValue, setInputValue] = useState(maxLength.toString()); + + const handleChange: ChangeEventHandler = (evt) => { + const val = evt.target.value; + setInputValue(val); + + const parsed = Number.parseInt(val, 10); + if (!Number.isNaN(parsed) && parsed >= 1 && parsed <= 64) { + setMaxLength(parsed); + } + }; + + const handleKeyDown: KeyboardEventHandler = (evt) => { + if (isKeyHotkey('escape', evt)) { + evt.stopPropagation(); + setInputValue(maxLength.toString()); + (evt.target as HTMLInputElement).blur(); + } + + if (isKeyHotkey('enter', evt)) { + (evt.target as HTMLInputElement).blur(); + } + }; + + return ( + + ); +} + const emojiSizeItems = [ { id: 'none', name: 'None (Same size as text)' }, { id: 'extraSmall', name: 'Extra Small' }, @@ -282,6 +373,32 @@ function IdentityCosmetics() { after={} /> + + } + /> + + + } + /> + = 1 && val <= 10 + ? val + : undefined; + case 'pronounPillMaxLength': + return typeof val === 'number' && Number.isInteger(val) && val >= 1 && val <= 64 + ? val + : undefined; case 'themeRemoteManualKind': case 'themeRemoteLightKind': case 'themeRemoteDarkKind': From b0349b431cf7c3a7d8e48ea2e5ce05b4e73a92f8 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 26 May 2026 23:37:09 -0500 Subject: [PATCH 3/9] fix: lists rendering p tags causing new lines --- .changeset/fix-list-rendering-p-tags.md | 5 +++++ src/app/plugins/react-custom-html-parser.test.tsx | 11 +++++++++++ src/app/plugins/react-custom-html-parser.tsx | 7 +++++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .changeset/fix-list-rendering-p-tags.md diff --git a/.changeset/fix-list-rendering-p-tags.md b/.changeset/fix-list-rendering-p-tags.md new file mode 100644 index 000000000..813308d6c --- /dev/null +++ b/.changeset/fix-list-rendering-p-tags.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fixed lists rendering `p` html tags on new lines. diff --git a/src/app/plugins/react-custom-html-parser.test.tsx b/src/app/plugins/react-custom-html-parser.test.tsx index 5f0cb8fb3..c29158224 100644 --- a/src/app/plugins/react-custom-html-parser.test.tsx +++ b/src/app/plugins/react-custom-html-parser.test.tsx @@ -446,4 +446,15 @@ describe('react custom html parser', () => { expect(screen.queryByText('<test>')).not.toBeInTheDocument(); } ); + + it('unwraps paragraph tags inside list items instead of rendering block breaks', () => { + const { container } = renderMessage( + '
  1. one

  2. two

  • bullet

' + ); + + expect(container.querySelector('p')).toBeNull(); + expect(container.textContent).toContain('one'); + expect(container.textContent).toContain('two'); + expect(container.textContent).toContain('bullet'); + }); }); diff --git a/src/app/plugins/react-custom-html-parser.tsx b/src/app/plugins/react-custom-html-parser.tsx index 8a15df7ea..adb78f3a6 100644 --- a/src/app/plugins/react-custom-html-parser.tsx +++ b/src/app/plugins/react-custom-html-parser.tsx @@ -111,7 +111,7 @@ function KatexRenderer({ useEffect(() => { let mounted = true; - Promise.all([import('katex'), import('katex/dist/katex.min.css')]).then(([katex]) => { + void Promise.all([import('katex'), import('katex/dist/katex.min.css')]).then(([katex]) => { if (mounted) { setHtml(katex.default.renderToString(math, { throwOnError: false, displayMode })); } @@ -430,7 +430,7 @@ export function CodeBlock({ const [copied, setCopied] = useTimeoutToggle(); const handleCopy = () => { - copyToClipboard(extractTextFromChildren(children)); + void copyToClipboard(extractTextFromChildren(children)); setCopied(); }; @@ -631,6 +631,9 @@ export const getReactCustomHtmlParser = ( } if (name === 'p') { + if (parent instanceof Element && parent.name === 'li') { + return <>{renderChildren()}; + } return ( {renderChildren()} From ee575c0dbdce638e0d759bee905c02ea4e713f81 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 26 May 2026 23:42:24 -0500 Subject: [PATCH 4/9] fix: nested list indentation --- .changeset/fix-nested-lists-behavior.md | 5 ++++ .../plugins/markdown/bidirectional.test.ts | 20 +++++++++++++ .../markdown/expandBlockNewlines.test.ts | 18 +++++++++++ .../plugins/markdown/expandBlockNewlines.ts | 30 +++++++++++++++++++ .../plugins/markdown/htmlToMarkdown.test.ts | 17 +++++++++++ src/app/plugins/markdown/htmlToMarkdown.ts | 7 +++-- 6 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 .changeset/fix-nested-lists-behavior.md diff --git a/.changeset/fix-nested-lists-behavior.md b/.changeset/fix-nested-lists-behavior.md new file mode 100644 index 000000000..f5b3113e4 --- /dev/null +++ b/.changeset/fix-nested-lists-behavior.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fixed nested lists having wrong indentation levels when editing. diff --git a/src/app/plugins/markdown/bidirectional.test.ts b/src/app/plugins/markdown/bidirectional.test.ts index 31ab6dd53..b5102798f 100644 --- a/src/app/plugins/markdown/bidirectional.test.ts +++ b/src/app/plugins/markdown/bidirectional.test.ts @@ -103,6 +103,26 @@ describe('bidirectional round-trip', () => { expect(result).toContain('2. Second'); }); + it('round-trips nested sublists with four-space indent', () => { + const markdown = '1. parent\n - child'; + const html = markdownToHtml(markdown); + expect(html).toMatch(/
  • [\s\S]*
      { + const markdown = '1. parent\n - child'; + const html = markdownToHtml(markdown); + expect(html).toMatch(/
    • [\s\S]*
        { const markdown = '||hidden message||'; const html = markdownToHtml(markdown); diff --git a/src/app/plugins/markdown/expandBlockNewlines.test.ts b/src/app/plugins/markdown/expandBlockNewlines.test.ts index 700d743a7..154284191 100644 --- a/src/app/plugins/markdown/expandBlockNewlines.test.ts +++ b/src/app/plugins/markdown/expandBlockNewlines.test.ts @@ -15,6 +15,24 @@ describe('expandBlockBoundariesAfterSingleNewlines', () => { it('still expands when a blockquote ends', () => { expect(expandBlockBoundariesAfterSingleNewlines('> quote\nplain')).toBe('> quote\n\nplain'); }); + + it('does not expand between consecutive ordered list items', () => { + expect(expandBlockBoundariesAfterSingleNewlines('1. one\n2. two')).toBe('1. one\n2. two'); + }); + + it('does not expand before a 2-space nested sublist', () => { + expect(expandBlockBoundariesAfterSingleNewlines('1. test\n - sub')).toBe('1. test\n - sub'); + }); + + it('does not expand before a 4-space nested sublist', () => { + expect(expandBlockBoundariesAfterSingleNewlines('1. test\n - sub')).toBe( + '1. test\n - sub' + ); + }); + + it('still expands before the first top-level list item after prose', () => { + expect(expandBlockBoundariesAfterSingleNewlines('intro\n- item')).toBe('intro\n\n- item'); + }); }); describe('consecutive blockquotes', () => { diff --git a/src/app/plugins/markdown/expandBlockNewlines.ts b/src/app/plugins/markdown/expandBlockNewlines.ts index d4164ba3a..f436bb66d 100644 --- a/src/app/plugins/markdown/expandBlockNewlines.ts +++ b/src/app/plugins/markdown/expandBlockNewlines.ts @@ -135,11 +135,41 @@ function nextLineIsBlockStarter(md: string, newlineIdx: number): boolean { return looksLikeBlockStart(effective); } +function leadingSpaces(line: string): number { + let k = 0; + while (k < line.length && line[k] === ' ') k++; + return k; +} + +function lineLooksLikeListItem(line: string): boolean { + const effective = effectiveContentAfterEscapes(line); + if (effective === null) return false; + return /^\d{1,9}\.\s/.test(effective) || /^[-*+]\s/.test(effective); +} + +function nextLineIsNestedListItem(md: string, newlineIdx: number): boolean { + const prevLine = lineAtNewline(md, newlineIdx); + const nextLine = lineAfterNewline(md, newlineIdx); + if (!lineLooksLikeListItem(nextLine)) return false; + return leadingSpaces(nextLine) > leadingSpaces(prevLine); +} + +function nextLineIsSiblingListItem(md: string, newlineIdx: number): boolean { + const prevLine = lineAtNewline(md, newlineIdx); + const nextLine = lineAfterNewline(md, newlineIdx); + if (!lineLooksLikeListItem(prevLine) || !lineLooksLikeListItem(nextLine)) return false; + return leadingSpaces(prevLine) === leadingSpaces(nextLine); +} + function shouldExpandSingleNewline(md: string, newlineIdx: number): boolean { // Consecutive `>` lines belong to one blockquote, keep the single `\n` between them. if (prevLineIsBlockquote(md, newlineIdx) && nextLineContinuesBlockquote(md, newlineIdx)) { return false; } + // Keep single `\n` between list items (siblings) and before nested sublists (2- or 4-space indent). + if (nextLineIsSiblingListItem(md, newlineIdx) || nextLineIsNestedListItem(md, newlineIdx)) { + return false; + } if (nextLineIsBlockStarter(md, newlineIdx)) return true; // CommonMark lazy continuation keeps non-`>` lines inside blockquotes, close on single `\n`. if (prevLineIsBlockquote(md, newlineIdx) && !nextLineContinuesBlockquote(md, newlineIdx)) { diff --git a/src/app/plugins/markdown/htmlToMarkdown.test.ts b/src/app/plugins/markdown/htmlToMarkdown.test.ts index 57e5e25bd..219e67089 100644 --- a/src/app/plugins/markdown/htmlToMarkdown.test.ts +++ b/src/app/plugins/markdown/htmlToMarkdown.test.ts @@ -4,9 +4,12 @@ import { MX_EMOTICON_MD_SEP, MX_EMOTICON_MD_START, } from './extensions/matrix-emoticon'; +import { toMatrixCustomHTML, trimCustomHtml } from '$components/editor/output'; import { plainToEditorInput } from '$components/editor/input'; import { BlockType } from '$components/editor/types'; +import { injectDataMd } from './injectDataMd'; import { htmlToMarkdown } from './htmlToMarkdown'; +import { markdownToHtml } from './markdownToHtml'; describe('htmlToMarkdown', () => { it('converts headings', () => { @@ -125,6 +128,20 @@ describe('htmlToMarkdown', () => { expect(result).toContain('Item 1'); }); + it('indents nested sublists with four spaces per level', () => { + const html = '
        1. parent

          • child

        '; + expect(htmlToMarkdown(html)).toContain('1. parent'); + expect(htmlToMarkdown(html)).toContain(' - child'); + }); + + it('edit-load and save round-trip keeps nested sublist', () => { + const md = '1. test\n - sub\n'; + const loaded = htmlToMarkdown(injectDataMd(markdownToHtml(md))); + expect(loaded).toContain(' - sub'); + const html = trimCustomHtml(toMatrixCustomHTML(plainToEditorInput(loaded), {})); + expect(html).toMatch(/
      • [\s\S]*
          { const result = htmlToMarkdown('bold'); expect(result).toContain('**bold**'); diff --git a/src/app/plugins/markdown/htmlToMarkdown.ts b/src/app/plugins/markdown/htmlToMarkdown.ts index cf00d0dd4..0e3756d8d 100644 --- a/src/app/plugins/markdown/htmlToMarkdown.ts +++ b/src/app/plugins/markdown/htmlToMarkdown.ts @@ -11,6 +11,9 @@ import { isAllowedHtmlTag } from './allowedHtmlTags'; import { formatMfmColorDataMd } from './extensions/matrix-mfm-color'; import { isMatrixHexColor } from '$utils/matrixHtml'; +/** CommonMark list nesting indent (four spaces per level). */ +const LIST_MARKDOWN_INDENT = ' '; + /** * Converts Matrix-compatible HTML back to markdown for round-trip editing. * Preserves original markdown syntax via data-md attributes and converts @@ -419,7 +422,7 @@ function processUnorderedList( insideCode: boolean = false ): string { const mdSequence = node.attribs['data-md'] || '-'; - const indent = ' '.repeat(depth); + const indent = LIST_MARKDOWN_INDENT.repeat(depth); const items = node.children .filter((c): c is Element => isTag(c) && c.name === 'li') .map((li) => { @@ -439,7 +442,7 @@ function processOrderedList(node: Element, depth: number = 0, insideCode: boolea ? mdSequence : `${mdSequence}.`; - const indent = ' '.repeat(depth); + const indent = LIST_MARKDOWN_INDENT.repeat(depth); const items = node.children .filter((c): c is Element => isTag(c) && c.name === 'li') .map((li, index) => { From 8daf965788a6739de09af68e9b4f88b85027e6e9 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 28 May 2026 16:37:02 -0500 Subject: [PATCH 5/9] fix math inside of color blocks --- src/app/plugins/markdown/extensions/matrix-math.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/plugins/markdown/extensions/matrix-math.ts b/src/app/plugins/markdown/extensions/matrix-math.ts index 21265f70f..26248a0b8 100644 --- a/src/app/plugins/markdown/extensions/matrix-math.ts +++ b/src/app/plugins/markdown/extensions/matrix-math.ts @@ -221,12 +221,18 @@ function isIgnorableMathContent(latex: string): boolean { * - the closing `$` is not preceded by whitespace, and * - the closing `$` is not immediately followed by an ASCII digit. */ +/** Opening `$[fg.color=…]` / `$[bg.color=…]` */ +const MFM_COLOR_FN_OPEN = /^\$\[(?:fg|bg)\.color=/; + function tryTokenizeInlineMath( src: string ): { type: 'math'; raw: string; latex: string } | undefined { if (!src.startsWith('$')) { return undefined; } + if (MFM_COLOR_FN_OPEN.test(src)) { + return undefined; + } if (src.startsWith('$$') && (src.length < 3 || src.charAt(2) !== '$')) { return undefined; } @@ -256,7 +262,7 @@ export const matrixMathExtension = { name: 'math', level: 'inline', start(src: string) { - if (/^\$\[(?:fg|bg)\.color=/.test(src)) return -1; + if (MFM_COLOR_FN_OPEN.test(src)) return -1; return src.indexOf('$'); }, tokenizer(src: string) { From b706cb9ed3f00a6ee8715846c5d7b56f1a481216 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 28 May 2026 17:41:06 -0500 Subject: [PATCH 6/9] changeset --- .changeset/fix-math-in-color.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-math-in-color.md diff --git a/.changeset/fix-math-in-color.md b/.changeset/fix-math-in-color.md new file mode 100644 index 000000000..cb09b6eeb --- /dev/null +++ b/.changeset/fix-math-in-color.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix math parsing inside of color blocks not being parsed properly. From 0487b72862e28094bf2f0b0bce0288921c1bd318 Mon Sep 17 00:00:00 2001 From: Shea Date: Wed, 3 Jun 2026 14:45:41 +0300 Subject: [PATCH 7/9] fix overflows and filename-less files Signed-off-by: Shea --- .changeset/fix-small-styling-fixes.md | 5 +++++ src/app/components/RenderMessageContent.tsx | 7 ++++++- src/app/components/message/MsgTypeRenderers.tsx | 2 +- src/app/features/room/message/MessageEditor.tsx | 7 ++++--- src/app/features/room/message/styles.css.ts | 1 + 5 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 .changeset/fix-small-styling-fixes.md diff --git a/.changeset/fix-small-styling-fixes.md b/.changeset/fix-small-styling-fixes.md new file mode 100644 index 000000000..c9d4c3e49 --- /dev/null +++ b/.changeset/fix-small-styling-fixes.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix missing filename breaking edits, and missing a fallback, and codeblock titles overflowing diff --git a/src/app/components/RenderMessageContent.tsx b/src/app/components/RenderMessageContent.tsx index 9591b2565..6cdb15c92 100644 --- a/src/app/components/RenderMessageContent.tsx +++ b/src/app/components/RenderMessageContent.tsx @@ -1,3 +1,4 @@ +import type { CSSProperties } from 'react'; import { memo, useMemo, useCallback } from 'react'; import type { IPreviewUrlResponse } from '$types/matrix-sdk'; import { MsgType } from '$types/matrix-sdk'; @@ -75,7 +76,8 @@ const isSableChatEmbedCandidate = (url: string): boolean => /^https:\/\//i.test(url) && (/\.preview\.sable\.css(\?|#|$)/i.test(url) || isHttpsFullSableCssUrl(url)); -const CAPTION_STYLE = { marginTop: config.space.S200 }; +const CAPTION_STYLE: CSSProperties = { marginTop: config.space.S200, maxWidth: '100%' }; +const TEXT_STYLE: CSSProperties = { maxWidth: '100%' }; function RenderMessageContentInternal({ displayName, @@ -216,6 +218,7 @@ function RenderMessageContentInternal({ ); @@ -293,6 +297,7 @@ function RenderMessageContentInternal({ renderBody={renderBody} renderUrlsPreview={messageUrlsPreview} renderBundledPreviews={messageBundlePreview} + style={TEXT_STYLE} /> ); } diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index 7d420655c..9ef884a43 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -426,7 +426,7 @@ export function MImage({ content, renderImageContent, outlined }: MImageProps) { }} > {renderImageContent({ - body: content.filename || 'Image', + body: content.filename || content.body || 'Image', info: imgInfo, mimeType: imgInfo?.mimetype, url: mxcUrl, diff --git a/src/app/features/room/message/MessageEditor.tsx b/src/app/features/room/message/MessageEditor.tsx index 10dbca6d7..bc0566ad5 100644 --- a/src/app/features/room/message/MessageEditor.tsx +++ b/src/app/features/room/message/MessageEditor.tsx @@ -292,9 +292,10 @@ export const MessageEditor = as<'div', MessageEditorProps>( content.format = contentBody.format; content.formatted_body = contentBody.formatted_body; content['m.new_content'] = newContent; - if (oldContent.info !== undefined && oldContent.filename?.length > 0) { - content.filename = oldContent.filename; - content['m.new_content'].filename = oldContent.filename; + if (oldContent.info !== undefined && oldContent.msgtype !== 'm.text') { + content.filename = 'filename' in oldContent ? oldContent.filename : oldContent.body; + content['m.new_content'].filename = + 'filename' in oldContent ? oldContent.filename : oldContent.body; content.info = oldContent.info; content['m.new_content'].info = oldContent.info; diff --git a/src/app/features/room/message/styles.css.ts b/src/app/features/room/message/styles.css.ts index f8946e188..031adf300 100644 --- a/src/app/features/room/message/styles.css.ts +++ b/src/app/features/room/message/styles.css.ts @@ -3,6 +3,7 @@ import { DefaultReset, config, toRem } from 'folds'; export const MessageBase = style({ position: 'relative', + maxWidth: '100%', }); export const MessageBaseBubbleCollapsed = style({ paddingTop: 0, From c119bc261d1ae878bd843bf421927c595712f248 Mon Sep 17 00:00:00 2001 From: Shea Date: Fri, 5 Jun 2026 05:07:22 +0300 Subject: [PATCH 8/9] change pixelation style Signed-off-by: Shea --- src/app/components/RenderMessageContent.tsx | 3 +- .../components/image-viewer/ImageViewer.tsx | 27 ++++++++++++++---- src/app/components/media/Image.tsx | 4 +-- .../message/content/ImageContent.tsx | 2 ++ .../features/settings/cosmetics/Themes.tsx | 7 ++--- src/app/state/settings.ts | 28 +++++++++---------- 6 files changed, 43 insertions(+), 28 deletions(-) diff --git a/src/app/components/RenderMessageContent.tsx b/src/app/components/RenderMessageContent.tsx index 9591b2565..c28004fa5 100644 --- a/src/app/components/RenderMessageContent.tsx +++ b/src/app/components/RenderMessageContent.tsx @@ -45,6 +45,7 @@ import { PdfViewer } from './Pdf-viewer'; import { TextViewer } from './text-viewer'; import { ClientSideHoverFreeze } from './ClientSideHoverFreeze'; import { CuteEventType, MCuteEvent } from './message/MCuteEvent'; +import type { IImageInfo } from '$types/matrix/common'; type RenderMessageContentProps = { displayName: string; @@ -334,7 +335,7 @@ function RenderMessageContentInternal({ } if (msgType === (MsgType.Image as string)) { - const info = (content as { info?: { mimetype?: string } }).info; + const { info } = content as { info?: IImageInfo }; const isGif = info?.mimetype === 'image/gif' || info?.mimetype === 'image/apng' || diff --git a/src/app/components/image-viewer/ImageViewer.tsx b/src/app/components/image-viewer/ImageViewer.tsx index 214347b3d..501e190ce 100644 --- a/src/app/components/image-viewer/ImageViewer.tsx +++ b/src/app/components/image-viewer/ImageViewer.tsx @@ -4,24 +4,32 @@ import classNames from 'classnames'; import { Box, Chip, Header, Icon, IconButton, Icons, Text, as } from 'folds'; import { useImageGestures } from '$hooks/useImageGestures'; import { useSetting } from '$state/hooks/settings'; -import { isPixelatedViewerRendering, settingsAtom } from '$state/settings'; +import { isPixelatedRendering, settingsAtom } from '$state/settings'; import { downloadMedia } from '$utils/matrix'; import * as css from './ImageViewer.css'; +import type { IImageInfo } from '$types/matrix/common'; +import { CheckerboardIcon } from '@phosphor-icons/react'; export type ImageViewerProps = { alt: string; src: string; requestClose: () => void; + info?: IImageInfo; }; export const ImageViewer = as<'div', ImageViewerProps>( - ({ className, alt, src, requestClose, ...props }, ref) => { + ({ className, alt, src, requestClose, info, ...props }, ref) => { const zoomInputRef = useRef(null); const [pixelatedImageRendering] = useSetting(settingsAtom, 'pixelatedImageRendering'); const [isImageReady, setIsImageReady] = useState(false); const [isEditingZoom, setIsEditingZoom] = useState(false); const [zoomInput, setZoomInput] = useState('100'); + const [isPixelated, setIsPixelated] = useState( + isPixelatedRendering(pixelatedImageRendering, info) + ); + // oxlint-disable-next-line no-console + console.log(info); const { transforms, @@ -84,6 +92,16 @@ export const ImageViewer = as<'div', ImageViewerProps>( + setIsPixelated(!isPixelated)} + aria-label="Toggle Pixelation" + title={`Turn ${isPixelated ? 'Antialiasing' : 'Pixelation'} on`} + > + + ( onPointerDown={onPointerDown} > >( @@ -13,7 +13,7 @@ export const Image = forwardRef void; + info?: IImageInfo; }; type RenderImageProps = { alt: string; @@ -242,6 +243,7 @@ export const ImageContent = as<'div', ImageContentProps>( src: viewerFullSrc ?? srcState.data, alt: body, requestClose: () => setViewer(false), + info: info, })} diff --git a/src/app/features/settings/cosmetics/Themes.tsx b/src/app/features/settings/cosmetics/Themes.tsx index eca6eec35..dbcc9dcc1 100644 --- a/src/app/features/settings/cosmetics/Themes.tsx +++ b/src/app/features/settings/cosmetics/Themes.tsx @@ -222,10 +222,9 @@ function ThemeVisualPreferences() { 'pixelatedImageRendering' ); const pixelatedImageRenderingOptions: SettingMenuOption[] = [ - { value: 'both', label: 'Both' }, - { value: 'chat', label: 'Chat' }, - { value: 'viewer', label: 'Image viewer' }, - { value: 'none', label: 'Neither' }, + { value: 'always', label: 'Always' }, + { value: 'smart', label: 'Smart' }, + { value: 'never', label: 'never' }, ]; const [incomingInlineImagesDefaultHeight, setIncomingInlineImagesDefaultHeight] = useSetting( settingsAtom, diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index 822bd052c..715de0add 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -1,6 +1,7 @@ import { atom, type WritableAtom } from 'jotai'; import type { Store } from 'jotai/vanilla/store'; import { mobileOrTablet } from '$utils/user-agent'; +import type { IImageInfo } from '$types/matrix/common'; const STORAGE_KEY = 'settings'; export type DateFormat = 'D MMM YYYY' | 'DD/MM/YYYY' | 'MM/DD/YYYY' | 'YYYY/MM/DD' | ''; @@ -56,14 +57,14 @@ export type ThemeRemoteTweakFavorite = { export type RenderUserCardsMode = 'both' | 'light' | 'dark' | 'none'; /** Where to use crisp nearest-neighbor (pixelated) image scaling. */ -export type PixelatedImageRenderingMode = 'both' | 'chat' | 'viewer' | 'none'; +export type PixelatedImageRenderingMode = 'always' | 'smart' | 'never'; -export function isPixelatedChatRendering(mode: PixelatedImageRenderingMode): boolean { - return mode === 'both' || mode === 'chat'; -} - -export function isPixelatedViewerRendering(mode: PixelatedImageRenderingMode): boolean { - return mode === 'both' || mode === 'viewer'; +export function isPixelatedRendering( + mode: PixelatedImageRenderingMode, + info?: IImageInfo +): boolean { + if (mode === 'smart') return !info || !info.w || !info.h || info.w < 192 || info.h < 192; + return mode === 'always'; } export function shouldApplyUserHeroCards( @@ -302,7 +303,7 @@ export const defaultSettings: Settings = { autoplayGifs: true, autoplayStickers: true, autoplayEmojis: true, - pixelatedImageRendering: 'viewer', + pixelatedImageRendering: 'smart', incomingInlineImagesDefaultHeight: 32, incomingInlineImagesMaxHeight: 64, linkPreviewImageMaxHeight: 640, @@ -382,10 +383,9 @@ function migrateParsedLocalStorage(parsed: Record): void { if (typeof parsed.pixelatedImageRendering === 'boolean') { parsed.pixelatedImageRendering = parsed.pixelatedImageRendering ? 'both' : 'none'; } else if ( - parsed.pixelatedImageRendering !== 'both' && - parsed.pixelatedImageRendering !== 'chat' && - parsed.pixelatedImageRendering !== 'viewer' && - parsed.pixelatedImageRendering !== 'none' + parsed.pixelatedImageRendering !== 'always' && + parsed.pixelatedImageRendering !== 'smart' && + parsed.pixelatedImageRendering !== 'never' ) { delete parsed.pixelatedImageRendering; } @@ -514,9 +514,7 @@ function sanitizeSettingsKey(key: keyof Settings, val: unknown): unknown { ? val : undefined; case 'pixelatedImageRendering': - return val === 'both' || val === 'chat' || val === 'viewer' || val === 'none' - ? val - : undefined; + return val === 'always' || val === 'smart' || val === 'never' ? val : undefined; case 'jumboEmojiSize': return typeof val === 'string' && JUMBO_EMOJI_VALUES.has(val as JumboEmojiSize) ? val From 9b33efcbfa0e989e566fe7402b3ef498f6941878 Mon Sep 17 00:00:00 2001 From: Shea Date: Fri, 5 Jun 2026 07:33:53 +0300 Subject: [PATCH 9/9] implement 'smart' pixelation in chat Signed-off-by: Shea --- .changeset/change-pixelation-behavior.md | 5 +++++ src/app/components/RenderMessageContent.tsx | 4 ++-- src/app/components/image-viewer/ImageViewer.tsx | 4 +--- src/app/components/media/Image.tsx | 9 ++++++--- src/app/components/url-preview/UrlPreviewCard.tsx | 1 + src/app/state/settings.ts | 2 +- 6 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 .changeset/change-pixelation-behavior.md diff --git a/.changeset/change-pixelation-behavior.md b/.changeset/change-pixelation-behavior.md new file mode 100644 index 000000000..b5d53bbfe --- /dev/null +++ b/.changeset/change-pixelation-behavior.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Change image rendering to allow enabling anti-aliasing in the image viewer diff --git a/src/app/components/RenderMessageContent.tsx b/src/app/components/RenderMessageContent.tsx index c28004fa5..9fdcdedac 100644 --- a/src/app/components/RenderMessageContent.tsx +++ b/src/app/components/RenderMessageContent.tsx @@ -359,11 +359,11 @@ function RenderMessageContentInternal({ if (isGif && !autoplayGifs && p.src) { return ( - + ); } - return ; + return ; }} renderViewer={(p) => } /> diff --git a/src/app/components/image-viewer/ImageViewer.tsx b/src/app/components/image-viewer/ImageViewer.tsx index 501e190ce..573ef0cfa 100644 --- a/src/app/components/image-viewer/ImageViewer.tsx +++ b/src/app/components/image-viewer/ImageViewer.tsx @@ -28,8 +28,6 @@ export const ImageViewer = as<'div', ImageViewerProps>( const [isPixelated, setIsPixelated] = useState( isPixelatedRendering(pixelatedImageRendering, info) ); - // oxlint-disable-next-line no-console - console.log(info); const { transforms, @@ -98,7 +96,7 @@ export const ImageViewer = as<'div', ImageViewerProps>( radii="Pill" onClick={() => setIsPixelated(!isPixelated)} aria-label="Toggle Pixelation" - title={`Turn ${isPixelated ? 'Antialiasing' : 'Pixelation'} on`} + title={`Turn ${isPixelated ? 'Anti-aliasing' : 'Pixelation'} on`} > diff --git a/src/app/components/media/Image.tsx b/src/app/components/media/Image.tsx index 3dc8b71ab..389bbf810 100644 --- a/src/app/components/media/Image.tsx +++ b/src/app/components/media/Image.tsx @@ -4,16 +4,19 @@ import classNames from 'classnames'; import { useSetting } from '$state/hooks/settings'; import { isPixelatedRendering, settingsAtom } from '$state/settings'; import * as css from './media.css'; +import type { IImageInfo } from '$types/matrix/common'; -export const Image = forwardRef>( - ({ className, alt, ...props }, ref) => { +type ImageProps = ImgHTMLAttributes & { info?: IImageInfo }; + +export const Image = forwardRef( + ({ className, alt, info, ...props }, ref) => { const [pixelatedImageRendering] = useSetting(settingsAtom, 'pixelatedImageRendering'); return ( {alt} } renderImage={(p) => (