[PR #6160] [MERGED] fix(memory): clarify automatic setup and improve preparation reliability #7073

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6160
Author: @SpicyMarinara
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/advanced-memory-setup-reliability


📝 Commits (5)

  • 063afd3 chore: start advanced memory setup and reliability work
  • ceb721e fix(memory): clarify automatic setup and preserve scene context reliably
  • acce9b9 fix(memory): check scenes after generation and preserve settings edits
  • 3cf2777 fix(memory): preserve tracker cadence and queued settings limits
  • bbf33af fix(ui): preserve numeric input selection during saved updates

📊 Changes

31 files changed (+3213 additions, -262 deletions)

View changed files

📝 CHANGELOG.md (+7 -0)
📝 docs/agents/memory.md (+9 -7)
➕ e2e/advanced-memory-wizard.e2e.ts (+306 -0)
📝 e2e/advanced-memory.e2e.ts (+115 -5)
📝 e2e/core-flows.e2e.ts (+18 -4)
📝 e2e/game-native-dice.e2e.ts (+1 -1)
📝 packages/client/public/sprites/mari/generated/professor-mari-memory-wheel.png (+0 -0)
📝 packages/client/src/components/chat/AdvancedMemoryInspector.tsx (+138 -39)
📝 packages/client/src/components/chat/AdvancedMemoryProgress.tsx (+12 -4)
📝 packages/client/src/components/chat/AdvancedMemorySettings.tsx (+75 -24)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+9 -4)
📝 packages/client/src/components/chat/ChatSetupWizard.tsx (+48 -37)
📝 packages/client/src/components/presets/ChoiceSelectionModal.tsx (+9 -2)
📝 packages/client/src/components/ui/DraftNumberInput.tsx (+2 -2)
📝 packages/client/src/hooks/use-advanced-memory.ts (+27 -6)
📝 packages/client/src/lib/chat-wizard-defaults.ts (+15 -3)
📝 packages/client/src/localization/locales/en.json (+24 -6)
📝 packages/server/src/routes/advanced-memory.routes.ts (+15 -2)
📝 packages/server/src/routes/generate.routes.ts (+97 -6)
📝 packages/server/src/services/advanced-memory.ts (+539 -84)

...and 11 more files

📄 Description

Linked issue

Closes #6159

Why this change

Advanced Memory should let Roleplay users continue their story without managing context cutoffs manually. Its settings did not explain the compression threshold, raw recall excerpts appeared beside scene summaries under the same title, and the desired short summary length could exhaust a reasoning model’s entire completion allowance before it wrote usable text.

What changed

  • Reuse the existing memory setup in the Roleplay wizard, below Agents, including when no agents are installed. Clarify compression and constant-summary limits, helper-model guidance and moving-context controls; allow 0/0 to disable excerpts and 0/N for optional excerpts.
  • Show immediate preparation/resume feedback, acknowledge the persisted job before returning from initialization, and retain one job for concurrent requests. Give short summaries a separate bounded completion allowance and reject incomplete output with useful diagnostics.
  • Keep numbered scene summaries in one archive, with story timeframes, open/closed status, search, editable Summary text and full source-message inspection. Internal verbatim excerpts remain available to recall but no longer appear as separate scene entries. Align drawer controls and improve Professor Mari’s running frames.
  • Add confirmed memory reset using the existing operation and metadata queues. Preserve original messages and settings, invalidate old prepared context, and prevent late work from restoring cleared memory.
  • Carry source-grounded story-time anchors into recalled context and combined summaries, preserving unknown timeframes rather than inventing calendar dates. Keep character visibility and preset XML/Markdown/None formatting.
  • Move ongoing scene detection after the saved response. Follow configured automatic tracker schedules and share one actual tracker request (including authorized custom trackers and Beholder), or, without automatic trackers, use a standalone helper with a configurable five-message default and only its recent source window plus instructions. Preserve character visibility in shared calls, validate source/swipe revisions, and keep explicit historical preparation separate from ongoing checks.
  • Serialize numeric settings writes without disabling an edit in progress, derive related limits after earlier saves settle, and serialize read-only preparation with reset. These races have controlled regression proofs.
  • Preserve text selection in numeric inputs when a saved-value echo arrives immediately before editing; the shared input now settles that update before selection begins.
  • Fix a wizard race found by the full browser lane: selecting None while the preset save is pending can no longer open an empty variables dialog or skip the Participants step.
  • Reject empty visibility-filtered scene decisions and keep the ordinary tracker request intact when the added scene window cannot fit its context budget.

