[PR #1646] [MERGED] Generate the illustration on the Gallery Illustrate retry path #5177

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/1646
Author: @Romuromylus
Created: 5/30/2026
Status: ✅ Merged
Merged: 5/30/2026
Merged by: @Romuromylus

Base: refactor ← Head: fix/illustrate-on-retry


📝 Commits (3)

  • 0ad84a0 Generate the illustration on the Gallery Illustrate retry path
  • 2c17098 Format illustrate-on-retry files to repository Prettier style
  • a5f2e90 Drop redundant chat refresh and cover the no-options illustrate path

📊 Changes

3 files changed (+227 additions, -18 deletions)

View changed files

📝 src/engine/generation/start-generation.test.ts (+170 -3)
📝 src/engine/generation/start-generation.ts (+39 -14)
📝 src/features/runtime/generation/hooks/use-generate.ts (+18 -1)

📄 Description

Why this change

The Gallery "Illustrate" button routes through retryAgents → retryGenerationAgents → runGenerationAgentsForTarget, which ran the illustrator agent and persisted its image_prompt result but never called generateIllustrationAttachments. Only the normal startGeneration path did. So a successful illustrator prompt on the retry path was a silent no-op: the agent run was recorded, but no image was generated, no gallery row was written, no attachment was added, and no error surfaced.

What changed

  • start-generation.ts: runGenerationAgentsForTarget now runs the existing generateIllustrationAttachments helper when the target message has an illustrator prompt, appends its attachments via the existing appendSavedMessageAttachments, and surfaces its illustration / illustration_error events. runGenerationAgentsForTarget and retryGenerationAgents return { results, events } instead of AgentResult[]; the internal lorebook-keeper-backfill caller reads .results. RetryAgentsInput gains imagePromptSettings.
  • use-generate.ts: the retryAgents consumer destructures { results, events }, threads imagePromptSettings (matching the startGeneration call site), and handles the illustration / illustration_error events identically to the streaming switch (toast + ["gallery","images",chatId] invalidation).
  • The reused helper and its error text ("No image generation connection configured for the Illustrator agent.") are unchanged; no helper duplication.

Callers of the changed return shape, all updated: use-generate.ts (production), the internal runLorebookKeeperBackfill, and the existing retryGenerationAgents test assertions.

Verification

  • pnpm exec tsc -b clean; pnpm check:architecture clean (events flow out as plain GenerationEvent data; no React/Tauri import added to engine).
  • New engine tests on the retry path: a successful illustrator result invokes image generation + writes the gallery row + patches the attachment + emits illustration; a missing connection emits illustration_error; a non-illustrator retry returns results with no events. start-generation.test.ts (56 tests) and the full src/engine/generation suite (192 tests) green.

Manual

The user-visible Gallery Illustrate flow runs through real invoke() (image-gen provider + gallery storage), so a pnpm tauri dev pass is the UI-level confirmation. The Illustrate button passes no AbortSignal on this path, so a slow provider can't be cancelled mid-illustration (pre-existing retry behavior, not changed here).

Linked issue

Closes #1514.


🔄 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/1646 **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/illustrate-on-retry` --- ### 📝 Commits (3) - [`0ad84a0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0ad84a019551ab9a76e0c6ef1566cf8de8970906) Generate the illustration on the Gallery Illustrate retry path - [`2c17098`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2c1709890be3c00d5c6d1f33cb392a453574c932) Format illustrate-on-retry files to repository Prettier style - [`a5f2e90`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a5f2e90ff06cb9f6b7d28239876fb36901c5152d) Drop redundant chat refresh and cover the no-options illustrate path ### 📊 Changes **3 files changed** (+227 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/start-generation.test.ts` (+170 -3) 📝 `src/engine/generation/start-generation.ts` (+39 -14) 📝 `src/features/runtime/generation/hooks/use-generate.ts` (+18 -1) </details> ### 📄 Description ## Why this change The Gallery "Illustrate" button routes through `retryAgents → retryGenerationAgents → runGenerationAgentsForTarget`, which ran the illustrator agent and persisted its `image_prompt` result but **never called `generateIllustrationAttachments`**. Only the normal `startGeneration` path did. So a successful illustrator prompt on the retry path was a silent no-op: the agent run was recorded, but no image was generated, no gallery row was written, no attachment was added, and no error surfaced. ## What changed - `start-generation.ts`: `runGenerationAgentsForTarget` now runs the existing `generateIllustrationAttachments` helper when the target message has an illustrator prompt, appends its attachments via the existing `appendSavedMessageAttachments`, and surfaces its `illustration` / `illustration_error` events. `runGenerationAgentsForTarget` and `retryGenerationAgents` return `{ results, events }` instead of `AgentResult[]`; the internal lorebook-keeper-backfill caller reads `.results`. `RetryAgentsInput` gains `imagePromptSettings`. - `use-generate.ts`: the `retryAgents` consumer destructures `{ results, events }`, threads `imagePromptSettings` (matching the `startGeneration` call site), and handles the `illustration` / `illustration_error` events identically to the streaming switch (toast + `["gallery","images",chatId]` invalidation). - The reused helper and its error text ("No image generation connection configured for the Illustrator agent.") are unchanged; no helper duplication. Callers of the changed return shape, all updated: `use-generate.ts` (production), the internal `runLorebookKeeperBackfill`, and the existing `retryGenerationAgents` test assertions. ## Verification - `pnpm exec tsc -b` clean; `pnpm check:architecture` clean (events flow out as plain `GenerationEvent` data; no React/Tauri import added to engine). - New engine tests on the retry path: a successful illustrator result invokes image generation + writes the gallery row + patches the attachment + emits `illustration`; a missing connection emits `illustration_error`; a non-illustrator retry returns results with no events. `start-generation.test.ts` (56 tests) and the full `src/engine/generation` suite (192 tests) green. ## Manual The user-visible Gallery Illustrate flow runs through real `invoke()` (image-gen provider + gallery storage), so a `pnpm tauri dev` pass is the UI-level confirmation. The Illustrate button passes no `AbortSignal` on this path, so a slow provider can't be cancelled mid-illustration (pre-existing retry behavior, not changed here). ## Linked issue Closes #1514. --- <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#5177
No description provided.