[PR #6844] [MERGED] fix(mari): review cards belong to their chat, and none get stuck #7353

Closed
opened 2026-10-23 04:18:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6844
Author: @kolacheee
Created: 9/29/2026
Status: ✅ Merged
Merged: 9/29/2026
Merged by: @kolacheee

Base: staging ← Head: fix/mari-review-cards


📝 Commits (2)

  • d9f250c fix(mari): review cards belong to their chat, and none get stuck
  • 87045ba Merge remote-tracking branch 'origin/staging' into fix/mari-review-cards

📊 Changes

8 files changed (+392 additions, -11 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/home/professor-mari.md (+6 -2)
📝 packages/server/src/routes/chats.routes.ts (+3 -0)
📝 packages/server/src/routes/professor-mari-workspace.routes.ts (+33 -2)
📝 packages/server/src/services/mari-db/mari-db.service.ts (+73 -2)
➕ packages/server/src/services/professor-mari/mari-session.ts (+27 -0)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+19 -5)
➕ scripts/regressions/mari/review-cards.regression.ts (+229 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #6842

Why this change

A user on 2.4.6 worked with Professor Mari on character cards. Afterwards, "Review Mari's changes" cards stayed on screen for good: deleting the chat, deleting every Mari chat and starting a new one did not clear them. Their cards all read "Professor Mari · Edited · No field changes to show." Reproduced on staging, four causes combined:

  • Cards are global. Every Mari chat showed every pending review, because reviews recorded no chat and deleting a chat never touched them.
  • Mari could edit her own built-in card. Startup rewrites that card to the shipped version, so the edit vanished at the next restart and its review could never be restored.
  • An edit that changes nothing still made a card. That is the empty "No field changes" card.
  • A refused Restore was a dead end, saying "Review a fresh proposal instead". A failed Keep said only "Internal Server Error".

What changed

  • Cards belong to their chat.
    • A new mari-session.ts gives each Mari chat's run its own session id, professor-mari-workspace:<chatId>. Mari's app actions, her direct CLI calls and her shell's mari commands all carry it.
    • The workspace status lists a chat's own cards, plus cards that no chat owns: changes made with the mari CLI in a terminal, and reviews from before this change.
    • Deleting a Mari chat keeps its reviews through the new MariDbService.keepReviewsForChat. The changes stay applied and the cards go.
  • Mari's own card is off limits. A planMutation floor refuses any change to the __professor_mari__ character row. It covers character.update, raw mari db patch and delete, and transforms, like the existing Permissions Mode floor.
  • No-op edits make no card. When every row in a mutation is unchanged apart from updatedAt, executeMutation returns without writing. A null field and a missing field count as equal, since a replace row omits null columns such as embedding. Mari reads "No changes: every row already has these values…".
  • A refused Restore explains itself: "This data changed after Professor Mari made the change, so restoring would overwrite the newer version. Press Keep to dismiss this card; the current data stays as it is."
  • A failed Keep or Restore says why. Both routes catch the error and return reviewActionFailure(). A data folder Marinara cannot write to reads as "Marinara could not update this review's saved file (EACCES), so the card stays. Check that Marinara can write to its data folder."
  • Docs. docs/home/professor-mari.md gains the new rules. It also no longer claims that a card expires after 10 minutes (reviews are kept up to 14 days) or that new items skip the card.
  • Tests and changelog. A new regression, scripts/regressions/mari/review-cards.regression.ts, and one CHANGELOG.md entry.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

The boxes are left for a human to tick. What the agent ran:

  • pnpm check: exit 0.
  • node scripts/run-regressions.mjs: 444/444 passed.
  • The new regression drives the real MariDbService on a file-native store:
    • Mari's card is refused through the action, a raw patch and a raw delete, and stays unchanged.
    • An unchanged character.update or raw patch writes nothing and makes no card, while a real change still does.
    • The chat, CLI and new-chat visibility is checked, and keepReviewsForChat keeps only that chat's review, with the change still applied.
    • A refused Restore points at Keep, and Keep then clears the card.
    • A Keep whose file rename fails with EACCES stays pending, and the message names the data folder.
    • Source checks cover the agent's session id, the status filter, the delete hook and both route error paths.
    • Mutation-checked by removing the floor, the no-op skip and the error message in turn; each fails with its own message.
  • All 11 Mari regressions and open-issues pass.
  • Local CodeRabbit (coderabbit review --committed --base-commit <merge-base>): 8 files reviewed, no findings.

Manual verification notes

Clicked through on a scratch install of this branch (not the live install). The reviews came from the mari CLI, some with a chat's session id:

  • Chat A showed its own card and the CLI card. New chat showed only the CLI card.
  • Deleting chat A from the Mari chat list returned 204. Its card was gone, its character still existed, and the CLI card remained.
  • After the character was edited outside the review, Restore showed the new message pointing at Keep.
  • With the pending folder made read-only, Keep showed the EACCES message and the card stayed.

Needs manual verification:

  • Manually verify with a real model: ask Mari to change something in one chat, start a new chat and confirm the card is not there, then return to the first chat and confirm it is.
  • Manually verify that asking Mari to edit her own card makes her report that it cannot be edited, instead of claiming success.
  • Existing reviews from before this change name no chat, so they still show in every Mari chat until kept, restored or expired (14 days). Manually verify Keep clears them.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

docs/home/professor-mari.md and CHANGELOG.md changed. Translation follow-up: #6843.

UI evidence (if applicable)

  • New chat before: every Mari chat showed every pending card, including ones made in deleted chats. After: a new chat shows only cards that no chat owns.
  • Refused Restore before: "…Review a fresh proposal instead." After: "…Press Keep to dismiss this card; the current data stays as it is."
  • Failed Keep before: "Internal Server Error". After: "Marinara could not update this review's saved file (EACCES), so the card stays. Check that Marinara can write to its data folder."

Summary by CodeRabbit

  • New Features
    • Review cards are scoped to their originating chat. Changes remain applied when a chat is deleted, while its cards are removed.
    • Unanswered review cards remain available for up to 14 days before closing and keeping the change.
  • Bug Fixes
    • No-op edits no longer create review cards, and Professor Mari’s built-in card cannot be edited or deleted.
    • Restore and Keep failures now provide clearer messages, including when saved files are inaccessible or in use.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/6844 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/29/2026 **Status:** ✅ Merged **Merged:** 9/29/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `fix/mari-review-cards` --- ### 📝 Commits (2) - [`d9f250c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d9f250c67e864b0954e08fbd389d17556269633e) fix(mari): review cards belong to their chat, and none get stuck - [`87045ba`](https://github.com/Pasta-Devs/Marinara-Engine/commit/87045ba652c28cac2a2a52aedfa65549c33e9ce7) Merge remote-tracking branch 'origin/staging' into fix/mari-review-cards ### 📊 Changes **8 files changed** (+392 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/home/professor-mari.md` (+6 -2) 📝 `packages/server/src/routes/chats.routes.ts` (+3 -0) 📝 `packages/server/src/routes/professor-mari-workspace.routes.ts` (+33 -2) 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+73 -2) ➕ `packages/server/src/services/professor-mari/mari-session.ts` (+27 -0) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+19 -5) ➕ `scripts/regressions/mari/review-cards.regression.ts` (+229 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #6842 ## Why this change A user on 2.4.6 worked with Professor Mari on character cards. Afterwards, "Review Mari's changes" cards stayed on screen for good: deleting the chat, deleting every Mari chat and starting a new one did not clear them. Their cards all read "Professor Mari · Edited · No field changes to show." Reproduced on staging, four causes combined: - **Cards are global.** Every Mari chat showed every pending review, because reviews recorded no chat and deleting a chat never touched them. - **Mari could edit her own built-in card.** Startup rewrites that card to the shipped version, so the edit vanished at the next restart and its review could never be restored. - **An edit that changes nothing still made a card.** That is the empty "No field changes" card. - **A refused Restore was a dead end,** saying "Review a fresh proposal instead". A failed Keep said only "Internal Server Error". ## What changed - **Cards belong to their chat.** - A new `mari-session.ts` gives each Mari chat's run its own session id, `professor-mari-workspace:<chatId>`. Mari's app actions, her direct CLI calls and her shell's `mari` commands all carry it. - The workspace status lists a chat's own cards, plus cards that no chat owns: changes made with the `mari` CLI in a terminal, and reviews from before this change. - Deleting a Mari chat keeps its reviews through the new `MariDbService.keepReviewsForChat`. The changes stay applied and the cards go. - **Mari's own card is off limits.** A `planMutation` floor refuses any change to the `__professor_mari__` character row. It covers `character.update`, raw `mari db patch` and `delete`, and transforms, like the existing Permissions Mode floor. - **No-op edits make no card.** When every row in a mutation is unchanged apart from `updatedAt`, `executeMutation` returns without writing. A null field and a missing field count as equal, since a replace row omits null columns such as `embedding`. Mari reads "No changes: every row already has these values…". - **A refused Restore explains itself:** "This data changed after Professor Mari made the change, so restoring would overwrite the newer version. Press Keep to dismiss this card; the current data stays as it is." - **A failed Keep or Restore says why.** Both routes catch the error and return `reviewActionFailure()`. A data folder Marinara cannot write to reads as "Marinara could not update this review's saved file (EACCES), so the card stays. Check that Marinara can write to its data folder." - **Docs.** `docs/home/professor-mari.md` gains the new rules. It also no longer claims that a card expires after 10 minutes (reviews are kept up to 14 days) or that new items skip the card. - **Tests and changelog.** A new regression, `scripts/regressions/mari/review-cards.regression.ts`, and one `CHANGELOG.md` entry. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` The boxes are left for a human to tick. What the agent ran: - `pnpm check`: exit 0. - `node scripts/run-regressions.mjs`: 444/444 passed. - The new regression drives the real `MariDbService` on a file-native store: - Mari's card is refused through the action, a raw patch and a raw delete, and stays unchanged. - An unchanged `character.update` or raw patch writes nothing and makes no card, while a real change still does. - The chat, CLI and new-chat visibility is checked, and `keepReviewsForChat` keeps only that chat's review, with the change still applied. - A refused Restore points at Keep, and Keep then clears the card. - A Keep whose file rename fails with EACCES stays pending, and the message names the data folder. - Source checks cover the agent's session id, the status filter, the delete hook and both route error paths. - Mutation-checked by removing the floor, the no-op skip and the error message in turn; each fails with its own message. - All 11 Mari regressions and `open-issues` pass. - Local CodeRabbit (`coderabbit review --committed --base-commit <merge-base>`): 8 files reviewed, no findings. ### Manual verification notes Clicked through on a scratch install of this branch (not the live install). The reviews came from the `mari` CLI, some with a chat's session id: - Chat A showed its own card and the CLI card. **New chat** showed only the CLI card. - Deleting chat A from the Mari chat list returned 204. Its card was gone, its character still existed, and the CLI card remained. - After the character was edited outside the review, **Restore** showed the new message pointing at **Keep**. - With the pending folder made read-only, **Keep** showed the EACCES message and the card stayed. Needs manual verification: - Manually verify with a real model: ask Mari to change something in one chat, start a new chat and confirm the card is not there, then return to the first chat and confirm it is. - Manually verify that asking Mari to edit her own card makes her report that it cannot be edited, instead of claiming success. - Existing reviews from before this change name no chat, so they still show in every Mari chat until kept, restored or expired (14 days). Manually verify **Keep** clears them. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) `docs/home/professor-mari.md` and `CHANGELOG.md` changed. Translation follow-up: #6843. ## UI evidence (if applicable) - New chat before: every Mari chat showed every pending card, including ones made in deleted chats. After: a new chat shows only cards that no chat owns. - Refused Restore before: "…Review a fresh proposal instead." After: "…Press Keep to dismiss this card; the current data stays as it is." - Failed Keep before: "Internal Server Error". After: "Marinara could not update this review's saved file (EACCES), so the card stays. Check that Marinara can write to its data folder." <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Review cards are scoped to their originating chat. Changes remain applied when a chat is deleted, while its cards are removed. * Unanswered review cards remain available for up to 14 days before closing and keeping the change. * **Bug Fixes** * No-op edits no longer create review cards, and Professor Mari’s built-in card cannot be edited or deleted. * Restore and Keep failures now provide clearer messages, including when saved files are inaccessible or in use. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:18:55 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7353
No description provided.