[PR #8679] [MERGED] fix(chat): the favorite layout keeps the Scoped Regex Scripts choice for new chats #8742

Closed
opened 2026-11-07 17:39:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: fix/scoped-regex-new-chats-8676


📝 Commits (1)

  • debfdb5 fix(chat): the favorite layout keeps the Scoped Regex Scripts choice for new chats (#8676)

📊 Changes

9 files changed (+113 additions, -12 deletions)

View changed files

📝 docs/chats/chat-settings.md (+3 -3)
📝 docs/chats/settings-profiles.md (+3 -3)
📝 docs/extending/regex-scripts.md (+3 -1)
📝 e2e/chat-window-favorite.e2e.ts (+60 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+5 -1)
📝 packages/client/src/components/chat/ChatWindowFavoriteButton.tsx (+16 -2)
📝 packages/server/src/routes/app-settings.routes.ts (+1 -1)
📝 packages/shared/src/utils/chat-window-defaults.ts (+11 -1)
📝 scripts/regressions/chat-window-defaults.regression.ts (+11 -0)

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

Why this change

  • A user with per-character regex scripts needs Scoped Regex Scripts on in every chat. However often they press Use this layout for new roleplay chats, each new roleplay chat starts with scoped regex off.
  • Cause: the favorite-layout star (ChatWindowFavoriteButton) saved only {windowLayout, chatSettingsHintDismissed}. chats.storage.ts create() copies that favorite into each new chat of the mode, and scopedRegexMode was never in it. So new chats fell back to the prompt preset's Scoped regex default, which is Disabled.
  • Second fault: the star's "already starred" check ignored the scoped mode. On an upgraded install the layout is already starred, so after choosing Exclusive the star stayed filled, and clicking it cleared the favorite instead of saving it. That's the reporter's "no matter how many times I set it".
  • Staging still has the bug (no change since v2.5.1).

What changed

  • packages/shared/src/utils/chat-window-defaults.ts:
    • ChatWindowDefault gets an optional scopedRegexMode.
    • parseChatWindowDefault keeps a valid value (the existing scopedRegexModeSchema), leaves out a missing or null one, and rejects others. The save route then answers 400, and a corrupt stored favorite is ignored, as other bad fields already are.
    • Older favorites serialize exactly as before.
  • ChatWindowFavoriteButton.tsx takes scopedRegexMode, includes it in the filled/unfilled check, and saves it only when the chat has its own choice.
  • ChatSettingsDrawer.tsx passes null while the chat uses the preset default, so "Use preset default" saves nothing.
  • No server change was needed: chat creation already spreads the favorite. The comment at the app-settings PUT trust boundary is updated.
  • Docs:
    • docs/chats/chat-settings.md and docs/chats/settings-profiles.md: the favorite now also keeps the scoped regex mode; a starred settings profile still wins.
    • docs/extending/regex-scripts.md: lists all three ways to keep scoped regex on (preset default, favorite layout, default settings profile). It also corrects an older sentence: the per-script switches are global, not per chat.
  • Tests:
    • The chat-window-defaults regression covers four cases: saving a favorite with a scoped mode then creating a new roleplay chat, mode isolation, a null choice not stored, and an invalid value rejected.
    • The chat-window-favorite e2e (desktop and mobile) covers the full flow: star, choose Exclusive, the star unfills, star again, and a new roleplay chat has Exclusive.
    • Both fail on the old code.

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 the agent ran locally, after rebasing on staging:

  • node ./scripts/pnpm-runner.mjs check passes.

  • These regressions pass: chat-window-defaults, chat-window-default-upgrade, floating-window, preset-regex-defaults, chat-profile-followers and chat-profile-starting-picks.

  • E2E results:

    • e2e/chat-window-favorite.e2e.ts passes 5/5 on desktop-chromium and 5/5 on mobile-chromium.
    • e2e/preset-regex.e2e.ts passes 3/3 on desktop.
  • An independent review agent repeated the fails-before proofs. It fixed the trust-boundary comment and two doc sentences.

  • Local CodeRabbit asked for the docs-i18n follow-up issue to be linked; it is now #8681.

For a human to verify:

  • Manually verify in a browser, in a Roleplay chat whose character has a character-scoped regex script, that choosing Exclusive in Chat Settings → Scoped Regex Scripts turns an already-filled favorite-layout star back to unfilled. Clicking it should fill it again.
  • Manually verify that a new Roleplay chat started from Home with that character shows Scoped Regex Scripts set to Exclusive, with "Use preset default" off.
  • Manually verify that switching back to "Use preset default" and re-starring makes later new chats follow the prompt preset's Scoped regex default again.
  • Manually verify that with a starred (non-Default) settings profile, the profile's own scoped choice, or the preset default when it has none, wins over the favorite in new chats.
  • Manually verify that Conversation and Game favorites are unchanged for users who never set a scoped mode: the star stays filled after the upgrade.

Design note: the star used to save the layout and tips only. Keeping the scoped mode follows the issue's expected behavior. The in-app copy still says "layout", which remains accurate.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) 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/chats/chat-settings.md, docs/chats/settings-profiles.md and docs/extending/regex-scripts.md changed. Follow-up: #8681 ([docs-i18n] catch-up for these pages). The translated packs on docs-i18n will be updated in one catch-up PR after this merges, and that PR closes it.

🤖 Generated with Claude Code


🔄 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/8679 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/scoped-regex-new-chats-8676` --- ### 📝 Commits (1) - [`debfdb5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/debfdb5583757771686a1fed22e95512051a8c9e) fix(chat): the favorite layout keeps the Scoped Regex Scripts choice for new chats (#8676) ### 📊 Changes **9 files changed** (+113 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `docs/chats/chat-settings.md` (+3 -3) 📝 `docs/chats/settings-profiles.md` (+3 -3) 📝 `docs/extending/regex-scripts.md` (+3 -1) 📝 `e2e/chat-window-favorite.e2e.ts` (+60 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+5 -1) 📝 `packages/client/src/components/chat/ChatWindowFavoriteButton.tsx` (+16 -2) 📝 `packages/server/src/routes/app-settings.routes.ts` (+1 -1) 📝 `packages/shared/src/utils/chat-window-defaults.ts` (+11 -1) 📝 `scripts/regressions/chat-window-defaults.regression.ts` (+11 -0) </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 #8676 ## Why this change - A user with per-character regex scripts needs **Scoped Regex Scripts** on in every chat. However often they press **Use this layout for new roleplay chats**, each new roleplay chat starts with scoped regex off. - **Cause:** the favorite-layout star (`ChatWindowFavoriteButton`) saved only `{windowLayout, chatSettingsHintDismissed}`. `chats.storage.ts create()` copies that favorite into each new chat of the mode, and `scopedRegexMode` was never in it. So new chats fell back to the prompt preset's Scoped regex default, which is Disabled. - **Second fault:** the star's "already starred" check ignored the scoped mode. On an upgraded install the layout is already starred, so after choosing Exclusive the star stayed filled, and clicking it **cleared** the favorite instead of saving it. That's the reporter's "no matter how many times I set it". - Staging still has the bug (no change since v2.5.1). ## What changed - `packages/shared/src/utils/chat-window-defaults.ts`: - `ChatWindowDefault` gets an optional `scopedRegexMode`. - `parseChatWindowDefault` keeps a valid value (the existing `scopedRegexModeSchema`), leaves out a missing or null one, and rejects others. The save route then answers 400, and a corrupt stored favorite is ignored, as other bad fields already are. - Older favorites serialize exactly as before. - `ChatWindowFavoriteButton.tsx` takes `scopedRegexMode`, includes it in the filled/unfilled check, and saves it only when the chat has its own choice. - `ChatSettingsDrawer.tsx` passes `null` while the chat uses the preset default, so "Use preset default" saves nothing. - No server change was needed: chat creation already spreads the favorite. The comment at the app-settings PUT trust boundary is updated. - **Docs:** - `docs/chats/chat-settings.md` and `docs/chats/settings-profiles.md`: the favorite now also keeps the scoped regex mode; a starred settings profile still wins. - `docs/extending/regex-scripts.md`: lists all three ways to keep scoped regex on (preset default, favorite layout, default settings profile). It also corrects an older sentence: the per-script switches are global, not per chat. - **Tests:** - The `chat-window-defaults` regression covers four cases: saving a favorite with a scoped mode then creating a new roleplay chat, mode isolation, a null choice not stored, and an invalid value rejected. - The `chat-window-favorite` e2e (desktop and mobile) covers the full flow: star, choose Exclusive, the star unfills, star again, and a new roleplay chat has Exclusive. - Both fail on the old code. ## 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 the agent ran locally, after rebasing on staging: - `node ./scripts/pnpm-runner.mjs check` passes. - These regressions pass: chat-window-defaults, chat-window-default-upgrade, floating-window, preset-regex-defaults, chat-profile-followers and chat-profile-starting-picks. - E2E results: - `e2e/chat-window-favorite.e2e.ts` passes 5/5 on desktop-chromium and 5/5 on mobile-chromium. - `e2e/preset-regex.e2e.ts` passes 3/3 on desktop. - An independent review agent repeated the fails-before proofs. It fixed the trust-boundary comment and two doc sentences. - Local CodeRabbit asked for the docs-i18n follow-up issue to be linked; it is now #8681. For a human to verify: - Manually verify in a browser, in a Roleplay chat whose character has a character-scoped regex script, that choosing Exclusive in Chat Settings → Scoped Regex Scripts turns an already-filled favorite-layout star back to unfilled. Clicking it should fill it again. - Manually verify that a new Roleplay chat started from Home with that character shows Scoped Regex Scripts set to Exclusive, with "Use preset default" off. - Manually verify that switching back to "Use preset default" and re-starring makes later new chats follow the prompt preset's Scoped regex default again. - Manually verify that with a starred (non-Default) settings profile, the profile's own scoped choice, or the preset default when it has none, wins over the favorite in new chats. - Manually verify that Conversation and Game favorites are unchanged for users who never set a scoped mode: the star stays filled after the upgrade. Design note: the star used to save the layout and tips only. Keeping the scoped mode follows the issue's expected behavior. The in-app copy still says "layout", which remains accurate. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) 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/chats/chat-settings.md`, `docs/chats/settings-profiles.md` and `docs/extending/regex-scripts.md` changed. Follow-up: #8681 ([docs-i18n] catch-up for these pages). The translated packs on `docs-i18n` will be updated in one catch-up PR after this merges, and that PR closes it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:23 +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#8742
No description provided.