[PR #4686] [MERGED] feat(agents): per-chat image connection override + snapshot button for custom image agents #6470

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4686
Author: @kolacheee
Created: 8/6/2026
Status: ✅ Merged
Merged: 8/7/2026
Merged by: @kolacheee

Base: staging ← Head: feat/4682-custom-agent-image-qol


📝 Commits (7)

  • a61d858 feat(agents): per-chat image connection override + snapshot button for custom image agents
  • aa8defb Merge branch 'staging' into feat/4682-custom-agent-image-qol
  • 48f7596 fix(agents): scope forced-image directive to single-agent retries
  • 765d919 fix(agents): reject multi-agent forceImageGeneration requests at the route boundary
  • 4c7597e fix(agents): attribute snapshot failures to the running agent + surface promptless successes
  • 2adefc5 fix(agents): restrict forced snapshots to image-capable custom agents
  • 9e09166 Merge branch 'staging' into feat/4682-custom-agent-image-qol

📊 Changes

12 files changed (+390 additions, -7 deletions)

View changed files

📝 docs/agents/custom-agents.md (+7 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+111 -0)
📝 packages/client/src/hooks/use-generate.ts (+3 -0)
📝 packages/client/src/localization/locales/en.json (+1 -0)
📝 packages/server/src/routes/capability-packages.routes.ts (+1 -1)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+92 -5)
📝 packages/server/src/services/agents/agent-executor.ts (+12 -0)
📝 packages/server/src/services/generation/agent-resolution.ts (+2 -0)
➕ packages/server/src/services/generation/custom-agent-image-settings.ts (+84 -0)
📝 packages/server/src/services/storage/chat-presets.storage.ts (+6 -1)
📝 packages/shared/src/types/chat.ts (+3 -0)
📝 scripts/regressions/prompt.regression.ts (+68 -0)

📄 Description

Linked issue

Closes #4682

Why this change

Custom agents that generate images can't be tuned per-chat the way the vanilla Illustrator can — the only workaround is duplicating the agent once per style/connection combo. #4682's investigation found per-chat prompt template and image style already apply to custom agents; this PR closes the two real gaps: a per-chat image connection override and an on-demand snapshot button (generate now, no activation keywords).

What changed

Per-chat image connection override

  • ChatMetadata.customAgentImageSettings?: Partial<Record<agentType, { imageConnectionId }>> (shared). The inner key deliberately ends in ConnectionId: the existing dangling-connection sweeper prunes any such key at any depth (its module comment anticipates exactly this map shape), so deleted connections need zero new cleanup code.
  • New applyCustomAgentImageChatSettings helper (mirrors applyKnowledgeAgentChatSettings; no-ops for built-in agent types), chained at both custom-agent settings-merge sites (agent-resolution.ts, retry-agents-route.ts) — both image_prompt handlers read resolved settings, so they're untouched and the override inherits the existing missing-connection warning + default-Images fallback.
  • Key registered with the chat-preset sanitizer + preserve block and the capability-package cleanup list; removing an agent from a chat prunes its entry (same pattern as the prompt-template override).
  • Drawer: an Image Connection select on each image-capable custom agent's card (Agent default + missing-connection affordances, matching the Illustrator's select).

Snapshot button

  • Camera action on the same card → retryAgents(chatId, [agentId], { forceImageGeneration: true }).
  • Server: the flag (a) injects a <manual_image_request> directive into the agent prompt — mirroring the Illustrator's manual-request block — so the agent knows the user explicitly asked and shouldn't decline; (b) forces shouldGenerate on that agent's image_prompt result, scoped via !usesChatIllustratorSettings so the vanilla Illustrator path is untouched; (c) bypasses review-before-send for forced snapshots (the camera press is the explicit request, and the review approval round-trip only supports the vanilla Illustrator); (d) emits an agent_error if the forced agent still returns no prompt, so the button never silently no-ops.

