mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #4637] [Issue]: Professor Mari permanently unresponsive after agentic task completes — stuck sending/isBusy deadlock gates all recovery paths (Android/Termux) #2535
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#2535
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 @kolacheee on GitHub (Aug 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4637
Originally assigned to: @SpicyMarinara on GitHub.
Summary
After a Professor Mari agentic/workspace task completes, the UI can become permanently unresponsive — suggestion chips, the command input, and starting a new session are all dead — requiring a full app reload. Root cause: the
sending/isBusyflag chain can get stuck after the stream has already finished, because post-completion cleanup awaits have no timeout/abort/resume protection, and every in-app path that could recover is itself gated on!isBusy— a true deadlock. Reported on Android via Termux (v2.4.1, agentic run); the code is unchanged on current staging.Expected behavior
Once a task completes (reply + suggestions visible), Mari returns to idle: chips clickable, input enabled, restart available. Any post-run cleanup that stalls should be bounded and must never wedge the UI.
Actual behavior
All three reported controls hang off one expression —
const isBusy = sending || hasActiveGeneration || workspaceActive(packages/client/src/components/chat/HomeProfessorMariChat.tsx:2380):disabled={isBusy}(:3740 floating, :4388 embedded)disabled={isBusy}(:3837/:3841, :4495/:4499), andhandleSubmitearly-returns onisBusy(:3604)runRestartbeginsif (isBusy) return;(:2950) and the Restart button isdisabled={isBusy}(:4295)The trap: after
sendWorkspaceMessagefinishes streaming (itsfinallyat :3469-3474 clearsworkspaceActive/activity — so the reply and chips are on screen and the Stop button disappears),handleSubmitis still inside itssending = truewindow (:3618) running three unprotected plain awaits:await loadMessages(chat.id)(:3628),await refreshWorkspaceStatus()(:3632),await invalidateWorkspaceData()(:3633 —invalidateQueries({refetchType: "all"}), which awaits every query refetch app-wide).setSending(false)only runs in thefinallyat :3649, after all of them.apiFetchhas no timeout (api-client.ts:204-224).If any of those requests hangs,
sendingis stuck true forever:loadMessagescall would abort the hung one (messageLoadAbortRef, :2439-2441) — but every caller (submit :3604, restart :2950, chat select :3164, regenerate :3513) early-returns onisBusy. The stuck flag gates every path that could clear it.(workspaceActive || hasActiveGeneration)(:4283), both already false.sending.Result: a completed task with visible-but-dead chips and a dead composer. Only a reload discards the hung promise. (Same unprotected pattern in
handleRegenerateMessage: setSending :3530, loadMessages :3555/:3560, finally :3564.)Why Android/Termux hits this
fetchpromise that never settles nor rejects after resume — the exact platform pathology this repo already documents forreader.read()inapi-client.ts:457-461. PR #3941 (#3940) armored the stream reads against this; the post-completion plain fetches got no equivalent protection.loadMessages— TCP connects from the kernel backlog, no response ever arrives, and fetch waits forever.Confirmed sibling entry points into the same deadlock
waitForWorkspaceRunToSettle(the #3941 recovery path, :108-130, entered at :3461-3468) issues its status GET (:113) with no AbortSignal and no per-request timeout — a stalled GET wedgesworkspaceActiveinstead, with activity stuck on "Finishing in the background…". (Its 30-minute deadlineWORKSPACE_SETTLE_MAX_WAIT_MS, :103/:111, is only checked between iterations.)api-client.tspermanently disarms after one settled read (wasHidden = falsereset at :508) and is not armed for visible-at-start streams — a later half-open stream hangs the finalreader.read()unguarded, wedgingworkspaceActive.professor-mari-workspace.routes.ts:148-153), so the client depends entirely on a clean stream close to reach its terminal handling.Steps to reproduce
Deterministic desktop simulation (the real-world trigger is probabilistic backgrounding):
GET /chats/:id/messagesrequest that fires right after the stream completes (Network → block URL / offline at the right moment), soloadMessagesnever settles.Real-world repro (per the report): run a long agentic task on Android (Termux server), background or lock the phone around completion, return.
Environment
93738d9b1)Logs, screenshots, or video
Verified by code trace (six independent confirmation passes over the trigger sequences; key lines quoted above and re-checked by hand against staging).
Additional context
Relation to #4628: distinct root cause. The completion-burst theory (unthrottled render wedging the phone) was explicitly refuted — the user seeing the completed task and chips proves paint finished. #4628 is only an accessory here: its post-completion main-thread stall widens the window in which backgrounding lands mid-await. Relation to #3940/#3941: the user has that fix (merge commit
96b5d5bbeis in v2.4.1); this bug lives in the paths #3941 did not cover.Suggested layered fix (any of 1–3 unwedges; together they're robust):
sendingcritical section: clearsendingas soon as the send stream settles; run the post-run refetches (loadMessages/refreshWorkspaceStatus/invalidateWorkspaceData) as best-effort background cleanup outside the gating window (or bound them withAbortSignal.timeout).waitForWorkspaceRunToSettle(e.g.AbortSignal.any([signal, AbortSignal.timeout(10_000)])), treating a timeout like a failed poll iteration.Template check