[PR #6966] [MERGED] fix(chat): editable image captioning prompt, and stop on caption failures #7408

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

📋 Pull Request Information

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

Base: staging ← Head: fix/image-captioning-prompt


📝 Commits (6)

  • da59142 fix(chat): let users edit the image captioning prompt and stop on caption failures
  • ad8eec9 Merge remote-tracking branch 'origin/staging' into fix/image-captioning-prompt
  • e0ba1e1 Merge remote-tracking branch 'origin/staging' into fix/image-captioning-prompt
  • babcd84 Merge remote-tracking branch 'origin/staging' into fix/image-captioning-prompt
  • cfe4afe fix(chat): recaption after a prompt change, and report load errors
  • c813e8c docs(changelog): drop repeated entries

📊 Changes

10 files changed (+402 additions, -46 deletions)

View changed files

📝 CHANGELOG.md (+4 -2)
📝 docs/prompts/generation-parameters.md (+4 -0)
➕ e2e/image-captioning-prompt.e2e.ts (+164 -0)
📝 packages/client/src/features/chat-settings/sections/AdvancedParametersSection.tsx (+45 -2)
📝 packages/client/src/localization/locales/en.json (+3 -0)
📝 packages/server/src/services/generation/image-captioning-runtime.ts (+73 -38)
📝 packages/server/src/services/generation/prompt-attachments.ts (+2 -0)
➕ packages/shared/src/constants/image-captioning-prompt.ts (+5 -0)
📝 packages/shared/src/index.ts (+1 -0)
📝 scripts/regressions/prompt-attachments.regression.ts (+101 -4)

📄 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 #6960

Why this change

The image captioning prompt was hard-coded, so the only way to ask for more detailed captions was to edit image-captioning-runtime.js. When the captioning connection was broken, Marinara quietly sent the raw image to the chat model, so captioning looked like it worked when it didn't.

What changed

  • Editable prompt: with Image Captioning on, Chat Settings shows a Captioning Prompt box under the connection picker. It holds the default prompt until you change it, and Reset to default prompt brings the default back. Clearing the box also goes back to the default. It's saved per chat, like the other settings in that section.
  • Default prompt in one place: it now lives in packages/shared/src/constants/image-captioning-prompt.ts, with the same text as before.
  • Failures stop the reply: a failed or empty caption call, or a captioning connection that can't be used (deleted, no model, no URL), now gives a clear error in the chat ("Image captioning failed for "x.png": …"). It uses the generate route's normal error path. Before, the image went to the chat model anyway, which is what the reporter saw. Turns without images aren't affected.
  • Docs and changelog: the docs (docs/prompts/generation-parameters.md) and the CHANGELOG are updated. The old regression that expected the silent fallback now expects the error.

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

What I ran (not a replacement for the checklist):

  • Checks: pnpm check, pnpm regression:prompt and pnpm smoke:ui (7/7) pass.

  • Regression prompt-attachments: covers a failed call, an empty reply and a deleted connection, which all give an error. A turn with no images still works, the custom prompt is used, and a blank one falls back to the default. Before the fix it failed with "Missing expected rejection".

  • New e2e/image-captioning-prompt.e2e.ts:

    • The prompt box shows, saves, survives a reload and resets, on desktop and mobile Chromium.
    • A generation test, on desktop, shows a broken captioning connection now gives an error instead of the old "Nice apple." reply, and a working one gets the chat's prompt.
    • Both tests fail before the fix.
  • Local CodeRabbit: 2 findings, both fixed, with new regression cases that fail before.

    • Captions are now cached together with a hash of their prompt, so editing the prompt captions images again. Older captions count as made with the default.
    • An explicit "on" now stays on when loading a connection throws, so that error is shown.

To check by hand:

  • Turn on Image Captioning in a chat, edit the prompt to ask for more detail, attach an image, and check Peek Prompt or the debug log for your prompt.
  • Point captioning at a broken connection and attach an image. You should get a clear error, not a normal reply.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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)

docs/prompts/generation-parameters.md is updated. The translated packs will follow in a docs-i18n PR.

UI evidence (if applicable)

Covered by the new e2e on desktop and mobile Chromium; it reuses the existing text area and reset button styles.

Summary by CodeRabbit

  • New Features
    • Set a custom image-captioning prompt for an individual chat. Restore the default prompt at any time; chat-specific prompts are not copied when saving connection defaults.
  • Bug Fixes
    • Image-captioning failures now display an error instead of silently sending the image without a caption. Replies stop if captioning is unavailable or fails.

