[PR #1645] [MERGED] Surface connected command failures instead of swallowing them #5178

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1645
Author: @Romuromylus
Created: 5/30/2026
Status: ✅ Merged
Merged: 5/30/2026
Merged by: @Romuromylus

Base: refactor ← Head: fix/connected-command-errors


📝 Commits (2)

  • 0c243bc Surface connected command failures instead of swallowing them
  • aa6303e Format connected-command files to repository Prettier style

📊 Changes

4 files changed (+110 additions, -17 deletions)

View changed files

📝 src/engine/generation/connected-commands.test.ts (+71 -0)
📝 src/engine/generation/connected-commands.ts (+32 -17)
📝 src/engine/generation/generation-events.ts (+1 -0)
📝 src/features/runtime/generation/hooks/use-generate.ts (+6 -0)

📄 Description

Why this change

persistConnectedCommandTags wrapped executeCommand in a blanket .catch(() => null), and parseCharacterCommands strips command tags from the visible content unconditionally (regardless of whether the command ran). So when a connected command threw, the failure collapsed to null, emitted no event, and left the user with a clean message and no error or retry. Two integration commands (haptic, spotify) also returned a silent null when their integration was absent, while their tag was still stripped from the content.

What changed

Mirror the existing selfie_error event end to end, for commands:

  • generation-events.ts / connected-commands.ts: add a command_error variant to both the GenerationEvent and ConnectedCommandEvent unions, plus an eventsPushCommandError helper (sibling of eventsPushSelfieError).
  • connected-commands.ts: replace the blanket .catch(() => null) around executeCommand with a try/catch that emits command_error and lets generation continue (no rethrow); emit command_error on the haptic/spotify integration-absent branches.
  • use-generate.ts: consume command_error with a toast, exactly like selfie_error.

The fix is mode-neutral — no mode flag is added to the shared helper (per marinara-mode-separation); roleplay/game modes that route through the same helper now get the same visible error instead of a silent strip.

Verification

  • pnpm exec tsc -b clean; pnpm check:architecture clean (events ride the existing pass-through; no new caller wiring, no React/Tauri import added to engine).
  • New connected-commands.test.ts cases: a throwing command emits command_error (tag still stripped), the loop continues after a failure, an unsupported haptic without integrations surfaces an error, and the happy path emits no error. Full src/engine/generation suite (193 tests) green.

Risk / note

The toast consumer is untested, consistent with the existing untested selfie_error/illustration_error siblings (covered by tsc + the structural mirror). A message with many failing command tags fires one toast per failure (per-command granularity, matches the existing design); aggregation is out of scope. Raw error text surfaces in the toast, parity with selfie_error.

Linked issue

Closes #1535.


🔄 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/1645 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 5/30/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `refactor` ← **Head:** `fix/connected-command-errors` --- ### 📝 Commits (2) - [`0c243bc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0c243bc99bae10b35d1b49e65571fc12511177ea) Surface connected command failures instead of swallowing them - [`aa6303e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aa6303e6cf1b7079e35246427605852aaa816ab6) Format connected-command files to repository Prettier style ### 📊 Changes **4 files changed** (+110 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/connected-commands.test.ts` (+71 -0) 📝 `src/engine/generation/connected-commands.ts` (+32 -17) 📝 `src/engine/generation/generation-events.ts` (+1 -0) 📝 `src/features/runtime/generation/hooks/use-generate.ts` (+6 -0) </details> ### 📄 Description ## Why this change `persistConnectedCommandTags` wrapped `executeCommand` in a blanket `.catch(() => null)`, and `parseCharacterCommands` strips command tags from the visible content **unconditionally** (regardless of whether the command ran). So when a connected command threw, the failure collapsed to `null`, emitted no event, and left the user with a clean message and no error or retry. Two integration commands (`haptic`, `spotify`) also returned a silent `null` when their integration was absent, while their tag was still stripped from the content. ## What changed Mirror the existing `selfie_error` event end to end, for commands: - `generation-events.ts` / `connected-commands.ts`: add a `command_error` variant to both the `GenerationEvent` and `ConnectedCommandEvent` unions, plus an `eventsPushCommandError` helper (sibling of `eventsPushSelfieError`). - `connected-commands.ts`: replace the blanket `.catch(() => null)` around `executeCommand` with a `try/catch` that emits `command_error` and lets generation continue (no rethrow); emit `command_error` on the `haptic`/`spotify` integration-absent branches. - `use-generate.ts`: consume `command_error` with a toast, exactly like `selfie_error`. The fix is **mode-neutral** — no mode flag is added to the shared helper (per `marinara-mode-separation`); roleplay/game modes that route through the same helper now get the same visible error instead of a silent strip. ## Verification - `pnpm exec tsc -b` clean; `pnpm check:architecture` clean (events ride the existing pass-through; no new caller wiring, no React/Tauri import added to engine). - New `connected-commands.test.ts` cases: a throwing command emits `command_error` (tag still stripped), the loop continues after a failure, an unsupported `haptic` without integrations surfaces an error, and the happy path emits no error. Full `src/engine/generation` suite (193 tests) green. ## Risk / note The toast consumer is untested, consistent with the existing untested `selfie_error`/`illustration_error` siblings (covered by tsc + the structural mirror). A message with many failing command tags fires one toast per failure (per-command granularity, matches the existing design); aggregation is out of scope. Raw error text surfaces in the toast, parity with `selfie_error`. ## Linked issue Closes #1535. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:13:58 +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#5178
No description provided.