mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #240] [MERGED] feat(chat): "Mari is thinking…" / "updating your stuff…" indicator #4525
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#4525
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/240
Author: @LukaTheHero
Created: 4/26/2026
Status: ✅ Merged
Merged: 4/26/2026
Merged by: @LukaTheHero
Base:
main← Head:feat/mari-thinking-indicator-v2📝 Commits (6)
fb8926efeat(chat): add "Mari is thinking…" indicator for command executionca899a0fix(chat): address review comments on Mari thinking indicatorde189c9fix(chat): hide Mari indicator immediately on chat switchaf7e356chore(chat): skip idle hide timer when pill has no owner0bcad4cfix(chat): replace subscribeWithSelector transport, gate pill on token edgec71b81dfix(chat): restore Mari pill on chat-switch-back mid-stream📊 Changes
7 files changed (+268 additions, -0 deletions)
View changed files
📝
CHANGELOG.md(+6 -0)📝
packages/client/src/components/chat/ChatInput.tsx(+4 -0)📝
packages/client/src/components/chat/ConversationInput.tsx(+4 -0)➕
packages/client/src/components/chat/MariThinkingIndicator.tsx(+166 -0)📝
packages/client/src/hooks/use-generate.ts(+48 -0)📝
packages/client/src/stores/chat.store.ts(+29 -0)📝
packages/server/src/routes/generate.routes.ts(+11 -0)📄 Description
Picks up @cha1latte's work in #222 and ships it with two correctness fixes and a small UX extension. His four commits are preserved with original authorship; my changes are the final commit on top.
What this does
A pill above the input bar tells you when Mari is doing background work, so you can tell the difference between "still thinking" and "stalled."
create_character,update_character,fetch, …) execute in the post-stream loop.What's new vs #222
Bug fix: indicator never appeared in practice
The original used
useChatStore.subscribe(selector, evaluate)to react to store changes. That's the samesubscribeWithSelector+ React 19 batching combination thatGameSurface.tsx:2079-2081already documents as unreliable for fast start/end transitions. The SSE events arrived (verified via Network → EventStream) but the subscription dropped them — pill never showed.Switched the transport to window
CustomEvents (marinara:mari-phase), matching the established pattern (marinara:generation-complete,marinara:generation-error) already used elsewhere inuse-generate.ts. CustomEvents fire synchronously, outside React's batching, so every transition is observed.UX extension: pill now covers the generation phase too
The original only showed the pill during the post-stream command window. But there's a similar dead-air window during token streaming — typing indicator hides on first token, then nothing visible until commands start (or completion). Extended the pill to cover that window too: "Mari is thinking…" fires on the first token (same edge that clears the typing indicator, so they never overlap), seamlessly transitions to "Mari is updating your stuff…" when commands start.
Cleanup
setCommandsExecutingmissing fromuseCallbackdeps).isMariParticipantas a pure function.evaluate().commandsExecutingChatIdsset +setCommandsExecutingaction — still useful as a synchronous read source for any future consumer, costs nothing.Why a new PR instead of pushing to #222
#222 is from @cha1latte's fork — I can't push to it. Cherry-picked his four commits onto this branch with original authorship preserved (you'll see his name on the first four commits in the history), then layered the fixes on top as one commit. Will close #222 with a comment explaining the situation and crediting his diagnosis.
Files
packages/client/src/components/chat/MariThinkingIndicator.tsxpackages/client/src/hooks/use-generate.tsmarinara:mari-phaseon first token, onassistant_commands_start, and from termination cleanuppackages/client/src/stores/chat.store.tscommandsExecutingChatIdsset +setCommandsExecutingaction (preserved from #222)packages/client/src/components/chat/ChatInput.tsx<MariThinkingIndicator />packages/client/src/components/chat/ConversationInput.tsx<MariThinkingIndicator />packages/server/src/routes/generate.routes.tsassistant_commands_start/_endSSE events around the command loop (preserved from #222)CHANGELOG.mdRobustness
I walked every edge case I could think of:
assistant_commands_endANDdoneboth call cleanup): second short-circuits.finallyblock always dispatchesidle. No stuck states.ChatInput+ConversationInputboth render it): only one mounts at a time; if both ever did, they'd both render the same correct pill — no state contention since each instance has its own refs.Testing
pnpm checkpasses (no errors, no warnings).Test plan
Summary by CodeRabbit
New Features
Chore
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.