mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2428] [MERGED] Scope regenerate and streaming character ids per chat #5602
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#5602
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/2428
Author: @Romuromylus
Created: 6/6/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/per-chat-regenerate-streaming-ids📝 Commits (1)
db8e811Scope regenerate and streaming character ids per chat📊 Changes
2 files changed (+55 additions, -12 deletions)
View changed files
📝
src/features/runtime/generation/hooks/use-generate.ts(+8 -7)📝
src/shared/stores/chat.store.ts(+47 -5)📄 Description
Linked issue
Closes #2321
Why this change
regenerateMessageIdandstreamingCharacterIdwere the last two generation-UI fields left as global scalars inchat.store, while their siblings (streamBuffers/thinkingBuffers/abortControllers) are already per-chat Maps. During concurrent generation across chats, chat A's regenerate/streaming-character id leaked into chat B's foreground view (typing routed to the wrong bubble, wrong streaming card/voice).What changed
src/shared/stores/chat.store.ts: addedregenerateMessageIdByChatId/streamingCharacterIdByChatIdMaps next to the existing per-chat maps. The setters take an optionalchatId, write the per-chat entry, and mirror to the global scalar only when that chat is active — byte-for-byte the same shape assetStreamBuffer.setActiveChatIdrestores both globals from the maps on switch (and nulls them on no-chat);reset()clears the maps.src/features/runtime/generation/hooks/use-generate.ts: set/clear both ids with the explicitchatId.releaseForegroundGenerationUinow clears the completing chat's own ids regardless of foreground (they self-scope by chatId), so a background chat's completion can't leave stale per-chat entries.Refactor impact
Primary owner: shared API / chat store
Impact areas reviewed:
src/shared/stores/chat.store.ts(per-chat maps + global mirror)src/features/runtime/generation/hooks/use-generate.ts(explicit chatId at set/clear sites)Boundary notes:
chatIdarg is optional and falls back to the active chat (only callers are in use-generate.ts, now all explicit). Existing consumers (ConversationView,ChatRoleplaySurface) read the global mirror unchanged. No persistence/IPC/Rust change.Pressure points touched:
Validation
pnpm checkpasses before PR push/handoffManual verification notes
pnpm vitest run src/features/runtime/generation src/engine/generation— 67 passed. A local-only store test confirmed cross-chat isolation: chat A's regenerate/streaming ids do not bleed into B on switch, A's values restore on switch back, a background chat's completion clears its own ids without touching the foreground, and switching to no-chat clears both globals.pnpm exec tsc -b— clean.Feature Discoverability
src/features/shell/discovery/Reason:
Docs and release impact
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.