[PR #311] [MERGED] feat(conversation): add durable note tag for connected roleplays #4554

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/311
Author: @cha1latte
Created: 4/29/2026
Status: ✅ Merged
Merged: 5/3/2026
Merged by: @SpicyMarinara

Base: main ← Head: feat/conversation-notes


📝 Commits (3)

  • 493b0a5 feat(conversation): add durable note tag for connected roleplays
  • 059d74e fix(notes): scope single-note delete to chat + add loading and error states
  • 908a65d fix(notes): add id tie-breaker to note ordering for deterministic pruning

📊 Changes

10 files changed (+355 additions, -3 deletions)

View changed files

📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+121 -1)
📝 packages/client/src/hooks/use-chats.ts (+31 -0)
📝 packages/server/src/db/migrate.ts (+11 -0)
📝 packages/server/src/db/schema/chats.ts (+17 -0)
📝 packages/server/src/db/seed-mari.ts (+2 -1)
📝 packages/server/src/routes/chats.routes.ts (+18 -0)
📝 packages/server/src/routes/generate.routes.ts (+59 -0)
📝 packages/server/src/services/conversation/character-commands.ts (+17 -1)
📝 packages/server/src/services/storage/chats.storage.ts (+69 -0)
📝 packages/shared/src/types/chat.ts (+10 -0)

📄 Description

Summary

Adds a new <note> tag, sibling to the existing <influence> tag, that conversation-mode characters can emit. Where <influence> is one-shot (consumed on first read into the connected roleplay), <note> is durable — it persists into the connected roleplay's prompt every turn until the user clears it from the chat settings drawer.

Why

The conversation→roleplay context flow only had <influence>, which evaporates after a single read. When something important happens in a DM that the roleplay character should durably remember (a fact learned, a promise made, a name introduced), the only options were a single-shot influence (gone after one turn) or asking the user to manually edit the roleplay's summary field. <note> fills that gap with a near-mirror of <influence> minus the consumption flag.

Greenlit by @SpicyMarinara in the #🍝-marinara-engine Discord post here. No GitHub issue was opened in advance — happy to file one retroactively if maintainers prefer.

Architecture

Layer What changed
Schema New conversation_notes table mirroring ooc_influences minus the consumed column. Created automatically by the existing idempotent runMigrations() (also added to migrate.ts).
Shared types New ConversationNote interface alongside OocInfluence.
Parser New NOTE_RE in character-commands.ts, parallel to INFLUENCE_RE. Tag is stripped from the visible message via the existing .replace() chain.
Queue After conversation generation, parsed notes are saved via chats.createNote() with char-budget pruning.
Injection New <conversation_notes> block built in generate.routes.ts, injected before the last user message in roleplay/game prompts. Same scene-chat bypass as <ooc_influences>. Not consumed — that's the behavioral difference.
Storage New CRUD methods + a 4000-char total budget per roleplay (oldest pruned at insert).
REST GET /chats/:id/notes, DELETE /chats/:id/notes/:noteId, DELETE /chats/:id/notes. Disconnect flow also deletes the chat's notes alongside influences.
Client hooks useChatNotes, useDeleteChatNote, useClearChatNotes — same shape as the memory hooks pair.
UI New "Conversation Notes" section in ChatSettingsDrawer.tsx, only shown for roleplay/game chats with a connection. View list, per-note delete (× button), and clear-all (trash icon at the section header).
Docs Updated seed-mari.ts so Professor Mari knows about the new tag, and the in-prompt connected-roleplay-instructions block teaches conversation characters when to use <note> vs <influence>.

Known limitations

  • No edit UI in v1. Per-note delete ships; per-note edit is deferred. Workaround: delete the stale note, ask the character to re-emit if needed. Adds nontrivial UI (textarea, save/cancel, validation) for what feels like a low-frequency need.
  • Notes are not visible to the conversation character. They're injected into the roleplay prompt only. The conversation that emitted them doesn't see them in its own context. Intentional — preserves the asymmetric information flow the engine already uses for <influence>.
  • Hard 4000-char total budget per roleplay, oldest pruned at insert. No per-note size cap (a single very large note can crowd out everything else). Pragmatic default; can be tuned later.

