[PR #2215] [MERGED] Fix autonomous unread count races #5477

Closed
opened 2026-10-22 04:16:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2215
Author: @Xelvanis
Created: 6/4/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @Xelvanis

Base: refactor ← Head: fix/autonomous-unread-atomic


📝 Commits (4)

  • d845aae Fix autonomous unread count races
  • 6e9f35f Normalize autonomous unread character IDs
  • 0be0d87 Ignore scratch and dedupe lorebook row aliases
  • f81a959 Normalize persisted autonomous unread IDs

📊 Changes

3 files changed (+315 additions, -40 deletions)

View changed files

📝 .gitignore (+1 -0)
📝 src-tauri/src/commands/storage/chats.rs (+312 -31)
📝 src-tauri/src/commands/storage/commands/entities.rs (+2 -9)

📄 Description

Linked issue

N/A

Why this change

  • Autonomous unread marks now accumulate persisted badge counts, so concurrent mark calls need to preserve every increment and contributing character ID instead of allowing a last-write-wins overwrite.

What changed

  • Updated chat metadata writes to use the storage layer's locked patch_if path.
  • Kept autonomous unread count validation and character ID normalization in the Rust storage owner.
  • Added focused Rust coverage for accumulation, invalid counts, and concurrent unread marks.

Refactor impact

Primary owner:

Rust storage

Impact areas reviewed:

  • Embedded Tauri chat command path
  • Hostable HTTP dispatch path for the same command
  • Sidebar unread metadata consumers

Boundary notes:

  • Privileged storage behavior remains in src-tauri.
  • Shared API and remote runtime dispatch already route to the same Rust command; no frontend command boundary changes were needed.

Pressure points touched:

  • None. This does not touch ModeSurface, GameSurface, shared mode UI, command registration, or import modules.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • cargo test --manifest-path src-tauri/Cargo.toml mark_autonomous_unread passed: 3 tests.
  • pnpm check passed, including line endings, architecture, frontend, Rust workspace check, docs, discovery metadata, launcher safety, and unused-code checks.
  • git diff --check passed.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Internal Rust storage bugfix for existing autonomous unread metadata. No new discoverable user workflow.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

No docs changes needed; behavior is an internal persistence correctness fix for existing unread metadata.

UI evidence

N/A. No visible layout change.

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation and reliability of autonomous unread chat marking with enhanced concurrent update handling.

🔄 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/2215 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 6/4/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/autonomous-unread-atomic` --- ### 📝 Commits (4) - [`d845aae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d845aae470d70fac04026742098bf216e0b1233c) Fix autonomous unread count races - [`6e9f35f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6e9f35f9d5ea53f41a332fb1372af236ccc02242) Normalize autonomous unread character IDs - [`0be0d87`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0be0d87c2025fcbc297056a7f17301bf165c0576) Ignore scratch and dedupe lorebook row aliases - [`f81a959`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f81a95902b765577b92e11bba97ac54efcd5c51d) Normalize persisted autonomous unread IDs ### 📊 Changes **3 files changed** (+315 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+1 -0) 📝 `src-tauri/src/commands/storage/chats.rs` (+312 -31) 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+2 -9) </details> ### 📄 Description ## Linked issue N/A ## Why this change - Autonomous unread marks now accumulate persisted badge counts, so concurrent mark calls need to preserve every increment and contributing character ID instead of allowing a last-write-wins overwrite. ## What changed - Updated chat metadata writes to use the storage layer's locked `patch_if` path. - Kept autonomous unread count validation and character ID normalization in the Rust storage owner. - Added focused Rust coverage for accumulation, invalid counts, and concurrent unread marks. ## Refactor impact Primary owner: Rust storage Impact areas reviewed: - Embedded Tauri chat command path - Hostable HTTP dispatch path for the same command - Sidebar unread metadata consumers Boundary notes: - Privileged storage behavior remains in `src-tauri`. - Shared API and remote runtime dispatch already route to the same Rust command; no frontend command boundary changes were needed. Pressure points touched: - None. This does not touch ModeSurface, GameSurface, shared mode UI, command registration, or import modules. ## Validation - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `cargo test --manifest-path src-tauri/Cargo.toml mark_autonomous_unread` passed: 3 tests. - `pnpm check` passed, including line endings, architecture, frontend, Rust workspace check, docs, discovery metadata, launcher safety, and unused-code checks. - `git diff --check` passed. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Internal Rust storage bugfix for existing autonomous unread metadata. No new discoverable user workflow. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims No docs changes needed; behavior is an internal persistence correctness fix for existing unread metadata. ## UI evidence N/A. No visible layout change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved validation and reliability of autonomous unread chat marking with enhanced concurrent update handling. <!-- 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-22 04:16:40 +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#5477
No description provided.