mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7218] [MERGED] fix(chat): keep a large message trash responsive #7629
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7629
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7218
Author: @SpicyMarinara
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/large-trash-responsive-7210📝 Commits (5)
80662e6fix(chat): keep a large message trash responsive252709fMerge origin/staging into fix/large-trash-responsive-721063ed1ebfix(chat): fill a large trash 200 rows at a time6723f57fix(chat): restart the trash's progressive fill when the chat changes (#7210)f5d5a67Merge remote-tracking branch 'origin/staging' into fix/large-trash-responsive-7210📊 Changes
4 files changed (+384 additions, -70 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)➕
e2e/message-trash-responsive.e2e.ts(+196 -0)📝
packages/client/src/components/chat/ChatMessageMarksPanels.tsx(+185 -69)📝
packages/client/src/components/chat/ChatMessageSearch.tsx(+2 -1)📄 Description
Linked issue
Closes #7210
Why this change
message-trash-batchingfixture), and every row re-rendered and restyled when a restore or delete started or finished, which took several more seconds. Phones are hit hardest.What changed
ChatMessageMarksPanels.tsx(only product file):requestIdleCallback, or a 16 ms timer in WebKit). Every row ends up in the DOM. If the list shrinks, the count shrinks with it, so a list that grows large again also fills in batch by batch.memocomponents with stable callbacks. A busy change, a delete confirmation on one row, or a refetch that keeps the same entries no longer re-renders the other rows.aria-busyand a dimmed cover (bg-[var(--background)]/50,cursor-progress) instead of adisabledattribute on each of the 10,002 row buttons. Restyling those buttons, or a disabledfieldsetaround them, took about 2–3 s in WebKit even after React stopped re-rendering the rows. Row actions are ignored while busy, including from the keyboard. Restore all and Empty trash are still natively disabled.divide-y, so appending a batch never restyles the rows above it. It looks the same: the first row's border is the line under the header.e2e/message-trash-responsive.e2e.ts(new): with 1,001 mocked entries, it checks that:aria-busyand keeps the restore request count at 1 when a row's Restore is pressed with Enter;memoremoved (8,503 row renders vs 6,501), and without the busy guard (2 restore requests).CHANGELOG.md: an[Unreleased]entry.Measurements
The table below is from the first commit, with batches of 100. Numbers for the final batches of 200 are under Batch size.
These come from a temporary measuring spec (not committed). It used the same 5,001-entry mock as
message-trash-batching, on the Vite dev build. Baseline and fix runs alternated on a busy machine (load average 7–26 from other jobs), so read the numbers as relative. "Max block" is the longest gap in a 10 ms page heartbeat.message-trash-batching, desktop-chromium: 8.5 s / 9.2 s before, 3.5 s / 6.1 s after.message-trash-batching, mobile-webkit: 12.1 s / 15.6 s before, 4.7 s / 11.8 s after. The conflicts-only test now waits for the progressive fill before its 5,001-row count.allDescendantsMightBeInvalid). That forces a whole-document style recalculation, about 85k elements with this list open. It happens for any focus change in that window and in baseline too. It's a likely follow-up; see the note below.Batch size: 100 → 200 (verification follow-up)
With batches of 100, the existing conflicts-only
message-trash-batchingtest (unchanged) clicks Restore all while the list is still filling in. It then waits for all 5,001 rows withtoHaveCount(5001)and the default 10 s timeout. CI runs this spec about 3× slower than a local machine: on the 2026-10-07 nightly matrix it took 30.1 s on desktop-chromium and 51.6 s on mobile-webkit, against 9.2 s and 15.6 s locally. In a temporary copy of that test, time spent in the finaltoHaveCount(5001)wait:A Chromium trace shows that each batch restyles only its own ~1.7k new elements and lays out only the ~2.4k new objects, so the cost is per row, not per list. Wrapping each batch in a
div(plain,contain: contentorcontain: layout style) made WebKit's fill slower: 6.6–9.1 s against 5.1 s. ReplacingrequestIdleCallbackwith a 0 ms timer did not speed up Chromium under throttle. Fewer, larger batches were the one simple lever. I kept the 16 ms WebKit timer because a timer that is always ready could delay WebKit paints, and a heartbeat can't show that. The new spec's per-update limit and the CHANGELOG now say 200.Final numbers, 5,001 entries, Vite dev build, load average 3–5. "Max block" is the longest gap in a 10 ms heartbeat; p90 is over gaps above 50 ms.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdAgent-run checks:
pnpm checkpassed, including localization, format, lint, e2e types and build.pnpm localization:checkpassed (no new strings).desktop-chromiumandmobile-webkit:message-trash-batching,message-marks-trashand the newmessage-trash-responsive. The existing specs are unchanged.message-trash-responsivealso passed with--repeat-each=3ondesktop-chromium,mobile-chromiumandmobile-webkit.Verification pass (after merging
origin/staging, with batches of 200; head63ed1ebbe):pnpm checkpassed (exit 0), includinglocalization:check.desktop-chromiumandmobile-webkit(16/16):message-trash-responsive,message-trash-batching,message-marks-trash,message-marks-colorsandchat-settings-tools.message-trash-responsiveandmessage-trash-batchingpassed with--repeat-each=3 --workers=3on all three projects (27/27).--repeat-each=3 --workers=4over the three trash specs on desktop-chromium and mobile-webkit: 29/30.message-marks-trashroleplay on mobile-webkit: the fixture delete returnedtrashed: false.messageTrashfeature on (off by default) and restores it infinally, so parallel repeats on one server switch it off under each other.{ all: true }and shows the empty state.--backgroundin light and dark themes.Manual verification notes
/trash/restore). The warning or error toast stays up for about 15 s.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Only
CHANGELOG.mdchanged.docs/chats/chat-settings.mddescribes the Trash tab only in general terms, so no user docs changed.Possible follow-up, not filed: any focus change inside the Chat Settings window makes Chromium recalculate style for every element in the window (see Measurements). This is probably a Tailwind
group-focus-within:/:is(... *)selector. It is independent of the trash, but a large list there makes it visible.UI evidence (if applicable)
Not attached. The busy state dims the rows behind a cover instead of dimming only the row buttons. The idle look is unchanged.
Local review
I ran the local CodeRabbit CLI (0.7.6) once on the committed branch, and the verification pass ran it once more on the final branch (base
b5b46c786). Both runs returned the same single finding, which I did not apply:inertto the row container while busy so keyboard users cannot focus or activate rows. Not applied: togglinginerton the list restyles every row. In my measurements,inertplus a dim on the 5,001-row list blocked WebKit for about 3.4 s when a restore started, worse than before this PR, so it would undo the WebKit fix. The verification pass measured it again on the final code: withinert={busy}, WebKit blocked for 2.3–2.4 s on the Restore all click and 1.7 s on the response, against 0.08–0.13 s and 0.07 s without it. Chromium's response block rose from about 75 ms to 375 ms. Keyboard activation is already handled:restoreEntryanddeleteEntryreturn early whilebusyRef.currentis true. The new spec presses Enter on a covered row's Restore while Restore all is pending and checks that only one restore request was sent. The list also exposesaria-busyinstead of being hidden from assistive technology.🤖 Generated with Claude Code
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.