Test plan

  • Conversation character emits a <note> tag → tag is stripped from the visible message
  • Note appears in the roleplay's settings drawer "Conversation Notes" section with timestamp + delete button
  • Use Peek Prompt on a roleplay turn → confirm <conversation_notes> block appears in the assembled prompt with the note as a bulleted line under the framing text
  • Generate multiple roleplay turns → note persists in every prompt (durability)
  • Per-note × button removes a single note
  • Trash icon at section header clears all notes (confirm dialog appears)
  • After clear-all, <conversation_notes> section is absent from Peek Prompt (correct empty-list behavior)
  • <influence> regression: emit one, generate next turn (referenced), generate the turn after (no longer referenced) — Peek Prompt confirms <ooc_influences> is consumed
  • Disconnect the conversation from the roleplay → all notes are deleted (cascade via deleteNotesForChat)
  • Light mode renders cleanly in the drawer section
  • Dark mode renders cleanly in the drawer section
  • Mobile viewport (~400px) renders cleanly
  • Empty state shows the helper text mentioning <note>...</note>

Screenshots

Empty state, dark mode:
image

Populated, dark mode:
image

Populated, light mode:
image

Mobile viewport (~400px), light mode:
image

Peek Prompt showing the <conversation_notes> section:
image

Summary by CodeRabbit

Release Notes

  • New Features
    • Conversation notes section added to chat settings, displaying note count and character usage
    • Users can delete individual notes or clear all notes with confirmation dialogs
    • Notes now persist across conversation turns and automatically integrate into future responses

