[PR #7644] [MERGED] fix(memory): delete a recollection and keep paid Helper replies on Resume #7854

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

📋 Pull Request Information

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

Base: staging ← Head: fix/recollections-delete-and-keep


📝 Commits (3)

  • f964b6e fix(memory): delete a recollection and keep paid Helper replies on Resume
  • 1587ea2 test(e2e): close the scene-check notice before Chat Settings in the recollections test
  • 391aa5d Merge branch 'staging' into fix/recollections-delete-and-keep

📊 Changes

7 files changed (+386 additions, -34 deletions)

View changed files

📝 docs/agents/memory.md (+1 -1)
📝 e2e/advanced-memory.e2e.ts (+42 -4)
📝 packages/client/src/components/chat/AdvancedMemoryInspector.tsx (+53 -19)
📝 packages/client/src/localization/locales/en.json (+4 -0)
📝 packages/server/src/routes/advanced-memory.routes.ts (+2 -1)
📝 packages/server/src/services/advanced-memory.ts (+22 -9)
📝 scripts/regressions/advanced-memory-recollections.regression.ts (+262 -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

No linked issue: requested by the maintainer on 2026-10-14. Follow-up to #7637 and #7605 (#7602, character recollections).

Why this change

  • A scene's recollections can be edited in Access memories for this chat, but not deleted. The maintainer asked whether generated recollections can be edited and deleted from the scene they were written for.
  • A paid Helper reply could be paid for twice. When a recollection run was cancelled while a reply's recollections were being saved, some characters' recollections were saved and the rest were lost. Resume then sent a new request for the missing characters, because a request for fewer characters can't reuse the saved reply. The same could happen with recollections that came with a new scene summary.
  • During Writing character recollections, the progress counter jumped between the scene count and the parts of one scene's request (for example 0/2, 1/1, 1/2).

What changed

  • Delete a recollection: each recollection inside its scene has a Delete button next to Save correction, with the same confirm dialog that other destructive memory actions use.
    • A deleted recollection is saved as an empty, hand-edited one. Recall already skips empty recollections, and no run rewrites a hand-edited one. So the deletion holds through the upkeep after a reply, Prepare, Resume, a changed scene summary, and turning the setting off and on. Export, import and branches carry it as it is.
    • The empty field stays, with "Deleted. It won't be written again, but you can write one here." Typing a new one and saving makes it a hand-edited recollection again.
    • The record route accepts empty text only for a recollection. Every other memory still needs at least one character, with the same error as before.
    • Delete is also offered on an empty recollection the Helper wrote nothing for, so the user can stop later runs from asking for it.
  • Keep paid Helper replies:
    • Checked first: summarize() already caches every finished, well-formed reply before any later step that can fail. The comment "Save a completed paid response even if cancellation arrived with it" holds there: the cache write runs without the cancel signal, and Resume reuses the reply. Replies that fail their own format check, or that ended unfinished (length, error, abort and so on), are still not cached. advanced-memory-post-generation requires that.
    • The loss was one step later. A reply's recollections were saved one character at a time, still under the cancel signal. Saving them now runs without that signal, in the recollection run and after a new scene summary, so a cancel takes effect only after the whole reply is saved.
  • Progress: a recollection run's counter counts scenes only. The per-part update inside summarize() is skipped for recollection-only requests.
  • What reaches prompts is unchanged, so the prepared-memory revision stays the same. No storage-format change.
  • Docs: docs/agents/memory.md gets one sentence about Delete.

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 observed, not a substitute for the boxes above):

  • node scripts/run-regressions.mjs --filter advanced-memory: 18/18 passed.
  • pnpm check: exit 0. One existing lint warning in HomeProfessorMariChat.tsx, unrelated.
  • pnpm localization:check: passed.
  • npx playwright test e2e/advanced-memory.e2e.ts --project desktop-chromium --project mobile-chromium -g "Character recollections" --workers=1 (custom ports): 2/2 passed at 1587ea297. The other tests in that file and mobile-webkit were not run.
    • The first run failed on mobile-chromium in the test's existing review step, before the new delete steps. There, the "Advanced Memory found a problem in 1 scene." notice covers the Chat Settings button. The test now closes that notice before opening Chat Settings at that step; no assertion was changed.
    • The test now also covers Delete: Cancel keeps the recollection, Delete empties it and marks it hand-edited, the deleted note shows, the Delete button hides, and typing a new one saves it as Manually edited.
  • pnpm check:e2e-types: exit 0 after the e2e change.

New regression sections in advanced-memory-recollections.regression.ts:

  • 11, Delete: a deleted recollection stays deleted and out of recall through the upkeep after a reply, Prepare, a changed summary (only the other character's generated recollection is rewritten), turning the setting off and on, export and import, and a branch (including Prepare in each copy). Typing a new one saves it as hand-edited and recalls it. Empty text is still refused for a scene summary.
  • 12, Keep paid replies: a run cancelled right after the first character's recollection is saved, both in a recollection run and after a new scene summary. Resume makes no request for that scene. A run that fails while saving after the reply arrived: Resume makes no new request either (this one already held, and is now pinned).
  • 13, Progress: a two-scene recollection run reports only 0/2, 1/2 and 2/2.

Fail-before against staging's code (154a33092):

  • 11: Error: Memory text must contain between 1 and 500000 characters at the delete call.
  • 12, recollection run: Resume asked for ['BACKFILL_J', 'BACKFILL_K'] instead of ['BACKFILL_K'], so it paid again for the scene whose reply had arrived.
  • 12, after a scene summary: 1 recollection request on Resume instead of 0.
  • 13: the counter showed ['0/2', '1/1', '1/2', '2/2'] instead of ['0/2', '1/2', '2/2'].

Manual verification notes

  • Manually verify in a Roleplay chat with Character recollections on: open Access memories for this chat, open a scene and press Delete on one character's recollection. The confirm dialog appears, Cancel keeps the recollection, and Delete empties the field and shows "Deleted. It won't be written again, but you can write one here."
  • Manually verify with Peek Prompt that the deleted recollection's line is gone from that recalled scene and the other characters' lines remain.
  • Manually verify that the deleted recollection stays empty after the next reply, after Prepare, and after turning Character recollections off and on.
  • Manually verify that correcting that scene's summary rewrites the other characters' generated recollections after the next reply and leaves the deleted one empty.
  • Manually verify that typing a new recollection into the empty field and saving shows Manually edited, and that Peek Prompt shows it.
  • Manually verify with a real Helper: press Cancel during Writing character recollections, then Resume. The Helper's request log should show no second request for a scene that was already answered.
  • Manually verify that the progress counter during Writing character recollections counts scenes only.
  • Manually verify the Delete button and its confirm dialog in light and dark mode on a phone-sized window.

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)

docs/agents/memory.md is updated (one sentence). [docs-i18n] follow-up: #7645..

UI evidence (if applicable)

The e2e test captures light and dark screenshots of the delete confirm dialog and the deleted recollection (character-recollections-delete-confirm-*.png, character-recollections-deleted-*.png). They are not attached here.

Local CodeRabbit review

coderabbit review --agent --committed --base-commit 154a33092 on f964b6e7d: 1 finding.

  • docs/agents/memory.md needs the docs-i18n packs updated or a [docs-i18n] follow-up: already handled by #7645, linked above. CodeRabbit only saw the diff, not the issue. No code change.

The later e2e-only commit (1587ea297) was not re-reviewed locally.

Notes for the maintainer

  • Importing a memory file into a chat that already has a generated recollection for the same scene and character keeps the local one. That is the existing "import never overwrites local memories" rule, so a deletion in the file doesn't apply there. Import into a chat without that recollection, and branches, keep it deleted.

Summary by CodeRabbit

  • New Features
    • Character recollections can now be permanently deleted. Deleted recollections are excluded from prompts and won’t be automatically rewritten; you can enter and save replacement text at any time.
  • Bug Fixes
    • Improved recollection saving and progress tracking, including when cancellation or a storage issue occurs after a response is received.

🔄 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/7644 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/recollections-delete-and-keep` --- ### 📝 Commits (3) - [`f964b6e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f964b6e7ddaba49e417de4f273fb00ab6f6b6792) fix(memory): delete a recollection and keep paid Helper replies on Resume - [`1587ea2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1587ea297491567886549fbf3f4cdf92eb63d213) test(e2e): close the scene-check notice before Chat Settings in the recollections test - [`391aa5d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/391aa5de67f6ae7ec8b43c32a0bf0b6673a4353e) Merge branch 'staging' into fix/recollections-delete-and-keep ### 📊 Changes **7 files changed** (+386 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/memory.md` (+1 -1) 📝 `e2e/advanced-memory.e2e.ts` (+42 -4) 📝 `packages/client/src/components/chat/AdvancedMemoryInspector.tsx` (+53 -19) 📝 `packages/client/src/localization/locales/en.json` (+4 -0) 📝 `packages/server/src/routes/advanced-memory.routes.ts` (+2 -1) 📝 `packages/server/src/services/advanced-memory.ts` (+22 -9) 📝 `scripts/regressions/advanced-memory-recollections.regression.ts` (+262 -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 No linked issue: requested by the maintainer on 2026-10-14. Follow-up to #7637 and #7605 (#7602, character recollections). ## Why this change - A scene's recollections can be edited in **Access memories for this chat**, but not deleted. The maintainer asked whether generated recollections can be edited and deleted from the scene they were written for. - A paid Helper reply could be paid for twice. When a recollection run was cancelled while a reply's recollections were being saved, some characters' recollections were saved and the rest were lost. **Resume** then sent a new request for the missing characters, because a request for fewer characters can't reuse the saved reply. The same could happen with recollections that came with a new scene summary. - During **Writing character recollections**, the progress counter jumped between the scene count and the parts of one scene's request (for example 0/2, 1/1, 1/2). ## What changed - **Delete a recollection:** each recollection inside its scene has a **Delete** button next to **Save correction**, with the same confirm dialog that other destructive memory actions use. - A deleted recollection is saved as an empty, hand-edited one. Recall already skips empty recollections, and no run rewrites a hand-edited one. So the deletion holds through the upkeep after a reply, **Prepare**, **Resume**, a changed scene summary, and turning the setting off and on. Export, import and branches carry it as it is. - The empty field stays, with "Deleted. It won't be written again, but you can write one here." Typing a new one and saving makes it a hand-edited recollection again. - The record route accepts empty text only for a recollection. Every other memory still needs at least one character, with the same error as before. - Delete is also offered on an empty recollection the Helper wrote nothing for, so the user can stop later runs from asking for it. - **Keep paid Helper replies:** - Checked first: `summarize()` already caches every finished, well-formed reply before any later step that can fail. The comment "Save a completed paid response even if cancellation arrived with it" holds there: the cache write runs without the cancel signal, and Resume reuses the reply. Replies that fail their own format check, or that ended unfinished (`length`, `error`, `abort` and so on), are still not cached. `advanced-memory-post-generation` requires that. - The loss was one step later. A reply's recollections were saved one character at a time, still under the cancel signal. Saving them now runs without that signal, in the recollection run and after a new scene summary, so a cancel takes effect only after the whole reply is saved. - **Progress:** a recollection run's counter counts scenes only. The per-part update inside `summarize()` is skipped for recollection-only requests. - What reaches prompts is unchanged, so the prepared-memory revision stays the same. No storage-format change. - Docs: `docs/agents/memory.md` gets one sentence about **Delete**. ## 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 observed, not a substitute for the boxes above): - `node scripts/run-regressions.mjs --filter advanced-memory`: 18/18 passed. - `pnpm check`: exit 0. One existing lint warning in `HomeProfessorMariChat.tsx`, unrelated. - `pnpm localization:check`: passed. - `npx playwright test e2e/advanced-memory.e2e.ts --project desktop-chromium --project mobile-chromium -g "Character recollections" --workers=1` (custom ports): 2/2 passed at `1587ea297`. The other tests in that file and `mobile-webkit` were not run. - The first run failed on mobile-chromium in the test's existing review step, before the new delete steps. There, the "Advanced Memory found a problem in 1 scene." notice covers the Chat Settings button. The test now closes that notice before opening Chat Settings at that step; no assertion was changed. - The test now also covers Delete: Cancel keeps the recollection, Delete empties it and marks it hand-edited, the deleted note shows, the Delete button hides, and typing a new one saves it as **Manually edited**. - `pnpm check:e2e-types`: exit 0 after the e2e change. New regression sections in `advanced-memory-recollections.regression.ts`: - **11, Delete:** a deleted recollection stays deleted and out of recall through the upkeep after a reply, Prepare, a changed summary (only the other character's generated recollection is rewritten), turning the setting off and on, export and import, and a branch (including Prepare in each copy). Typing a new one saves it as hand-edited and recalls it. Empty text is still refused for a scene summary. - **12, Keep paid replies:** a run cancelled right after the first character's recollection is saved, both in a recollection run and after a new scene summary. Resume makes no request for that scene. A run that fails while saving after the reply arrived: Resume makes no new request either (this one already held, and is now pinned). - **13, Progress:** a two-scene recollection run reports only 0/2, 1/2 and 2/2. Fail-before against staging's code (`154a33092`): - 11: `Error: Memory text must contain between 1 and 500000 characters` at the delete call. - 12, recollection run: Resume asked for `['BACKFILL_J', 'BACKFILL_K']` instead of `['BACKFILL_K']`, so it paid again for the scene whose reply had arrived. - 12, after a scene summary: 1 recollection request on Resume instead of 0. - 13: the counter showed `['0/2', '1/1', '1/2', '2/2']` instead of `['0/2', '1/2', '2/2']`. ### Manual verification notes - Manually verify in a Roleplay chat with **Character recollections** on: open **Access memories for this chat**, open a scene and press **Delete** on one character's recollection. The confirm dialog appears, **Cancel** keeps the recollection, and **Delete** empties the field and shows "Deleted. It won't be written again, but you can write one here." - Manually verify with Peek Prompt that the deleted recollection's line is gone from that recalled scene and the other characters' lines remain. - Manually verify that the deleted recollection stays empty after the next reply, after **Prepare**, and after turning **Character recollections** off and on. - Manually verify that correcting that scene's summary rewrites the other characters' generated recollections after the next reply and leaves the deleted one empty. - Manually verify that typing a new recollection into the empty field and saving shows **Manually edited**, and that Peek Prompt shows it. - Manually verify with a real Helper: press Cancel during **Writing character recollections**, then **Resume**. The Helper's request log should show no second request for a scene that was already answered. - Manually verify that the progress counter during **Writing character recollections** counts scenes only. - Manually verify the **Delete** button and its confirm dialog in light and dark mode on a phone-sized window. ## 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) `docs/agents/memory.md` is updated (one sentence). `[docs-i18n]` follow-up: #7645.. ## UI evidence (if applicable) The e2e test captures light and dark screenshots of the delete confirm dialog and the deleted recollection (`character-recollections-delete-confirm-*.png`, `character-recollections-deleted-*.png`). They are not attached here. ## Local CodeRabbit review `coderabbit review --agent --committed --base-commit 154a33092` on `f964b6e7d`: 1 finding. - `docs/agents/memory.md` needs the `docs-i18n` packs updated or a `[docs-i18n]` follow-up: already handled by #7645, linked above. CodeRabbit only saw the diff, not the issue. No code change. The later e2e-only commit (`1587ea297`) was not re-reviewed locally. ## Notes for the maintainer - Importing a memory file into a chat that already has a generated recollection for the same scene and character keeps the local one. That is the existing "import never overwrites local memories" rule, so a deletion in the file doesn't apply there. Import into a chat without that recollection, and branches, keep it deleted. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Character recollections can now be permanently deleted. Deleted recollections are excluded from prompts and won’t be automatically rewritten; you can enter and save replacement text at any time. * **Bug Fixes** * Improved recollection saving and progress tracking, including when cancellation or a storage issue occurs after a response is received. <!-- 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-24 04:08:10 +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#7854
No description provided.