[PR #5794] [MERGED] fix(chat): honor Messages per page in the transcript render window #6938

Closed
opened 2026-10-23 04:15:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5794
Author: @Romuromylus
Created: 9/2/2026
Status: ✅ Merged
Merged: 9/3/2026
Merged by: @Romuromylus

Base: staging ← Head: fix/messages-per-page-render-window


📝 Commits (4)

  • ca910ec fix(chat): honor Messages per page in the transcript render window
  • 7f89376 fix(chat): re-anchor the transcript window when its size changes
  • 3042587 Merge remote-tracking branch 'pasta/staging' into fix/messages-per-page-render-window
  • 756ff7c fix(chat): keep the open-at-bottom deferral retryable on a failed jump

📊 Changes

5 files changed (+145 additions, -11 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+16 -3)
📝 packages/client/src/components/chat/ConversationView.tsx (+33 -4)
📝 packages/client/src/lib/transcript-render-window.ts (+28 -4)
➕ scripts/regressions/transcript-render-window.regression.ts (+67 -0)

📄 Description

Linked issue

Closes #5789

Why this change

The "Messages per page" setting (Settings > General > Responses) promises to control how many messages load at once, with 0 meaning "load all messages at once". Since #3114 the chat transcript also runs a render window that keeps at most 80 loaded messages mounted, and that window never consulted the setting. So a Roleplay (or Conversation) chat with more than 80 messages always showed at most 80 on screen: at 100 the newest 100 were fetched but only 80 rendered, and at 0 the whole history was fetched but everything older than the last 80 sat behind the "Show older" controls. From the user's side the setting looked ignored, which is exactly what the reporter saw.

What changed

  • packages/client/src/lib/transcript-render-window.ts: new resolveTranscriptRenderWindowSize(messagesPerPage). A page size above the default 80 widens the window to match, 0 (or an invalid/negative value) returns null meaning unbounded, and anything at or below 80 keeps the existing 80-message window. getTranscriptRenderWindow now accepts maxMountedMessages: null and mounts every loaded message in that case. The previous constant is exported as DEFAULT_MAX_MOUNTED_TRANSCRIPT_MESSAGES.
  • ChatRoleplaySurface.tsx and ConversationView.tsx: read messagesPerPage from the UI store and pass the resolved window size into getTranscriptRenderWindow. The step size for "Show older" / "Show newer" and the goto-message reveal are unchanged.
  • scripts/regressions/transcript-render-window.regression.ts: covers the size resolution (20, 80, 100, 500, 0, negative, NaN, undefined) and the window output for 80 / 100 / unbounded, including goto-request clamping and empty input.
  • Both surfaces also reset the pinned window start index whenever the resolved window size changes (the setting can change while a chat stays mounted; a start index pinned via "Show older" or a jump is relative to the old size), mirroring the existing chat-switch reset. Conversation mode's open-at-bottom effect now defers explicitly to a pending jump-to-message request: with an unbounded window nothing is ever hidden after the target, so the hidden-after guard alone no longer kept the initial bottom scroll from racing the jump. The deferral latches the chat as opened only once the jump target is within the loaded messages (the same test ChatArea uses before it scrolls); a target that is still paging in, out of range, or unreachable leaves the effect retryable so the chat still opens at the bottom once the request clears. These came out of the regression-safety and PR review passes.
  • CHANGELOG Unreleased entry.

Scope note: this only touches how many loaded messages get mounted. Fetch pagination (useChatMessages limit + Load More) already honored the setting and is unchanged. Users on the default of 20 keep the same 80-message render window, so the long-chat render-cost bound from #3114 is preserved for them; only users who explicitly raise the setting above 80 or set it to 0 opt into mounting more.

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

  • pnpm check green on the branch; node ./scripts/run-regressions.mjs --filter transcript-render-window passes.
  • Deployed the branch to my private instance. Regression-safety review (blast-radius map + adversarial hunters over every consumer of the window state) ran over the diff; its two actionable findings are folded in as the second commit, the rest were refuted against the code (pure mount cost of an explicit "load all" is the documented setting semantics, not a regression).
  • Deployed the branch to my private instance. Verification on a Roleplay chat with more than 80 messages: with Messages per page = 100 the transcript renders 100 messages with no "Show older" control until Load More is used; with 0 every message renders and the window controls never appear; with the default 20 the behavior is identical to staging (80 mounted after loading more, "Show older" appears beyond that).

Follow-ups (pre-existing, reproduced on staging, not changed here)

  • #5795: /goto does not scroll in Conversation mode (neither pages older messages in nor scrolls to a mounted target). Found while trying to exercise the jump-to-message deferral; the path is broken before this PR, so the deferral is verified by code review only.
  • #5796: changing "Messages per page" while a chat is open collapses the loaded transcript to one message until reload (fetch/trim side in ChatArea, not the render window).

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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)

UI evidence (if applicable)

Not a visual change; the transcript simply stops hiding messages the setting asked for.

Summary by CodeRabbit

  • Bug Fixes

    • Chat transcript views now honor the configured Messages per page setting.
    • Values above 80 display the selected number of messages instead of being capped.
    • A value of 0 now displays all loaded messages without requiring “Show older” actions.
    • Changing the setting refreshes the transcript window correctly.
    • Opening a chat at a requested message no longer incorrectly forces scrolling to the bottom.
  • Tests

    • Added regression coverage for transcript sizing, unbounded loading, invalid values, and message navigation.