🔄 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/311 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 4/29/2026 **Status:** ✅ Merged **Merged:** 5/3/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `feat/conversation-notes` --- ### 📝 Commits (3) - [`493b0a5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/493b0a55bb0f1566e1bc5f415d7983774b6226dd) feat(conversation): add durable note tag for connected roleplays - [`059d74e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/059d74e1ffb6c319926dd14c2d3b0a3614fb1351) fix(notes): scope single-note delete to chat + add loading and error states - [`908a65d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/908a65d0d1205b306a613f29f53f93214d516e44) fix(notes): add id tie-breaker to note ordering for deterministic pruning ### 📊 Changes **10 files changed** (+355 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+121 -1) 📝 `packages/client/src/hooks/use-chats.ts` (+31 -0) 📝 `packages/server/src/db/migrate.ts` (+11 -0) 📝 `packages/server/src/db/schema/chats.ts` (+17 -0) 📝 `packages/server/src/db/seed-mari.ts` (+2 -1) 📝 `packages/server/src/routes/chats.routes.ts` (+18 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+59 -0) 📝 `packages/server/src/services/conversation/character-commands.ts` (+17 -1) 📝 `packages/server/src/services/storage/chats.storage.ts` (+69 -0) 📝 `packages/shared/src/types/chat.ts` (+10 -0) </details> ### 📄 Description ## Summary Adds a new `<note>` tag, sibling to the existing `<influence>` tag, that conversation-mode characters can emit. Where `<influence>` is one-shot (consumed on first read into the connected roleplay), `<note>` is durable — it persists into the connected roleplay's prompt every turn until the user clears it from the chat settings drawer. ## Why The conversation→roleplay context flow only had `<influence>`, which evaporates after a single read. When something important happens in a DM that the roleplay character should *durably* remember (a fact learned, a promise made, a name introduced), the only options were a single-shot influence (gone after one turn) or asking the user to manually edit the roleplay's summary field. `<note>` fills that gap with a near-mirror of `<influence>` minus the consumption flag. Greenlit by @SpicyMarinara in the `#🍝-marinara-engine` [Discord post here](https://discord.com/channels/1417099416812392641/1497363827006640199). No GitHub issue was opened in advance — happy to file one retroactively if maintainers prefer. ## Architecture | Layer | What changed | |-------|--------------| | Schema | New `conversation_notes` table mirroring `ooc_influences` minus the `consumed` column. Created automatically by the existing idempotent `runMigrations()` (also added to `migrate.ts`). | | Shared types | New `ConversationNote` interface alongside `OocInfluence`. | | Parser | New `NOTE_RE` in `character-commands.ts`, parallel to `INFLUENCE_RE`. Tag is stripped from the visible message via the existing `.replace()` chain. | | Queue | After conversation generation, parsed notes are saved via `chats.createNote()` with char-budget pruning. | | Injection | New `<conversation_notes>` block built in `generate.routes.ts`, injected before the last user message in roleplay/game prompts. Same scene-chat bypass as `<ooc_influences>`. **Not consumed** — that's the behavioral difference. | | Storage | New CRUD methods + a 4000-char total budget per roleplay (oldest pruned at insert). | | REST | `GET /chats/:id/notes`, `DELETE /chats/:id/notes/:noteId`, `DELETE /chats/:id/notes`. Disconnect flow also deletes the chat's notes alongside influences. | | Client hooks | `useChatNotes`, `useDeleteChatNote`, `useClearChatNotes` — same shape as the memory hooks pair. | | UI | New "Conversation Notes" section in `ChatSettingsDrawer.tsx`, only shown for roleplay/game chats with a connection. View list, per-note delete (× button), and clear-all (trash icon at the section header). | | Docs | Updated `seed-mari.ts` so Professor Mari knows about the new tag, and the in-prompt connected-roleplay-instructions block teaches conversation characters when to use `<note>` vs `<influence>`. | ## Known limitations - **No edit UI in v1.** Per-note delete ships; per-note edit is deferred. Workaround: delete the stale note, ask the character to re-emit if needed. Adds nontrivial UI (textarea, save/cancel, validation) for what feels like a low-frequency need. - **Notes are not visible to the conversation character.** They're injected into the *roleplay* prompt only. The conversation that emitted them doesn't see them in its own context. Intentional — preserves the asymmetric information flow the engine already uses for `<influence>`. - **Hard 4000-char total budget per roleplay**, oldest pruned at insert. No per-note size cap (a single very large note can crowd out everything else). Pragmatic default; can be tuned later. ## Test plan - [x] Conversation character emits a `<note>` tag → tag is stripped from the visible message - [x] Note appears in the roleplay's settings drawer "Conversation Notes" section with timestamp + delete button - [x] Use Peek Prompt on a roleplay turn → confirm `<conversation_notes>` block appears in the assembled prompt with the note as a bulleted line under the framing text - [x] Generate multiple roleplay turns → note persists in every prompt (durability) - [x] Per-note × button removes a single note - [x] Trash icon at section header clears all notes (confirm dialog appears) - [x] After clear-all, `<conversation_notes>` section is absent from Peek Prompt (correct empty-list behavior) - [x] `<influence>` regression: emit one, generate next turn (referenced), generate the turn after (no longer referenced) — Peek Prompt confirms `<ooc_influences>` is consumed - [x] Disconnect the conversation from the roleplay → all notes are deleted (cascade via `deleteNotesForChat`) - [x] Light mode renders cleanly in the drawer section - [x] Dark mode renders cleanly in the drawer section - [x] Mobile viewport (~400px) renders cleanly - [x] Empty state shows the helper text mentioning `<note>...</note>` ## Screenshots **Empty state, dark mode:** <img width="266" height="150" alt="image" src="https://github.com/user-attachments/assets/d763dd87-2315-4d6e-ba88-446355dca168" /> **Populated, dark mode:** <img width="271" height="125" alt="image" src="https://github.com/user-attachments/assets/901f67cb-6441-4bbd-8419-492c26d36eda" /> **Populated, light mode:** <img width="265" height="125" alt="image" src="https://github.com/user-attachments/assets/a2b7fca9-a8c6-44ee-8297-541ebf43d8bf" /> **Mobile viewport (~400px), light mode:** <img width="398" height="849" alt="image" src="https://github.com/user-attachments/assets/a5bbfc54-3d01-4bca-b783-37d5f3ddd10c" /> **Peek Prompt showing the `<conversation_notes>` section:** <img width="914" height="730" alt="image" src="https://github.com/user-attachments/assets/4791c8e3-8789-4a48-bf32-0fbbf89dfb69" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Conversation notes section added to chat settings, displaying note count and character usage * Users can delete individual notes or clear all notes with confirmation dialogs * Notes now persist across conversation turns and automatically integrate into future responses <!-- 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:08:40 +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#4554
No description provided.