[PR #6500] [MERGED] fix: reset Advanced Recall context and repair scene access #7203

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

📋 Pull Request Information

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

Base: staging ← Head: codex/sept21-scene-check-cadence


📝 Commits (3)

  • 71890fc docs: track Advanced Memory scene check visibility fix
  • 90468ca fix: preserve scene knowledge and allow access corrections
  • 8e4f019 fix: reset Advanced Memory context at scene boundaries

📊 Changes

17 files changed (+825 additions, -78 deletions)

View changed files

📝 CHANGELOG.md (+8 -0)
📝 e2e/advanced-memory.e2e.ts (+34 -1)
📝 e2e/core-flows.e2e.ts (+71 -0)
📝 packages/client/index.html (+1 -1)
📝 packages/client/src/components/chat/AdvancedMemoryInspector.tsx (+64 -2)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+1 -0)
📝 packages/client/src/hooks/use-advanced-memory.ts (+5 -1)
📝 packages/client/src/localization/locales/en.json (+4 -0)
📝 packages/server/src/routes/advanced-memory.routes.ts (+10 -2)
📝 packages/server/src/routes/generate.routes.ts (+22 -7)
📝 packages/server/src/services/advanced-memory.ts (+186 -51)
📝 packages/server/src/services/prompt/advanced-memory-prompt.ts (+9 -1)
📝 packages/shared/src/types/advanced-memory.ts (+8 -1)
📝 scripts/regressions/advanced-memory-core.regression.ts (+166 -1)
📝 scripts/regressions/advanced-memory-history-start.regression.ts (+143 -4)
📝 scripts/regressions/advanced-memory-post-generation.regression.ts (+63 -6)
📝 scripts/regressions/prompt.regression.ts (+30 -0)

📄 Description

Linked issue

Closes #6499. Closes #6501. Closes #6502. Closes #6503.
Implementation owner: SpicyMarinara / Codex.

Why this change

Advanced Recall scene checks could disappear from the Agents menu when the main reply's stream closed. A later personal start flag also removed earlier scenes from a character's archive, despite an earlier confirmed knowledge start. The automatic context cutoff kept a near-full sliding window instead of resetting to the current scene and leaving room to grow. The scene inspector had no way to correct character access without processing the archive again. Empty recall markers added prompt spacing, and the page viewport disabled native image zoom in app shells that honor its scale restrictions.

What changed

  • At the context cap, reset to the latest detected scene and preserve that start while new messages accumulate until the next reset. Manual flag changes replace the automatic window; historical preparation cannot move the current flag. Keep the existing unfinished-scene excerpt fallback when no complete scene can free enough room.
  • Keep the existing response stream open for post-generation Advanced Recall activity after releasing the main generation. Show both standalone and bundled tracker checks, use exactly the configured number of recent messages, and skip checks on regenerated swipes.
  • Use personal and shared start flags for live context; use confirmed knowledge starts and hidden-message rules for archive access. Preserve existing summaries and vectors across the upgrade.
  • Add Edit character access beside the existing scene correction editor. Save audience-only corrections without any model or embedding call; reuse exclusions so later archive maintenance does not recreate removed access. Keep narrator access, validate character/source eligibility, and reuse already indexed eligible excerpts. Summary text remains editable through the existing Save correction button.
  • Remove spacing belonging to an empty Recalled Scenes marker while preserving authored formatting.
  • Allow native page pinch zoom in the existing chat image viewer, retaining the existing viewport/layout handling.

No archive reset, storage migration or new dependency is needed. This does not infer scene participants from prose or retroactively restore missing hide flags; manual scene access corrections address existing misassignments.

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

Automated evidence (checkboxes remain human verification tasks):

  • Local CodeRabbit reviewed the full patch and the cutoff follow-up with zero findings.
  • pnpm check passed: localization, formatting, lint, types and production builds. One pre-existing GameNarration hook warning remains.
  • The reset/grow/reset regression fails against the previous implementation and passes with this fix, including no backfill when more space becomes available and another reset after further growth. The visible automatic cutoff marker also passed on all three browser projects.
  • All eight Advanced Memory regression suites passed. Coverage includes a 1,000-message archive, per-character live cutoffs, hidden sources, immediate audience correction without model calls, existing vectors/excerpts, removal/regrant, narrator access and corrections surviving maintenance.
  • pnpm regression:prompt passed, including exact empty-marker formatting in XML/Markdown/plain formats and grouped/ungrouped prompts.
  • Real HTTP regression proves the main reply and the next reply finish while background memory work is held; standalone and bundled checks emit visible activity. Existing streaming/provider, agent isolation and regeneration tests pass.
  • Focused browser checks passed on desktop Chromium, mobile Chromium and mobile WebKit: 10 passed, two desktop skips for mobile-only zoom cases. Scene access editing, saving and responsive light/dark layouts pass on all three. The initial editor test clicked the hidden checkbox directly; it now clicks the visible label.
  • The first Linux CI run exposed a browser-driver issue: Input.synthesizePinchGesture did not zoom even a blank page. The test now dispatches two touch contacts through Chromium; the exact updated viewer test passes in Linux Chromium and local mobile Chromium/WebKit. It does not mock the native zoom assertion.
  • ARM64 Docker build and disposable-container API/frontend, native binding, non-root and persistent-data write/restart/read checks passed.

