mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#5844
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3211
Author: @kolacheee
Created: 7/4/2026
Status: ✅ Merged
Merged: 7/4/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/3210-segment-reactions📝 Commits (10+)
5a300b9feat: allow reacting to individual character segments in conversation mode (#3210)d9c67a3fix: keep segment reaction chips outside card-CSS scope and handle stale segment targets3724f96fix: polish segment-reaction chrome (chip width cap, action-bar containing block, empty theme boxes, annotation parser parity)97358bffeat: attribute segment reactions to the exact quoted part in promptse931849fix: harden exact-part reaction attribution (speaker-set parity, canonical names, content shape)9caea8efeat: inline reaction notes under the targeted part + character-to-character reactions5080cf8fix: harden inline reaction notes and targeted reacts (linear react grammar, display-shape parity, verified injection targets, swipe mirror)2806197fix: residual polish for inline notes and targeted reacts (marker line-equality, tiered dedupe, quoted-target tolerance, attachment-only targets, id pairing)7dd6aa1fix: same-reply targeted reacts only aim at parts before the reactor's turn; clarify react instruction1ce009cAvoid empty grouped message wrappers📊 Changes
12 files changed (+1104 additions, -209 deletions)
View changed files
📝
CHANGELOG.md(+3 -0)📝
packages/client/src/components/chat/ConversationMessage.tsx(+74 -19)📝
packages/client/src/components/chat/ConversationMessageGrouped.tsx(+133 -52)📝
packages/client/src/components/chat/ConversationMessageShared.tsx(+20 -79)📝
packages/client/src/components/chat/ConversationView.tsx(+10 -11)📝
packages/client/src/components/chat/MessageReactions.tsx(+6 -4)📝
packages/client/src/lib/reactions.ts(+102 -4)📝
packages/server/src/routes/generate.routes.ts(+505 -34)📝
packages/server/src/services/conversation/character-commands.ts(+61 -6)📝
packages/shared/src/index.ts(+1 -0)📝
packages/shared/src/types/chat.ts(+13 -0)➕
packages/shared/src/utils/speaker-segments.ts(+176 -0)📄 Description
Fixes #3210
Summary
In conversation mode, emoji reactions can now target an individual character's segment of a merged multi-character reply. Each speaker segment in the grouped layout gets its own add-reaction button (beside the speaker's name, on hover/tap) and its own reaction chip row; reactions without a segment target keep applying to the whole message exactly as before.
In the prompt, characters see segment reactions as a
[User reacted with 😹, Aurey reacted with 🙄]line injected directly under the exact part they were aimed at (position conveys the target, like a chat app). And characters can now react to each other:[react: emoji="🙄" to "Character Name"]puts the reaction on that character's most recent part — same merged reply or recent history — rendered as a chip under it.Why
A multi-character reply is stored as one
messagesrow that the client splits into per-speaker segments, but reactions were a single flat list on the whole message — so in a group conversation you could only react to the entire block, never to one character's line (issue #3210). This implements the storage + client workaround suggested in the issue: the merged-generation model and the singlePATCH /messages/{id}/extracall are unchanged.Architecture
packages/shared/src/types/chat.tsMessageReactiongains optionalsegment(grouped-segment index) +segmentSpeaker(parsed speaker name at react time). Absent = whole-message, so existing data needs no migration.packages/client/src/lib/reactions.tstoggleReactionidentity is now (emoji, segment target); newsplitReactionsBySegmentroutes each reaction to its segment only when the index is still in range and the stored speaker still matches and the segment has text — otherwise it falls back to the whole-message row, so an edit/regeneration that re-segments the content can never mis-attach a reaction to the wrong character (it degrades to whole-message display instead).findRetargetableUserReactionlets a new pick move the user's stale same-emoji/same-speaker entry instead of stacking a duplicate.ConversationMessage.tsx/ConversationMessageShared.tsxConversationMessageGrouped.tsxReactionAddButtonin the speaker name row (hover-toolbar visibility discipline, mobile tap supported) and per-segmentMessageReactionschip row, in both classic and bubble styles. Thedata-card-cssattribute moved from the block root onto per-segment content wrappers (+ one trailing-chrome wrapper), so the chip rows render outside card-CSS reach — preserving the same isolation invariant the shell keeps for the whole-message row.MessageReactions.tsxpackages/shared/src/utils/speaker-segments.ts(new)parseSpeakerTags,parseNamePrefixFormat,groupConsecutiveSegments, + combinedparseGroupedSpeakerSegments) moved fromConversationMessageShared.tsxinto shared, so the client's grouped layout and the server's reaction attribution derive segment indexes from the same code and can't drift. Parsers also computestart/endcharacter offsets per group (for the inline injection), andstripLeadingMessageTimestamps— the display-shape timestamp strip both sides segment against — lives here (ConversationView now imports it instead of a local copy).packages/server/src/routes/generate.routes.tsannotateContentWithReactionsinjects segment reactions inline under the targeted part in the prompt (grouped per part,[User reacted with 😹, Aurey reacted with 🙄]), resolving the stored index against the display shape and mapping into the prompt shape by (speaker, ordinal) validated by text containment — mapping failure falls back to a quoted end-note, stale index to speaker-only wording, unparseable to plain. Only canonical character names are echoed; disabled/removed characters are covered in the known-speaker set; excerpts truncate on code-point boundaries; segmentation caps at 32 KB; stale cross-swipe twins of inlined reactions are suppressed; the message object is replaced (not mutated) so follow-up generation passes can't double-annotate.packages/server/src/services/conversation/character-commands.ts+generate.routes.ts[react]handler[react: emoji="🙄" to "Character Name"]— targeted character-to-character reactions. Deliberately a linear single-quantifier regex + deterministic body parser (a suffix-aware regex was super-linear → ReDoS, caught in review). Target resolution: the character's last part in the just-saved reply, else newest-first through recent history (skipping hidden command-anchor rows), resolved against all chat members (disabled included) + each message's author, matching the client's segmentation set.addMessageReactoris segment-aware (identity = emoji + segment + speaker, mirroring the client'stoggleReaction), and writes mirror to every swipe row like the client PATCH route, so swiping doesn't drop character reactions. Unresolvable names fall back to the classic user-message react.Commit 2 (
fix: keep segment reaction chips outside card-CSS scope...) applies fixes from an adversarial multi-agent review of commit 1: card-CSS isolation for the chip rows, empty-segment targeting, chips disappearing during edit, duplicate entries across swipe re-segmentation, and prompt annotations claiming a speaker part the active swipe doesn't have. Commit 3 polishes findings from a verification pass over commit 2 (bubble chip width cap, action-bar containing block, phantom theme boxes, parser-precedence parity). Commits 4–5 move the segment parsers topackages/sharedand add exact-part attribution, hardened per a further verification pass. Commits 6–7 (maintainer-requested follow-ups) switch the prompt to inline notes injected under the targeted part and add character-to-character targeted reactions, with a hardening round fixing what a fourth adversarial review found — most notably a ReDoS in the first draft of the extended[react:]grammar (linear rewrite, timed at 0.56 ms on inputs that previously hung for minutes) plus display-shape parity, verified injection targets, and swipe mirroring.Known limitations
[data-card-css]wrapper per segment (instead of one on the block root), a theme that styles the container element itself ([data-card-css] { border/background/padding }) draws per-segment boxes on grouped messages instead of one block-wide box. Descendant-selector reach is unchanged. Inherent to keeping chip rows outside theme reach; flagging for theme authors.Test plan (manual verification needed)
[<persona> reacted with <emoji>]on its own line directly under the targeted part — even when that character has several parts in the same merged reply.[react: emoji="🙄" to "Name"], the chip appears under that character's part with the reacting character in the tooltip, and the next Peek Prompt shows both reactors in the inline note (e.g.[You reacted with 😹, Aurey Louvette reacted with 🙄]).[react: emoji="😂"]from characters still lands on your latest message, and survives swiping the reacted message.[react:]reactions (bot reacting to your message) still work and don't merge into a segment entry.Docs touched
CHANGELOG.md(Unreleased → Added).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.