[PR #7442] [MERGED] fix(chat-profiles): hide or show summarised messages when a profile changes the setting #7735

Closed
opened 2026-10-24 04:06:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7442
Author: @SpicyMarinara
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/profile-apply-hide-summarised


📝 Commits (1)

  • be3fe3c fix(chat-profiles): hide or show summarised messages when a profile changes the setting

📊 Changes

5 files changed (+233 additions, -59 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/routes/chats.routes.ts (+5 -58)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+62 -0)
📝 packages/server/src/services/storage/chat-presets.storage.ts (+7 -1)
➕ scripts/regressions/profile-apply-hide-summarised.regression.ts (+158 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7426

Why this change

  • Applying a settings profile by hand could switch a chat's Hide summarised messages setting without changing which messages are hidden. If the profile had it on and the chat had it off, the switch showed on but the summarised messages were still sent to the AI next to their summary. If the profile had it off and the chat had it on, the switch showed off but the messages stayed hidden from the AI.
  • Cause: PATCH /api/chats/:id/metadata hides or shows the summarised messages, and updates summaryEntries[].hiddenMessageIds, only for its own writes. applyToChat writes the whole metadata object and skipped that step.

What changed

  • summaryHidingPatch (generate-route-utils.ts, next to computeSummaryHideIds) now holds the hide/show step the PATCH route had inline. When the setting goes from off to on it hides each enabled entry's messages, except the recent tail, and records them in hiddenMessageIds. When it goes from on to off it shows only the messages the summaries hid. If the setting does not change it touches nothing and returns {}.
  • The PATCH route calls it inside its patchMetadata updater, which already holds the chat's metadata queue, as before.
  • applyToChat calls it inside its own withChatMetadataPatchQueue section and saves the result in the same metadata write. The lock order is the same as the PATCH route's: metadata queue first, then each message's extra queue (inside bulkSetHiddenFromAI). So no new nesting and no deadlock.
  • The recent tail comes from the metadata being saved. On apply that is the profile's Recent messages left visible value, which applies at the same moment. For the PATCH route the result is the same as before, because the client sends hideSummarisedMessages on its own.
  • The follower path from #7422 (Save and update N other chats) is unchanged. hideSummarisedMessages is not in CHAT_PROFILE_FOLLOWER_SYNC_KEYS, and #7422 deliberately lets each follower keep its own value. So the helper sees no change and returns early for followers. The regression checks this.
  • New regression scripts/regressions/profile-apply-hide-summarised.regression.ts. It fails on staging at "applying the profile hides messages 1-3" and passes with this change.
  • CHANGELOG entry under [Unreleased].

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

Commands run by the agent (results as reported locally, not a substitute for the boxes above):

  • pnpm check: exit 0
  • node ./scripts/run-regressions.mjs --filter scripts/regressions/profile-apply-hide-summarised.regression.ts: passes with the fix. On staging (fix not applied) it fails at "applying the profile hides messages 1-3" (actual [6], expected [1, 2, 3, 6]).
  • Mutation check: reading the tail from the chat's previous metadata instead of the metadata being saved fails at the same assertion.
  • Also passing: chat-profile-followers, summary-write-range, experience-state-ordinal, advanced-memory-generation, chat-variables-preset-precedence, open-issues, prompt.
  • What the regression covers:
    • Profile on, chat off: messages 1-3 are hidden and the entry's hiddenMessageIds is set. Messages 4-5 are kept as the profile's tail of 2, and message 6, hidden by the user, stays hidden.
    • Applying the same profile again changes nothing.
    • Profile off, chat on: messages 1-3 are shown again, hiddenMessageIds is removed, and the user's own hidden message 6 stays hidden.
    • Applying the off profile again changes nothing.
    • The PATCH toggle still hides, ignores a same-value patch and shows again, using the chat's own tail.
    • Save and update keeps a follower's own setting, hidden messages and summary entries.

Manual verification notes

  • Manually verify in the browser: open a Roleplay chat that has a summary covering earlier messages, with Hide summarised messages off. Apply a settings profile saved with it on. Confirm the summary popover switch shows on and the summarised messages (except the recent ones) show as hidden from the AI.
  • Manually verify in the browser: with the switch on, apply a profile saved with it off. Confirm the switch shows off and the messages the summary hid are visible to the AI again. A message you hid yourself stays hidden.
  • Manually verify that applying a profile that leaves the setting as it is does not change any message's hidden state.
  • Manually verify that the switch in the summary popover still hides and shows messages as before.
  • Manually verify that Save and update N other chats leaves each other chat's Hide summarised messages switch and its hidden messages as they were.

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)

Only CHANGELOG.md changed. No docs/ files changed, so no translated docs follow-up is needed.

Local CodeRabbit review

  • coderabbit review --agent --committed --base-commit $(git merge-base HEAD origin/staging): completed with 0 findings. Nothing was rejected.

UI evidence (if applicable)

No UI changes.


🔄 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/7442 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/profile-apply-hide-summarised` --- ### 📝 Commits (1) - [`be3fe3c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/be3fe3c6d51bb60eebd37919dec1077faa3f6368) fix(chat-profiles): hide or show summarised messages when a profile changes the setting ### 📊 Changes **5 files changed** (+233 additions, -59 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/routes/chats.routes.ts` (+5 -58) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+62 -0) 📝 `packages/server/src/services/storage/chat-presets.storage.ts` (+7 -1) ➕ `scripts/regressions/profile-apply-hide-summarised.regression.ts` (+158 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7426 ## Why this change - Applying a settings profile by hand could switch a chat's **Hide summarised messages** setting without changing which messages are hidden. If the profile had it on and the chat had it off, the switch showed on but the summarised messages were still sent to the AI next to their summary. If the profile had it off and the chat had it on, the switch showed off but the messages stayed hidden from the AI. - Cause: `PATCH /api/chats/:id/metadata` hides or shows the summarised messages, and updates `summaryEntries[].hiddenMessageIds`, only for its own writes. `applyToChat` writes the whole metadata object and skipped that step. ## What changed - `summaryHidingPatch` (`generate-route-utils.ts`, next to `computeSummaryHideIds`) now holds the hide/show step the PATCH route had inline. When the setting goes from off to on it hides each enabled entry's messages, except the recent tail, and records them in `hiddenMessageIds`. When it goes from on to off it shows only the messages the summaries hid. If the setting does not change it touches nothing and returns `{}`. - The PATCH route calls it inside its `patchMetadata` updater, which already holds the chat's metadata queue, as before. - `applyToChat` calls it inside its own `withChatMetadataPatchQueue` section and saves the result in the same metadata write. The lock order is the same as the PATCH route's: metadata queue first, then each message's extra queue (inside `bulkSetHiddenFromAI`). So no new nesting and no deadlock. - The recent tail comes from the metadata being saved. On apply that is the profile's **Recent messages left visible** value, which applies at the same moment. For the PATCH route the result is the same as before, because the client sends `hideSummarisedMessages` on its own. - The follower path from #7422 (**Save and update N other chats**) is unchanged. `hideSummarisedMessages` is not in `CHAT_PROFILE_FOLLOWER_SYNC_KEYS`, and #7422 deliberately lets each follower keep its own value. So the helper sees no change and returns early for followers. The regression checks this. - New regression `scripts/regressions/profile-apply-hide-summarised.regression.ts`. It fails on staging at "applying the profile hides messages 1-3" and passes with this change. - CHANGELOG entry under `[Unreleased]`. ## 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` Commands run by the agent (results as reported locally, not a substitute for the boxes above): - `pnpm check`: exit 0 - `node ./scripts/run-regressions.mjs --filter scripts/regressions/profile-apply-hide-summarised.regression.ts`: passes with the fix. On staging (fix not applied) it fails at "applying the profile hides messages 1-3" (actual `[6]`, expected `[1, 2, 3, 6]`). - Mutation check: reading the tail from the chat's previous metadata instead of the metadata being saved fails at the same assertion. - Also passing: `chat-profile-followers`, `summary-write-range`, `experience-state-ordinal`, `advanced-memory-generation`, `chat-variables-preset-precedence`, `open-issues`, `prompt`. - What the regression covers: - Profile on, chat off: messages 1-3 are hidden and the entry's `hiddenMessageIds` is set. Messages 4-5 are kept as the profile's tail of 2, and message 6, hidden by the user, stays hidden. - Applying the same profile again changes nothing. - Profile off, chat on: messages 1-3 are shown again, `hiddenMessageIds` is removed, and the user's own hidden message 6 stays hidden. - Applying the off profile again changes nothing. - The PATCH toggle still hides, ignores a same-value patch and shows again, using the chat's own tail. - **Save and update** keeps a follower's own setting, hidden messages and summary entries. ### Manual verification notes - Manually verify in the browser: open a Roleplay chat that has a summary covering earlier messages, with **Hide summarised messages** off. Apply a settings profile saved with it on. Confirm the summary popover switch shows on and the summarised messages (except the recent ones) show as hidden from the AI. - Manually verify in the browser: with the switch on, apply a profile saved with it off. Confirm the switch shows off and the messages the summary hid are visible to the AI again. A message you hid yourself stays hidden. - Manually verify that applying a profile that leaves the setting as it is does not change any message's hidden state. - Manually verify that the switch in the summary popover still hides and shows messages as before. - Manually verify that **Save and update N other chats** leaves each other chat's **Hide summarised messages** switch and its hidden messages as they were. ## 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) Only `CHANGELOG.md` changed. No `docs/` files changed, so no translated docs follow-up is needed. ## Local CodeRabbit review - `coderabbit review --agent --committed --base-commit $(git merge-base HEAD origin/staging)`: completed with 0 findings. Nothing was rejected. ## UI evidence (if applicable) No UI changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:06:59 +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#7735
No description provided.