[PR #1197] [MERGED] Avoid duplicate chat message loads in startGeneration #4971

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1197
Author: @Xelvanis
Created: 5/25/2026
Status: ✅ Merged
Merged: 5/25/2026
Merged by: @cha1latte

Base: refactor ← Head: chore/reuse-start-generation-messages


📝 Commits (1)

  • 12f4ef0 Avoid redundant message reload after saving user message

📊 Changes

2 files changed (+152 additions, -3 deletions)

View changed files

📝 src/engine/generation/start-generation.test.ts (+130 -0)
📝 src/engine/generation/start-generation.ts (+22 -3)

📄 Description

Summary

  • Reuse the pre-commit chat message list in startGeneration after a normal user-message save by appending the returned saved message record.
  • Reload messages instead when the storage adapter returns a non-record or incomplete saved-message shape.
  • Add focused generation tests for reuse, non-record fallback, and incomplete-record fallback.

Fixes #1189

Impact

  • Owner: TypeScript engine generation lifecycle.
  • Affected paths: shared generation startup for conversation, roleplay, game, and background/autonomous generation.
  • No React, shared API, Rust, native, or storage command changes.

Verification

  • pnpm test src/engine/generation/start-generation.test.ts
  • pnpm typecheck
  • pnpm check:architecture

Changelog

Not updated. This repo currently has no CHANGELOG.md, and the change is an internal generation-path cleanup with no user-facing behavior change.

Remaining Risk

The optimized path still assumes no out-of-band same-chat message is inserted between the pre-save load and the saved user message append. Existing UI/background callers mostly gate generation per chat, and malformed saved-message returns still reload, so this is treated as low residual risk.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced message persistence validation with automatic fallback to reload messages when saved records are incomplete or missing.
  • Tests

    • Added test suite covering message-loading scenarios including successful message reuse, incomplete record handling, and missing record fallback cases.

Review Change Stack


🔄 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/1197 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/25/2026 **Status:** ✅ Merged **Merged:** 5/25/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `chore/reuse-start-generation-messages` --- ### 📝 Commits (1) - [`12f4ef0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/12f4ef080e9392537d1176f53eb4a756e8bc979a) Avoid redundant message reload after saving user message ### 📊 Changes **2 files changed** (+152 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/start-generation.test.ts` (+130 -0) 📝 `src/engine/generation/start-generation.ts` (+22 -3) </details> ### 📄 Description ## Summary - Reuse the pre-commit chat message list in `startGeneration` after a normal user-message save by appending the returned saved message record. - Reload messages instead when the storage adapter returns a non-record or incomplete saved-message shape. - Add focused generation tests for reuse, non-record fallback, and incomplete-record fallback. Fixes #1189 ## Impact - Owner: TypeScript engine generation lifecycle. - Affected paths: shared generation startup for conversation, roleplay, game, and background/autonomous generation. - No React, shared API, Rust, native, or storage command changes. ## Verification - `pnpm test src/engine/generation/start-generation.test.ts` - `pnpm typecheck` - `pnpm check:architecture` ## Changelog Not updated. This repo currently has no `CHANGELOG.md`, and the change is an internal generation-path cleanup with no user-facing behavior change. ## Remaining Risk The optimized path still assumes no out-of-band same-chat message is inserted between the pre-save load and the saved user message append. Existing UI/background callers mostly gate generation per chat, and malformed saved-message returns still reload, so this is treated as low residual risk. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Enhanced message persistence validation with automatic fallback to reload messages when saved records are incomplete or missing. * **Tests** * Added test suite covering message-loading scenarios including successful message reuse, incomplete record handling, and missing record fallback cases. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1197?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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-22 04:12:08 +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#4971
No description provided.