Manual verification notes

Manually verify on the original iPhone app: open a saved scene, use Edit character access to replace the incorrect character, save, and generate for each character without resetting memory. Confirm personal POV flags trim live messages while earlier eligible scenes remain available, and the narrator retains access. Confirm reaching the context cap resets to the latest scene, then holds that visible cutoff while the conversation grows to the cap again. Confirm a five-message standalone check appears after the reply in Agents. Open a chat image and pinch with two fingers.

Local proof uses synthetic fixture chats, isolated databases and mock providers. Private chat/memory exports are not included in this PR or uploaded for review. Physical iPhone pinch behavior and the original live chat remain manual verification items.

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

Five Unreleased entries and localized English labels/help for the audience editor. No version or user-facing docs changes.

UI evidence (if applicable)

Browser tests capture light/dark scene-access controls and post-generation Advanced Recall activity. Mobile Chromium drives a real native touch pinch; WebKit verifies the viewer and viewport/layout behavior. Physical iPhone two-finger pinch is not automated by this suite.

Downloadable UI proof gallery contains the captured fixture screenshots.

Summary by CodeRabbit

  • New Features

    • Edit which characters can access saved Advanced Memory scenes without reprocessing chat history.
    • Advanced Memory preserves confirmed memories across POV changes and resets live context to the latest scene when limits are reached.
    • Scene checks now display progress and completion status in the Agents menu.
    • Mobile chat image previews support native pinch-to-zoom.
  • Bug Fixes

    • Scene checks use the configured message range more accurately.
    • Empty recalled-scene markers no longer add unwanted blank lines to prompts.