Docs: new "Per-chat controls for image agents" section in docs/agents/custom-agents.md. A [docs-i18n] follow-up issue will be opened for the language packs.

Pre-PR adversarial review: a multi-lens review of this diff found 3 real issues before submission — review-mode breaking/rerouting forced snapshots, the force being post-hoc only (silent no-op on declined prompts), and stale overrides after agent removal. All three are fixed in this PR and re-verified; the review also confirmed no third settings-resolution path bypasses the override.

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

Manual verification notes

Automated/scripted checks already performed (green):

  • pnpm check (lint + production build) — passes, run twice (after implementation and after review fixes)
  • Live on the built app (production node dist, disposable test agent + dummy connection, cleaned up after):
    • Image Connection select renders only for image-capable custom agents; the prompt-template picker and re-run button are unchanged for others
    • Selecting a connection persists exactly customAgentImageSettings: { "<agentType>": { imageConnectionId } } in chat metadata; Agent default reset deletes the entry
    • Camera click sends POST /generate/retry-agents with agentTypes: ["<that agent>"] and forceImageGeneration: true

Still to verify manually in a real browser (please tick above once done):

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

docs/agents/custom-agents.md updated in this PR; [docs-i18n] follow-up to be filed for translated packs. No version bump.

Summary by CodeRabbit

  • New Features

    • Added per-chat image settings for custom agents, including image connection selection.
    • Added a camera action to trigger image generation directly from chat settings.
    • Added support for forcing image generation during eligible custom-agent retries.
    • Added clear error handling when no usable image prompt is produced.
    • Preserved custom-agent image settings when applying chat presets.
  • Documentation

    • Documented custom-agent image controls and camera-triggered generation.

