mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #4682] [Feature]: Per-chat image connection override + snapshot button for custom image agents (approved QoL) #2562
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#2562
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Aug 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4682
Originally assigned to: @kolacheee on GitHub.
What problem does this solve?
From a Discord request (maintainer-approved, see Additional context): custom agents that generate images with their own connection can't be tuned per-chat the way the vanilla Illustrator can —
Today's workaround is duplicating the agent once per style/connection combo, which is exactly the copy-paste churn the requester wants to avoid.
Investigation result — two of the three requested overrides already work per-chat for custom agents:
chatMeta.agentPromptTemplateIdsis keyed generically by agent type; every active custom agent already gets anAgentPromptTemplateSelectdropdown in the chat-settings drawer (ChatSettingsDrawer.tsx:3953-3958), applied server-side for all agents (agent-resolution.ts:399-404).chatMeta.imageStyleProfileId, which theimage_prompthandler reads unconditionally (generate.routes.ts:8785-8790; retry mirrorretry-agents-route.ts:3296-3299) — no illustrator gate — so it already restyles custom-agent images.The genuinely missing pieces are: (1) a per-chat image connection override for custom image agents, and (2) the snapshot button. The image connection is locked to vanilla by
usesChatIllustratorSettings = resultAgent?.type === "illustrator" || (!resultAgent && result.agentType === "illustrator")(generate.routes.ts:8590-8591; retry twin:3238-3239) — the else-branch reads only the agent's ownsettings.imageConnectionId.Proposed solution
Both parts extend existing patterns; no new endpoints, no migrations, no new execution paths (~150-250 LOC across ~9 files).
1. Per-chat image connection for custom image agents
ChatMetadata(sharedchat.ts, next toknowledgeAgentSources):customAgentImageSettings?: Partial<Record<string /* agent type */, { imageConnectionId?: string | null }>>. The inner key name deliberately ends inConnectionId: the dangling-connection sweeper cleans any metadata key matching*ConnectionIdat any depth, and its module comment already anticipates exactly this<type>.imageConnectionIdmap shape (connection-reference-cleanup.ts:7-21) — so deleted connections need zero new cleanup code.applyKnowledgeAgentChatSettings(knowledge-agent-settings.ts:34-53) that overwrites the resolvedsettings.imageConnectionIdfor custom agents when the chat map has an entry; called at the two existing custom-agent settings-merge sites (agent-resolution.ts:380,retry-agents-route.ts:1498). Bothimage_prompthandlers read the resolved settings, so they don't change at all — the override inherits the existing dangling-connection warning and default-Images fallback for free.sanitizePresetAgentMap(chat-presets.storage.ts:64, preserve-block:305-310) and the capability-package cleanup list (capability-packages.routes.ts:42).renderActiveCustomAgentSettingsCard), for agents with thetrigger_image_generationcapability, render the same image-connection select the Illustrator section uses ("Agent default" empty option + reset affordance).2. Snapshot button
The plumbing nearly exists: the vanilla Illustrate button calls
retryAgents(chatId, ["illustrator"], { illustratorRetryTargets: ["illustration"] })→ forced manual plan; custom agents already have a per-chat re-run button (handleRerunCustomAgent→retryAgents(chat.id, [agentId])), but on that path image generation remains the agent LLM's decision (retry-agents-route.ts:3243) andillustratorRetryTargetsis rejected for non-illustrator agents (:3846). Add a camera button next to the existing re-run button that passes a new retry option forcingshouldGenerate: trueon that agent'simage_promptresult.Honest caveat: a forced run still requires the agent's own prompt template to emit an image prompt — an agent whose LLM returns no prompt generates nothing (
:3249). The vanilla button avoids this by bypassing the LLM entirely with a hardcoded manual plan; generalizing that to arbitrary user-authored agents is the scope trap this proposal deliberately avoids. Document the requirement instead ("your agent should always emit a prompt when asked").Out of scope (keeping it small): per-chat override of the custom agent's text (prompt-writing) connection — the same keyed-map pattern extends to it later if wanted; a chat-settings UI hint that prompt/style already work could ship as just a docs note.
Alternatives considered
usesChatIllustratorSettingsto all image agents: rejected — it would apply the Illustrator's chat-level keys (illustratorImageConnectionIdetc.) to every custom agent, conflating unrelated agents' settings instead of keying per agent.Additional context
Maintainer approved with "keep it small-scale" and delegated implementation ("Yes... Just keep it small-scale"). I intend to follow up with the PR per that approval; this issue records the request and the verified implementation shape for review. All file:line references verified against current staging (2.4.2). Related recent work: #4337 (custom image agents + ComfyUI references).
Known edge cases accounted for: connection deletion (auto-swept, see above); agent deletion leaves an inert map entry (harmless — keyed lookups just miss; same behavior as
agentPromptTemplateIdstoday); group chats unaffected (plain per-chat metadata); retry path covered symmetrically (both handler twins get the same resolved settings).Template check