[PR #934] [MERGED] fix(chat): allow clearing Discord mirror URL via select-all+backspace #4845

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/934
Author: @Romuromylus
Created: 5/17/2026
Status: ✅ Merged
Merged: 5/17/2026
Merged by: @Romuromylus

Base: staging ← Head: fix/914-discord-mirror-clear


📝 Commits (3)

  • bf018ab fix(chat): allow clearing Discord mirror URL via select-all+backspace
  • 06231f6 Merge branch 'staging' into fix/914-discord-mirror-clear
  • 441569a Merge branch 'staging' into fix/914-discord-mirror-clear

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+1 -1)

📄 Description

Linked issue

Closes #914

Why this change

Reported in #914: selecting the Discord mirror URL field and hitting Backspace (or any select-all + delete) does not clear the URL. The only workaround today is char-by-char deletion, which the OP correctly flagged as broken behaviour.

The clear flow currently dispatches a useUpdateChatMetadata mutation with discordWebhookUrl: e.target.value.trim() || undefined. When the input is empty, the value resolves to undefined, JSON.stringify drops undefined-valued keys before sending, the PATCH body arrives at /chats/:id/metadata without the key at all, and the server's { ...existing, ...incoming } merge in chats.routes.ts:369 therefore preserves whatever URL was previously stored. The local controlled-input state updates regardless, which is why the field looks empty until the drawer re-reads metadata and the old value reappears.

Char-by-char deletion suffers from the same final keystroke — the apparent success is just the optimistic local state catching up before the user reopens the drawer.

What changed

  • packages/client/src/components/chat/ChatSettingsDrawer.tsx — drop the || undefined fallback in the Discord mirror URL onChange so an empty input dispatches discordWebhookUrl: "" instead. The trimmed empty string survives JSON serialisation, the server-side regex validation at chats.routes.ts:362 short-circuits on falsy values (no spurious "Invalid Discord webhook URL" 400), the merge sets the stored value to "", and every existing consumer already treats empty string as "no URL":
    • generate.routes.ts:894 reads typeof earlyMeta.discordWebhookUrl === "string" ? earlyMeta.discordWebhookUrl : "".
    • generate.routes.ts:953,1231,6839,6844 gate Discord posting behind a truthy discordWebhookUrl check.
    • game.routes.ts:937 returns the trimmed value or "".
    • The drawer's own validation banner at ChatSettingsDrawer.tsx:4758 is metadata.discordWebhookUrl && !regex.test(...) — falsy short-circuits, no banner on empty.

One-line fix, no schema or migration impact.

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

Will verify on my private EasyPanel fork build before promoting this out of draft:

  • Manually verify in a conversation/roleplay chat that pasting a valid Discord webhook URL still persists and triggers mirroring on the next reply.
  • Manually verify that selecting the entire URL and pressing Backspace clears the field, the validation banner does not appear, and the cleared state survives a drawer close/reopen + chat switch.
  • Manually verify that char-by-char deletion ends in the same cleared state (no regression).
  • Manually verify that pasting an invalid URL still surfaces the "Invalid webhook URL format" banner.

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)

UI evidence (if applicable)

Will add a short screen capture of the clear flow alongside the manual-verification pass.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Discord webhook URL field in chat settings to properly handle clearing and value updates when the input field is modified.

Review Change Stack


🔄 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/934 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 5/17/2026 **Status:** ✅ Merged **Merged:** 5/17/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `staging` ← **Head:** `fix/914-discord-mirror-clear` --- ### 📝 Commits (3) - [`bf018ab`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bf018abcd40dc8cd82143ac2f1a7211a02d59895) fix(chat): allow clearing Discord mirror URL via select-all+backspace - [`06231f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/06231f65156190a5577cd489125065001cf0cc75) Merge branch 'staging' into fix/914-discord-mirror-clear - [`441569a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/441569abdaa3d5dcd916a15bbb1857ab018843d2) Merge branch 'staging' into fix/914-discord-mirror-clear ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+1 -1) </details> ### 📄 Description ## Linked issue Closes #914 ## Why this change Reported in #914: selecting the Discord mirror URL field and hitting Backspace (or any select-all + delete) does not clear the URL. The only workaround today is char-by-char deletion, which the OP correctly flagged as broken behaviour. The clear flow currently dispatches a `useUpdateChatMetadata` mutation with `discordWebhookUrl: e.target.value.trim() || undefined`. When the input is empty, the value resolves to `undefined`, `JSON.stringify` drops `undefined`-valued keys before sending, the PATCH body arrives at `/chats/:id/metadata` without the key at all, and the server's `{ ...existing, ...incoming }` merge in `chats.routes.ts:369` therefore preserves whatever URL was previously stored. The local controlled-input state updates regardless, which is why the field *looks* empty until the drawer re-reads metadata and the old value reappears. Char-by-char deletion suffers from the same final keystroke — the apparent success is just the optimistic local state catching up before the user reopens the drawer. ## What changed - `packages/client/src/components/chat/ChatSettingsDrawer.tsx` — drop the `|| undefined` fallback in the Discord mirror URL onChange so an empty input dispatches `discordWebhookUrl: ""` instead. The trimmed empty string survives JSON serialisation, the server-side regex validation at `chats.routes.ts:362` short-circuits on falsy values (no spurious "Invalid Discord webhook URL" 400), the merge sets the stored value to `""`, and every existing consumer already treats empty string as "no URL": - `generate.routes.ts:894` reads `typeof earlyMeta.discordWebhookUrl === "string" ? earlyMeta.discordWebhookUrl : ""`. - `generate.routes.ts:953,1231,6839,6844` gate Discord posting behind a truthy `discordWebhookUrl` check. - `game.routes.ts:937` returns the trimmed value or `""`. - The drawer's own validation banner at `ChatSettingsDrawer.tsx:4758` is `metadata.discordWebhookUrl && !regex.test(...)` — falsy short-circuits, no banner on empty. One-line fix, no schema or migration impact. ## 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 Will verify on my private EasyPanel fork build before promoting this out of draft: - Manually verify in a conversation/roleplay chat that pasting a valid Discord webhook URL still persists and triggers mirroring on the next reply. - Manually verify that selecting the entire URL and pressing Backspace clears the field, the validation banner does not appear, and the cleared state survives a drawer close/reopen + chat switch. - Manually verify that char-by-char deletion ends in the same cleared state (no regression). - Manually verify that pasting an invalid URL still surfaces the "Invalid webhook URL format" banner. ## Docs and release impact - [x] 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) ## UI evidence (if applicable) Will add a short screen capture of the clear flow alongside the manual-verification pass. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed Discord webhook URL field in chat settings to properly handle clearing and value updates when the input field is modified. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/934?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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-22 04:11:07 +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#4845
No description provided.