WIP: moon-miniapp-backport-bugfixes #3615

Draft
moonman wants to merge 37 commits from moonman/pleroma-fe:moon-miniapp-backport-bugfixes into develop
Member

Checklist

  • Adding a changelog: In the changelog.d directory, create a file named <code>.<type>.

I recommend looking at each of these commits individually and applying them, not just merging this giant-ass merge request. the last several are pretty critical, came from users complaints, many of them were "I keep getting complaints, proactively find things that cause a null json value and patch them." sorry in advance for slop but it erased almost 100% of the daily complaints I got.

### Checklist - [ ] Adding a changelog: In the `changelog.d` directory, create a file named `<code>.<type>`. <!-- `<code>` can be anything, but we recommend using a more or less unique identifier to avoid collisions, such as the branch name. `<type>` can be `add`, `change`, `remove`, `fix`, `security` or `skip`. `skip` is only used if there is no user-visible change in the MR (for example, only editing comments in the code). Otherwise, choose a type that corresponds to your change. In the file, write the changelog entry. For example, if an MR adds group functionality, we can create a file named `group.add` and write `Add group functionality` in it. If one changelog entry is not enough, you may add more. But that might mean you can split it into two MRs. Only use more than one changelog entry if you really need to (for example, when one change in the code fix two different bugs, or when refactoring). --> I recommend looking at each of these commits individually and applying them, not just merging this giant-ass merge request. the last several are pretty critical, came from users complaints, many of them were "I keep getting complaints, proactively find things that cause a null json value and patch them." sorry in advance for slop but it erased almost 100% of the daily complaints I got.
The block expiry label on block cards and user cards formatted
user.mute_expires_at instead of user.block_expires_at, so a temporary
block displayed the mute expiry date, or "Invalid Date" when the user
was not muted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Block cards, mute cards and user cards look their user up by id, and
the user can be missing from the store when the expiry computeds run.
Object.hasOwn() then threw on undefined. Treat a missing user as
having no expiry information.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
promisedRequest() called .split() on the Content-Type header without
checking it exists. Bodyless responses (204/205 and HEAD) and many
proxy error pages leave the header out, so the request threw a
TypeError: successful requests were reported as failed, and HTTP
errors lost their status code.

Return no data for bodyless responses, and treat a missing header as
an unknown content type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StatusCodeError read body.error without checking for a body.
promisedRequest() passes null for empty error responses
(Content-Length: 0, or a literal JSON null), so building the error
threw a TypeError. Callers then saw the TypeError instead of the
HTTP status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parseUser() assumed account data is always present. Statuses from
deleted or suspended accounts, tombstones, broken quotes and some
notifications come with a null account, and parsing them threw. That
dropped the whole timeline page or notification batch they were in.

Substitute a stub user with empty values in that case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parseUser() assumed display_name, fields and acct are always present:

- a missing display name was escaped into the literal string
  "undefined" and shown as the user's name
- missing fields, null field entries or fields without a name or value
  threw while building fields_html/fields_text
- an account source without fields replaced the parsed profile fields
  with undefined
- a missing acct threw while computing is_local

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parseNotification() threw on notifications that:

- have no pleroma object, as sent by backends without Pleroma
  extensions
- are status notifications with the status key missing entirely; only
  an explicit null was handled
- are reports with missing or null entries in the statuses list

A single such notification made the whole notification batch fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Backends can return null entries in status and notification lists
(deleted statuses, for example), as well as in mentions and media
attachments. The normalizer and the store ingestion code dereferenced
every entry, so one empty entry made the whole timeline or
notification batch fail to load.

Drop empty entries when fetching timelines, parsing mentions and
attachments, and adding statuses, notifications and users to the
stores. Let the parse functions pass empty input through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The users store indexed screen_name and url only when a user was first
added:

- users first seen without a screen_name or url threw on
  .toLowerCase(), failing the whole batch they arrived in
- once a user's full data arrived later, they were never indexed
- after a user changed their handle or URL, lookups kept pointing at
  the old values

