mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2821] [MERGED] feat(summary): compress roleplay rolling summaries by auto-hiding summarized messages #5752
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#5752
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/2821
Author: @Romuromylus
Created: 6/23/2026
Status: ✅ Merged
Merged: 6/23/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/2820-roleplay-summary-token-compression📝 Commits (10+)
b1d258dfeat(summary): compress roleplay rolling summaries by auto-hiding summarized messages12d5d83fix(summary): restore legacy hide fallback and stop chat pref leaking globally7084608fix(summary): make unhide-on-delete atomic and drop the shared hide fallback6463dfafix(summary): own hide pref per-chat, compensate failed delete, scope refetched26140fix(summary): compensate against the exact unhidden set on failed delete6709302chore(summary): return the updated message IDs from the bulk-hidden route65066dachore(summary): keep the bulk-hidden response a count2eabcb1fix(summary): descope approval-path hide, simplify delete, harden tail bounds488e17bfix(summary): apply the recent-message tail to manual hiding too82a7decfix(summary): hide the tail-excluded subset on manual last-N, persist hidden set📊 Changes
10 files changed (+372 additions, -70 deletions)
View changed files
📝
packages/client/src/components/chat/ChatRoleplaySurface.tsx(+18 -0)📝
packages/client/src/components/chat/SummaryPopover.tsx(+54 -18)📝
packages/client/src/hooks/use-chats.ts(+12 -0)📝
packages/client/src/hooks/use-generate.ts(+6 -0)📝
packages/server/src/routes/chats.routes.ts(+112 -33)📝
packages/server/src/routes/generate.routes.ts(+29 -2)📝
packages/server/src/routes/generate/generate-route-utils.ts(+40 -0)📝
packages/server/src/services/storage/chats.storage.ts(+69 -14)📝
packages/shared/src/types/chat.ts(+30 -3)📝
packages/shared/src/utils/chat-summary-entries.ts(+2 -0)📄 Description
Linked issue
Closes #2820
Why this change
In roleplay / visual-novel mode the rolling summary runs automatically every N user messages and injects a recap into the prompt, but it never hides the messages it just summarized. The originals stay in context, so each summary is a net token increase layered on top of the history it was meant to compress — the opposite of what a rolling summary is for. The only ways to save tokens today are to manually cap context in Advanced Parameters or to manually summarize with "Hide summarised messages" ticked, and even that hides everything with no tail (so the most recent turns can vanish) and never reaches the automatic path.
The primitives already existed —
hiddenFromAI, per-entrymessageIds, thebulkSetHiddenFromAIstorage method, the collapsible hidden-message UI. This change wires them into the automatic summary path so the summary becomes a real token reduction, behind an opt-in toggle.What changed
ChatMetadata.hideSummarisedMessages(default off — existing chats are untouched). The server auto-summary reads it; the Summary-popover toggle now writes it per-chat instead of only the browser-local UI store (legacy pref is used as the initial display value for back-compat).runAutomaticRoleplaySummaryhides the messages a summary covered, except the most-recentsummaryTailMessages(reused from the conversation-mode field; default 10,0hides the whole batch). The set math lives in two pure, unit-tested helpers —computeSummaryHideIdsandresolveRoleplaySummaryTail— and the same helpers run on the approval-gated commit path so behavior is consistent whether or not agent-write approval is required.chat_summarySSE event carrieshiddenMessageIds; the client invalidates the message-list query so server-driven hides show immediately.Scope notes: the manual "Hide summarised messages" popover path is intentionally left as hide-everything (no behavior change for existing manual use). Conversation-mode day/week summaries are untouched — roleplay and conversation summary paths are mutually exclusive by chat mode.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
summaryTailMessagesstay visible.0(whole batch hidden) and to a larger value (more recent messages preserved).Docs and release impact
UI evidence (if applicable)
To follow once verified on a live build.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.