🔄 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/5794 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 9/2/2026 **Status:** ✅ Merged **Merged:** 9/3/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `staging` ← **Head:** `fix/messages-per-page-render-window` --- ### 📝 Commits (4) - [`ca910ec`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ca910ec1db1a3bfe47e7665f5fc15c699a44ef32) fix(chat): honor Messages per page in the transcript render window - [`7f89376`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7f893767d08de940154909a20372ad14ca47976f) fix(chat): re-anchor the transcript window when its size changes - [`3042587`](https://github.com/Pasta-Devs/Marinara-Engine/commit/304258728e0b685e3891a00f77286d5ba7a39891) Merge remote-tracking branch 'pasta/staging' into fix/messages-per-page-render-window - [`756ff7c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/756ff7c0b8225208fe9149bfb10e45d251cacaf3) fix(chat): keep the open-at-bottom deferral retryable on a failed jump ### 📊 Changes **5 files changed** (+145 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+16 -3) 📝 `packages/client/src/components/chat/ConversationView.tsx` (+33 -4) 📝 `packages/client/src/lib/transcript-render-window.ts` (+28 -4) ➕ `scripts/regressions/transcript-render-window.regression.ts` (+67 -0) </details> ### 📄 Description ## Linked issue Closes #5789 ## Why this change The "Messages per page" setting (Settings > General > Responses) promises to control how many messages load at once, with `0` meaning "load all messages at once". Since #3114 the chat transcript also runs a render window that keeps at most 80 loaded messages mounted, and that window never consulted the setting. So a Roleplay (or Conversation) chat with more than 80 messages always showed at most 80 on screen: at 100 the newest 100 were fetched but only 80 rendered, and at 0 the whole history was fetched but everything older than the last 80 sat behind the "Show older" controls. From the user's side the setting looked ignored, which is exactly what the reporter saw. ## What changed - `packages/client/src/lib/transcript-render-window.ts`: new `resolveTranscriptRenderWindowSize(messagesPerPage)`. A page size above the default 80 widens the window to match, `0` (or an invalid/negative value) returns `null` meaning unbounded, and anything at or below 80 keeps the existing 80-message window. `getTranscriptRenderWindow` now accepts `maxMountedMessages: null` and mounts every loaded message in that case. The previous constant is exported as `DEFAULT_MAX_MOUNTED_TRANSCRIPT_MESSAGES`. - `ChatRoleplaySurface.tsx` and `ConversationView.tsx`: read `messagesPerPage` from the UI store and pass the resolved window size into `getTranscriptRenderWindow`. The step size for "Show older" / "Show newer" and the goto-message reveal are unchanged. - `scripts/regressions/transcript-render-window.regression.ts`: covers the size resolution (20, 80, 100, 500, 0, negative, NaN, undefined) and the window output for 80 / 100 / unbounded, including goto-request clamping and empty input. - Both surfaces also reset the pinned window start index whenever the resolved window size changes (the setting can change while a chat stays mounted; a start index pinned via "Show older" or a jump is relative to the old size), mirroring the existing chat-switch reset. Conversation mode's open-at-bottom effect now defers explicitly to a pending jump-to-message request: with an unbounded window nothing is ever hidden after the target, so the hidden-after guard alone no longer kept the initial bottom scroll from racing the jump. The deferral latches the chat as opened only once the jump target is within the loaded messages (the same test ChatArea uses before it scrolls); a target that is still paging in, out of range, or unreachable leaves the effect retryable so the chat still opens at the bottom once the request clears. These came out of the regression-safety and PR review passes. - CHANGELOG Unreleased entry. Scope note: this only touches how many *loaded* messages get mounted. Fetch pagination (`useChatMessages` limit + Load More) already honored the setting and is unchanged. Users on the default of 20 keep the same 80-message render window, so the long-chat render-cost bound from #3114 is preserved for them; only users who explicitly raise the setting above 80 or set it to 0 opt into mounting more. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - `pnpm check` green on the branch; `node ./scripts/run-regressions.mjs --filter transcript-render-window` passes. - Deployed the branch to my private instance. Regression-safety review (blast-radius map + adversarial hunters over every consumer of the window state) ran over the diff; its two actionable findings are folded in as the second commit, the rest were refuted against the code (pure mount cost of an explicit "load all" is the documented setting semantics, not a regression). - Deployed the branch to my private instance. Verification on a Roleplay chat with more than 80 messages: with Messages per page = 100 the transcript renders 100 messages with no "Show older" control until Load More is used; with 0 every message renders and the window controls never appear; with the default 20 the behavior is identical to staging (80 mounted after loading more, "Show older" appears beyond that). ### Follow-ups (pre-existing, reproduced on staging, not changed here) - #5795: `/goto` does not scroll in Conversation mode (neither pages older messages in nor scrolls to a mounted target). Found while trying to exercise the jump-to-message deferral; the path is broken before this PR, so the deferral is verified by code review only. - #5796: changing "Messages per page" while a chat is open collapses the loaded transcript to one message until reload (fetch/trim side in ChatArea, not the render window). ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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) ## UI evidence (if applicable) Not a visual change; the transcript simply stops hiding messages the setting asked for. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Chat transcript views now honor the configured **Messages per page** setting. - Values above 80 display the selected number of messages instead of being capped. - A value of 0 now displays all loaded messages without requiring “Show older” actions. - Changing the setting refreshes the transcript window correctly. - Opening a chat at a requested message no longer incorrectly forces scrolling to the bottom. - **Tests** - Added regression coverage for transcript sizing, unbounded loading, invalid values, and message navigation. <!-- 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 2026-10-23 04:15:03 +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#6938
No description provided.