🔄 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/6966 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/2/2026 **Status:** ✅ Merged **Merged:** 10/2/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/image-captioning-prompt` --- ### 📝 Commits (6) - [`da59142`](https://github.com/Pasta-Devs/Marinara-Engine/commit/da5914289cf15161234856111a49b689a827f29a) fix(chat): let users edit the image captioning prompt and stop on caption failures - [`ad8eec9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ad8eec9f8977f13d9a85ed77acbeb7a727cb3a6b) Merge remote-tracking branch 'origin/staging' into fix/image-captioning-prompt - [`e0ba1e1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e0ba1e1e690a867cb2330f29d16d0fc5928ac6ea) Merge remote-tracking branch 'origin/staging' into fix/image-captioning-prompt - [`babcd84`](https://github.com/Pasta-Devs/Marinara-Engine/commit/babcd8456272c5036353ab35ce039bb8a30fbafb) Merge remote-tracking branch 'origin/staging' into fix/image-captioning-prompt - [`cfe4afe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cfe4afe608e01ca46de5c28269b121dfe819b8fd) fix(chat): recaption after a prompt change, and report load errors - [`c813e8c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c813e8c6e9307e5ea2713be31a01d62275b52704) docs(changelog): drop repeated entries ### 📊 Changes **10 files changed** (+402 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -2) 📝 `docs/prompts/generation-parameters.md` (+4 -0) ➕ `e2e/image-captioning-prompt.e2e.ts` (+164 -0) 📝 `packages/client/src/features/chat-settings/sections/AdvancedParametersSection.tsx` (+45 -2) 📝 `packages/client/src/localization/locales/en.json` (+3 -0) 📝 `packages/server/src/services/generation/image-captioning-runtime.ts` (+73 -38) 📝 `packages/server/src/services/generation/prompt-attachments.ts` (+2 -0) ➕ `packages/shared/src/constants/image-captioning-prompt.ts` (+5 -0) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `scripts/regressions/prompt-attachments.regression.ts` (+101 -4) </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`. ## Linked issue Closes #6960 ## Why this change The image captioning prompt was hard-coded, so the only way to ask for more detailed captions was to edit `image-captioning-runtime.js`. When the captioning connection was broken, Marinara quietly sent the raw image to the chat model, so captioning looked like it worked when it didn't. ## What changed - **Editable prompt:** with Image Captioning on, Chat Settings shows a **Captioning Prompt** box under the connection picker. It holds the default prompt until you change it, and **Reset to default prompt** brings the default back. Clearing the box also goes back to the default. It's saved per chat, like the other settings in that section. - **Default prompt in one place:** it now lives in `packages/shared/src/constants/image-captioning-prompt.ts`, with the same text as before. - **Failures stop the reply:** a failed or empty caption call, or a captioning connection that can't be used (deleted, no model, no URL), now gives a clear error in the chat ("Image captioning failed for "x.png": …"). It uses the generate route's normal error path. Before, the image went to the chat model anyway, which is what the reporter saw. Turns without images aren't affected. - **Docs and changelog:** the docs (`docs/prompts/generation-parameters.md`) and the CHANGELOG are updated. The old regression that expected the silent fallback now expects the error. ## 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 What I ran (not a replacement for the checklist): - **Checks:** `pnpm check`, `pnpm regression:prompt` and `pnpm smoke:ui` (7/7) pass. - **Regression `prompt-attachments`:** covers a failed call, an empty reply and a deleted connection, which all give an error. A turn with no images still works, the custom prompt is used, and a blank one falls back to the default. Before the fix it failed with "Missing expected rejection". - **New `e2e/image-captioning-prompt.e2e.ts`:** - The prompt box shows, saves, survives a reload and resets, on desktop and mobile Chromium. - A generation test, on desktop, shows a broken captioning connection now gives an error instead of the old "Nice apple." reply, and a working one gets the chat's prompt. - Both tests fail before the fix. - **Local CodeRabbit:** 2 findings, both fixed, with new regression cases that fail before. - Captions are now cached together with a hash of their prompt, so editing the prompt captions images again. Older captions count as made with the default. - An explicit "on" now stays on when loading a connection throws, so that error is shown. To check by hand: - Turn on Image Captioning in a chat, edit the prompt to ask for more detail, attach an image, and check Peek Prompt or the debug log for your prompt. - Point captioning at a broken connection and attach an image. You should get a clear error, not a normal reply. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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) `docs/prompts/generation-parameters.md` is updated. The translated packs will follow in a `docs-i18n` PR. ## UI evidence (if applicable) Covered by the new e2e on desktop and mobile Chromium; it reuses the existing text area and reset button styles. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Set a custom image-captioning prompt for an individual chat. Restore the default prompt at any time; chat-specific prompts are not copied when saving connection defaults. * **Bug Fixes** * Image-captioning failures now display an error instead of silently sending the image without a caption. Replies stop if captioning is unavailable or fails. <!-- 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:19:29 +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#7408
No description provided.