mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #1127] [Tech debt]: Unify speaker-tag parsing across ChatMessage and ConversationMessage #558
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#558
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?
Originally created by @aeriondyseti on GitHub (May 24, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1127
Originally assigned to: @cha1latte on GitHub.
The situation
The client has three independent implementations of
<speaker="Name">…</speaker>handling right now:packages/client/src/components/chat/ChatMessage.tsxplain-text branch —renderWithSpeakerTags(around line 258)packages/client/src/components/chat/ChatMessage.tsxHTML branch — inlineString.replace(around line 572)packages/client/src/components/chat/ConversationMessage.tsx—parseSpeakerTags(around line 193)Each uses a slightly different regex and a slightly different fallback for unknown speakers or missing colour maps. A bug fix in one path doesn't automatically reach the others — #1125 fixed (1), but (2) and (3) had to be audited by hand for parity. That's the kind of footgun that grows over time.
What I'd suggest
Extract a shared parser that returns a structured representation, and have each surface render that structure with its own styling rules:
Three call sites, one parser. The regex-per-surface coupling goes away.
Why now
The fix for #1125 surfaced a textbook SRP violation:
renderWithSpeakerTagshad two responsibilities (stripping tags + colouring per speaker) entangled in a single early-return condition — and that entanglement was the bug. Splitting parse → render at the architecture level prevents the same class of bug from recurring in the sibling implementations.Done when
Out of scope
Bare-tag handling — see #1126. A unified parser would probably fix that as a side-effect, but the regex-alignment decision should be made deliberately, not snuck in.
Surfaced during code review of #1125.
@cha1latte commented on GitHub (May 25, 2026):
Triage note: labeling this as
normal-scopebecause the issue is a focused client tech-debt cleanup: one shared speaker-tag parser used by existing chat surfaces with visible behavior preserved.The least risky next step is to keep the change limited to parser extraction and parity verification across the current render paths.
@cha1latte commented on GitHub (May 25, 2026):
Merged in #1128