[PR #7236] [MERGED] feat(memory): tell users about memory problems and fix them in one click #7642

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

📋 Pull Request Information

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

Base: staging ← Head: feat/advanced-memory-fix-all


📝 Commits (5)

  • ac08962 feat(memory): tell users about memory problems and fix them in one click
  • f481e32 Merge origin/staging into feat/advanced-memory-fix-all
  • 9e317cb fix(memory): keep a pending Fix request and repair scenes after a failed continuity retry
  • 9bd22ca Merge remote-tracking branch 'origin/feat/advanced-memory-fix-all' into feat/advanced-memory-fix-all
  • b58a6b6 Merge origin/staging into feat/advanced-memory-fix-all

📊 Changes

17 files changed (+1123 additions, -65 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/TROUBLESHOOTING.md (+10 -0)
📝 docs/agents/memory.md (+18 -3)
📝 docs/chats/chat-settings.md (+1 -1)
📝 e2e/advanced-memory.e2e.ts (+172 -0)
📝 packages/client/src/components/chat/AdvancedMemoryInspector.tsx (+45 -12)
📝 packages/client/src/components/chat/AdvancedMemorySettings.tsx (+113 -5)
📝 packages/client/src/components/chat/ChatArea.tsx (+8 -1)
📝 packages/client/src/components/chat/ChatSettingsBubble.tsx (+31 -3)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+40 -2)
📝 packages/client/src/hooks/use-advanced-memory.ts (+118 -3)
📝 packages/client/src/localization/locales/en.json (+21 -1)
📝 packages/client/src/stores/ui.store.ts (+5 -0)
📝 packages/server/src/routes/advanced-memory.routes.ts (+3 -0)
📝 packages/server/src/services/advanced-memory.ts (+133 -34)
📝 packages/shared/src/types/advanced-memory.ts (+75 -0)
➕ scripts/regressions/advanced-memory-fix.regression.ts (+329 -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 #7234

Why this change

  • Users of Advanced Memory Recall don't learn that a chat's memory is broken. Unclear participants, older scenes never checked, summaries withheld after visibility or name changes, missing scene summaries and hand-edited summaries that no longer match are all saved while the job still says Memory is ready. The only live signal was a server log line (LOG_LEVEL defaults to warn). The maintainer sees those in her server console, while launcher, installer, Android and Termux users never do. There is no role or debug gating; the difference is only where the warnings appear.
  • In the app, the only warning was a muted grey line in Chat Settings → Memory Recall. It covered only unmatched participants, and its status query ran only while Chat Settings was open. Error toasts only fired from the live generation stream or while Chat Settings / Agent activity was mounted.
  • Fixing it was manual and scene by scene. Prepare existing history didn't recheck unmatched participants and stopped at the first hand-edited summary needing review, so those came up one per rerun.
  • Maintainer request (2026-10-07): notify users, add a Fix button that applies the needed changes for them, let the helper decide who was in a scene, and afterwards list the changed scene numbers so the user can check them.

What changed

  • One problem list (advancedMemoryProblems(status) in packages/shared). It sorts problems into scenes Fix can repair (unclear or unchecked participants, outdated, withheld or missing summaries) and scenes only the user can settle (hand-edited summaries that no longer match, or participants the helper still couldn't decide), plus blockers (unconfirmed knowledge ranges, unusable Decision connection) and a stopped job. Deleted and excluded summaries and the unscoped-summary/agent advisories are not problems. The badge, the notice, the Fix box and the server's Fix report all use it.
  • Notice (ChatSettingsBubble + useAdvancedMemoryAttention). The Chat Settings button now watches the open Roleplay chat's Advanced Memory even with Chat Settings closed. While problems exist it shows a steady dot in the accent color, held steady so it never pulses with Accent Pulse, with a screen-reader description. Each new problem scene triggers one notice: "Advanced Memory found problems in N scenes." with Fix (or Review memory when nothing is fixable). Announced scenes are remembered per chat in localStorage (try/catch, capped). Because the status observer is always mounted, the existing "Advanced Memory stopped" toast now also fires with Chat Settings closed. Access memories for this chat gets the same dot.
  • Fix (POST /chats/:id/advanced-memory/initialize { fixAll: true }, no new endpoint). It reuses the preparation run, so the queue, locks, progress and Pause all apply, and it waits for running work instead of joining it.
    • It asks the helper again about Check who was there scenes and checks every older unchecked scene, including failed checks. A clear answer is saved. An unclear answer keeps the scene's current characters (never widened, still filtered by visibility), adds a scene-audience-unresolved marker and lists the scene for review, so the next Fix doesn't ask again.
    • It redoes summaries whose sources, visibility or names changed, using the visibility-annotated helper path, and prepares missing scenes. It never acknowledges old text, and deleted summaries stay deleted.
    • Hand-edited summaries are never rewritten. Instead of correctionReviewError stopping the run, Fix lists the scene for review and continues with the others. When a correction's scene boundaries moved, overlapping scenes are skipped and their older summaries kept.
    • A failed participant check no longer stops Fix. The scene keeps its access and is listed.
    • A stopped continuity update is resumed first.
    • The result is saved as job.fixResult = { jobId, fixedSceneIds, reviewSceneIds }. A scene counts as fixed only if it was flagged before Fix and is no longer flagged after it. The run logs [advanced-memory] Fix for chat … N fixed, M need review with Pino. The helper prompts are unchanged, so debug prompt logging still applies, and the client sends debugMode.
    • Default (non-Fix) preparation is unchanged.
  • Chat Settings → Memory Recall shows a small Fix box: "N scenes need your review: #…", "N scenes need fixing." with Fix, and afterwards "Fixed N scenes: #…". It is a polite live region. Each number opens that scene, or its missing-summary card, in Access memories and moves focus to it. When the user can't fix something, the box says what to do: confirming knowledge ranges replaces the Fix button with Confirm character knowledge. The old "couldn't confirm who was in some scenes" warning line is folded into this box. If Chat Settings was closed when Fix finished, a single notice ("Advanced Memory fixed N scenes." / "M scenes still need your review.") offers Show.
  • New English strings use chat.advancedMemory.fix.* keys in en.json only. The unused warning.sceneAudienceUnmatched key was removed.
  • Docs: new Fixing memory problems section in docs/agents/memory.md (plus the participants, visibility and Prepare existing history paragraphs), a troubleshooting entry, and a sentence in docs/chats/chat-settings.md. CHANGELOG entry at the top of [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

Agent-run results (not a substitute for the boxes above):

  • pnpm check: exit 0 (formatting, impeccable, localization, lint, e2e types, build).
  • pnpm localization:check: passes.
  • New scripts/regressions/advanced-memory-fix.regression.ts, with a fake helper over a real file store. One Fix run:
    • rechecks an unmatched scene and saves the clear answer;
    • leaves a still-unclear scene's access unchanged, marked unresolved;
    • redoes a recap whose visibility changed, with visibility annotations;
    • leaves a hand-edited summary needing review untouched while the run ends ready;
    • prepares a missing scene and checks an older scene;
    • keeps the scene and grants nothing when a helper check fails;
    • doesn't regenerate a deleted summary;
    • lists a correction with moved boundaries for review. Preparation without Fix still stops there.
    • It also asserts the exact helper calls, fixResult IDs and agreement with advancedMemoryProblems, that a second Fix only retries the failed check, and that saving access by hand settles the unclear scene.
  • All 15 advanced-memory-* regressions, plus memory-recall*, roleplay-user-private-memory and native-export-memory: pass.
  • e2e/advanced-memory.e2e.ts and e2e/advanced-memory-wizard.e2e.ts on desktop-chromium and mobile-webkit: 40 passed. Existing tests are unchanged. The new test covers:
    • the dot and its accessible description;
    • one notice, with no repeat after reload, and a new notice for a new problem scene;
    • the Fix box listing before Fix;
    • the notice's Fix posting fixAll: true and showing progress with Pause;
    • the result notice after closing Chat Settings, and Show;
    • "Fixed 2 scenes: #1 #3" and "1 scene needs your review: #2" in the live region;
    • Open Scene #3 and #2 focusing that scene's heading in Access memories;
    • light/dark screenshots.

Manual verification notes

  • Manually verify in a browser, in a Roleplay chat with Advanced Memory on that has a scene marked Check who was there:
    • the Chat Settings button shows a steady accent dot that does not pulse with Accent Pulse on;
    • one notice appears;
    • reloading does not show the notice again.
  • Manually verify that pressing Fix in the notice opens Chat Settings → Memory Recall with progress and Pause processing, and that Pause stops it with completed work kept.
  • Manually verify against a real Helper model that afterwards:
    • Fixed N scenes lists the repaired scenes;
    • a hand-edited summary whose messages changed is listed under need your review with its text unchanged;
    • selecting a number opens that scene in Access memories for this chat.
  • Manually verify that with Chat Settings closed during Fix, a result notice with Show appears once.
  • Manually verify on a phone (or phone-width window), in light and dark mode, that the dot, notice, Fix box and scene buttons are readable and reachable.
  • Manually verify with a screen reader that the Chat Settings button announces "Advanced Memory needs attention" and that the Fix result is announced.
  • Manually verify in an Individual group chat with an unconfirmed character knowledge range that the Fix box offers Confirm character knowledge instead of Fix.

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)

Docs changed: docs/agents/memory.md, docs/TROUBLESHOOTING.md, docs/chats/chat-settings.md, CHANGELOG.md. Translation follow-up: #7235 (related: #7225).

UI evidence (if applicable)

Playwright captured light and dark screenshots of the notice, the Fix box before Fix and the Fix result on desktop and iPhone (memory-fix-notice-*, memory-fix-box-*, memory-fix-result-* in the test output folder). They were not uploaded, because the agent can't post images; please add screenshots when verifying manually.

Summary by CodeRabbit

  • New Features
    • Advanced Memory flags scenes with missing, outdated, or unclear memories and offers a bulk Fix action.
    • Results separate repaired scenes from those needing review. Manually edited summaries are preserved, and unclear participant checks do not broaden scene access.
    • Chat Settings indicators and scene links help you find issues and open affected summaries. Fix can resume after interrupted continuity work, and you can retry after an error.
  • Documentation
    • Added guidance for understanding Advanced Memory notices, fixing scenes, and reviewing unresolved issues.

🔄 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/7236 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/advanced-memory-fix-all` --- ### 📝 Commits (5) - [`ac08962`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ac08962c5fd6d94639fd4987730f23d273c7f7e9) feat(memory): tell users about memory problems and fix them in one click - [`f481e32`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f481e3248b309689a4abae0f5603370ae0360dbc) Merge origin/staging into feat/advanced-memory-fix-all - [`9e317cb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9e317cbf86578dcd02c120981cf23101257d8d70) fix(memory): keep a pending Fix request and repair scenes after a failed continuity retry - [`9bd22ca`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9bd22ca42e4946c946e55ce0702bc4da6842b329) Merge remote-tracking branch 'origin/feat/advanced-memory-fix-all' into feat/advanced-memory-fix-all - [`b58a6b6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b58a6b650185132c081c68cf2a7ec9c8ff2ed6ef) Merge origin/staging into feat/advanced-memory-fix-all ### 📊 Changes **17 files changed** (+1123 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/TROUBLESHOOTING.md` (+10 -0) 📝 `docs/agents/memory.md` (+18 -3) 📝 `docs/chats/chat-settings.md` (+1 -1) 📝 `e2e/advanced-memory.e2e.ts` (+172 -0) 📝 `packages/client/src/components/chat/AdvancedMemoryInspector.tsx` (+45 -12) 📝 `packages/client/src/components/chat/AdvancedMemorySettings.tsx` (+113 -5) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+8 -1) 📝 `packages/client/src/components/chat/ChatSettingsBubble.tsx` (+31 -3) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+40 -2) 📝 `packages/client/src/hooks/use-advanced-memory.ts` (+118 -3) 📝 `packages/client/src/localization/locales/en.json` (+21 -1) 📝 `packages/client/src/stores/ui.store.ts` (+5 -0) 📝 `packages/server/src/routes/advanced-memory.routes.ts` (+3 -0) 📝 `packages/server/src/services/advanced-memory.ts` (+133 -34) 📝 `packages/shared/src/types/advanced-memory.ts` (+75 -0) ➕ `scripts/regressions/advanced-memory-fix.regression.ts` (+329 -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 #7234 ## Why this change - Users of **Advanced Memory Recall** don't learn that a chat's memory is broken. Unclear participants, older scenes never checked, summaries withheld after visibility or name changes, missing scene summaries and hand-edited summaries that no longer match are all saved while the job still says **Memory is ready**. The only live signal was a server log line (`LOG_LEVEL` defaults to `warn`). The maintainer sees those in her server console, while launcher, installer, Android and Termux users never do. There is no role or debug gating; the difference is only where the warnings appear. - In the app, the only warning was a muted grey line in **Chat Settings → Memory Recall**. It covered only unmatched participants, and its status query ran only while Chat Settings was open. Error toasts only fired from the live generation stream or while Chat Settings / Agent activity was mounted. - Fixing it was manual and scene by scene. **Prepare existing history** didn't recheck unmatched participants and stopped at the first hand-edited summary needing review, so those came up one per rerun. - Maintainer request (2026-10-07): notify users, add a **Fix** button that applies the needed changes for them, let the helper decide who was in a scene, and afterwards list the changed scene numbers so the user can check them. ## What changed - **One problem list** (`advancedMemoryProblems(status)` in `packages/shared`). It sorts problems into scenes Fix can repair (unclear or unchecked participants, outdated, withheld or missing summaries) and scenes only the user can settle (hand-edited summaries that no longer match, or participants the helper still couldn't decide), plus blockers (unconfirmed knowledge ranges, unusable Decision connection) and a stopped job. Deleted and excluded summaries and the unscoped-summary/agent advisories are not problems. The badge, the notice, the Fix box and the server's Fix report all use it. - **Notice** (`ChatSettingsBubble` + `useAdvancedMemoryAttention`). The Chat Settings button now watches the open Roleplay chat's Advanced Memory even with Chat Settings closed. While problems exist it shows a steady dot in the accent color, held steady so it never pulses with Accent Pulse, with a screen-reader description. Each new problem scene triggers one notice: "Advanced Memory found problems in N scenes." with **Fix** (or **Review memory** when nothing is fixable). Announced scenes are remembered per chat in `localStorage` (try/catch, capped). Because the status observer is always mounted, the existing "Advanced Memory stopped" toast now also fires with Chat Settings closed. **Access memories for this chat** gets the same dot. - **Fix** (`POST /chats/:id/advanced-memory/initialize { fixAll: true }`, no new endpoint). It reuses the preparation run, so the queue, locks, progress and **Pause** all apply, and it waits for running work instead of joining it. - It asks the helper again about **Check who was there** scenes and checks every older unchecked scene, including failed checks. A clear answer is saved. An unclear answer keeps the scene's current characters (never widened, still filtered by visibility), adds a `scene-audience-unresolved` marker and lists the scene for review, so the next Fix doesn't ask again. - It redoes summaries whose sources, visibility or names changed, using the visibility-annotated helper path, and prepares missing scenes. It never acknowledges old text, and deleted summaries stay deleted. - Hand-edited summaries are never rewritten. Instead of `correctionReviewError` stopping the run, Fix lists the scene for review and continues with the others. When a correction's scene boundaries moved, overlapping scenes are skipped and their older summaries kept. - A failed participant check no longer stops Fix. The scene keeps its access and is listed. - A stopped continuity update is resumed first. - The result is saved as `job.fixResult = { jobId, fixedSceneIds, reviewSceneIds }`. A scene counts as fixed only if it was flagged before Fix and is no longer flagged after it. The run logs `[advanced-memory] Fix for chat … N fixed, M need review` with Pino. The helper prompts are unchanged, so debug prompt logging still applies, and the client sends `debugMode`. - Default (non-Fix) preparation is unchanged. - **Chat Settings → Memory Recall** shows a small Fix box: "N scenes need your review: #…", "N scenes need fixing." with **Fix**, and afterwards "Fixed N scenes: #…". It is a polite live region. Each number opens that scene, or its missing-summary card, in **Access memories** and moves focus to it. When the user can't fix something, the box says what to do: confirming knowledge ranges replaces the Fix button with **Confirm character knowledge**. The old "couldn't confirm who was in some scenes" warning line is folded into this box. If Chat Settings was closed when Fix finished, a single notice ("Advanced Memory fixed N scenes." / "M scenes still need your review.") offers **Show**. - New English strings use `chat.advancedMemory.fix.*` keys in `en.json` only. The unused `warning.sceneAudienceUnmatched` key was removed. - Docs: new **Fixing memory problems** section in `docs/agents/memory.md` (plus the participants, visibility and Prepare existing history paragraphs), a troubleshooting entry, and a sentence in `docs/chats/chat-settings.md`. CHANGELOG entry at the top of `[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` Agent-run results (not a substitute for the boxes above): - `pnpm check`: exit 0 (formatting, impeccable, localization, lint, e2e types, build). - `pnpm localization:check`: passes. - New `scripts/regressions/advanced-memory-fix.regression.ts`, with a fake helper over a real file store. One Fix run: - rechecks an unmatched scene and saves the clear answer; - leaves a still-unclear scene's access unchanged, marked unresolved; - redoes a recap whose visibility changed, with visibility annotations; - leaves a hand-edited summary needing review untouched while the run ends `ready`; - prepares a missing scene and checks an older scene; - keeps the scene and grants nothing when a helper check fails; - doesn't regenerate a deleted summary; - lists a correction with moved boundaries for review. Preparation without Fix still stops there. - It also asserts the exact helper calls, `fixResult` IDs and agreement with `advancedMemoryProblems`, that a second Fix only retries the failed check, and that saving access by hand settles the unclear scene. - All 15 `advanced-memory-*` regressions, plus `memory-recall*`, `roleplay-user-private-memory` and `native-export-memory`: pass. - `e2e/advanced-memory.e2e.ts` and `e2e/advanced-memory-wizard.e2e.ts` on `desktop-chromium` and `mobile-webkit`: 40 passed. Existing tests are unchanged. The new test covers: - the dot and its accessible description; - one notice, with no repeat after reload, and a new notice for a new problem scene; - the Fix box listing before Fix; - the notice's **Fix** posting `fixAll: true` and showing progress with Pause; - the result notice after closing Chat Settings, and **Show**; - "Fixed 2 scenes: #1 #3" and "1 scene needs your review: #2" in the live region; - **Open Scene #3** and **#2** focusing that scene's heading in Access memories; - light/dark screenshots. ### Manual verification notes - Manually verify in a browser, in a Roleplay chat with Advanced Memory on that has a scene marked **Check who was there**: - the Chat Settings button shows a steady accent dot that does not pulse with **Accent Pulse** on; - one notice appears; - reloading does not show the notice again. - Manually verify that pressing **Fix** in the notice opens **Chat Settings → Memory Recall** with progress and **Pause processing**, and that **Pause** stops it with completed work kept. - Manually verify against a real Helper model that afterwards: - **Fixed N scenes** lists the repaired scenes; - a hand-edited summary whose messages changed is listed under **need your review** with its text unchanged; - selecting a number opens that scene in **Access memories for this chat**. - Manually verify that with Chat Settings closed during Fix, a result notice with **Show** appears once. - Manually verify on a phone (or phone-width window), in light and dark mode, that the dot, notice, Fix box and scene buttons are readable and reachable. - Manually verify with a screen reader that the Chat Settings button announces "Advanced Memory needs attention" and that the Fix result is announced. - Manually verify in an Individual group chat with an unconfirmed character knowledge range that the Fix box offers **Confirm character knowledge** instead of **Fix**. ## 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) Docs changed: `docs/agents/memory.md`, `docs/TROUBLESHOOTING.md`, `docs/chats/chat-settings.md`, `CHANGELOG.md`. Translation follow-up: #7235 (related: #7225). ## UI evidence (if applicable) Playwright captured light and dark screenshots of the notice, the Fix box before Fix and the Fix result on desktop and iPhone (`memory-fix-notice-*`, `memory-fix-box-*`, `memory-fix-result-*` in the test output folder). They were not uploaded, because the agent can't post images; please add screenshots when verifying manually. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Advanced Memory flags scenes with missing, outdated, or unclear memories and offers a bulk **Fix** action. * Results separate repaired scenes from those needing review. Manually edited summaries are preserved, and unclear participant checks do not broaden scene access. * Chat Settings indicators and scene links help you find issues and open affected summaries. Fix can resume after interrupted continuity work, and you can retry after an error. * **Documentation** * Added guidance for understanding Advanced Memory notices, fixing scenes, and reviewing unresolved issues. <!-- 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:06:06 +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#7642
No description provided.