🔄 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/6500 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/21/2026 **Status:** ✅ Merged **Merged:** 9/21/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/sept21-scene-check-cadence` --- ### 📝 Commits (3) - [`71890fc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/71890fc77673c80462ecf29a26be43379d7028f7) docs: track Advanced Memory scene check visibility fix - [`90468ca`](https://github.com/Pasta-Devs/Marinara-Engine/commit/90468cabac4df20a66a6068c052702f61f64b451) fix: preserve scene knowledge and allow access corrections - [`8e4f019`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8e4f019be128491e3f2a1dd0746b8d8278859ed0) fix: reset Advanced Memory context at scene boundaries ### 📊 Changes **17 files changed** (+825 additions, -78 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+8 -0) 📝 `e2e/advanced-memory.e2e.ts` (+34 -1) 📝 `e2e/core-flows.e2e.ts` (+71 -0) 📝 `packages/client/index.html` (+1 -1) 📝 `packages/client/src/components/chat/AdvancedMemoryInspector.tsx` (+64 -2) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+1 -0) 📝 `packages/client/src/hooks/use-advanced-memory.ts` (+5 -1) 📝 `packages/client/src/localization/locales/en.json` (+4 -0) 📝 `packages/server/src/routes/advanced-memory.routes.ts` (+10 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+22 -7) 📝 `packages/server/src/services/advanced-memory.ts` (+186 -51) 📝 `packages/server/src/services/prompt/advanced-memory-prompt.ts` (+9 -1) 📝 `packages/shared/src/types/advanced-memory.ts` (+8 -1) 📝 `scripts/regressions/advanced-memory-core.regression.ts` (+166 -1) 📝 `scripts/regressions/advanced-memory-history-start.regression.ts` (+143 -4) 📝 `scripts/regressions/advanced-memory-post-generation.regression.ts` (+63 -6) 📝 `scripts/regressions/prompt.regression.ts` (+30 -0) </details> ### 📄 Description ## Linked issue Closes #6499. Closes #6501. Closes #6502. Closes #6503. Implementation owner: SpicyMarinara / Codex. ## Why this change Advanced Recall scene checks could disappear from the Agents menu when the main reply's stream closed. A later personal start flag also removed earlier scenes from a character's archive, despite an earlier confirmed knowledge start. The automatic context cutoff kept a near-full sliding window instead of resetting to the current scene and leaving room to grow. The scene inspector had no way to correct character access without processing the archive again. Empty recall markers added prompt spacing, and the page viewport disabled native image zoom in app shells that honor its scale restrictions. ## What changed - At the context cap, reset to the latest detected scene and preserve that start while new messages accumulate until the next reset. Manual flag changes replace the automatic window; historical preparation cannot move the current flag. Keep the existing unfinished-scene excerpt fallback when no complete scene can free enough room. - Keep the existing response stream open for post-generation Advanced Recall activity after releasing the main generation. Show both standalone and bundled tracker checks, use exactly the configured number of recent messages, and skip checks on regenerated swipes. - Use personal and shared start flags for live context; use confirmed knowledge starts and hidden-message rules for archive access. Preserve existing summaries and vectors across the upgrade. - Add **Edit character access** beside the existing scene correction editor. Save audience-only corrections without any model or embedding call; reuse exclusions so later archive maintenance does not recreate removed access. Keep narrator access, validate character/source eligibility, and reuse already indexed eligible excerpts. Summary text remains editable through the existing Save correction button. - Remove spacing belonging to an empty Recalled Scenes marker while preserving authored formatting. - Allow native page pinch zoom in the existing chat image viewer, retaining the existing viewport/layout handling. No archive reset, storage migration or new dependency is needed. This does not infer scene participants from prose or retroactively restore missing hide flags; manual scene access corrections address existing misassignments. ## 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` Automated evidence (checkboxes remain human verification tasks): - Local CodeRabbit reviewed the full patch and the cutoff follow-up with zero findings. - `pnpm check` passed: localization, formatting, lint, types and production builds. One pre-existing GameNarration hook warning remains. - The reset/grow/reset regression fails against the previous implementation and passes with this fix, including no backfill when more space becomes available and another reset after further growth. The visible automatic cutoff marker also passed on all three browser projects. - All eight Advanced Memory regression suites passed. Coverage includes a 1,000-message archive, per-character live cutoffs, hidden sources, immediate audience correction without model calls, existing vectors/excerpts, removal/regrant, narrator access and corrections surviving maintenance. - `pnpm regression:prompt` passed, including exact empty-marker formatting in XML/Markdown/plain formats and grouped/ungrouped prompts. - Real HTTP regression proves the main reply and the next reply finish while background memory work is held; standalone and bundled checks emit visible activity. Existing streaming/provider, agent isolation and regeneration tests pass. - Focused browser checks passed on desktop Chromium, mobile Chromium and mobile WebKit: 10 passed, two desktop skips for mobile-only zoom cases. Scene access editing, saving and responsive light/dark layouts pass on all three. The initial editor test clicked the hidden checkbox directly; it now clicks the visible label. - The first Linux CI run exposed a browser-driver issue: `Input.synthesizePinchGesture` did not zoom even a blank page. The test now dispatches two touch contacts through Chromium; the exact updated viewer test passes in Linux Chromium and local mobile Chromium/WebKit. It does not mock the native zoom assertion. - ARM64 Docker build and disposable-container API/frontend, native binding, non-root and persistent-data write/restart/read checks passed. ### Manual verification notes Manually verify on the original iPhone app: open a saved scene, use Edit character access to replace the incorrect character, save, and generate for each character without resetting memory. Confirm personal POV flags trim live messages while earlier eligible scenes remain available, and the narrator retains access. Confirm reaching the context cap resets to the latest scene, then holds that visible cutoff while the conversation grows to the cap again. Confirm a five-message standalone check appears after the reply in Agents. Open a chat image and pinch with two fingers. Local proof uses synthetic fixture chats, isolated databases and mock providers. Private chat/memory exports are not included in this PR or uploaded for review. Physical iPhone pinch behavior and the original live chat remain manual verification items. ## 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 - [ ] Version/release files updated (only if this PR includes a version bump) Five Unreleased entries and localized English labels/help for the audience editor. No version or user-facing docs changes. ## UI evidence (if applicable) Browser tests capture light/dark scene-access controls and post-generation Advanced Recall activity. Mobile Chromium drives a real native touch pinch; WebKit verifies the viewer and viewport/layout behavior. Physical iPhone two-finger pinch is not automated by this suite. [Downloadable UI proof gallery](https://gist.github.com/SpicyMarinara/4eb34528b69aeb22c21d529032d498fb) contains the captured fixture screenshots. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Edit which characters can access saved Advanced Memory scenes without reprocessing chat history. - Advanced Memory preserves confirmed memories across POV changes and resets live context to the latest scene when limits are reached. - Scene checks now display progress and completion status in the Agents menu. - Mobile chat image previews support native pinch-to-zoom. - **Bug Fixes** - Scene checks use the configured message range more accurately. - Empty recalled-scene markers no longer add unwanted blank lines to prompts. <!-- 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-23 04:17:29 +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#7203
No description provided.