[GH-ISSUE #935] [Issue]: Translation 'Connection' selector cannot be cleared back to unset #455

Closed
opened 2026-10-20 17:29:03 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Romuromylus on GitHub (May 17, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/935

Originally assigned to: @Romuromylus on GitHub.

Summary

Picking the placeholder option in the chat translation Connection dropdown does not actually clear the persisted translationConnectionId. The previously-selected connection silently reappears after the drawer is closed and reopened. Same || undefined chain that #914 / #934 fixed for the Discord mirror URL, applied here to a <select>.

Expected behavior

In Chat Settings → Translation → Provider: AI → Connection, choosing the empty "Select connection…" option should clear the chat's translation connection so no AI connection is bound to translation.

Actual behavior

The selector visually clears (the controlled-input state updates), but translationConnectionId is never actually overwritten on the server. Reopening the drawer shows the old connection still selected, and subsequent AI translation calls keep using it.

Steps to reproduce

  1. Open a chat, open the chat settings drawer.
  2. Scroll to Translation, set Provider to AI.
  3. Pick any AI connection from the Connection dropdown — the value is persisted.
  4. Re-open the dropdown and select the empty placeholder option ("Select connection…").
  5. Close the drawer, then reopen it (or reload). The previously-selected connection is still bound.

Environment

  • Marinara Engine version: 1.5.9
  • Install type: source (fork build on EasyPanel/Docker)
  • OS + version: Linux container (deployed); reproduces regardless of client OS
  • Browser or app shell: Chrome 141

Logs, screenshots, or video

Reproduced via direct API probe against the deployed fork:

// Mimic exactly what the onChange dispatches when the placeholder option is picked
JSON.stringify({ translationConnectionId: undefined })  // → "{}"

// PATCH /api/chats/<id>/metadata with that empty body returns 200,
// then GET /api/chats/<id> still shows the prior translationConnectionId.

The PATCH handler at packages/server/src/routes/chats.routes.ts:369 does { ...existing, ...incoming }. Since JSON.stringify drops undefined keys, the field is never present in incoming, so the existing value survives the merge. This is the same chain #914 / PR #934 fixed for discordWebhookUrl.

Additional context

  • Root cause: packages/client/src/components/chat/ChatSettingsDrawer.tsx:5000
    updateMeta.mutate({ id: chat.id, translationConnectionId: e.target.value || undefined })
    
    The || undefined rewrites "" → undefined, which JSON.stringify drops.
  • Sister bug to #914 (Discord mirror URL clear, fixed by #934). Same shape, same one-character fix (drop || undefined, send e.target.value directly). I'll open a follow-up PR.
  • Server-side guard at packages/server/src/routes/translate.routes.ts:59 (if (!input.connectionId)) treats empty string the same as undefined, so sending "" is safe.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (May 17, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/935 Originally assigned to: @Romuromylus on GitHub. ## Summary Picking the placeholder option in the chat translation **Connection** dropdown does not actually clear the persisted `translationConnectionId`. The previously-selected connection silently reappears after the drawer is closed and reopened. Same `|| undefined` chain that #914 / #934 fixed for the Discord mirror URL, applied here to a `<select>`. ## Expected behavior In **Chat Settings → Translation → Provider: AI → Connection**, choosing the empty "Select connection…" option should clear the chat's translation connection so no AI connection is bound to translation. ## Actual behavior The selector visually clears (the controlled-input state updates), but `translationConnectionId` is never actually overwritten on the server. Reopening the drawer shows the old connection still selected, and subsequent AI translation calls keep using it. ## Steps to reproduce 1. Open a chat, open the chat settings drawer. 2. Scroll to **Translation**, set **Provider** to **AI**. 3. Pick any AI connection from the **Connection** dropdown — the value is persisted. 4. Re-open the dropdown and select the empty placeholder option ("Select connection…"). 5. Close the drawer, then reopen it (or reload). The previously-selected connection is still bound. ## Environment - Marinara Engine version: 1.5.9 - Install type: source (fork build on EasyPanel/Docker) - OS + version: Linux container (deployed); reproduces regardless of client OS - Browser or app shell: Chrome 141 ## Logs, screenshots, or video Reproduced via direct API probe against the deployed fork: ```js // Mimic exactly what the onChange dispatches when the placeholder option is picked JSON.stringify({ translationConnectionId: undefined }) // → "{}" // PATCH /api/chats/<id>/metadata with that empty body returns 200, // then GET /api/chats/<id> still shows the prior translationConnectionId. ``` The PATCH handler at `packages/server/src/routes/chats.routes.ts:369` does `{ ...existing, ...incoming }`. Since `JSON.stringify` drops `undefined` keys, the field is never present in `incoming`, so the existing value survives the merge. This is the same chain #914 / PR #934 fixed for `discordWebhookUrl`. ## Additional context - Root cause: `packages/client/src/components/chat/ChatSettingsDrawer.tsx:5000` ```tsx updateMeta.mutate({ id: chat.id, translationConnectionId: e.target.value || undefined }) ``` The `|| undefined` rewrites `""` → `undefined`, which `JSON.stringify` drops. - Sister bug to #914 (Discord mirror URL clear, fixed by #934). Same shape, same one-character fix (drop `|| undefined`, send `e.target.value` directly). I'll open a follow-up PR. - Server-side guard at `packages/server/src/routes/translate.routes.ts:59` (`if (!input.connectionId)`) treats empty string the same as undefined, so sending `""` is safe. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:29:03 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Romuromylus commented on GitHub (May 17, 2026):

Working on this

<!-- gh-comment-id:4470123128 --> @Romuromylus commented on GitHub (May 17, 2026): Working on this
Author
Owner

@SpicyMarinara commented on GitHub (May 17, 2026):

Awesome, closing for the clear-up process.

<!-- gh-comment-id:4470126315 --> @SpicyMarinara commented on GitHub (May 17, 2026): Awesome, closing for the clear-up process.
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#455
No description provided.