Validation

Automated validation:

  • pnpm check — passed (localization, formatting, TypeScript/ESLint, E2E types and production build).
  • pnpm regression:prompt — passed.
  • Advanced Memory regressions — passed: 800-message scope/cancellation/cache/reset controls, 0/0 and 0/N recall, source timeframes across XML/Markdown/None, hidden-date exclusion, reasoning budgets, concurrent initialization, post-generation cadence, multiple scene transitions, source changes and the pending-prepare/reset race.
  • Actual generation and agent executor proofs — passed: the fifth saved message triggers after the main response; builtin/custom trackers share their existing request; hidden character history stays excluded; streamed/non-streamed singleton, batch and Beholder calls strip the private scene result before tracker application, including inline thinking and fenced JSON. Empty filtered windows cannot advance the scene cursor; oversized scene additions preserve the tracker request, streaming and pending scene check.
  • Focused pnpm smoke:ui — 16/16 passed: fifteen cases across desktop Chromium, Android-sized Chromium and iPhone-sized WebKit, plus the affected WebKit dark native-dice case. Includes held-response autosave ordering, stale-status cancellation, related limits when context increases/decreases, queued minimum/maximum edits, persisted scene interval and 0/0 excerpts, delayed resume acknowledgment, disabled duplicate action, archive search/reset cancellation, source inspection, timeframe labels, button/panel geometry, and the delayed preset-None save.
  • Tracker cadence route regression — passed with a failing-before control: a ten-message custom tracker does not start a standalone helper after five messages; keyword-gated trackers wait too, while manual-only and disabled trackers retain standalone checks.
  • Actual-component numeric-selection reproduction — passed in Chromium and WebKit: the old timing prepended stale digits (159992048); the corrected input retains and commits 2048.
  • Storage-watcher regression — passed after waiting for piped diagnostics to close; lease/error assertions are retained.
  • Wizard-default capture regression — passed, preserving options without copying old character knowledge or runtime progress.
  • Final hosted validation on bbf33af8 — 263/263 Node regressions and all ten browser shards passed (desktop Chromium, mobile Chromium and mobile WebKit). Required validation, container build, CodeQL and the completed CodeRabbit review also passed; no unresolved review threads remain. Full regression run.

Boxes below remain human verification tasks.

  • 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

Manually verify preparation and resume with the affected GPT-6 Astra connection and a representative existing Individual group chat, including character knowledge ranges. Manually inspect the four-frame animation on a physical phone. Automated browser coverage uses desktop Chromium, Android-sized Chromium and iPhone-sized WebKit; provider regressions use the real Astra adapter against a local response fixture, not paid remote generations.

Docs and release impact

User-facing changes are recorded in CHANGELOG.md and the Advanced Memory guide is aligned with the new controls and scene-check flow. Translation synchronization is tracked in #6163. No release version or install/update behavior changes.

  • 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
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Automated light/dark drawer and wizard screenshots were captured and inspected. Final local evidence is under /private/tmp/marinara-6160-selection-browser-final and /private/tmp/marinara-6160-dice-capture-final. Physical-device and live-provider verification remain listed above.