Update the indexes on every update, drop the stale key, and allow
lookups with a missing query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parseStatus() took text and summary from Pleroma's content variant
maps whenever those maps existed, even when they lacked a text/plain
entry. HTML-only or attachment-only statuses then had an undefined
text. StatusBody read .length on it during setup, so the status did
not render at all. A missing spoiler_text was also escaped into the
literal string "undefined".

Fall back to the standard content and spoiler_text fields when the
plain-text variant is missing, and default text, summary, raw_html
and emojis to empty values. Make StatusBody tolerate missing text,
summary and HTML.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Typing a mention sent a backend account search for nearly every
keystroke. Each one also asked the backend to resolve remote
accounts. This quickly tripped the backend's search rate limit (HTTP
429), and mention suggestions stopped working.

- don't search for queries shorter than two characters; locally known
  users are enough for those
- raise the debounce from 300ms to 500ms, so typing at a normal speed
  collapses into a single search
- abort an in-flight search when a newer query supersedes it
- only resolve remote accounts from the explicit user pickers (mutes
  and blocks, user selector), not from suggestions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the backend account search failed, for example on a 429, the
rejection propagated out of the suggestor. No suggestions were shown,
not even users already known locally, and the error surfaced as an
unhandled rejection.

Log the failure and continue with locally known users. Aborted
searches are not logged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Backspacing or retyping a mention, or searching again in a user
picker, repeated identical account searches against a rate-limited
endpoint.

Keep the 20 most recent results for 30 seconds, keyed by query and
whether remote accounts were resolved. Cached results are only reused
for the same account token and the same user map, which is replaced
on logout, so a different session never sees them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The favorites tab on another user's profile always fetched
/api/v1/favourites, which returns the signed-in user's own favorites.
The user id was never passed to the public favorites endpoint either.

- fetch other users' favorites from Pleroma's public favorites endpoint
- keep using the regular endpoint for the signed-in user, so their own
  tab works even without public favorites support
- only treat a 501 from the public endpoint as "unsupported"; a 403
  means that one user hides their favorites, and should not disable
  the tab for everyone

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getInstanceConfig() read data.pleroma.vapid_public_key and
data.pleroma.metadata.* unconditionally. On backends without Pleroma
extensions, or with no metadata object, this threw half way through.
The approval and birthday settings were then never applied.

Also:

- read the character limit from Mastodon's
  configuration.statuses.max_characters when max_toot_chars is absent,
  and keep the default instead of overwriting it with undefined
- store pleromaExtensionsAvailable as a boolean instead of the whole
  pleroma object

getInstanceConfig is now exported so it can be tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On boot, the stored token was used to log in at the same time as
nodeinfo and the instance config were fetched. loginUser() decides
whether to start the chats and shoutbox fetchers from those
capabilities. If login finished first, the capabilities were still
unset and those features silently stayed off until the next reload.

Finish capability discovery before logging in. All of these requests
are usually preloaded into the page, so the extra wait is small.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parseUser() initialised privileges as an array and only replaced it
with a Set when Pleroma account data was present. Announcements,
interactions and user cards call privileges.has(). For accounts
without Pleroma data, those calls threw "privileges.has is not a
function".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scrobbles store checks the pleromaScrobblesAvailable capability,
but the capabilities store defined scrobblesSupport instead. The check
always saw undefined, so scrobbles were never fetched or shown.

- define pleromaScrobblesAvailable, enabled by default, since nodeinfo
  doesn't advertise scrobbles and the API has to be probed
- only disable scrobbles when the backend answers 501; previously any
  failed request, even a transient one, disabled them for the rest of
  the session
- don't throw when the user is no longer in the store by the time the
  response arrives

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For users who cannot manage announcements, fetchAnnouncements()
returned the fetched list instead of storing it. The announcements
page and the unread counter were therefore always empty for everyone
except admins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The bookmark folder poller started on every login, regardless of
whether the backend supports bookmark folders. On other backends it
logged a failed request every four minutes. Starting it again, for
example on a repeated login, also leaked another poller, because the
previous one was overwritten without being stopped.

