Impl MSC4461: Storing per-message profiles for users (#1589)

<!-- Please read
https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before
submitting your pull request -->

### Description

<!-- Please include a summary of the change. Please also include
relevant motivation and context. List any dependencies that are required
for this change. -->

Migrates PMP account data to the format described in
[MSC4461](https://github.com/matrix-org/matrix-spec-proposals/pull/4461).
Extensions to the format are defined in my informal
[MSCF002](https://github.com/j0lol/matrix-spec-proposals/blob/mscf/proposals/F0002-PK-proxy-tags.md).
(Though ambiguity behavior defined in this spec have not been
implemented just yet.)

Part of #1279

#### Type of change
breaking change on an experimental feature, with migrations

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings

### AI disclosure:

- [ ] Partially AI assisted (clarify which code was AI assisted and
briefly explain what it does).
- [ ] Fully AI generated (explain what all the generated code does in
moderate detail).
<!-- Write any explanation required here, but do not generate the
explanation using AI!! You must prove you understand what the code in
this PR does. -->
This commit is contained in:
Erwan Leboucher authored and GitHub committed 2026-08-03 19:46:44 +00:00
commit 4a735be2ba
21 files changed
+664 -523

No files matched your search

@@ -415,11 +415,13 @@ export function MessagePreview({
const [showPronouns] = useSetting(settingsAtom, 'showPronouns');
const [parsePronouns] = useSetting(settingsAtom, 'parsePronouns');
const { cleanedDisplayName: displayName, inlinePronoun } = useMemo(
() => getParsedPronouns(perMessageProfile?.name || fallbackDisplayName, parsePronouns),
[perMessageProfile?.name, fallbackDisplayName, parsePronouns]
() => getParsedPronouns(perMessageProfile?.displayname || fallbackDisplayName, parsePronouns),
[perMessageProfile?.displayname, fallbackDisplayName, parsePronouns]
);
const pronouns = useMemo(() => {
const resolved = [...(perMessageProfile?.pronouns ?? userProfile.pronouns ?? [])];
const resolved = [
...(perMessageProfile?.['io.fsky.nyx.pronouns'] ?? userProfile.pronouns ?? []),
];
if (
inlinePronoun &&
!resolved.some((item) => item.summary?.toLowerCase() === inlinePronoun.toLowerCase())
@@ -427,9 +429,9 @@ export function MessagePreview({
resolved.push({ summary: inlinePronoun, language: 'en' });
}
return resolved;
}, [perMessageProfile?.pronouns, userProfile.pronouns, inlinePronoun]);
}, [perMessageProfile, userProfile.pronouns, inlinePronoun]);
const avatarMxc =
perMessageProfile?.avatarUrl ??
perMessageProfile?.avatar_url ??
getMemberAvatarMxc(room, sender) ??
userProfile.avatarUrl ??
profile?.avatarUrl;
+1 -1
View File
@@ -512,7 +512,7 @@ export const Reply = as<'div', ReplyProps>(
eventType !== EventType.RoomMember && (
<Text size="T300" truncate style={{ fontFamily: usernameFont }}>
<b>
{pmp?.name ??
{pmp?.displayname ??
getMemberDisplayName(room, sender, nicknames) ??
cachedProfiles[sender]?.displayName ??
getMxIdLocalPart(sender)}
@@ -67,7 +67,7 @@ import { useFavoriteGifs } from '$hooks/useFavoriteGifs';
import type { IImageInfo } from '$types/matrix/common';
import { getIncomingMediaMxcUrl } from '../MsgTypeRenderers';
import { TemporaryPersonaPicker } from '$features/room/persona-picker/PersonaPicker';
import { type PerMessageProfile } from '$hooks/usePerMessageProfile';
import { type PerMessageProfileMsc4461 } from '$hooks/usePerMessageProfile';
import { buildReplacementPmpContent } from '$features/room/buildReplacementContent';
import { settingsAtom } from '$state/settings';
import { useSetting } from '$state/hooks/settings';
@@ -414,7 +414,7 @@ function OptionsReproxyPersonaPicker({
closeMenu,
anchor,
}: OptionsReproxyPersonaPickerProps) {
const reproxyMessage = async (profile: PerMessageProfile | undefined) => {
const reproxyMessage = async (profile: PerMessageProfileMsc4461 | undefined) => {
const content = buildReplacementPmpContent(mEvent.getContent(), mEvent.getId()!, profile);
await mx.sendMessage(roomId, content as RoomMessageEventContent);