🔄 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/6160 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/13/2026 **Status:** ✅ Merged **Merged:** 9/13/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/advanced-memory-setup-reliability` --- ### 📝 Commits (5) - [`063afd3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/063afd3588c2504141883fcf3e772a3a1c132367) chore: start advanced memory setup and reliability work - [`ceb721e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ceb721e330425b3a44ef9597b2cd16cfd3e5fc7b) fix(memory): clarify automatic setup and preserve scene context reliably - [`acce9b9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/acce9b96ad0be1a6fc0a48dfc6ccf8484fb792cb) fix(memory): check scenes after generation and preserve settings edits - [`3cf2777`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3cf2777a20fb437aa1bb81c29f3e93f9fd59ed87) fix(memory): preserve tracker cadence and queued settings limits - [`bbf33af`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bbf33af8e23f1ba89d3471759abbb39b3dc957a1) fix(ui): preserve numeric input selection during saved updates ### 📊 Changes **31 files changed** (+3213 additions, -262 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+7 -0) 📝 `docs/agents/memory.md` (+9 -7) ➕ `e2e/advanced-memory-wizard.e2e.ts` (+306 -0) 📝 `e2e/advanced-memory.e2e.ts` (+115 -5) 📝 `e2e/core-flows.e2e.ts` (+18 -4) 📝 `e2e/game-native-dice.e2e.ts` (+1 -1) 📝 `packages/client/public/sprites/mari/generated/professor-mari-memory-wheel.png` (+0 -0) 📝 `packages/client/src/components/chat/AdvancedMemoryInspector.tsx` (+138 -39) 📝 `packages/client/src/components/chat/AdvancedMemoryProgress.tsx` (+12 -4) 📝 `packages/client/src/components/chat/AdvancedMemorySettings.tsx` (+75 -24) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+9 -4) 📝 `packages/client/src/components/chat/ChatSetupWizard.tsx` (+48 -37) 📝 `packages/client/src/components/presets/ChoiceSelectionModal.tsx` (+9 -2) 📝 `packages/client/src/components/ui/DraftNumberInput.tsx` (+2 -2) 📝 `packages/client/src/hooks/use-advanced-memory.ts` (+27 -6) 📝 `packages/client/src/lib/chat-wizard-defaults.ts` (+15 -3) 📝 `packages/client/src/localization/locales/en.json` (+24 -6) 📝 `packages/server/src/routes/advanced-memory.routes.ts` (+15 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+97 -6) 📝 `packages/server/src/services/advanced-memory.ts` (+539 -84) _...and 11 more files_ </details> ### 📄 Description ## Linked issue Closes #6159 ## Why this change Advanced Memory should let Roleplay users continue their story without managing context cutoffs manually. Its settings did not explain the compression threshold, raw recall excerpts appeared beside scene summaries under the same title, and the desired short summary length could exhaust a reasoning model’s entire completion allowance before it wrote usable text. ## What changed - Reuse the existing memory setup in the Roleplay wizard, below Agents, including when no agents are installed. Clarify compression and constant-summary limits, helper-model guidance and moving-context controls; allow 0/0 to disable excerpts and 0/N for optional excerpts. - Show immediate preparation/resume feedback, acknowledge the persisted job before returning from initialization, and retain one job for concurrent requests. Give short summaries a separate bounded completion allowance and reject incomplete output with useful diagnostics. - Keep numbered scene summaries in one archive, with story timeframes, open/closed status, search, editable Summary text and full source-message inspection. Internal verbatim excerpts remain available to recall but no longer appear as separate scene entries. Align drawer controls and improve Professor Mari’s running frames. - Add confirmed memory reset using the existing operation and metadata queues. Preserve original messages and settings, invalidate old prepared context, and prevent late work from restoring cleared memory. - Carry source-grounded story-time anchors into recalled context and combined summaries, preserving unknown timeframes rather than inventing calendar dates. Keep character visibility and preset XML/Markdown/None formatting. - Move ongoing scene detection after the saved response. Follow configured automatic tracker schedules and share one actual tracker request (including authorized custom trackers and Beholder), or, without automatic trackers, use a standalone helper with a configurable five-message default and only its recent source window plus instructions. Preserve character visibility in shared calls, validate source/swipe revisions, and keep explicit historical preparation separate from ongoing checks. - Serialize numeric settings writes without disabling an edit in progress, derive related limits after earlier saves settle, and serialize read-only preparation with reset. These races have controlled regression proofs. - Preserve text selection in numeric inputs when a saved-value echo arrives immediately before editing; the shared input now settles that update before selection begins. - Fix a wizard race found by the full browser lane: selecting None while the preset save is pending can no longer open an empty variables dialog or skip the Participants step. - Reject empty visibility-filtered scene decisions and keep the ordinary tracker request intact when the added scene window cannot fit its context budget. ## Validation Automated validation: - `pnpm check` — passed (localization, formatting, TypeScript/ESLint, E2E types and production build). - `pnpm regression:prompt` — passed. - Advanced Memory regressions — passed: 800-message scope/cancellation/cache/reset controls, 0/0 and 0/N recall, source timeframes across XML/Markdown/None, hidden-date exclusion, reasoning budgets, concurrent initialization, post-generation cadence, multiple scene transitions, source changes and the pending-prepare/reset race. - Actual generation and agent executor proofs — passed: the fifth saved message triggers after the main response; builtin/custom trackers share their existing request; hidden character history stays excluded; streamed/non-streamed singleton, batch and Beholder calls strip the private scene result before tracker application, including inline thinking and fenced JSON. Empty filtered windows cannot advance the scene cursor; oversized scene additions preserve the tracker request, streaming and pending scene check. - Focused `pnpm smoke:ui` — 16/16 passed: fifteen cases across desktop Chromium, Android-sized Chromium and iPhone-sized WebKit, plus the affected WebKit dark native-dice case. Includes held-response autosave ordering, stale-status cancellation, related limits when context increases/decreases, queued minimum/maximum edits, persisted scene interval and 0/0 excerpts, delayed resume acknowledgment, disabled duplicate action, archive search/reset cancellation, source inspection, timeframe labels, button/panel geometry, and the delayed preset-None save. - Tracker cadence route regression — passed with a failing-before control: a ten-message custom tracker does not start a standalone helper after five messages; keyword-gated trackers wait too, while manual-only and disabled trackers retain standalone checks. - Actual-component numeric-selection reproduction — passed in Chromium and WebKit: the old timing prepended stale digits (159992048); the corrected input retains and commits 2048. - Storage-watcher regression — passed after waiting for piped diagnostics to close; lease/error assertions are retained. - Wizard-default capture regression — passed, preserving options without copying old character knowledge or runtime progress. - Final hosted validation on `bbf33af8` — 263/263 Node regressions and all ten browser shards passed (desktop Chromium, mobile Chromium and mobile WebKit). Required validation, container build, CodeQL and the completed CodeRabbit review also passed; no unresolved review threads remain. [Full regression run](https://github.com/Pasta-Devs/Marinara-Engine/actions/runs/34764926328). Boxes below remain human verification tasks. - [ ] `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 Manually verify preparation and resume with the affected GPT-6 Astra connection and a representative existing Individual group chat, including character knowledge ranges. Manually inspect the four-frame animation on a physical phone. Automated browser coverage uses desktop Chromium, Android-sized Chromium and iPhone-sized WebKit; provider regressions use the real Astra adapter against a local response fixture, not paid remote generations. ## Docs and release impact User-facing changes are recorded in CHANGELOG.md and the Advanced Memory guide is aligned with the new controls and scene-check flow. Translation synchronization is tracked in #6163. No release version or install/update behavior changes. - [ ] 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 - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Automated light/dark drawer and wizard screenshots were captured and inspected. Final local evidence is under `/private/tmp/marinara-6160-selection-browser-final` and `/private/tmp/marinara-6160-dice-capture-final`. Physical-device and live-provider verification remain listed above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:16:17 +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#7073
No description provided.