mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5728] [MERGED] fix(client): Professor Mari survives backgrounding like regular chats do #6904
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#6904
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/5728
Author: @kolacheee
Created: 9/1/2026
Status: ✅ Merged
Merged: 9/1/2026
Merged by: @kolacheee
Base:
staging← Head:fix/5719-mari-background-resilience📝 Commits (3)
df57079fix(client): recover Professor Mari from backgrounded-tab stream deaths (#5719)d7dcebafix(client): close the recovery races the #5719 review confirmedf7e714cMerge branch 'staging' into fix/5719-mari-background-resilience📊 Changes
5 files changed (+246 additions, -21 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/client/src/components/chat/HomeProfessorMariChat.tsx(+121 -15)📝
packages/client/src/hooks/use-generate.ts(+1 -6)📝
packages/client/src/lib/api-client.ts(+22 -0)➕
scripts/regressions/mari-background-stream.regression.ts(+101 -0)📄 Description
Linked issue
Closes #5719.
Why this change
Professor Mari appeared to die the moment the window lost focus ("Rendering stoped because window was unfocused" in the report), while regular chats kept generating in the background. The investigation showed the server was never the problem: Mari's whole agent loop runs server-side and the
/promptroute deliberately ignores passive disconnects and persists the finished reply. What died was the client. Regular chat classifies any plain transport error after the page was hidden as a passive disconnect and settles-then-reloads; Mari recovered from exactly one error class — the visible-tab resume watchdog'sStreamResumeDisconnectError. Android browsers tear down a hidden tab's connection with a bareTypeError, so Mari toasted "could not answer right now" while the server finished a reply the UI never showed. A cleanly closed socket was worse: an immediate false "did not receive a reply" fired with no recovery path at all, and a reply that finished while the client was detached (stream killed, or Mini-Mari closed and reopened) stayed invisible until a manual chat switch.What changed
isPassiveStreamDisconnectis hoisted fromuse-generate.tsintoapi-client.ts(next to the watchdog error it complements) and used by both regular chat and Mari. The watchdog error short-circuits true; everything else requires hidden-page history and excludes caller aborts and HTTP-levelApiErrors.visibilitychange/pagehideexactly likeuse-generatedoes, and its catch recovers from every passive-disconnect shape — "Finishing in the background…", wait for the run to settle, reload the persisted reply.waitForWorkspaceRunToSettlenow reports whether it ever observed the run active. If a live run is confirmed, Mari settles and reloads instead of showing the false "did not receive a reply"; a genuinely dead run still surfaces the honest toast.mari-background-streamcovers the shared classifier, Mari's tracking and recovery paths, the settle-and-confirm no-reply handling, the detached-run reload, and the server route's keep-running contract.Known limitation (pre-existing, documented in the commit): the workspace status
activeflag is global rather than run-scoped, so the settle poll could in principle observe an unrelated concurrent Mari action; run-scoping the status endpoint is a candidate follow-up.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm lintand the client production build are green locally;format:checkfails repo-wide on this Windows checkout (pre-existing autocrlf CRLF; touched files were run through Prettier directly).Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)CHANGELOG updated under [Unreleased] → Fixed. No user-facing docs under
docs/touched.UI evidence (if applicable)
Behavioral change only — the visible difference is recovery ("Finishing in the background…" then the reply) where there used to be an error toast, and replies appearing after reopening Mini-Mari.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.