🔄 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/4686 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/6/2026 **Status:** ✅ Merged **Merged:** 8/7/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/4682-custom-agent-image-qol` --- ### 📝 Commits (7) - [`a61d858`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a61d85859eb15f2649a2a02b5aa2eb1ba6e349ff) feat(agents): per-chat image connection override + snapshot button for custom image agents - [`aa8defb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aa8defbfc22bf9b0bf4e90b77983bae35b02687d) Merge branch 'staging' into feat/4682-custom-agent-image-qol - [`48f7596`](https://github.com/Pasta-Devs/Marinara-Engine/commit/48f759665419fdbc9dff46c88c4a576d1ac43f0d) fix(agents): scope forced-image directive to single-agent retries - [`765d919`](https://github.com/Pasta-Devs/Marinara-Engine/commit/765d9190a977685396b5a9288bab9224be39408d) fix(agents): reject multi-agent forceImageGeneration requests at the route boundary - [`4c7597e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4c7597eb7d8bfec0007e249f6b8fa78aa815063f) fix(agents): attribute snapshot failures to the running agent + surface promptless successes - [`2adefc5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2adefc5279138c5ad67ac0166a6ad3673b7d3679) fix(agents): restrict forced snapshots to image-capable custom agents - [`9e09166`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9e091666bf16f5ddff20b9fac1963a1a984c2bff) Merge branch 'staging' into feat/4682-custom-agent-image-qol ### 📊 Changes **12 files changed** (+390 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/custom-agents.md` (+7 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+111 -0) 📝 `packages/client/src/hooks/use-generate.ts` (+3 -0) 📝 `packages/client/src/localization/locales/en.json` (+1 -0) 📝 `packages/server/src/routes/capability-packages.routes.ts` (+1 -1) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+92 -5) 📝 `packages/server/src/services/agents/agent-executor.ts` (+12 -0) 📝 `packages/server/src/services/generation/agent-resolution.ts` (+2 -0) ➕ `packages/server/src/services/generation/custom-agent-image-settings.ts` (+84 -0) 📝 `packages/server/src/services/storage/chat-presets.storage.ts` (+6 -1) 📝 `packages/shared/src/types/chat.ts` (+3 -0) 📝 `scripts/regressions/prompt.regression.ts` (+68 -0) </details> ### 📄 Description <!-- Target branch: `staging`. --> ## Linked issue Closes #4682 ## Why this change Custom agents that generate images can't be tuned per-chat the way the vanilla Illustrator can — the only workaround is duplicating the agent once per style/connection combo. #4682's investigation found per-chat **prompt template** and **image style** already apply to custom agents; this PR closes the two real gaps: a per-chat **image connection** override and an on-demand **snapshot button** (generate now, no activation keywords). ## What changed **Per-chat image connection override** - `ChatMetadata.customAgentImageSettings?: Partial<Record<agentType, { imageConnectionId }>>` (shared). The inner key deliberately ends in `ConnectionId`: the existing dangling-connection sweeper prunes any such key at any depth (its module comment anticipates exactly this map shape), so deleted connections need zero new cleanup code. - New `applyCustomAgentImageChatSettings` helper (mirrors `applyKnowledgeAgentChatSettings`; no-ops for built-in agent types), chained at both custom-agent settings-merge sites (`agent-resolution.ts`, `retry-agents-route.ts`) — both `image_prompt` handlers read resolved settings, so they're untouched and the override inherits the existing missing-connection warning + default-Images fallback. - Key registered with the chat-preset sanitizer + preserve block and the capability-package cleanup list; removing an agent from a chat prunes its entry (same pattern as the prompt-template override). - Drawer: an **Image Connection** select on each image-capable custom agent's card (Agent default + missing-connection affordances, matching the Illustrator's select). **Snapshot button** - Camera action on the same card → `retryAgents(chatId, [agentId], { forceImageGeneration: true })`. - Server: the flag (a) injects a `<manual_image_request>` directive into the agent prompt — mirroring the Illustrator's manual-request block — so the agent knows the user explicitly asked and shouldn't decline; (b) forces `shouldGenerate` on that agent's `image_prompt` result, scoped via `!usesChatIllustratorSettings` so the vanilla Illustrator path is untouched; (c) bypasses review-before-send for forced snapshots (the camera press is the explicit request, and the review approval round-trip only supports the vanilla Illustrator); (d) emits an `agent_error` if the forced agent still returns no prompt, so the button never silently no-ops. **Docs**: new "Per-chat controls for image agents" section in `docs/agents/custom-agents.md`. A `[docs-i18n]` follow-up issue will be opened for the language packs. **Pre-PR adversarial review**: a multi-lens review of this diff found 3 real issues before submission — review-mode breaking/rerouting forced snapshots, the force being post-hoc only (silent no-op on declined prompts), and stale overrides after agent removal. All three are fixed in this PR and re-verified; the review also confirmed no third settings-resolution path bypasses the override. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated/scripted checks already performed (green): - `pnpm check` (lint + production build) — passes, run twice (after implementation and after review fixes) - Live on the **built** app (production `node dist`, disposable test agent + dummy connection, cleaned up after): - Image Connection select renders **only** for image-capable custom agents; the prompt-template picker and re-run button are unchanged for others - Selecting a connection persists exactly `customAgentImageSettings: { "<agentType>": { imageConnectionId } }` in chat metadata; **Agent default** reset deletes the entry - Camera click sends `POST /generate/retry-agents` with `agentTypes: ["<that agent>"]` and `forceImageGeneration: true` Still to verify manually in a real browser (please tick above once done): ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) `docs/agents/custom-agents.md` updated in this PR; `[docs-i18n]` follow-up to be filed for translated packs. No version bump. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added per-chat image settings for custom agents, including image connection selection. * Added a camera action to trigger image generation directly from chat settings. * Added support for forcing image generation during eligible custom-agent retries. * Added clear error handling when no usable image prompt is produced. * Preserved custom-agent image settings when applying chat presets. * **Documentation** * Documented custom-agent image controls and camera-triggered generation. <!-- 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-23 04:10:43 +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#6470
No description provided.