[PR #8963] [MERGED] perf(shell): keep app-wide restyles and re-renders out of the sidebar slide #8918

Closed
opened 2026-11-08 04:56:05 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8963
Author: @Gunterlie
Created: 11/7/2026
Status: ✅ Merged
Merged: 11/7/2026
Merged by: @Gunterlie

Base: staging ← Head: perf/sidebar-slide


📝 Commits (4)

  • 58390ad perf(shell): keep app-wide restyles and re-renders out of the sidebar slide
  • ad3fcb7 perf: stop :has() rules and the resize handle from restyling the whole app on DOM insertions
  • 71a8632 fix: clear stale composer focus, place a shown bubble from live bounds, re-publish inset after remount
  • 0babf77 fix: skip accent ticks only for the slot width slide; publish the inset at once when the slide is off

📊 Changes

9 files changed (+95 additions, -39 deletions)

View changed files

📝 packages/client/src/App.tsx (+9 -2)
📝 packages/client/src/components/characters/SpriteLibrary.tsx (+1 -1)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+2 -4)
📝 packages/client/src/components/chat/EchoChamberPanel.tsx (+5 -2)
📝 packages/client/src/components/layout/AppShell.tsx (+28 -7)
📝 packages/client/src/components/layout/GlobalOmnibar.tsx (+14 -0)
📝 packages/client/src/components/ui/FloatingWindow.tsx (+15 -9)
📝 packages/client/src/styles/globals.css (+7 -0)
📝 packages/client/src/styles/mari.css (+14 -14)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issue

Closes #8962

Why this change

Opening or closing a sidebar looks jittery and laggy. Profiling at 4x CPU slowdown shows that the slide itself is cheap: the slot width relayout costs about 8–20 ms for each toggle. The cost comes from work that runs during the slide:

  • The hidden Chat Settings window stays mounted. It measured the page again and computed its default layout again on every slide frame, which forced a synchronous style recalculation each frame.
  • The roleplay surface subscribed to sidebar state only to hide the Echo Chamber on mobile, so every toggle rendered every message again (the click handler took 149 ms at 4x).
  • AppShell wrote --mari-chat-ui-inset-* on <html> in the click frame and on every resize-drag move. Any inline style on <html> restyles the whole app (about 150–220 ms at 4x).
  • The accent pulse, on by default on desktop, writes root colour tokens every 500 ms. When a tick lands during a slide, the slide stalls.
  • Two :has() rules made Chromium restyle about 1,900 elements on every DOM insertion anywhere in the app: a Tailwind group-has-* class in the sprite library, and the omnibar sheet's :not(:has(:focus)) > :not(...) rule. A sidebar toggle inserts a small topbar element, which triggered it. This likely also slows message streaming.
  • The resize handle was mounted and unmounted as a sibling in the shell row, which restyled the chat column.

What changed

  • FloatingWindow: live bounds pause while the window is hidden, and catch up before paint when it shows again.
  • ChatRoleplaySurface / EchoChamberPanel: the panel reads sidebar state itself, so a toggle no longer renders the messages again.
  • AppShell: the chat UI inset variables publish after the slide (220 ms) or after a resize drag pauses. The first publish is immediate. Only floating chat UI reads them.
  • AppShell: both resize handles stay mounted and hide with the hidden attribute.
  • App: skip an accent tick while a shell panel slot transition runs.
  • GlobalOmnibar + mari.css: the omnibar publishes composer focus as data-mari-composer-focused; the sheet rules use that attribute instead of :has(:focus).
  • SpriteLibrary + globals.css: the "rows keep their colour while a folder drags" hover rule is plain CSS instead of Tailwind group-has-*.

A DOM insertion now restyles 19 elements instead of about 1,906.

Measurements

Headless Chromium, 1440×900, roleplay chat with 120 messages, 4x CPU slowdown, accent pulse on (default). Median of 5 toggles for each direction. "Frames" = frames painted in the first 300 ms after the click; "max gap" = longest time without a frame in that window.

