[PR #7676] [MERGED] refactor(generate): build the saved message's generation info in saved-message-extra.ts (#7573, slice 5) #7874

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7676
Author: @Gunterlie
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @Gunterlie

Base: staging ← Head: chore/7573-generation-info-extra


📝 Commits (2)

  • e8166d5 refactor(generate): build the saved message's generation info in saved-message-extra.ts
  • 0ed1a19 Merge remote-tracking branch 'origin/staging' into chore/7573-generation-info-extra

📊 Changes

4 files changed (+374 additions, -65 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+35 -60)
➕ packages/server/src/routes/generate/saved-message-extra.ts (+138 -0)
➕ scripts/regressions/generate-saved-message-extra.regression.ts (+192 -0)
📝 scripts/regressions/roleplay-streaming.regression.ts (+9 -5)

📄 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

Part of #7573 (fifth slice). Stacked on #7674: merge it first; GitHub retargets this PR to staging when its base branch is deleted.

Why this change

Every saved reply stores a generationInfo record: usage, timing, limits, preset values, thinking, Gemini parts, reasoning metadata and context injections. It was a 60-line object literal plus five follow-up assignments in the middle of the save step of generateForCharacter. One rule in it is easy to break silently: an absent value must be stored as null, not left out, so a regenerated swipe clears the previous swipe's thinking, Gemini parts and reasoning. As a pure function with its own regression, that rule is now pinned.

No behaviour change.

What changed

  • New packages/server/src/routes/generate/saved-message-extra.ts: buildGenerationInfoExtra(options) builds the same object, with the same keys in the same order and the same value expressions.
  • generate.routes.ts (now about 14,970 lines) calls it where the literal was and keeps every later change to the object, the DB writes and the SSE events.
  • New scripts/regressions/generate-saved-message-extra.regression.ts: all-absent inputs give explicit null keys (strict deepEqual), present values pass through, the Game-mode keys and market-place clear, tool-planning needs both the plan and its connection, the maxContext fallback and its null under suppressModelParameters, and the reasoningEffort fallback.
  • The roleplay-streaming pins now check that the route passes streamOutput.reasoningDurationMs and that the helper stores it next to finishReason.

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: passed.
  • Regressions: a sweep of 108 passed, run one at a time: the new one, every regression that reads generate.routes.ts, and every one that covers generation info, reasoning duration, Gemini parts or encrypted reasoning.
  • Local CodeRabbit: 0 findings. A separate review compared all 28 generationInfo keys and the five follow-up assignments with the old code and found no change.

Manual verification notes

  • Manually verify the generation info of a new reply (tokens, duration, model) shows as before.
  • Manually verify a swipe regenerated without thinking does not keep the previous swipe's thinking.
  • Manually verify a Gemini reply with thinking still keeps its thought signatures across turns.

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)

Summary by CodeRabbit

  • Improvements
    • Saved generation details now more consistently preserve provider, model settings, token usage, timing, completion status, and context information.
    • Reasoning details and game-specific information are saved when available, with clearer handling of missing or empty values.
  • Reliability
    • Improved consistency of saved generation details across standard and game conversations.

🔄 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/7676 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `chore/7573-generation-info-extra` --- ### 📝 Commits (2) - [`e8166d5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e8166d50e2c413d0a7abc00a9a7201ff637137a5) refactor(generate): build the saved message's generation info in saved-message-extra.ts - [`0ed1a19`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0ed1a191b1b2cb7e77f6974c8e24a94b13996ed8) Merge remote-tracking branch 'origin/staging' into chore/7573-generation-info-extra ### 📊 Changes **4 files changed** (+374 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+35 -60) ➕ `packages/server/src/routes/generate/saved-message-extra.ts` (+138 -0) ➕ `scripts/regressions/generate-saved-message-extra.regression.ts` (+192 -0) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+9 -5) </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`. ## Linked issue Part of #7573 (fifth slice). Stacked on #7674: merge it first; GitHub retargets this PR to `staging` when its base branch is deleted. ## Why this change Every saved reply stores a `generationInfo` record: usage, timing, limits, preset values, thinking, Gemini parts, reasoning metadata and context injections. It was a 60-line object literal plus five follow-up assignments in the middle of the save step of `generateForCharacter`. One rule in it is easy to break silently: an absent value must be stored as `null`, not left out, so a regenerated swipe clears the previous swipe's thinking, Gemini parts and reasoning. As a pure function with its own regression, that rule is now pinned. No behaviour change. ## What changed - New `packages/server/src/routes/generate/saved-message-extra.ts`: `buildGenerationInfoExtra(options)` builds the same object, with the same keys in the same order and the same value expressions. - `generate.routes.ts` (now about 14,970 lines) calls it where the literal was and keeps every later change to the object, the DB writes and the SSE events. - New `scripts/regressions/generate-saved-message-extra.regression.ts`: all-absent inputs give explicit `null` keys (strict `deepEqual`), present values pass through, the Game-mode keys and market-place clear, tool-planning needs both the plan and its connection, the `maxContext` fallback and its `null` under `suppressModelParameters`, and the `reasoningEffort` fallback. - The `roleplay-streaming` pins now check that the route passes `streamOutput.reasoningDurationMs` and that the helper stores it next to `finishReason`. ## 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`: passed. - Regressions: a sweep of 108 passed, run one at a time: the new one, every regression that reads `generate.routes.ts`, and every one that covers generation info, reasoning duration, Gemini parts or encrypted reasoning. - Local CodeRabbit: 0 findings. A separate review compared all 28 `generationInfo` keys and the five follow-up assignments with the old code and found no change. ### Manual verification notes - Manually verify the generation info of a new reply (tokens, duration, model) shows as before. - Manually verify a swipe regenerated without thinking does not keep the previous swipe's thinking. - Manually verify a Gemini reply with thinking still keeps its thought signatures across turns. ## Docs and release impact - [x] 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) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Saved generation details now more consistently preserve provider, model settings, token usage, timing, completion status, and context information. * Reasoning details and game-specific information are saved when available, with clearer handling of missing or empty values. * **Reliability** * Improved consistency of saved generation details across standard and game conversations. <!-- 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:23 +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#7874
No description provided.