[PR #7673] [MERGED] refactor(generate): move the reply command parsing into reply-commands.ts (#7573, slice 3) #7873

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

📋 Pull Request Information

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

Base: staging ← Head: chore/7573-reply-commands


📝 Commits (2)

  • b010488 refactor(generate): move the reply command parsing into reply-commands.ts
  • c8c5d5b Merge remote-tracking branch 'origin/staging' into chore/7573-reply-commands

📊 Changes

3 files changed (+313 additions, -113 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+23 -113)
➕ packages/server/src/routes/generate/reply-commands.ts (+144 -0)
➕ scripts/regressions/generate-reply-commands.regression.ts (+146 -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

Part of #7573 (third slice). Stacked on #7672 (which is stacked on #7671): merge those first, then retarget this PR to staging.

Why this change

The post-generation step of the generation handler is about 2,450 lines and writes fullResponse well over 100 times, so it is split in small parts. This is the first part: the reply command parsing. It was about 100 lines in the middle of generateForCharacter, with the selfie recovery and the direct-message parse mixed into the route state. As pure functions with their own regression, the rules (which speaker a command belongs to, when a recovered selfie counts, when the character list is read) are testable without a model.

No behaviour change.

What changed

  • New packages/server/src/routes/generate/reply-commands.ts:
    • parseConversationReplyCommands covers the speaker-attributed character-command parse, the enabled-command filter and the implicit-selfie recovery.
    • parseRoleplayDmReplyCommands covers the roleplay direct-message parse and its fallback text for a target without a card.
  • generate.routes.ts (now about 15,100 lines) keeps every write to its own state at the two call sites.
  • New scripts/regressions/generate-reply-commands.regression.ts. It covers per-speaker attribution in a merged group, the selfie recovery, a disabled command (stripped, no command content), the cardless DM fallback, and that the character list is not read when there is no DM command.

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 passed: generate-reply-commands, plus a sweep of 30 regressions: every one that reads generate.routes.ts and every one that covers character commands, selfies or direct messages. No source pin needed a change.
  • Local CodeRabbit: 0 findings. A separate line-by-line review confirmed that the route state starts from its initial values on every path into the block, so the unconditional assignments are equal to the old conditional writes.
  • The new regression tests the module; the two call sites were checked by reading.

Manual verification notes

  • Manually verify a conversation group chat: a character's [selfie] produces a selfie from that character.
  • Manually verify a reply without an explicit selfie command that asks for a photo still gets the recovered selfie when image generation is set up.
  • Manually verify a roleplay chat with DM commands on: a [dm: …] to a character with a card reaches that character, and one to a name without a card shows the fallback text.

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

  • Refactor
    • Conversation and roleplay replies continue to support character commands and direct-message targets, including speaker attribution, command filtering, target resolution, and fallback text.
    • Implicit selfie recovery now requires selfies to be enabled and a valid image-generation connection.
  • Tests
    • Added regression coverage for command parsing, selfie conditions, target resolution, and fallback behavior.

🔄 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/7673 **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-reply-commands` --- ### 📝 Commits (2) - [`b010488`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b01048851a2bbdc94965857f25fac562ac68e4e2) refactor(generate): move the reply command parsing into reply-commands.ts - [`c8c5d5b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c8c5d5bb4dacdc7232ac149a4e1c5367d8db1a4e) Merge remote-tracking branch 'origin/staging' into chore/7573-reply-commands ### 📊 Changes **3 files changed** (+313 additions, -113 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+23 -113) ➕ `packages/server/src/routes/generate/reply-commands.ts` (+144 -0) ➕ `scripts/regressions/generate-reply-commands.regression.ts` (+146 -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`. ## Linked issue Part of #7573 (third slice). Stacked on #7672 (which is stacked on #7671): merge those first, then retarget this PR to `staging`. ## Why this change The post-generation step of the generation handler is about 2,450 lines and writes `fullResponse` well over 100 times, so it is split in small parts. This is the first part: the reply command parsing. It was about 100 lines in the middle of `generateForCharacter`, with the selfie recovery and the direct-message parse mixed into the route state. As pure functions with their own regression, the rules (which speaker a command belongs to, when a recovered selfie counts, when the character list is read) are testable without a model. No behaviour change. ## What changed - New `packages/server/src/routes/generate/reply-commands.ts`: - `parseConversationReplyCommands` covers the speaker-attributed character-command parse, the enabled-command filter and the implicit-selfie recovery. - `parseRoleplayDmReplyCommands` covers the roleplay direct-message parse and its fallback text for a target without a card. - `generate.routes.ts` (now about 15,100 lines) keeps every write to its own state at the two call sites. - New `scripts/regressions/generate-reply-commands.regression.ts`. It covers per-speaker attribution in a merged group, the selfie recovery, a disabled command (stripped, no command content), the cardless DM fallback, and that the character list is not read when there is no DM command. ## 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 passed: `generate-reply-commands`, plus a sweep of 30 regressions: every one that reads `generate.routes.ts` and every one that covers character commands, selfies or direct messages. No source pin needed a change. - Local CodeRabbit: 0 findings. A separate line-by-line review confirmed that the route state starts from its initial values on every path into the block, so the unconditional assignments are equal to the old conditional writes. - The new regression tests the module; the two call sites were checked by reading. ### Manual verification notes - Manually verify a conversation group chat: a character's `[selfie]` produces a selfie from that character. - Manually verify a reply without an explicit selfie command that asks for a photo still gets the recovered selfie when image generation is set up. - Manually verify a roleplay chat with DM commands on: a `[dm: …]` to a character with a card reaches that character, and one to a name without a card shows the fallback text. ## 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 * **Refactor** * Conversation and roleplay replies continue to support character commands and direct-message targets, including speaker attribution, command filtering, target resolution, and fallback text. * Implicit selfie recovery now requires selfies to be enabled and a valid image-generation connection. * **Tests** * Added regression coverage for command parsing, selfie conditions, target resolution, and fallback behavior. <!-- 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:22 +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#7873
No description provided.