Toggle Before: frames / max gap After: frames / max gap
Left open 0 / 300 ms 5 / 83 ms
Left close 0 / 300 ms 5 / 71 ms
Right open 0 / 300 ms 3 / 178 ms
Right close 0 / 300 ms 5 / 83 ms

The first frame after the click came after 364–507 ms before and after 2–71 ms now. Script time for each toggle fell from 188–246 ms to 114–155 ms.

Pulse off, 4x: left open 1 / 297 → 5 / 83, left close 1 / 300 → 6 / 67, right open 0 / 300 (first frame at 575 ms) → 4 / 133, right close 1 / 299 → 4 / 86.

No throttle (1x), pulse on: left open 9 / 83 → 13 / 67, left close 10 / 84 → 14 / 65, right open 6 / 133 → 11 / 67, right close 12 / 83 → 13 / 67.

Known limits (not in this PR)

  • The chat UI inset now follows a sidebar toggle or a resize drag about 220 ms late. During a drag, floating chat UI (game inventory, readable display, Chat Settings bubble, presence card) keeps the old offset until the drag pauses; a toolbar panel opened within 220 ms of a right-panel toggle anchors to the old inset. This is the trade-off for not restyling the whole app during the slide.

  • The deferred inset publish still causes one whole-page style recalculation about 220–300 ms after the slide. It no longer stalls the slide. Mobile is not affected, because the inset is always 0 in overlay mode. A follow-up can let the consumers read the inset from the store and set it locally.

  • At 4x, each slide frame still costs about 50–80 ms: about 25 ms paint, about 22 ms for the visible Chat Settings bubble that follows the chat, and about 20 ms layout.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Agent checks on a local build (Playwright, Chromium): sidebar open/close at 1440, 768 and 390 px; resize by keyboard (ArrowRight) and mouse drag, with the inset following after the drag pauses; a hidden resize handle cannot take focus; five fast toggles settle with the slot state and inset in agreement; reduced motion has no slot transition; light/dark and default/SillyTavern themes; on a phone, the omnibar composer sets and clears data-mari-composer-focused. Console: no page errors; the only failed requests are two /api/connections/<id>/models calls (400 and 502) for providers without valid keys in the test data. These also happen on staging.

Review: a Marinara reviewer pass found no blocking issues. Fixed from it: a composer that unmounts while focused no longer leaves the sheet flag set; a window shown again places its bubble from live bounds; a remount publishes the inset at once. The local CodeRabbit CLI could not run: the CodeRabbit server rejects the stored session ("Your CodeRabbit session or Git provider access could not be authenticated"), and a new login needs an interactive browser. CodeRabbit on GitHub reviews this PR instead.

Please verify manually:

  • Open and close both sidebars in a long roleplay chat on a real desktop browser; the slide looks smooth.
  • Drag-resize both sidebars; floating chat UI (Chat Settings bubble, game inventory, presence card) moves to the new edge after you stop dragging.
  • On a phone, open Professor Mari in the omnibar sheet, open the software keyboard, and check that the sheet peek hides as before.
  • In the sprite library on a touch device, drag a folder; the rows keep their resting colour on hover.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

No docs or copy changes in this PR.

UI evidence (if applicable)

No visual change is intended. Screenshots at 390/768/1440 px in both modes match staging.

