[PR #7600] [MERGED] fix(commands): /send stores resolved macros like a normal send (#7585) #7827

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7600
Author: @SpicyMarinara
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/7585-send-resolves-macros


📝 Commits (3)

  • 03d87b2 fix(commands): /send stores resolved macros like a normal send (#7585)
  • e4a6ead fix(chat): wait for the persona and character lists before filling a sent message's macros
  • 4ccfb18 fix(chat): only wait for the persona and character lists when the message has macros

📊 Changes

8 files changed (+282 additions, -111 deletions)

View changed files

📝 e2e/roleplay-commands.e2e.ts (+42 -0)
📝 packages/client/src/components/chat/ChatInput.tsx (+34 -47)
📝 packages/client/src/components/chat/ConversationInput.tsx (+37 -50)
📝 packages/client/src/hooks/use-characters.ts (+25 -13)
📝 packages/client/src/lib/chat-macros.ts (+50 -0)
📝 packages/client/src/lib/slash-commands.ts (+3 -1)
📝 scripts/regressions/conversation-game-slash.regression.ts (+1 -0)
➕ scripts/regressions/send-command-macros.regression.ts (+90 -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

Closes #7585

Why this change

  • A normal send fills in macros before the message is saved, so {{random::red::green::blue}} is saved as one word and the chat and the model both see that word.
  • /send saved the text exactly as typed. The chat then showed one roll and the model's prompt rolled again with a different seed, so the two disagreed (the repro in #7585: /send ... {{random::...}} then /continue).
  • /send also skipped the other steps a normal send runs: the chat's user-input regex scripts and input translation.

What changed

  • /send now saves exactly what Send and Post only save. All three use one shared step, prepareUserInputMessage in packages/client/src/lib/chat-macros.ts. It runs the user-input regex scripts, then input translation if the chat has it turned on, then the macros.
  • Slash commands get a new required prepareUserMessage in their context. Both chat inputs (Roleplay ChatInput and Conversation ConversationInput) now provide it, including the quick-button command paths. Because the field is required, TypeScript will flag any future composer that runs slash commands without it.
  • Send and Post only now call the shared step instead of each keeping its own copy. They still do the same things in the same order, and a translation failure shows the same toast as before.
  • Right after the page opens, a message you type with macros ({{...}}) now waits for the persona and character lists to finish loading before its macros are filled in. This applies to Send, Post only and /send. Before, a message sent in that moment was saved with "User" for {{user}} and "Character" for {{char}} instead of the real names. A message without macros never waits, and once the lists are loaded nothing waits. The wait reuses the list request that is already running (the list queries in use-characters.ts are now shared with the existing hooks).
  • New e2e test in e2e/roleplay-commands.e2e.ts (Roleplay and Conversation): it holds back the persona list, checks that /send Plain hello. is saved at once, then types /send Pick {{random::red::green}}, I am {{user}}. and checks that the saved message has one colour and the persona's name, and that the chat shows the saved text.
  • New regression scripts/regressions/send-command-macros.regression.ts. It runs the real /send command, with and without quotes, and checks that {{random}}, {{user}}, regex scripts, input translation and the translation-failure fallback all give the same saved text as a normal send. The existing /send regression now passes the new context field. Its assertions are unchanged.

Slash commands checked for the same problem:

  • /sys and /as <name> <message> also save text as typed, but no normal send produces system or character messages. Macros in a character's message are meant to stay live so {{char}} names that character, so these two are unchanged.
  • /impersonate <direction> and /guided are never saved as messages. Their text only goes into one generation's prompt.
  • /random and /as <name> (no message) save fixed text that the command writes itself. /roll saves dice output.
  • Multiplayer guests: a guest's normal message and a guest's /send are both saved raw on the server, so the two agree. Whether guest messages should fill in macros is a separate question and is not changed here.
  • /remind saves its text as typed inside a narrator message, the same kind of case as /sys. Unchanged.
  • Not a slash command, but the same symptom: a Game-mode player message is saved with raw macros, so a {{random}} there can also show one roll in the Game log and give the model another. Game has no /send, and its send path deliberately skips regex and translation, so this needs its own follow-up and is not changed here.

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

Commands run by the agent:

  • node ./scripts/run-regressions.mjs --filter scripts/regressions/send-command-macros.regression.ts: passes. With the old /send code it fails and the saved text still has the raw {{random::...}}, {{user}}.
  • pnpm regression:prompt: 3/3 passed.
  • conversation-game-slash, slash-command-usage, dice-notation, chat-persona-macros, character-identity, open-issues, roleplay-commands, plus the --filter groups macro (4), slash (2), persona (5), regex (2) and translat (1): all passed.
  • pnpm check: exit 0. The one lint warning is already on staging, in HomeProfessorMariChat.tsx.
  • A temporary Playwright spec (deleted afterwards, desktop Chromium) typed /send Reply with the following word: {{random::...}}, {{user}} into a Roleplay chat and a Conversation chat. On staging, both saved the raw macros. With this branch, both saved one colour and the persona name, and the chat showed the same text.
  • e2e/chat-sweep.e2e.ts "Personas are chosen per chat…" fails both on staging and on this branch. It times out on the persona picker's "Ungrouped" button, before it reaches its /send step.
  • Local CodeRabbit (coderabbit review --agent --committed) on the first commit: 0 findings.
  • Review follow-up (second and third commits):
    • New e2e /send stores macros resolved like a normal send passes on desktop Chromium, mobile Chromium and mobile WebKit (6/6). It fails in both modes when the wait is removed (saves Pick red, I am User.), when every message waits (the plain message isn't saved while the list is held), and when a chat input passes /send an empty step (async (text) => text; saves the raw {{random::red::green}} and {{user}}).
    • The rest of e2e/roleplay-commands.e2e.ts on desktop Chromium: 21 passed, 1 failed. "Roleplay users send and edit private whispers and notes in Manual group chats" fails the same way without this PR, at the staging commit this branch is based on (it expects "This private command could not be read" and gets "Mari used whisper command!").
    • Local CodeRabbit on the whole branch after the second commit: 3 findings.
      • Two findings said a message without macros shouldn't wait for the lists. Fixed in the third commit: only a message containing {{ waits.
      • One finding asked to block the send when a list request fails. Not done: Send and Post only call this step outside any error handling, so a failure would silently drop the send. Saving "User" when the server can't return the persona list is what staging already does.
    • Local CodeRabbit on the third commit: 0 findings.
    • pnpm check: exit 0 (the same staging lint warning). pnpm regression:prompt: 3/3. The --filter groups send-command-macros, conversation-game-slash, slash, macro, persona, regex, translat, character-identity and open-issues all pass.

Manual verification notes

  • Manually verify in a Roleplay chat: /send Reply with the following word: {{random::red::green::blue::yellow::cyan::magenta}} saves one word. Then /continue and Peek prompt both show that same word.
  • Manually verify the same in a Conversation chat.
  • Manually verify /send I am {{user}}. saves your current persona's name.
  • Manually verify that sending straight after a page reload (before the persona list has loaded) still saves your persona's name, with Send, Post only and /send, and that a message without macros sends right away.
  • Manually verify a chat with Translate My Messages turned on: /send posts the translated text, the same as Post only.
  • Manually verify that a user-input regex script applies to /send the same way it applies to Send.
  • Manually verify that Send and Post only still behave as before, including the translation-failure toast.

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)

UI evidence (if applicable)

No visual changes.

Summary by CodeRabbit

  • Bug Fixes

    • /send now processes messages consistently with regular chat input, including macros, user-input transformations, and translation.
    • Plain-text messages can be sent without waiting for character and persona lists to load.
    • If input translation fails, the prepared message is still sent.
  • Tests

    • Added regression coverage for /send message preparation in roleplay and conversation chats, including macro resolution and translation fallback.

🔄 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/7600 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/7585-send-resolves-macros` --- ### 📝 Commits (3) - [`03d87b2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/03d87b2edeee4016f2f897b7ccec44c4de34b774) fix(commands): /send stores resolved macros like a normal send (#7585) - [`e4a6ead`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e4a6eadc299077995a052ef23006befdc82c0a35) fix(chat): wait for the persona and character lists before filling a sent message's macros - [`4ccfb18`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4ccfb1823392d27b713fb7c7fc1682cf3ea959a2) fix(chat): only wait for the persona and character lists when the message has macros ### 📊 Changes **8 files changed** (+282 additions, -111 deletions) <details> <summary>View changed files</summary> 📝 `e2e/roleplay-commands.e2e.ts` (+42 -0) 📝 `packages/client/src/components/chat/ChatInput.tsx` (+34 -47) 📝 `packages/client/src/components/chat/ConversationInput.tsx` (+37 -50) 📝 `packages/client/src/hooks/use-characters.ts` (+25 -13) 📝 `packages/client/src/lib/chat-macros.ts` (+50 -0) 📝 `packages/client/src/lib/slash-commands.ts` (+3 -1) 📝 `scripts/regressions/conversation-game-slash.regression.ts` (+1 -0) ➕ `scripts/regressions/send-command-macros.regression.ts` (+90 -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`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7585 ## Why this change - A normal send fills in macros before the message is saved, so `{{random::red::green::blue}}` is saved as one word and the chat and the model both see that word. - `/send` saved the text exactly as typed. The chat then showed one roll and the model's prompt rolled again with a different seed, so the two disagreed (the repro in #7585: `/send ... {{random::...}}` then `/continue`). - `/send` also skipped the other steps a normal send runs: the chat's user-input regex scripts and input translation. ## What changed - `/send` now saves exactly what **Send** and **Post only** save. All three use one shared step, `prepareUserInputMessage` in `packages/client/src/lib/chat-macros.ts`. It runs the user-input regex scripts, then input translation if the chat has it turned on, then the macros. - Slash commands get a new required `prepareUserMessage` in their context. Both chat inputs (Roleplay `ChatInput` and Conversation `ConversationInput`) now provide it, including the quick-button command paths. Because the field is required, TypeScript will flag any future composer that runs slash commands without it. - **Send** and **Post only** now call the shared step instead of each keeping its own copy. They still do the same things in the same order, and a translation failure shows the same toast as before. - Right after the page opens, a message you type with macros (`{{...}}`) now waits for the persona and character lists to finish loading before its macros are filled in. This applies to **Send**, **Post only** and `/send`. Before, a message sent in that moment was saved with "User" for `{{user}}` and "Character" for `{{char}}` instead of the real names. A message without macros never waits, and once the lists are loaded nothing waits. The wait reuses the list request that is already running (the list queries in `use-characters.ts` are now shared with the existing hooks). - New e2e test in `e2e/roleplay-commands.e2e.ts` (Roleplay and Conversation): it holds back the persona list, checks that `/send Plain hello.` is saved at once, then types `/send Pick {{random::red::green}}, I am {{user}}.` and checks that the saved message has one colour and the persona's name, and that the chat shows the saved text. - New regression `scripts/regressions/send-command-macros.regression.ts`. It runs the real `/send` command, with and without quotes, and checks that `{{random}}`, `{{user}}`, regex scripts, input translation and the translation-failure fallback all give the same saved text as a normal send. The existing `/send` regression now passes the new context field. Its assertions are unchanged. Slash commands checked for the same problem: - `/sys` and `/as <name> <message>` also save text as typed, but no normal send produces system or character messages. Macros in a character's message are meant to stay live so `{{char}}` names that character, so these two are unchanged. - `/impersonate <direction>` and `/guided` are never saved as messages. Their text only goes into one generation's prompt. - `/random` and `/as <name>` (no message) save fixed text that the command writes itself. `/roll` saves dice output. - Multiplayer guests: a guest's normal message and a guest's `/send` are both saved raw on the server, so the two agree. Whether guest messages should fill in macros is a separate question and is not changed here. - `/remind` saves its text as typed inside a narrator message, the same kind of case as `/sys`. Unchanged. - Not a slash command, but the same symptom: a Game-mode player message is saved with raw macros, so a `{{random}}` there can also show one roll in the Game log and give the model another. Game has no `/send`, and its send path deliberately skips regex and translation, so this needs its own follow-up and is not changed here. ## 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` Commands run by the agent: - `node ./scripts/run-regressions.mjs --filter scripts/regressions/send-command-macros.regression.ts`: passes. With the old `/send` code it fails and the saved text still has the raw `{{random::...}}, {{user}}`. - `pnpm regression:prompt`: 3/3 passed. - `conversation-game-slash`, `slash-command-usage`, `dice-notation`, `chat-persona-macros`, `character-identity`, `open-issues`, `roleplay-commands`, plus the `--filter` groups `macro` (4), `slash` (2), `persona` (5), `regex` (2) and `translat` (1): all passed. - `pnpm check`: exit 0. The one lint warning is already on staging, in `HomeProfessorMariChat.tsx`. - A temporary Playwright spec (deleted afterwards, desktop Chromium) typed `/send Reply with the following word: {{random::...}}, {{user}}` into a Roleplay chat and a Conversation chat. On staging, both saved the raw macros. With this branch, both saved one colour and the persona name, and the chat showed the same text. - `e2e/chat-sweep.e2e.ts` "Personas are chosen per chat…" fails both on staging and on this branch. It times out on the persona picker's "Ungrouped" button, before it reaches its `/send` step. - Local CodeRabbit (`coderabbit review --agent --committed`) on the first commit: 0 findings. - Review follow-up (second and third commits): - New e2e `/send stores macros resolved like a normal send` passes on desktop Chromium, mobile Chromium and mobile WebKit (6/6). It fails in both modes when the wait is removed (saves `Pick red, I am User.`), when every message waits (the plain message isn't saved while the list is held), and when a chat input passes `/send` an empty step (`async (text) => text`; saves the raw `{{random::red::green}}` and `{{user}}`). - The rest of `e2e/roleplay-commands.e2e.ts` on desktop Chromium: 21 passed, 1 failed. "Roleplay users send and edit private whispers and notes in Manual group chats" fails the same way without this PR, at the staging commit this branch is based on (it expects "This private command could not be read" and gets "Mari used whisper command!"). - Local CodeRabbit on the whole branch after the second commit: 3 findings. - Two findings said a message without macros shouldn't wait for the lists. Fixed in the third commit: only a message containing `{{` waits. - One finding asked to block the send when a list request fails. Not done: Send and Post only call this step outside any error handling, so a failure would silently drop the send. Saving "User" when the server can't return the persona list is what staging already does. - Local CodeRabbit on the third commit: 0 findings. - `pnpm check`: exit 0 (the same staging lint warning). `pnpm regression:prompt`: 3/3. The `--filter` groups `send-command-macros`, `conversation-game-slash`, `slash`, `macro`, `persona`, `regex`, `translat`, `character-identity` and `open-issues` all pass. ### Manual verification notes - Manually verify in a Roleplay chat: `/send Reply with the following word: {{random::red::green::blue::yellow::cyan::magenta}}` saves one word. Then `/continue` and **Peek prompt** both show that same word. - Manually verify the same in a Conversation chat. - Manually verify `/send I am {{user}}.` saves your current persona's name. - Manually verify that sending straight after a page reload (before the persona list has loaded) still saves your persona's name, with **Send**, **Post only** and `/send`, and that a message without macros sends right away. - Manually verify a chat with **Translate My Messages** turned on: `/send` posts the translated text, the same as **Post only**. - Manually verify that a user-input regex script applies to `/send` the same way it applies to **Send**. - Manually verify that **Send** and **Post only** still behave as before, including the translation-failure toast. ## 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) ## UI evidence (if applicable) No visual changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * `/send` now processes messages consistently with regular chat input, including macros, user-input transformations, and translation. * Plain-text messages can be sent without waiting for character and persona lists to load. * If input translation fails, the prepared message is still sent. * **Tests** * Added regression coverage for `/send` message preparation in roleplay and conversation chats, including macro resolution and translation fallback. <!-- 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:07:55 +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#7827
No description provided.