mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2887] [Issue]: Professor Mari "Restart" button silently deletes chat history before failing, causing delayed data loss #1468
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#1468
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 @spacyH on GitHub (Jun 27, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2887
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The "Restart" button in the Professor Mari home chat (
HomeProfessorMariChat.tsx) deletes all chat messages from the database before calling the server-side reset endpoint. When the server call subsequently fails, the user sees an error toast ("Professor Mari could not restart her notes."), but the destruction has already occurred. The messages appear to remain in the UI due to stale React state, only vanishing later when a refetch reveals the post-deletion reality.This creates a deeply confusing experience where the data loss appears to happen randomly and is disconnected from the user action that caused it.
[NOTE: The initial investigation & recommendations were made by Prof. Mari, then reviewed & refined by Cursor (Composer 2.5) and me.]
Expected behavior
Actual behavior
Chat messages are irreversibly deleted from the database even when the restart operation fails. The data loss is delayed in its visible effect because stale React state continues to render the deleted messages until a refetch occurs.
Steps to reproduce
/restartcommand)POST /chats/{chatId}/messages/bulk-delete— commits message deletion as soon as the server returns success (HTTP 204)POST /professor-mari/workspace/reset— only sent after Request A completesloadMessages()after the send completes), orWhy bulk-delete can succeed while reset fails
This is not a case of "the network works for one endpoint but not the other" in a mysterious way. Both requests usually hit the same server. The problem is ordering: the client performs an irreversible delete first, then attempts the reset. Any failure on the second step leaves you in a broken state.
Plausible failure modes for Request B after Request A has already committed:
abort()orclearHistory()(e.g. filesystemmkdir/writeFilefailure)So the bug does not require exotic network partitioning. It requires only: delete committed, then something goes wrong before the rest of restart finishes. In practice, server-side errors on the workspace reset path are at least as likely as a network flake on the second call.
Environment
Root Cause
packages/client/src/components/chat/HomeProfessorMariChat.tsxPOST /professor-mari/workspace/reset(packages/server/src/routes/professor-mari-workspace.routes.ts)ProfessorMariWorkspaceService.reset()(packages/server/src/services/professor-mari/workspace-agent.service.ts)GET /chats/internal/professor-mari(metadata markerinternalAssistant: "professor-mari"). The synthetic welcome message uses id__professor_mari_home_welcome__; that is not the persisted chat id.In
HomeProfessorMariChat.tsx, thehandleRestartfunction executes steps in a destructive order:Step 3 (bulk message deletion) runs before Step 4 (server reset). When Step 4 throws, the catch block in
runRestartfires and the error toast is shown — but the messages are already deleted from the database.Step 5 (clearing local UI state) is positioned after the throwing line, so it never executes. The component keeps rendering messages from local
useState, not React Query, masking the damage untilloadMessages()runs again.Two different "histories" (important distinction)
Restart clears two separate stores, and conflating them leads to incomplete fixes:
bulk-deletereset({ clearHistory: true })The server
reset()withclearHistory: trueonly wipes the workspace journal file. It does not delete chat messages. The client bulk-delete is required for a full "empty chat" restart — the bug is that it runs too early, not that it exists.Relevant server-side code
The server-side
reset()is well-behaved on its own — it only clears the workspace journal when asked:clearHistory()writes an empty workspace history file; it does not touch the chats/messages tables. The bug is entirely in the client-side ordering.Additional notes
/restartchat command triggers the samehandleRestart/runRestartpath and has the same bug.reset()but withoutclearHistory, so it does not trigger this specific data-loss path.clearHistory()method itself is not at fault — the issue is the client deleting messages before the server call.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 28, 2026):
Hm, that's strange. When I click Restart on Professor Mari's chat, all the messages instantly vanish and I get the toast notification that it was restarted. I'm also on Mac, though I did not install via Docker, obviously. I'll investigate the issue, but all looks good on my end and others are reporting it works correctly, too.
@SpicyMarinara commented on GitHub (Jun 28, 2026):
Fixed in the local staging branch: Professor Mari home-chat restart now requires /professor-mari/workspace/reset to succeed before it deletes chat messages, so a failed reset cannot silently remove chat history and leave stale UI behind. Added the #2887 changelog note.\n\nValidation: pnpm --filter @marinara-engine/client lint