Summary by CodeRabbit

  • Bug Fixes
    • Improved mobile chat-panel behavior so the panel hides appropriately when the sidebar or right panel is open.
    • Improved companion-sheet behavior with the software keyboard, including more consistent sizing and content visibility as the composer gains or loses focus.
    • Improved floating-window placement and bounds updates, and prevented live accent updates during panel animations.
    • Preserved sprite-folder hover styling while dragging.
    • Improved layout resizing and chat inset updates during panel transitions.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8963 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 11/7/2026 **Status:** ✅ Merged **Merged:** 11/7/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `perf/sidebar-slide` --- ### 📝 Commits (4) - [`58390ad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/58390ad04a940f8bddbdd905b3881f5b2bf5ec8a) perf(shell): keep app-wide restyles and re-renders out of the sidebar slide - [`ad3fcb7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ad3fcb7f0aea56a040c2fc07d4ebb4a697e04d86) perf: stop :has() rules and the resize handle from restyling the whole app on DOM insertions - [`71a8632`](https://github.com/Pasta-Devs/Marinara-Engine/commit/71a8632a19dd28403dc0ae769d27b3b9d3b63122) fix: clear stale composer focus, place a shown bubble from live bounds, re-publish inset after remount - [`0babf77`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0babf775feb33b3ecbd87bbbb2871a2e8007215a) fix: skip accent ticks only for the slot width slide; publish the inset at once when the slide is off ### 📊 Changes **9 files changed** (+95 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/App.tsx` (+9 -2) 📝 `packages/client/src/components/characters/SpriteLibrary.tsx` (+1 -1) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+2 -4) 📝 `packages/client/src/components/chat/EchoChamberPanel.tsx` (+5 -2) 📝 `packages/client/src/components/layout/AppShell.tsx` (+28 -7) 📝 `packages/client/src/components/layout/GlobalOmnibar.tsx` (+14 -0) 📝 `packages/client/src/components/ui/FloatingWindow.tsx` (+15 -9) 📝 `packages/client/src/styles/globals.css` (+7 -0) 📝 `packages/client/src/styles/mari.css` (+14 -14) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue Closes #8962 ## Why this change Opening or closing a sidebar looks jittery and laggy. Profiling at 4x CPU slowdown shows that the slide itself is cheap: the slot width relayout costs about 8–20 ms for each toggle. The cost comes from work that runs during the slide: - The hidden Chat Settings window stays mounted. It measured the page again and computed its default layout again on every slide frame, which forced a synchronous style recalculation each frame. - The roleplay surface subscribed to sidebar state only to hide the Echo Chamber on mobile, so every toggle rendered every message again (the click handler took 149 ms at 4x). - AppShell wrote `--mari-chat-ui-inset-*` on `<html>` in the click frame and on every resize-drag move. Any inline style on `<html>` restyles the whole app (about 150–220 ms at 4x). - The accent pulse, on by default on desktop, writes root colour tokens every 500 ms. When a tick lands during a slide, the slide stalls. - Two `:has()` rules made Chromium restyle about 1,900 elements on **every DOM insertion anywhere in the app**: a Tailwind `group-has-*` class in the sprite library, and the omnibar sheet's `:not(:has(:focus)) > :not(...)` rule. A sidebar toggle inserts a small topbar element, which triggered it. This likely also slows message streaming. - The resize handle was mounted and unmounted as a sibling in the shell row, which restyled the chat column. ## What changed - `FloatingWindow`: live bounds pause while the window is `hidden`, and catch up before paint when it shows again. - `ChatRoleplaySurface` / `EchoChamberPanel`: the panel reads sidebar state itself, so a toggle no longer renders the messages again. - `AppShell`: the chat UI inset variables publish after the slide (220 ms) or after a resize drag pauses. The first publish is immediate. Only floating chat UI reads them. - `AppShell`: both resize handles stay mounted and hide with the `hidden` attribute. - `App`: skip an accent tick while a shell panel slot transition runs. - `GlobalOmnibar` + `mari.css`: the omnibar publishes composer focus as `data-mari-composer-focused`; the sheet rules use that attribute instead of `:has(:focus)`. - `SpriteLibrary` + `globals.css`: the "rows keep their colour while a folder drags" hover rule is plain CSS instead of Tailwind `group-has-*`. A DOM insertion now restyles 19 elements instead of about 1,906. ### Measurements Headless Chromium, 1440×900, roleplay chat with 120 messages, 4x CPU slowdown, accent pulse on (default). Median of 5 toggles for each direction. "Frames" = frames painted in the first 300 ms after the click; "max gap" = longest time without a frame in that window. | Toggle | Before: frames / max gap | After: frames / max gap | | --- | --- | --- | | Left open | 0 / 300 ms | 5 / 83 ms | | Left close | 0 / 300 ms | 5 / 71 ms | | Right open | 0 / 300 ms | 3 / 178 ms | | Right close | 0 / 300 ms | 5 / 83 ms | The first frame after the click came after 364–507 ms before and after 2–71 ms now. Script time for each toggle fell from 188–246 ms to 114–155 ms. Pulse off, 4x: left open 1 / 297 → 5 / 83, left close 1 / 300 → 6 / 67, right open 0 / 300 (first frame at 575 ms) → 4 / 133, right close 1 / 299 → 4 / 86. No throttle (1x), pulse on: left open 9 / 83 → 13 / 67, left close 10 / 84 → 14 / 65, right open 6 / 133 → 11 / 67, right close 12 / 83 → 13 / 67. ### Known limits (not in this PR) - The chat UI inset now follows a sidebar toggle or a resize drag about 220 ms late. During a drag, floating chat UI (game inventory, readable display, Chat Settings bubble, presence card) keeps the old offset until the drag pauses; a toolbar panel opened within 220 ms of a right-panel toggle anchors to the old inset. This is the trade-off for not restyling the whole app during the slide. - The deferred inset publish still causes one whole-page style recalculation about 220–300 ms after the slide. It no longer stalls the slide. Mobile is not affected, because the inset is always 0 in overlay mode. A follow-up can let the consumers read the inset from the store and set it locally. - At 4x, each slide frame still costs about 50–80 ms: about 25 ms paint, about 22 ms for the visible Chat Settings bubble that follows the chat, and about 20 ms layout. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Agent checks on a local build (Playwright, Chromium): sidebar open/close at 1440, 768 and 390 px; resize by keyboard (ArrowRight) and mouse drag, with the inset following after the drag pauses; a hidden resize handle cannot take focus; five fast toggles settle with the slot state and inset in agreement; reduced motion has no slot transition; light/dark and default/SillyTavern themes; on a phone, the omnibar composer sets and clears `data-mari-composer-focused`. Console: no page errors; the only failed requests are two `/api/connections/<id>/models` calls (400 and 502) for providers without valid keys in the test data. These also happen on `staging`. Review: a Marinara reviewer pass found no blocking issues. Fixed from it: a composer that unmounts while focused no longer leaves the sheet flag set; a window shown again places its bubble from live bounds; a remount publishes the inset at once. The local CodeRabbit CLI could not run: the CodeRabbit server rejects the stored session ("Your CodeRabbit session or Git provider access could not be authenticated"), and a new login needs an interactive browser. CodeRabbit on GitHub reviews this PR instead. Please verify manually: - [ ] Open and close both sidebars in a long roleplay chat on a real desktop browser; the slide looks smooth. - [ ] Drag-resize both sidebars; floating chat UI (Chat Settings bubble, game inventory, presence card) moves to the new edge after you stop dragging. - [ ] On a phone, open Professor Mari in the omnibar sheet, open the software keyboard, and check that the sheet peek hides as before. - [ ] In the sprite library on a touch device, drag a folder; the rows keep their resting colour on hover. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) No docs or copy changes in this PR. ## UI evidence (if applicable) No visual change is intended. Screenshots at 390/768/1440 px in both modes match `staging`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Improved mobile chat-panel behavior so the panel hides appropriately when the sidebar or right panel is open. * Improved companion-sheet behavior with the software keyboard, including more consistent sizing and content visibility as the composer gains or loses focus. * Improved floating-window placement and bounds updates, and prevented live accent updates during panel animations. * Preserved sprite-folder hover styling while dragging. * Improved layout resizing and chat inset updates during panel transitions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi changed title from [PR #8963] perf(shell): keep app-wide restyles and re-renders out of the sidebar slide to [PR #8963] [MERGED] perf(shell): keep app-wide restyles and re-renders out of the sidebar slide 2026-11-08 07:11:08 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
Pasta-Devs/Marinara-Engine#8918
No description provided.