mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2475] [Issue]: Background autonomous trigger never sets the generation lock, allowing a duplicate autonomous reply #1218
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#1218
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 @Romuromylus on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2475
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Severity: Low — concurrency regression. The background autonomous-message trigger never sets the shared in-memory generation lock (
markGenerationInProgress), unlike main. During a busy/dnd-character delay window this allows a duplicate autonomous reply when the user navigates into the chat and the active-chat poller independently triggers.Expected behavior
checkConversationAutonomousshould set the shared generation lock when it decides to trigger (main does this on both the normal and offline-catch-up paths), so the active-chat poller's owncheckAutonomousMessagingshort-circuits and only one autonomous reply is produced.Actual behavior
checkConversationAutonomousreturnsshouldTrigger: truewithout ever locking:The shared lock
generationInProgressSinceis only read to gate (:445-451,:551-557), never set on a positive trigger. The background poller (use-background-autonomous.ts) relies solely on a per-hookgeneratingForRefSet plus anabortControllerscheck; it never sets the global lock. The only caller that sets it is the active-chat poller (use-autonomous-messaging.ts:79). So when the background poller has launcheddoGeneratefor a busy/dnd character (delay window) and the user switches into that chat, the active-chat hook readsgenerationInProgressSince, sees nothing in progress, and can trigger its own generation — theabortControllerscheck only covers the in-flight HTTP request, not the pre-flight/assembly window — yielding a duplicate autonomous reply.Steps to reproduce
doGenerateafter the delay.doGeneratealso runs → duplicate reply.Impact area
Environment
1fae2c42Logs, screenshots, or video
Static trace:
autonomous.service.ts:226, 237-243(returns trigger without lock),use-background-autonomous.ts:113-129(nomarkGenerationInProgress), contrastuse-autonomous-messaging.ts:79(the one caller that does lock).Regression notes
Regression vs main, which calls
markGenerationInProgress(chatId)on both the normal trigger and the offline-catch-up fallback (conversation.routes.ts~653/~673). The refactor dropped that, so the cross-poller in-memory lock is never honored on the background path.Additional context
Narrow window (requires a busy/dnd character, navigating in during the delay, and the active generation finishing before the background timer fires); outcome is a duplicate friendly message, no data loss — hence Low. Fix: call
markGenerationInProgress(input.chatId)before eachshouldTrigger: truereturn incheckConversationAutonomous, or have the background poller set the lock before scheduling the busy-delay timer.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 6, 2026):
Fixed on refactor in
038b7220.Foreground and background autonomous triggers now set generation-in-progress locks before delayed generation begins and clear them on abort/finally, preventing duplicate autonomous replies.
Verification: pnpm typecheck; pnpm build; pnpm check:architecture; cargo check --manifest-path src-tauri/Cargo.toml --workspace; focused Rust backup/profile tests; git diff --check; no .test.ts/.test.tsx files present.