- skip polling unless pleromaBookmarkFoldersAvailable is set
- ignore a start while a poller is already running, and clear it on
  stop so it can be started again
- return the request from the poll callback, so the interval starts
  counting after the request finishes, as promiseInterval intends

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tagging users, changing rights, (de)activating and (un)suggesting
users, reloading emoji and importing emoji packs from the filesystem
still used the unversioned /api/pleroma/... routes. The backend serves
the admin and emoji pack APIs under /api/v1/pleroma, which the other
admin calls already use, so these actions failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The (de)activate, (un)suggest, approve and confirm API helpers mapped
the request result to response.users. promisedRequest() resolves to
{ data, response, ... }, so they always returned undefined. The admin
store then threw reading .data from it, and the updated user state was
never applied.

Return the request result unchanged, and read the users from
data.users, as the backend answers { users: [...] }.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vite-plugin-vue-devtools hooks into every mounted app. In browser-mode
unit tests its hooks throw an unhandled rejection ("Cannot read
properties of undefined (reading 'app')") for some component tests.
Vitest then reports an error and exits non-zero, even though every test
passed.

Only load the devtools plugin outside of test mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
emoji_reactions was only set when a status had Pleroma data. Statuses
from backends without it, or with the field missing, had none, and
EmojiReactions threw on .length/.slice, so the status failed to render.
reactedWith() also threw for an emoji without a reaction entry.

Default emoji_reactions to an empty list in the normalizer, and make
the component treat missing reactions as none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parseStatus() set quote_visible to `pleroma.quote_visible || true`,
which is always true. Quotes the backend reports as not visible to the
user were therefore fetched anyway, failing, and the code for
unavailable quotes never ran. Mastodon quote states were ignored too.

- take quote_visible from Pleroma, or from the Mastodon quote state
  (only "accepted" quotes are visible), defaulting to visible
- don't fetch or display quotes that are not visible, and fetch them if
  they become visible later
- drop the "Quoted status unavailable" placeholder and simply omit
  unavailable quotes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every notification listens to selectionchange on the whole document.
For mention and status notifications, the root ref is a Status
component, not an element, so selecting text anywhere on the page
threw "this.$refs.root.contains is not a function" once for each such
notification. The handler also threw when the browser had no selection
at all.

Only track selection for expandable notifications with an element
root, and treat a missing selection like a collapsed one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The selection handler checked selection.offsetNode, which does not
exist; the end of a selection is focusNode. A selection that started
outside an expandable notification and ended inside it was therefore
not recognised, and releasing the mouse toggled the notification
instead of keeping the selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The chat view reuses one usePleromaChat instance and deactivates and
reactivates it when switching to another chat. Requests made for the
previous chat were not tied to it:

- a chat lookup finishing after switching away replaced the chat being
  shown and started another poller
- fetch errors from the previous chat were shown in the new one
- unsent and failed messages from the previous chat were kept, and
  shown in the new chat
- send retries kept running after leaving the chat

Track a generation that is bumped on every (de)activation, and drop
responses that belong to an older one. On deactivation, clear the chat
and its error and all loaded messages, cancel retries and mark the
chat's in-flight messages as failed. Only expose the current chat's
pending messages, so failed messages show up again when returning to
their chat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markAsRead() sent the newest message id to the backend, then, once the
request finished, recorded the newest message at that point as read,
reset the unread counter and cleared the chat's unread count. Messages
that arrived while the request was in flight were therefore marked as
read locally without the backend knowing, and their unread indicator
disappeared.

Record only the id that was actually sent, and only reset the unread
state when no newer message arrived in the meantime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
usePleromaChat attaches its streaming socket before the chat lookup
finishes, and its handlers assumed a loaded chat:

- a disconnect before the chat loaded started polling with no chat,
  and the fetch failed and showed an error
- a chat update before the chat loaded threw in addMessages
- a disconnect while already polling started a second poller and
  leaked the first, doubling the polling rate until reload
- deactivating a chat that was never activated threw in detachSocket

Ignore those events until the chat is loaded, don't start a poller
when one is running, and make detaching the socket idempotent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The visibility icon's title is bound to visibilityLocalized, which was
a method rather than a computed property. The title was therefore the
function's source text instead of a label. The method also read
this.status.visibility, which does not exist on chat messages, so
calling it would have thrown.

Make it a computed property based on the message's visibility.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
replyProfileLink looked up the replied-to user and read its profile
URL without checking whether the user is known. The neighbouring
replyToName already handles that case. Replies to users not in the
store threw, and the message failed to render.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The chat message list renders from the virtual scrolling height chart,
which is updated asynchronously. When a message disappeared (it was
deleted, or the chat was switched or cleared), the chart could still
list it for a moment. Rendering it read .messageChainId of the missing
item and crashed the chat view.

Skip chart entries whose message no longer exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The chat view's jump to bottom button calls scrollDown(), but the chat
view never defined it, so clicking the button threw
"scrollDown is not a function" and nothing happened.

Define scrollDown to scroll the page to the bottom of the chat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clearTimeline() reset the timeline's statuses but kept its repeat
bookkeeping. A repeat of a status that had been repeated before the
clear was then treated as a repeat of an already seen post, and was
hidden, although the earlier repeat was no longer in the timeline.

Reset the repeat maps along with the rest of the timeline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
startFetching() made an initial request that shows its results
immediately, and then started a promiseInterval, which also makes its
first call right away. Every timeline therefore started with two
identical requests. When the second one answered first, its results
were counted as new posts instead of being displayed, and the timeline
showed a "new posts" button.

Also, a failed initial request marked the timeline as exhausted, which
stopped "load older" from working.

Do the initial request as the first run of the interval, and only mark
the timeline exhausted after a successful initial request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ignore timeline responses that arrive after clearing it
Some checks are pending
ci/woodpecker/pr/build Pipeline is pending approval
ci/woodpecker/pr/changelog Pipeline is pending approval
ci/woodpecker/pr/lint Pipeline is pending approval
ci/woodpecker/pr/test-e2e Pipeline is pending approval
ci/woodpecker/pr/test Pipeline is pending approval
560c5ad2d1
Timelines are cleared and reloaded, for example when more than a page
of new posts arrived between polls. A request that was in flight
during the clear was still applied afterwards. It re-added posts from
before the reload and moved the pagination markers, which could leave
gaps when loading more.

Bump a generation counter when clearing a timeline, and drop responses
to requests made before the clear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hj changed title from moon-miniapp-backport-bugfixes to WIP: moon-miniapp-backport-bugfixes 2026-11-16 21:34:35 +00:00
Member

It would be very appreciated if every commit or commit set could be its own separate MR

It would be very appreciated if every commit or commit set could be its own separate MR
Some checks are pending
ci/woodpecker/pr/build Pipeline is pending approval
ci/woodpecker/pr/changelog Pipeline is pending approval
ci/woodpecker/pr/lint Pipeline is pending approval
ci/woodpecker/pr/test-e2e Pipeline is pending approval
ci/woodpecker/pr/test Pipeline is pending approval
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u moon-miniapp-backport-bugfixes:moonman-moon-miniapp-backport-bugfixes
git switch moonman-moon-miniapp-backport-bugfixes

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch develop
git merge --no-ff moonman-moon-miniapp-backport-bugfixes
git switch moonman-moon-miniapp-backport-bugfixes
git rebase develop
git switch develop
git merge --ff-only moonman-moon-miniapp-backport-bugfixes
git switch moonman-moon-miniapp-backport-bugfixes
git rebase develop
git switch develop
git merge --no-ff moonman-moon-miniapp-backport-bugfixes
git switch develop
git merge --squash moonman-moon-miniapp-backport-bugfixes
git switch develop
git merge --ff-only moonman-moon-miniapp-backport-bugfixes
git switch develop
git merge moonman-moon-miniapp-backport-bugfixes
git push origin develop
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pleroma/pleroma-fe!3615
No description provided.